babylon.module.d.ts 5.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748
  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. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/observable" {
  50. import { Nullable } from "babylonjs/types";
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * 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.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * 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).
  162. * 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.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. readonly observers: Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @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.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module "babylonjs/Misc/domManagement" {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Extracts text content from a DOM element hierarchy
  289. * @param element defines the root element
  290. * @returns a string
  291. */
  292. static GetDOMTextContent(element: HTMLElement): string;
  293. }
  294. }
  295. declare module "babylonjs/Misc/logger" {
  296. /**
  297. * Logger used througouht the application to allow configuration of
  298. * the log level required for the messages.
  299. */
  300. export class Logger {
  301. /**
  302. * No log
  303. */
  304. static readonly NoneLogLevel: number;
  305. /**
  306. * Only message logs
  307. */
  308. static readonly MessageLogLevel: number;
  309. /**
  310. * Only warning logs
  311. */
  312. static readonly WarningLogLevel: number;
  313. /**
  314. * Only error logs
  315. */
  316. static readonly ErrorLogLevel: number;
  317. /**
  318. * All logs
  319. */
  320. static readonly AllLogLevel: number;
  321. private static _LogCache;
  322. /**
  323. * Gets a value indicating the number of loading errors
  324. * @ignorenaming
  325. */
  326. static errorsCount: number;
  327. /**
  328. * Callback called when a new log is added
  329. */
  330. static OnNewCacheEntry: (entry: string) => void;
  331. private static _AddLogEntry;
  332. private static _FormatMessage;
  333. private static _LogDisabled;
  334. private static _LogEnabled;
  335. private static _WarnDisabled;
  336. private static _WarnEnabled;
  337. private static _ErrorDisabled;
  338. private static _ErrorEnabled;
  339. /**
  340. * Log a message to the console
  341. */
  342. static Log: (message: string) => void;
  343. /**
  344. * Write a warning message to the console
  345. */
  346. static Warn: (message: string) => void;
  347. /**
  348. * Write an error message to the console
  349. */
  350. static Error: (message: string) => void;
  351. /**
  352. * Gets current log cache (list of logs)
  353. */
  354. static readonly LogCache: string;
  355. /**
  356. * Clears the log cache
  357. */
  358. static ClearLogCache(): void;
  359. /**
  360. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  361. */
  362. static LogLevels: number;
  363. }
  364. }
  365. declare module "babylonjs/Misc/typeStore" {
  366. /** @hidden */
  367. export class _TypeStore {
  368. /** @hidden */
  369. static RegisteredTypes: {
  370. [key: string]: Object;
  371. };
  372. /** @hidden */
  373. static GetClass(fqdn: string): any;
  374. }
  375. }
  376. declare module "babylonjs/Misc/deepCopier" {
  377. /**
  378. * Class containing a set of static utilities functions for deep copy.
  379. */
  380. export class DeepCopier {
  381. /**
  382. * Tries to copy an object by duplicating every property
  383. * @param source defines the source object
  384. * @param destination defines the target object
  385. * @param doNotCopyList defines a list of properties to avoid
  386. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  387. */
  388. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  389. }
  390. }
  391. declare module "babylonjs/Misc/precisionDate" {
  392. /**
  393. * Class containing a set of static utilities functions for precision date
  394. */
  395. export class PrecisionDate {
  396. /**
  397. * Gets either window.performance.now() if supported or Date.now() else
  398. */
  399. static readonly Now: number;
  400. }
  401. }
  402. declare module "babylonjs/Misc/devTools" {
  403. /** @hidden */
  404. export class _DevTools {
  405. static WarnImport(name: string): string;
  406. }
  407. }
  408. declare module "babylonjs/Misc/webRequest" {
  409. /**
  410. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  411. */
  412. export class WebRequest {
  413. private _xhr;
  414. /**
  415. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  416. * i.e. when loading files, where the server/service expects an Authorization header
  417. */
  418. static CustomRequestHeaders: {
  419. [key: string]: string;
  420. };
  421. /**
  422. * Add callback functions in this array to update all the requests before they get sent to the network
  423. */
  424. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  425. private _injectCustomRequestHeaders;
  426. /**
  427. * Gets or sets a function to be called when loading progress changes
  428. */
  429. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  430. /**
  431. * Returns client's state
  432. */
  433. readonly readyState: number;
  434. /**
  435. * Returns client's status
  436. */
  437. readonly status: number;
  438. /**
  439. * Returns client's status as a text
  440. */
  441. readonly statusText: string;
  442. /**
  443. * Returns client's response
  444. */
  445. readonly response: any;
  446. /**
  447. * Returns client's response url
  448. */
  449. readonly responseURL: string;
  450. /**
  451. * Returns client's response as text
  452. */
  453. readonly responseText: string;
  454. /**
  455. * Gets or sets the expected response type
  456. */
  457. responseType: XMLHttpRequestResponseType;
  458. /** @hidden */
  459. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  460. /** @hidden */
  461. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  462. /**
  463. * Cancels any network activity
  464. */
  465. abort(): void;
  466. /**
  467. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  468. * @param body defines an optional request body
  469. */
  470. send(body?: Document | BodyInit | null): void;
  471. /**
  472. * Sets the request method, request URL
  473. * @param method defines the method to use (GET, POST, etc..)
  474. * @param url defines the url to connect with
  475. */
  476. open(method: string, url: string): void;
  477. }
  478. }
  479. declare module "babylonjs/Misc/fileRequest" {
  480. import { Observable } from "babylonjs/Misc/observable";
  481. /**
  482. * File request interface
  483. */
  484. export interface IFileRequest {
  485. /**
  486. * Raised when the request is complete (success or error).
  487. */
  488. onCompleteObservable: Observable<IFileRequest>;
  489. /**
  490. * Aborts the request for a file.
  491. */
  492. abort: () => void;
  493. }
  494. }
  495. declare module "babylonjs/Misc/performanceMonitor" {
  496. /**
  497. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  498. */
  499. export class PerformanceMonitor {
  500. private _enabled;
  501. private _rollingFrameTime;
  502. private _lastFrameTimeMs;
  503. /**
  504. * constructor
  505. * @param frameSampleSize The number of samples required to saturate the sliding window
  506. */
  507. constructor(frameSampleSize?: number);
  508. /**
  509. * Samples current frame
  510. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  511. */
  512. sampleFrame(timeMs?: number): void;
  513. /**
  514. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  515. */
  516. readonly averageFrameTime: number;
  517. /**
  518. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  519. */
  520. readonly averageFrameTimeVariance: number;
  521. /**
  522. * Returns the frame time of the most recent frame
  523. */
  524. readonly instantaneousFrameTime: number;
  525. /**
  526. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  527. */
  528. readonly averageFPS: number;
  529. /**
  530. * Returns the average framerate in frames per second using the most recent frame time
  531. */
  532. readonly instantaneousFPS: number;
  533. /**
  534. * Returns true if enough samples have been taken to completely fill the sliding window
  535. */
  536. readonly isSaturated: boolean;
  537. /**
  538. * Enables contributions to the sliding window sample set
  539. */
  540. enable(): void;
  541. /**
  542. * Disables contributions to the sliding window sample set
  543. * Samples will not be interpolated over the disabled period
  544. */
  545. disable(): void;
  546. /**
  547. * Returns true if sampling is enabled
  548. */
  549. readonly isEnabled: boolean;
  550. /**
  551. * Resets performance monitor
  552. */
  553. reset(): void;
  554. }
  555. /**
  556. * RollingAverage
  557. *
  558. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  559. */
  560. export class RollingAverage {
  561. /**
  562. * Current average
  563. */
  564. average: number;
  565. /**
  566. * Current variance
  567. */
  568. variance: number;
  569. protected _samples: Array<number>;
  570. protected _sampleCount: number;
  571. protected _pos: number;
  572. protected _m2: number;
  573. /**
  574. * constructor
  575. * @param length The number of samples required to saturate the sliding window
  576. */
  577. constructor(length: number);
  578. /**
  579. * Adds a sample to the sample set
  580. * @param v The sample value
  581. */
  582. add(v: number): void;
  583. /**
  584. * Returns previously added values or null if outside of history or outside the sliding window domain
  585. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  586. * @return Value previously recorded with add() or null if outside of range
  587. */
  588. history(i: number): number;
  589. /**
  590. * Returns true if enough samples have been taken to completely fill the sliding window
  591. * @return true if sample-set saturated
  592. */
  593. isSaturated(): boolean;
  594. /**
  595. * Resets the rolling average (equivalent to 0 samples taken so far)
  596. */
  597. reset(): void;
  598. /**
  599. * Wraps a value around the sample range boundaries
  600. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  601. * @return Wrapped position in sample range
  602. */
  603. protected _wrapPosition(i: number): number;
  604. }
  605. }
  606. declare module "babylonjs/Misc/stringDictionary" {
  607. import { Nullable } from "babylonjs/types";
  608. /**
  609. * This class implement a typical dictionary using a string as key and the generic type T as value.
  610. * The underlying implementation relies on an associative array to ensure the best performances.
  611. * The value can be anything including 'null' but except 'undefined'
  612. */
  613. export class StringDictionary<T> {
  614. /**
  615. * This will clear this dictionary and copy the content from the 'source' one.
  616. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  617. * @param source the dictionary to take the content from and copy to this dictionary
  618. */
  619. copyFrom(source: StringDictionary<T>): void;
  620. /**
  621. * Get a value based from its key
  622. * @param key the given key to get the matching value from
  623. * @return the value if found, otherwise undefined is returned
  624. */
  625. get(key: string): T | undefined;
  626. /**
  627. * Get a value from its key or add it if it doesn't exist.
  628. * This method will ensure you that a given key/data will be present in the dictionary.
  629. * @param key the given key to get the matching value from
  630. * @param factory the factory that will create the value if the key is not present in the dictionary.
  631. * The factory will only be invoked if there's no data for the given key.
  632. * @return the value corresponding to the key.
  633. */
  634. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  635. /**
  636. * Get a value from its key if present in the dictionary otherwise add it
  637. * @param key the key to get the value from
  638. * @param val if there's no such key/value pair in the dictionary add it with this value
  639. * @return the value corresponding to the key
  640. */
  641. getOrAdd(key: string, val: T): T;
  642. /**
  643. * Check if there's a given key in the dictionary
  644. * @param key the key to check for
  645. * @return true if the key is present, false otherwise
  646. */
  647. contains(key: string): boolean;
  648. /**
  649. * Add a new key and its corresponding value
  650. * @param key the key to add
  651. * @param value the value corresponding to the key
  652. * @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
  653. */
  654. add(key: string, value: T): boolean;
  655. /**
  656. * Update a specific value associated to a key
  657. * @param key defines the key to use
  658. * @param value defines the value to store
  659. * @returns true if the value was updated (or false if the key was not found)
  660. */
  661. set(key: string, value: T): boolean;
  662. /**
  663. * Get the element of the given key and remove it from the dictionary
  664. * @param key defines the key to search
  665. * @returns the value associated with the key or null if not found
  666. */
  667. getAndRemove(key: string): Nullable<T>;
  668. /**
  669. * Remove a key/value from the dictionary.
  670. * @param key the key to remove
  671. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  672. */
  673. remove(key: string): boolean;
  674. /**
  675. * Clear the whole content of the dictionary
  676. */
  677. clear(): void;
  678. /**
  679. * Gets the current count
  680. */
  681. readonly count: number;
  682. /**
  683. * Execute a callback on each key/val of the dictionary.
  684. * Note that you can remove any element in this dictionary in the callback implementation
  685. * @param callback the callback to execute on a given key/value pair
  686. */
  687. forEach(callback: (key: string, val: T) => void): void;
  688. /**
  689. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  690. * If the callback returns null or undefined the method will iterate to the next key/value pair
  691. * Note that you can remove any element in this dictionary in the callback implementation
  692. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  693. * @returns the first item
  694. */
  695. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  696. private _count;
  697. private _data;
  698. }
  699. }
  700. declare module "babylonjs/Meshes/dataBuffer" {
  701. /**
  702. * Class used to store gfx data (like WebGLBuffer)
  703. */
  704. export class DataBuffer {
  705. /**
  706. * Gets or sets the number of objects referencing this buffer
  707. */
  708. references: number;
  709. /** Gets or sets the size of the underlying buffer */
  710. capacity: number;
  711. /**
  712. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  713. */
  714. is32Bits: boolean;
  715. /**
  716. * Gets the underlying buffer
  717. */
  718. readonly underlyingResource: any;
  719. }
  720. }
  721. declare module "babylonjs/Meshes/buffer" {
  722. import { Nullable, DataArray } from "babylonjs/types";
  723. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  724. /**
  725. * Class used to store data that will be store in GPU memory
  726. */
  727. export class Buffer {
  728. private _engine;
  729. private _buffer;
  730. /** @hidden */
  731. _data: Nullable<DataArray>;
  732. private _updatable;
  733. private _instanced;
  734. /**
  735. * Gets the byte stride.
  736. */
  737. readonly byteStride: number;
  738. /**
  739. * Constructor
  740. * @param engine the engine
  741. * @param data the data to use for this buffer
  742. * @param updatable whether the data is updatable
  743. * @param stride the stride (optional)
  744. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  745. * @param instanced whether the buffer is instanced (optional)
  746. * @param useBytes set to true if the stride in in bytes (optional)
  747. */
  748. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  749. /**
  750. * Create a new VertexBuffer based on the current buffer
  751. * @param kind defines the vertex buffer kind (position, normal, etc.)
  752. * @param offset defines offset in the buffer (0 by default)
  753. * @param size defines the size in floats of attributes (position is 3 for instance)
  754. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  755. * @param instanced defines if the vertex buffer contains indexed data
  756. * @param useBytes defines if the offset and stride are in bytes
  757. * @returns the new vertex buffer
  758. */
  759. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  760. /**
  761. * Gets a boolean indicating if the Buffer is updatable?
  762. * @returns true if the buffer is updatable
  763. */
  764. isUpdatable(): boolean;
  765. /**
  766. * Gets current buffer's data
  767. * @returns a DataArray or null
  768. */
  769. getData(): Nullable<DataArray>;
  770. /**
  771. * Gets underlying native buffer
  772. * @returns underlying native buffer
  773. */
  774. getBuffer(): Nullable<DataBuffer>;
  775. /**
  776. * Gets the stride in float32 units (i.e. byte stride / 4).
  777. * May not be an integer if the byte stride is not divisible by 4.
  778. * DEPRECATED. Use byteStride instead.
  779. * @returns the stride in float32 units
  780. */
  781. getStrideSize(): number;
  782. /**
  783. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  784. * @param data defines the data to store
  785. */
  786. create(data?: Nullable<DataArray>): void;
  787. /** @hidden */
  788. _rebuild(): void;
  789. /**
  790. * Update current buffer data
  791. * @param data defines the data to store
  792. */
  793. update(data: DataArray): void;
  794. /**
  795. * Updates the data directly.
  796. * @param data the new data
  797. * @param offset the new offset
  798. * @param vertexCount the vertex count (optional)
  799. * @param useBytes set to true if the offset is in bytes
  800. */
  801. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  802. /**
  803. * Release all resources
  804. */
  805. dispose(): void;
  806. }
  807. /**
  808. * Specialized buffer used to store vertex data
  809. */
  810. export class VertexBuffer {
  811. /** @hidden */
  812. _buffer: Buffer;
  813. private _kind;
  814. private _size;
  815. private _ownsBuffer;
  816. private _instanced;
  817. private _instanceDivisor;
  818. /**
  819. * The byte type.
  820. */
  821. static readonly BYTE: number;
  822. /**
  823. * The unsigned byte type.
  824. */
  825. static readonly UNSIGNED_BYTE: number;
  826. /**
  827. * The short type.
  828. */
  829. static readonly SHORT: number;
  830. /**
  831. * The unsigned short type.
  832. */
  833. static readonly UNSIGNED_SHORT: number;
  834. /**
  835. * The integer type.
  836. */
  837. static readonly INT: number;
  838. /**
  839. * The unsigned integer type.
  840. */
  841. static readonly UNSIGNED_INT: number;
  842. /**
  843. * The float type.
  844. */
  845. static readonly FLOAT: number;
  846. /**
  847. * Gets or sets the instance divisor when in instanced mode
  848. */
  849. instanceDivisor: number;
  850. /**
  851. * Gets the byte stride.
  852. */
  853. readonly byteStride: number;
  854. /**
  855. * Gets the byte offset.
  856. */
  857. readonly byteOffset: number;
  858. /**
  859. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  860. */
  861. readonly normalized: boolean;
  862. /**
  863. * Gets the data type of each component in the array.
  864. */
  865. readonly type: number;
  866. /**
  867. * Constructor
  868. * @param engine the engine
  869. * @param data the data to use for this vertex buffer
  870. * @param kind the vertex buffer kind
  871. * @param updatable whether the data is updatable
  872. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  873. * @param stride the stride (optional)
  874. * @param instanced whether the buffer is instanced (optional)
  875. * @param offset the offset of the data (optional)
  876. * @param size the number of components (optional)
  877. * @param type the type of the component (optional)
  878. * @param normalized whether the data contains normalized data (optional)
  879. * @param useBytes set to true if stride and offset are in bytes (optional)
  880. */
  881. 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);
  882. /** @hidden */
  883. _rebuild(): void;
  884. /**
  885. * Returns the kind of the VertexBuffer (string)
  886. * @returns a string
  887. */
  888. getKind(): string;
  889. /**
  890. * Gets a boolean indicating if the VertexBuffer is updatable?
  891. * @returns true if the buffer is updatable
  892. */
  893. isUpdatable(): boolean;
  894. /**
  895. * Gets current buffer's data
  896. * @returns a DataArray or null
  897. */
  898. getData(): Nullable<DataArray>;
  899. /**
  900. * Gets underlying native buffer
  901. * @returns underlying native buffer
  902. */
  903. getBuffer(): Nullable<DataBuffer>;
  904. /**
  905. * Gets the stride in float32 units (i.e. byte stride / 4).
  906. * May not be an integer if the byte stride is not divisible by 4.
  907. * DEPRECATED. Use byteStride instead.
  908. * @returns the stride in float32 units
  909. */
  910. getStrideSize(): number;
  911. /**
  912. * Returns the offset as a multiple of the type byte length.
  913. * DEPRECATED. Use byteOffset instead.
  914. * @returns the offset in bytes
  915. */
  916. getOffset(): number;
  917. /**
  918. * Returns the number of components per vertex attribute (integer)
  919. * @returns the size in float
  920. */
  921. getSize(): number;
  922. /**
  923. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  924. * @returns true if this buffer is instanced
  925. */
  926. getIsInstanced(): boolean;
  927. /**
  928. * Returns the instancing divisor, zero for non-instanced (integer).
  929. * @returns a number
  930. */
  931. getInstanceDivisor(): number;
  932. /**
  933. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  934. * @param data defines the data to store
  935. */
  936. create(data?: DataArray): void;
  937. /**
  938. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  939. * This function will create a new buffer if the current one is not updatable
  940. * @param data defines the data to store
  941. */
  942. update(data: DataArray): void;
  943. /**
  944. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  945. * Returns the directly updated WebGLBuffer.
  946. * @param data the new data
  947. * @param offset the new offset
  948. * @param useBytes set to true if the offset is in bytes
  949. */
  950. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  951. /**
  952. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  953. */
  954. dispose(): void;
  955. /**
  956. * Enumerates each value of this vertex buffer as numbers.
  957. * @param count the number of values to enumerate
  958. * @param callback the callback function called for each value
  959. */
  960. forEach(count: number, callback: (value: number, index: number) => void): void;
  961. /**
  962. * Positions
  963. */
  964. static readonly PositionKind: string;
  965. /**
  966. * Normals
  967. */
  968. static readonly NormalKind: string;
  969. /**
  970. * Tangents
  971. */
  972. static readonly TangentKind: string;
  973. /**
  974. * Texture coordinates
  975. */
  976. static readonly UVKind: string;
  977. /**
  978. * Texture coordinates 2
  979. */
  980. static readonly UV2Kind: string;
  981. /**
  982. * Texture coordinates 3
  983. */
  984. static readonly UV3Kind: string;
  985. /**
  986. * Texture coordinates 4
  987. */
  988. static readonly UV4Kind: string;
  989. /**
  990. * Texture coordinates 5
  991. */
  992. static readonly UV5Kind: string;
  993. /**
  994. * Texture coordinates 6
  995. */
  996. static readonly UV6Kind: string;
  997. /**
  998. * Colors
  999. */
  1000. static readonly ColorKind: string;
  1001. /**
  1002. * Matrix indices (for bones)
  1003. */
  1004. static readonly MatricesIndicesKind: string;
  1005. /**
  1006. * Matrix weights (for bones)
  1007. */
  1008. static readonly MatricesWeightsKind: string;
  1009. /**
  1010. * Additional matrix indices (for bones)
  1011. */
  1012. static readonly MatricesIndicesExtraKind: string;
  1013. /**
  1014. * Additional matrix weights (for bones)
  1015. */
  1016. static readonly MatricesWeightsExtraKind: string;
  1017. /**
  1018. * Deduces the stride given a kind.
  1019. * @param kind The kind string to deduce
  1020. * @returns The deduced stride
  1021. */
  1022. static DeduceStride(kind: string): number;
  1023. /**
  1024. * Gets the byte length of the given type.
  1025. * @param type the type
  1026. * @returns the number of bytes
  1027. */
  1028. static GetTypeByteLength(type: number): number;
  1029. /**
  1030. * Enumerates each value of the given parameters as numbers.
  1031. * @param data the data to enumerate
  1032. * @param byteOffset the byte offset of the data
  1033. * @param byteStride the byte stride of the data
  1034. * @param componentCount the number of components per element
  1035. * @param componentType the type of the component
  1036. * @param count the number of values to enumerate
  1037. * @param normalized whether the data is normalized
  1038. * @param callback the callback function called for each value
  1039. */
  1040. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  1041. private static _GetFloatValue;
  1042. }
  1043. }
  1044. declare module "babylonjs/Maths/math.scalar" {
  1045. /**
  1046. * Scalar computation library
  1047. */
  1048. export class Scalar {
  1049. /**
  1050. * Two pi constants convenient for computation.
  1051. */
  1052. static TwoPi: number;
  1053. /**
  1054. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1055. * @param a number
  1056. * @param b number
  1057. * @param epsilon (default = 1.401298E-45)
  1058. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1059. */
  1060. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1061. /**
  1062. * Returns a string : the upper case translation of the number i to hexadecimal.
  1063. * @param i number
  1064. * @returns the upper case translation of the number i to hexadecimal.
  1065. */
  1066. static ToHex(i: number): string;
  1067. /**
  1068. * Returns -1 if value is negative and +1 is value is positive.
  1069. * @param value the value
  1070. * @returns the value itself if it's equal to zero.
  1071. */
  1072. static Sign(value: number): number;
  1073. /**
  1074. * Returns the value itself if it's between min and max.
  1075. * Returns min if the value is lower than min.
  1076. * Returns max if the value is greater than max.
  1077. * @param value the value to clmap
  1078. * @param min the min value to clamp to (default: 0)
  1079. * @param max the max value to clamp to (default: 1)
  1080. * @returns the clamped value
  1081. */
  1082. static Clamp(value: number, min?: number, max?: number): number;
  1083. /**
  1084. * the log2 of value.
  1085. * @param value the value to compute log2 of
  1086. * @returns the log2 of value.
  1087. */
  1088. static Log2(value: number): number;
  1089. /**
  1090. * Loops the value, so that it is never larger than length and never smaller than 0.
  1091. *
  1092. * This is similar to the modulo operator but it works with floating point numbers.
  1093. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1094. * With t = 5 and length = 2.5, the result would be 0.0.
  1095. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1096. * @param value the value
  1097. * @param length the length
  1098. * @returns the looped value
  1099. */
  1100. static Repeat(value: number, length: number): number;
  1101. /**
  1102. * Normalize the value between 0.0 and 1.0 using min and max values
  1103. * @param value value to normalize
  1104. * @param min max to normalize between
  1105. * @param max min to normalize between
  1106. * @returns the normalized value
  1107. */
  1108. static Normalize(value: number, min: number, max: number): number;
  1109. /**
  1110. * Denormalize the value from 0.0 and 1.0 using min and max values
  1111. * @param normalized value to denormalize
  1112. * @param min max to denormalize between
  1113. * @param max min to denormalize between
  1114. * @returns the denormalized value
  1115. */
  1116. static Denormalize(normalized: number, min: number, max: number): number;
  1117. /**
  1118. * Calculates the shortest difference between two given angles given in degrees.
  1119. * @param current current angle in degrees
  1120. * @param target target angle in degrees
  1121. * @returns the delta
  1122. */
  1123. static DeltaAngle(current: number, target: number): number;
  1124. /**
  1125. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1126. * @param tx value
  1127. * @param length length
  1128. * @returns The returned value will move back and forth between 0 and length
  1129. */
  1130. static PingPong(tx: number, length: number): number;
  1131. /**
  1132. * Interpolates between min and max with smoothing at the limits.
  1133. *
  1134. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1135. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1136. * @param from from
  1137. * @param to to
  1138. * @param tx value
  1139. * @returns the smooth stepped value
  1140. */
  1141. static SmoothStep(from: number, to: number, tx: number): number;
  1142. /**
  1143. * Moves a value current towards target.
  1144. *
  1145. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1146. * Negative values of maxDelta pushes the value away from target.
  1147. * @param current current value
  1148. * @param target target value
  1149. * @param maxDelta max distance to move
  1150. * @returns resulting value
  1151. */
  1152. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1153. /**
  1154. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1155. *
  1156. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1157. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1158. * @param current current value
  1159. * @param target target value
  1160. * @param maxDelta max distance to move
  1161. * @returns resulting angle
  1162. */
  1163. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1164. /**
  1165. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1166. * @param start start value
  1167. * @param end target value
  1168. * @param amount amount to lerp between
  1169. * @returns the lerped value
  1170. */
  1171. static Lerp(start: number, end: number, amount: number): number;
  1172. /**
  1173. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1174. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1175. * @param start start value
  1176. * @param end target value
  1177. * @param amount amount to lerp between
  1178. * @returns the lerped value
  1179. */
  1180. static LerpAngle(start: number, end: number, amount: number): number;
  1181. /**
  1182. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1183. * @param a start value
  1184. * @param b target value
  1185. * @param value value between a and b
  1186. * @returns the inverseLerp value
  1187. */
  1188. static InverseLerp(a: number, b: number, value: number): number;
  1189. /**
  1190. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1191. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1192. * @param value1 spline value
  1193. * @param tangent1 spline value
  1194. * @param value2 spline value
  1195. * @param tangent2 spline value
  1196. * @param amount input value
  1197. * @returns hermite result
  1198. */
  1199. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1200. /**
  1201. * Returns a random float number between and min and max values
  1202. * @param min min value of random
  1203. * @param max max value of random
  1204. * @returns random value
  1205. */
  1206. static RandomRange(min: number, max: number): number;
  1207. /**
  1208. * This function returns percentage of a number in a given range.
  1209. *
  1210. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1211. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1212. * @param number to convert to percentage
  1213. * @param min min range
  1214. * @param max max range
  1215. * @returns the percentage
  1216. */
  1217. static RangeToPercent(number: number, min: number, max: number): number;
  1218. /**
  1219. * This function returns number that corresponds to the percentage in a given range.
  1220. *
  1221. * PercentToRange(0.34,0,100) will return 34.
  1222. * @param percent to convert to number
  1223. * @param min min range
  1224. * @param max max range
  1225. * @returns the number
  1226. */
  1227. static PercentToRange(percent: number, min: number, max: number): number;
  1228. /**
  1229. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1230. * @param angle The angle to normalize in radian.
  1231. * @return The converted angle.
  1232. */
  1233. static NormalizeRadians(angle: number): number;
  1234. }
  1235. }
  1236. declare module "babylonjs/Maths/math.constants" {
  1237. /**
  1238. * Constant used to convert a value to gamma space
  1239. * @ignorenaming
  1240. */
  1241. export const ToGammaSpace: number;
  1242. /**
  1243. * Constant used to convert a value to linear space
  1244. * @ignorenaming
  1245. */
  1246. export const ToLinearSpace = 2.2;
  1247. /**
  1248. * Constant used to define the minimal number value in Babylon.js
  1249. * @ignorenaming
  1250. */
  1251. let Epsilon: number;
  1252. export { Epsilon };
  1253. }
  1254. declare module "babylonjs/Maths/math.viewport" {
  1255. /**
  1256. * Class used to represent a viewport on screen
  1257. */
  1258. export class Viewport {
  1259. /** viewport left coordinate */
  1260. x: number;
  1261. /** viewport top coordinate */
  1262. y: number;
  1263. /**viewport width */
  1264. width: number;
  1265. /** viewport height */
  1266. height: number;
  1267. /**
  1268. * Creates a Viewport object located at (x, y) and sized (width, height)
  1269. * @param x defines viewport left coordinate
  1270. * @param y defines viewport top coordinate
  1271. * @param width defines the viewport width
  1272. * @param height defines the viewport height
  1273. */
  1274. constructor(
  1275. /** viewport left coordinate */
  1276. x: number,
  1277. /** viewport top coordinate */
  1278. y: number,
  1279. /**viewport width */
  1280. width: number,
  1281. /** viewport height */
  1282. height: number);
  1283. /**
  1284. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1285. * @param renderWidth defines the rendering width
  1286. * @param renderHeight defines the rendering height
  1287. * @returns a new Viewport
  1288. */
  1289. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1290. /**
  1291. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1292. * @param renderWidth defines the rendering width
  1293. * @param renderHeight defines the rendering height
  1294. * @param ref defines the target viewport
  1295. * @returns the current viewport
  1296. */
  1297. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1298. /**
  1299. * Returns a new Viewport copied from the current one
  1300. * @returns a new Viewport
  1301. */
  1302. clone(): Viewport;
  1303. }
  1304. }
  1305. declare module "babylonjs/Misc/arrayTools" {
  1306. /**
  1307. * Class containing a set of static utilities functions for arrays.
  1308. */
  1309. export class ArrayTools {
  1310. /**
  1311. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1312. * @param size the number of element to construct and put in the array
  1313. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1314. * @returns a new array filled with new objects
  1315. */
  1316. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1317. }
  1318. }
  1319. declare module "babylonjs/Maths/math.like" {
  1320. import { float, int, DeepImmutable } from "babylonjs/types";
  1321. /**
  1322. * @hidden
  1323. */
  1324. export interface IColor4Like {
  1325. r: float;
  1326. g: float;
  1327. b: float;
  1328. a: float;
  1329. }
  1330. /**
  1331. * @hidden
  1332. */
  1333. export interface IColor3Like {
  1334. r: float;
  1335. g: float;
  1336. b: float;
  1337. }
  1338. /**
  1339. * @hidden
  1340. */
  1341. export interface IVector4Like {
  1342. x: float;
  1343. y: float;
  1344. z: float;
  1345. w: float;
  1346. }
  1347. /**
  1348. * @hidden
  1349. */
  1350. export interface IVector3Like {
  1351. x: float;
  1352. y: float;
  1353. z: float;
  1354. }
  1355. /**
  1356. * @hidden
  1357. */
  1358. export interface IVector2Like {
  1359. x: float;
  1360. y: float;
  1361. }
  1362. /**
  1363. * @hidden
  1364. */
  1365. export interface IMatrixLike {
  1366. toArray(): DeepImmutable<Float32Array>;
  1367. updateFlag: int;
  1368. }
  1369. /**
  1370. * @hidden
  1371. */
  1372. export interface IViewportLike {
  1373. x: float;
  1374. y: float;
  1375. width: float;
  1376. height: float;
  1377. }
  1378. /**
  1379. * @hidden
  1380. */
  1381. export interface IPlaneLike {
  1382. normal: IVector3Like;
  1383. d: float;
  1384. normalize(): void;
  1385. }
  1386. }
  1387. declare module "babylonjs/Maths/math.vector" {
  1388. import { Viewport } from "babylonjs/Maths/math.viewport";
  1389. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1390. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1391. /**
  1392. * Class representing a vector containing 2 coordinates
  1393. */
  1394. export class Vector2 {
  1395. /** defines the first coordinate */
  1396. x: number;
  1397. /** defines the second coordinate */
  1398. y: number;
  1399. /**
  1400. * Creates a new Vector2 from the given x and y coordinates
  1401. * @param x defines the first coordinate
  1402. * @param y defines the second coordinate
  1403. */
  1404. constructor(
  1405. /** defines the first coordinate */
  1406. x?: number,
  1407. /** defines the second coordinate */
  1408. y?: number);
  1409. /**
  1410. * Gets a string with the Vector2 coordinates
  1411. * @returns a string with the Vector2 coordinates
  1412. */
  1413. toString(): string;
  1414. /**
  1415. * Gets class name
  1416. * @returns the string "Vector2"
  1417. */
  1418. getClassName(): string;
  1419. /**
  1420. * Gets current vector hash code
  1421. * @returns the Vector2 hash code as a number
  1422. */
  1423. getHashCode(): number;
  1424. /**
  1425. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1426. * @param array defines the source array
  1427. * @param index defines the offset in source array
  1428. * @returns the current Vector2
  1429. */
  1430. toArray(array: FloatArray, index?: number): Vector2;
  1431. /**
  1432. * Copy the current vector to an array
  1433. * @returns a new array with 2 elements: the Vector2 coordinates.
  1434. */
  1435. asArray(): number[];
  1436. /**
  1437. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1438. * @param source defines the source Vector2
  1439. * @returns the current updated Vector2
  1440. */
  1441. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1442. /**
  1443. * Sets the Vector2 coordinates with the given floats
  1444. * @param x defines the first coordinate
  1445. * @param y defines the second coordinate
  1446. * @returns the current updated Vector2
  1447. */
  1448. copyFromFloats(x: number, y: number): Vector2;
  1449. /**
  1450. * Sets the Vector2 coordinates with the given floats
  1451. * @param x defines the first coordinate
  1452. * @param y defines the second coordinate
  1453. * @returns the current updated Vector2
  1454. */
  1455. set(x: number, y: number): Vector2;
  1456. /**
  1457. * Add another vector with the current one
  1458. * @param otherVector defines the other vector
  1459. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1460. */
  1461. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1462. /**
  1463. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1464. * @param otherVector defines the other vector
  1465. * @param result defines the target vector
  1466. * @returns the unmodified current Vector2
  1467. */
  1468. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1469. /**
  1470. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1471. * @param otherVector defines the other vector
  1472. * @returns the current updated Vector2
  1473. */
  1474. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1475. /**
  1476. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1477. * @param otherVector defines the other vector
  1478. * @returns a new Vector2
  1479. */
  1480. addVector3(otherVector: Vector3): Vector2;
  1481. /**
  1482. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1483. * @param otherVector defines the other vector
  1484. * @returns a new Vector2
  1485. */
  1486. subtract(otherVector: Vector2): Vector2;
  1487. /**
  1488. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1489. * @param otherVector defines the other vector
  1490. * @param result defines the target vector
  1491. * @returns the unmodified current Vector2
  1492. */
  1493. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1494. /**
  1495. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1496. * @param otherVector defines the other vector
  1497. * @returns the current updated Vector2
  1498. */
  1499. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1500. /**
  1501. * Multiplies in place the current Vector2 coordinates by the given ones
  1502. * @param otherVector defines the other vector
  1503. * @returns the current updated Vector2
  1504. */
  1505. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1506. /**
  1507. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1508. * @param otherVector defines the other vector
  1509. * @returns a new Vector2
  1510. */
  1511. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1512. /**
  1513. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1514. * @param otherVector defines the other vector
  1515. * @param result defines the target vector
  1516. * @returns the unmodified current Vector2
  1517. */
  1518. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1519. /**
  1520. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  1521. * @param x defines the first coordinate
  1522. * @param y defines the second coordinate
  1523. * @returns a new Vector2
  1524. */
  1525. multiplyByFloats(x: number, y: number): Vector2;
  1526. /**
  1527. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1528. * @param otherVector defines the other vector
  1529. * @returns a new Vector2
  1530. */
  1531. divide(otherVector: Vector2): Vector2;
  1532. /**
  1533. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1534. * @param otherVector defines the other vector
  1535. * @param result defines the target vector
  1536. * @returns the unmodified current Vector2
  1537. */
  1538. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1539. /**
  1540. * Divides the current Vector2 coordinates by the given ones
  1541. * @param otherVector defines the other vector
  1542. * @returns the current updated Vector2
  1543. */
  1544. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1545. /**
  1546. * Gets a new Vector2 with current Vector2 negated coordinates
  1547. * @returns a new Vector2
  1548. */
  1549. negate(): Vector2;
  1550. /**
  1551. * Multiply the Vector2 coordinates by scale
  1552. * @param scale defines the scaling factor
  1553. * @returns the current updated Vector2
  1554. */
  1555. scaleInPlace(scale: number): Vector2;
  1556. /**
  1557. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1558. * @param scale defines the scaling factor
  1559. * @returns a new Vector2
  1560. */
  1561. scale(scale: number): Vector2;
  1562. /**
  1563. * Scale the current Vector2 values by a factor to a given Vector2
  1564. * @param scale defines the scale factor
  1565. * @param result defines the Vector2 object where to store the result
  1566. * @returns the unmodified current Vector2
  1567. */
  1568. scaleToRef(scale: number, result: Vector2): Vector2;
  1569. /**
  1570. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1571. * @param scale defines the scale factor
  1572. * @param result defines the Vector2 object where to store the result
  1573. * @returns the unmodified current Vector2
  1574. */
  1575. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1576. /**
  1577. * Gets a boolean if two vectors are equals
  1578. * @param otherVector defines the other vector
  1579. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1580. */
  1581. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1582. /**
  1583. * Gets a boolean if two vectors are equals (using an epsilon value)
  1584. * @param otherVector defines the other vector
  1585. * @param epsilon defines the minimal distance to consider equality
  1586. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1587. */
  1588. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1589. /**
  1590. * Gets a new Vector2 from current Vector2 floored values
  1591. * @returns a new Vector2
  1592. */
  1593. floor(): Vector2;
  1594. /**
  1595. * Gets a new Vector2 from current Vector2 floored values
  1596. * @returns a new Vector2
  1597. */
  1598. fract(): Vector2;
  1599. /**
  1600. * Gets the length of the vector
  1601. * @returns the vector length (float)
  1602. */
  1603. length(): number;
  1604. /**
  1605. * Gets the vector squared length
  1606. * @returns the vector squared length (float)
  1607. */
  1608. lengthSquared(): number;
  1609. /**
  1610. * Normalize the vector
  1611. * @returns the current updated Vector2
  1612. */
  1613. normalize(): Vector2;
  1614. /**
  1615. * Gets a new Vector2 copied from the Vector2
  1616. * @returns a new Vector2
  1617. */
  1618. clone(): Vector2;
  1619. /**
  1620. * Gets a new Vector2(0, 0)
  1621. * @returns a new Vector2
  1622. */
  1623. static Zero(): Vector2;
  1624. /**
  1625. * Gets a new Vector2(1, 1)
  1626. * @returns a new Vector2
  1627. */
  1628. static One(): Vector2;
  1629. /**
  1630. * Gets a new Vector2 set from the given index element of the given array
  1631. * @param array defines the data source
  1632. * @param offset defines the offset in the data source
  1633. * @returns a new Vector2
  1634. */
  1635. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1636. /**
  1637. * Sets "result" from the given index element of the given array
  1638. * @param array defines the data source
  1639. * @param offset defines the offset in the data source
  1640. * @param result defines the target vector
  1641. */
  1642. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1643. /**
  1644. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1645. * @param value1 defines 1st point of control
  1646. * @param value2 defines 2nd point of control
  1647. * @param value3 defines 3rd point of control
  1648. * @param value4 defines 4th point of control
  1649. * @param amount defines the interpolation factor
  1650. * @returns a new Vector2
  1651. */
  1652. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1653. /**
  1654. * 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".
  1655. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1656. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1657. * @param value defines the value to clamp
  1658. * @param min defines the lower limit
  1659. * @param max defines the upper limit
  1660. * @returns a new Vector2
  1661. */
  1662. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1663. /**
  1664. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1665. * @param value1 defines the 1st control point
  1666. * @param tangent1 defines the outgoing tangent
  1667. * @param value2 defines the 2nd control point
  1668. * @param tangent2 defines the incoming tangent
  1669. * @param amount defines the interpolation factor
  1670. * @returns a new Vector2
  1671. */
  1672. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1673. /**
  1674. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1675. * @param start defines the start vector
  1676. * @param end defines the end vector
  1677. * @param amount defines the interpolation factor
  1678. * @returns a new Vector2
  1679. */
  1680. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1681. /**
  1682. * Gets the dot product of the vector "left" and the vector "right"
  1683. * @param left defines first vector
  1684. * @param right defines second vector
  1685. * @returns the dot product (float)
  1686. */
  1687. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1688. /**
  1689. * Returns a new Vector2 equal to the normalized given vector
  1690. * @param vector defines the vector to normalize
  1691. * @returns a new Vector2
  1692. */
  1693. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1694. /**
  1695. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1696. * @param left defines 1st vector
  1697. * @param right defines 2nd vector
  1698. * @returns a new Vector2
  1699. */
  1700. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1701. /**
  1702. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1703. * @param left defines 1st vector
  1704. * @param right defines 2nd vector
  1705. * @returns a new Vector2
  1706. */
  1707. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1708. /**
  1709. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1710. * @param vector defines the vector to transform
  1711. * @param transformation defines the matrix to apply
  1712. * @returns a new Vector2
  1713. */
  1714. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1715. /**
  1716. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1717. * @param vector defines the vector to transform
  1718. * @param transformation defines the matrix to apply
  1719. * @param result defines the target vector
  1720. */
  1721. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1722. /**
  1723. * Determines if a given vector is included in a triangle
  1724. * @param p defines the vector to test
  1725. * @param p0 defines 1st triangle point
  1726. * @param p1 defines 2nd triangle point
  1727. * @param p2 defines 3rd triangle point
  1728. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1729. */
  1730. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1731. /**
  1732. * Gets the distance between the vectors "value1" and "value2"
  1733. * @param value1 defines first vector
  1734. * @param value2 defines second vector
  1735. * @returns the distance between vectors
  1736. */
  1737. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1738. /**
  1739. * Returns the squared distance between the vectors "value1" and "value2"
  1740. * @param value1 defines first vector
  1741. * @param value2 defines second vector
  1742. * @returns the squared distance between vectors
  1743. */
  1744. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1745. /**
  1746. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1747. * @param value1 defines first vector
  1748. * @param value2 defines second vector
  1749. * @returns a new Vector2
  1750. */
  1751. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1752. /**
  1753. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1754. * @param p defines the middle point
  1755. * @param segA defines one point of the segment
  1756. * @param segB defines the other point of the segment
  1757. * @returns the shortest distance
  1758. */
  1759. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1760. }
  1761. /**
  1762. * Classed used to store (x,y,z) vector representation
  1763. * A Vector3 is the main object used in 3D geometry
  1764. * It can represent etiher the coordinates of a point the space, either a direction
  1765. * Reminder: js uses a left handed forward facing system
  1766. */
  1767. export class Vector3 {
  1768. /**
  1769. * Defines the first coordinates (on X axis)
  1770. */
  1771. x: number;
  1772. /**
  1773. * Defines the second coordinates (on Y axis)
  1774. */
  1775. y: number;
  1776. /**
  1777. * Defines the third coordinates (on Z axis)
  1778. */
  1779. z: number;
  1780. private static _UpReadOnly;
  1781. private static _ZeroReadOnly;
  1782. /**
  1783. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1784. * @param x defines the first coordinates (on X axis)
  1785. * @param y defines the second coordinates (on Y axis)
  1786. * @param z defines the third coordinates (on Z axis)
  1787. */
  1788. constructor(
  1789. /**
  1790. * Defines the first coordinates (on X axis)
  1791. */
  1792. x?: number,
  1793. /**
  1794. * Defines the second coordinates (on Y axis)
  1795. */
  1796. y?: number,
  1797. /**
  1798. * Defines the third coordinates (on Z axis)
  1799. */
  1800. z?: number);
  1801. /**
  1802. * Creates a string representation of the Vector3
  1803. * @returns a string with the Vector3 coordinates.
  1804. */
  1805. toString(): string;
  1806. /**
  1807. * Gets the class name
  1808. * @returns the string "Vector3"
  1809. */
  1810. getClassName(): string;
  1811. /**
  1812. * Creates the Vector3 hash code
  1813. * @returns a number which tends to be unique between Vector3 instances
  1814. */
  1815. getHashCode(): number;
  1816. /**
  1817. * Creates an array containing three elements : the coordinates of the Vector3
  1818. * @returns a new array of numbers
  1819. */
  1820. asArray(): number[];
  1821. /**
  1822. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1823. * @param array defines the destination array
  1824. * @param index defines the offset in the destination array
  1825. * @returns the current Vector3
  1826. */
  1827. toArray(array: FloatArray, index?: number): Vector3;
  1828. /**
  1829. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1830. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1831. */
  1832. toQuaternion(): Quaternion;
  1833. /**
  1834. * Adds the given vector to the current Vector3
  1835. * @param otherVector defines the second operand
  1836. * @returns the current updated Vector3
  1837. */
  1838. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1839. /**
  1840. * Adds the given coordinates to the current Vector3
  1841. * @param x defines the x coordinate of the operand
  1842. * @param y defines the y coordinate of the operand
  1843. * @param z defines the z coordinate of the operand
  1844. * @returns the current updated Vector3
  1845. */
  1846. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1847. /**
  1848. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1849. * @param otherVector defines the second operand
  1850. * @returns the resulting Vector3
  1851. */
  1852. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1853. /**
  1854. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1855. * @param otherVector defines the second operand
  1856. * @param result defines the Vector3 object where to store the result
  1857. * @returns the current Vector3
  1858. */
  1859. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1860. /**
  1861. * Subtract the given vector from the current Vector3
  1862. * @param otherVector defines the second operand
  1863. * @returns the current updated Vector3
  1864. */
  1865. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1866. /**
  1867. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1868. * @param otherVector defines the second operand
  1869. * @returns the resulting Vector3
  1870. */
  1871. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1872. /**
  1873. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1874. * @param otherVector defines the second operand
  1875. * @param result defines the Vector3 object where to store the result
  1876. * @returns the current Vector3
  1877. */
  1878. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1879. /**
  1880. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1881. * @param x defines the x coordinate of the operand
  1882. * @param y defines the y coordinate of the operand
  1883. * @param z defines the z coordinate of the operand
  1884. * @returns the resulting Vector3
  1885. */
  1886. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1887. /**
  1888. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1889. * @param x defines the x coordinate of the operand
  1890. * @param y defines the y coordinate of the operand
  1891. * @param z defines the z coordinate of the operand
  1892. * @param result defines the Vector3 object where to store the result
  1893. * @returns the current Vector3
  1894. */
  1895. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1896. /**
  1897. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1898. * @returns a new Vector3
  1899. */
  1900. negate(): Vector3;
  1901. /**
  1902. * Multiplies the Vector3 coordinates by the float "scale"
  1903. * @param scale defines the multiplier factor
  1904. * @returns the current updated Vector3
  1905. */
  1906. scaleInPlace(scale: number): Vector3;
  1907. /**
  1908. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1909. * @param scale defines the multiplier factor
  1910. * @returns a new Vector3
  1911. */
  1912. scale(scale: number): Vector3;
  1913. /**
  1914. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1915. * @param scale defines the multiplier factor
  1916. * @param result defines the Vector3 object where to store the result
  1917. * @returns the current Vector3
  1918. */
  1919. scaleToRef(scale: number, result: Vector3): Vector3;
  1920. /**
  1921. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1922. * @param scale defines the scale factor
  1923. * @param result defines the Vector3 object where to store the result
  1924. * @returns the unmodified current Vector3
  1925. */
  1926. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1927. /**
  1928. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1929. * @param otherVector defines the second operand
  1930. * @returns true if both vectors are equals
  1931. */
  1932. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1933. /**
  1934. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1935. * @param otherVector defines the second operand
  1936. * @param epsilon defines the minimal distance to define values as equals
  1937. * @returns true if both vectors are distant less than epsilon
  1938. */
  1939. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1940. /**
  1941. * Returns true if the current Vector3 coordinates equals the given floats
  1942. * @param x defines the x coordinate of the operand
  1943. * @param y defines the y coordinate of the operand
  1944. * @param z defines the z coordinate of the operand
  1945. * @returns true if both vectors are equals
  1946. */
  1947. equalsToFloats(x: number, y: number, z: number): boolean;
  1948. /**
  1949. * Multiplies the current Vector3 coordinates by the given ones
  1950. * @param otherVector defines the second operand
  1951. * @returns the current updated Vector3
  1952. */
  1953. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1954. /**
  1955. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1956. * @param otherVector defines the second operand
  1957. * @returns the new Vector3
  1958. */
  1959. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1960. /**
  1961. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1962. * @param otherVector defines the second operand
  1963. * @param result defines the Vector3 object where to store the result
  1964. * @returns the current Vector3
  1965. */
  1966. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1967. /**
  1968. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1969. * @param x defines the x coordinate of the operand
  1970. * @param y defines the y coordinate of the operand
  1971. * @param z defines the z coordinate of the operand
  1972. * @returns the new Vector3
  1973. */
  1974. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1975. /**
  1976. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1977. * @param otherVector defines the second operand
  1978. * @returns the new Vector3
  1979. */
  1980. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1981. /**
  1982. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1983. * @param otherVector defines the second operand
  1984. * @param result defines the Vector3 object where to store the result
  1985. * @returns the current Vector3
  1986. */
  1987. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1988. /**
  1989. * Divides the current Vector3 coordinates by the given ones.
  1990. * @param otherVector defines the second operand
  1991. * @returns the current updated Vector3
  1992. */
  1993. divideInPlace(otherVector: Vector3): Vector3;
  1994. /**
  1995. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1996. * @param other defines the second operand
  1997. * @returns the current updated Vector3
  1998. */
  1999. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2000. /**
  2001. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2002. * @param other defines the second operand
  2003. * @returns the current updated Vector3
  2004. */
  2005. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2006. /**
  2007. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2008. * @param x defines the x coordinate of the operand
  2009. * @param y defines the y coordinate of the operand
  2010. * @param z defines the z coordinate of the operand
  2011. * @returns the current updated Vector3
  2012. */
  2013. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2014. /**
  2015. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2016. * @param x defines the x coordinate of the operand
  2017. * @param y defines the y coordinate of the operand
  2018. * @param z defines the z coordinate of the operand
  2019. * @returns the current updated Vector3
  2020. */
  2021. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2022. /**
  2023. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2024. * Check if is non uniform within a certain amount of decimal places to account for this
  2025. * @param epsilon the amount the values can differ
  2026. * @returns if the the vector is non uniform to a certain number of decimal places
  2027. */
  2028. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2029. /**
  2030. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2031. */
  2032. readonly isNonUniform: boolean;
  2033. /**
  2034. * Gets a new Vector3 from current Vector3 floored values
  2035. * @returns a new Vector3
  2036. */
  2037. floor(): Vector3;
  2038. /**
  2039. * Gets a new Vector3 from current Vector3 floored values
  2040. * @returns a new Vector3
  2041. */
  2042. fract(): Vector3;
  2043. /**
  2044. * Gets the length of the Vector3
  2045. * @returns the length of the Vector3
  2046. */
  2047. length(): number;
  2048. /**
  2049. * Gets the squared length of the Vector3
  2050. * @returns squared length of the Vector3
  2051. */
  2052. lengthSquared(): number;
  2053. /**
  2054. * Normalize the current Vector3.
  2055. * Please note that this is an in place operation.
  2056. * @returns the current updated Vector3
  2057. */
  2058. normalize(): Vector3;
  2059. /**
  2060. * Reorders the x y z properties of the vector in place
  2061. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2062. * @returns the current updated vector
  2063. */
  2064. reorderInPlace(order: string): this;
  2065. /**
  2066. * Rotates the vector around 0,0,0 by a quaternion
  2067. * @param quaternion the rotation quaternion
  2068. * @param result vector to store the result
  2069. * @returns the resulting vector
  2070. */
  2071. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2072. /**
  2073. * Rotates a vector around a given point
  2074. * @param quaternion the rotation quaternion
  2075. * @param point the point to rotate around
  2076. * @param result vector to store the result
  2077. * @returns the resulting vector
  2078. */
  2079. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2080. /**
  2081. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2082. * The cross product is then orthogonal to both current and "other"
  2083. * @param other defines the right operand
  2084. * @returns the cross product
  2085. */
  2086. cross(other: Vector3): Vector3;
  2087. /**
  2088. * Normalize the current Vector3 with the given input length.
  2089. * Please note that this is an in place operation.
  2090. * @param len the length of the vector
  2091. * @returns the current updated Vector3
  2092. */
  2093. normalizeFromLength(len: number): Vector3;
  2094. /**
  2095. * Normalize the current Vector3 to a new vector
  2096. * @returns the new Vector3
  2097. */
  2098. normalizeToNew(): Vector3;
  2099. /**
  2100. * Normalize the current Vector3 to the reference
  2101. * @param reference define the Vector3 to update
  2102. * @returns the updated Vector3
  2103. */
  2104. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2105. /**
  2106. * Creates a new Vector3 copied from the current Vector3
  2107. * @returns the new Vector3
  2108. */
  2109. clone(): Vector3;
  2110. /**
  2111. * Copies the given vector coordinates to the current Vector3 ones
  2112. * @param source defines the source Vector3
  2113. * @returns the current updated Vector3
  2114. */
  2115. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2116. /**
  2117. * Copies the given floats to the current Vector3 coordinates
  2118. * @param x defines the x coordinate of the operand
  2119. * @param y defines the y coordinate of the operand
  2120. * @param z defines the z coordinate of the operand
  2121. * @returns the current updated Vector3
  2122. */
  2123. copyFromFloats(x: number, y: number, z: number): Vector3;
  2124. /**
  2125. * Copies the given floats to the current Vector3 coordinates
  2126. * @param x defines the x coordinate of the operand
  2127. * @param y defines the y coordinate of the operand
  2128. * @param z defines the z coordinate of the operand
  2129. * @returns the current updated Vector3
  2130. */
  2131. set(x: number, y: number, z: number): Vector3;
  2132. /**
  2133. * Copies the given float to the current Vector3 coordinates
  2134. * @param v defines the x, y and z coordinates of the operand
  2135. * @returns the current updated Vector3
  2136. */
  2137. setAll(v: number): Vector3;
  2138. /**
  2139. * Get the clip factor between two vectors
  2140. * @param vector0 defines the first operand
  2141. * @param vector1 defines the second operand
  2142. * @param axis defines the axis to use
  2143. * @param size defines the size along the axis
  2144. * @returns the clip factor
  2145. */
  2146. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2147. /**
  2148. * Get angle between two vectors
  2149. * @param vector0 angle between vector0 and vector1
  2150. * @param vector1 angle between vector0 and vector1
  2151. * @param normal direction of the normal
  2152. * @return the angle between vector0 and vector1
  2153. */
  2154. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2155. /**
  2156. * Returns a new Vector3 set from the index "offset" of the given array
  2157. * @param array defines the source array
  2158. * @param offset defines the offset in the source array
  2159. * @returns the new Vector3
  2160. */
  2161. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2162. /**
  2163. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2164. * This function is deprecated. Use FromArray instead
  2165. * @param array defines the source array
  2166. * @param offset defines the offset in the source array
  2167. * @returns the new Vector3
  2168. */
  2169. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2170. /**
  2171. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2172. * @param array defines the source array
  2173. * @param offset defines the offset in the source array
  2174. * @param result defines the Vector3 where to store the result
  2175. */
  2176. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2177. /**
  2178. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2179. * This function is deprecated. Use FromArrayToRef instead.
  2180. * @param array defines the source array
  2181. * @param offset defines the offset in the source array
  2182. * @param result defines the Vector3 where to store the result
  2183. */
  2184. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2185. /**
  2186. * Sets the given vector "result" with the given floats.
  2187. * @param x defines the x coordinate of the source
  2188. * @param y defines the y coordinate of the source
  2189. * @param z defines the z coordinate of the source
  2190. * @param result defines the Vector3 where to store the result
  2191. */
  2192. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2193. /**
  2194. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2195. * @returns a new empty Vector3
  2196. */
  2197. static Zero(): Vector3;
  2198. /**
  2199. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2200. * @returns a new unit Vector3
  2201. */
  2202. static One(): Vector3;
  2203. /**
  2204. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2205. * @returns a new up Vector3
  2206. */
  2207. static Up(): Vector3;
  2208. /**
  2209. * Gets a up Vector3 that must not be updated
  2210. */
  2211. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2212. /**
  2213. * Gets a zero Vector3 that must not be updated
  2214. */
  2215. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2216. /**
  2217. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2218. * @returns a new down Vector3
  2219. */
  2220. static Down(): Vector3;
  2221. /**
  2222. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2223. * @returns a new forward Vector3
  2224. */
  2225. static Forward(): Vector3;
  2226. /**
  2227. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2228. * @returns a new forward Vector3
  2229. */
  2230. static Backward(): Vector3;
  2231. /**
  2232. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2233. * @returns a new right Vector3
  2234. */
  2235. static Right(): Vector3;
  2236. /**
  2237. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2238. * @returns a new left Vector3
  2239. */
  2240. static Left(): Vector3;
  2241. /**
  2242. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2243. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2244. * @param vector defines the Vector3 to transform
  2245. * @param transformation defines the transformation matrix
  2246. * @returns the transformed Vector3
  2247. */
  2248. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2249. /**
  2250. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2251. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2252. * @param vector defines the Vector3 to transform
  2253. * @param transformation defines the transformation matrix
  2254. * @param result defines the Vector3 where to store the result
  2255. */
  2256. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2257. /**
  2258. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2259. * This method computes tranformed coordinates only, not transformed direction vectors
  2260. * @param x define the x coordinate of the source vector
  2261. * @param y define the y coordinate of the source vector
  2262. * @param z define the z coordinate of the source vector
  2263. * @param transformation defines the transformation matrix
  2264. * @param result defines the Vector3 where to store the result
  2265. */
  2266. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2267. /**
  2268. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2269. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2270. * @param vector defines the Vector3 to transform
  2271. * @param transformation defines the transformation matrix
  2272. * @returns the new Vector3
  2273. */
  2274. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2275. /**
  2276. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2277. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2278. * @param vector defines the Vector3 to transform
  2279. * @param transformation defines the transformation matrix
  2280. * @param result defines the Vector3 where to store the result
  2281. */
  2282. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2283. /**
  2284. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2285. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2286. * @param x define the x coordinate of the source vector
  2287. * @param y define the y coordinate of the source vector
  2288. * @param z define the z coordinate of the source vector
  2289. * @param transformation defines the transformation matrix
  2290. * @param result defines the Vector3 where to store the result
  2291. */
  2292. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2293. /**
  2294. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2295. * @param value1 defines the first control point
  2296. * @param value2 defines the second control point
  2297. * @param value3 defines the third control point
  2298. * @param value4 defines the fourth control point
  2299. * @param amount defines the amount on the spline to use
  2300. * @returns the new Vector3
  2301. */
  2302. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2303. /**
  2304. * 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"
  2305. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2306. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2307. * @param value defines the current value
  2308. * @param min defines the lower range value
  2309. * @param max defines the upper range value
  2310. * @returns the new Vector3
  2311. */
  2312. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2313. /**
  2314. * 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"
  2315. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2316. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2317. * @param value defines the current value
  2318. * @param min defines the lower range value
  2319. * @param max defines the upper range value
  2320. * @param result defines the Vector3 where to store the result
  2321. */
  2322. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2323. /**
  2324. * Checks if a given vector is inside a specific range
  2325. * @param v defines the vector to test
  2326. * @param min defines the minimum range
  2327. * @param max defines the maximum range
  2328. */
  2329. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2330. /**
  2331. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2332. * @param value1 defines the first control point
  2333. * @param tangent1 defines the first tangent vector
  2334. * @param value2 defines the second control point
  2335. * @param tangent2 defines the second tangent vector
  2336. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2337. * @returns the new Vector3
  2338. */
  2339. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2340. /**
  2341. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2342. * @param start defines the start value
  2343. * @param end defines the end value
  2344. * @param amount max defines amount between both (between 0 and 1)
  2345. * @returns the new Vector3
  2346. */
  2347. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2348. /**
  2349. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2350. * @param start defines the start value
  2351. * @param end defines the end value
  2352. * @param amount max defines amount between both (between 0 and 1)
  2353. * @param result defines the Vector3 where to store the result
  2354. */
  2355. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2356. /**
  2357. * Returns the dot product (float) between the vectors "left" and "right"
  2358. * @param left defines the left operand
  2359. * @param right defines the right operand
  2360. * @returns the dot product
  2361. */
  2362. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2363. /**
  2364. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2365. * The cross product is then orthogonal to both "left" and "right"
  2366. * @param left defines the left operand
  2367. * @param right defines the right operand
  2368. * @returns the cross product
  2369. */
  2370. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2371. /**
  2372. * Sets the given vector "result" with the cross product of "left" and "right"
  2373. * The cross product is then orthogonal to both "left" and "right"
  2374. * @param left defines the left operand
  2375. * @param right defines the right operand
  2376. * @param result defines the Vector3 where to store the result
  2377. */
  2378. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2379. /**
  2380. * Returns a new Vector3 as the normalization of the given vector
  2381. * @param vector defines the Vector3 to normalize
  2382. * @returns the new Vector3
  2383. */
  2384. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2385. /**
  2386. * Sets the given vector "result" with the normalization of the given first vector
  2387. * @param vector defines the Vector3 to normalize
  2388. * @param result defines the Vector3 where to store the result
  2389. */
  2390. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2391. /**
  2392. * Project a Vector3 onto screen space
  2393. * @param vector defines the Vector3 to project
  2394. * @param world defines the world matrix to use
  2395. * @param transform defines the transform (view x projection) matrix to use
  2396. * @param viewport defines the screen viewport to use
  2397. * @returns the new Vector3
  2398. */
  2399. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2400. /** @hidden */
  2401. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2402. /**
  2403. * Unproject from screen space to object space
  2404. * @param source defines the screen space Vector3 to use
  2405. * @param viewportWidth defines the current width of the viewport
  2406. * @param viewportHeight defines the current height of the viewport
  2407. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2408. * @param transform defines the transform (view x projection) matrix to use
  2409. * @returns the new Vector3
  2410. */
  2411. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2412. /**
  2413. * Unproject from screen space to object space
  2414. * @param source defines the screen space Vector3 to use
  2415. * @param viewportWidth defines the current width of the viewport
  2416. * @param viewportHeight defines the current height of the viewport
  2417. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2418. * @param view defines the view matrix to use
  2419. * @param projection defines the projection matrix to use
  2420. * @returns the new Vector3
  2421. */
  2422. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2423. /**
  2424. * Unproject from screen space to object space
  2425. * @param source defines the screen space Vector3 to use
  2426. * @param viewportWidth defines the current width of the viewport
  2427. * @param viewportHeight defines the current height of the viewport
  2428. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2429. * @param view defines the view matrix to use
  2430. * @param projection defines the projection matrix to use
  2431. * @param result defines the Vector3 where to store the result
  2432. */
  2433. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2434. /**
  2435. * Unproject from screen space to object space
  2436. * @param sourceX defines the screen space x coordinate to use
  2437. * @param sourceY defines the screen space y coordinate to use
  2438. * @param sourceZ defines the screen space z coordinate to use
  2439. * @param viewportWidth defines the current width of the viewport
  2440. * @param viewportHeight defines the current height of the viewport
  2441. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2442. * @param view defines the view matrix to use
  2443. * @param projection defines the projection matrix to use
  2444. * @param result defines the Vector3 where to store the result
  2445. */
  2446. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2447. /**
  2448. * Gets the minimal coordinate values between two Vector3
  2449. * @param left defines the first operand
  2450. * @param right defines the second operand
  2451. * @returns the new Vector3
  2452. */
  2453. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2454. /**
  2455. * Gets the maximal coordinate values between two Vector3
  2456. * @param left defines the first operand
  2457. * @param right defines the second operand
  2458. * @returns the new Vector3
  2459. */
  2460. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2461. /**
  2462. * Returns the distance between the vectors "value1" and "value2"
  2463. * @param value1 defines the first operand
  2464. * @param value2 defines the second operand
  2465. * @returns the distance
  2466. */
  2467. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2468. /**
  2469. * Returns the squared distance between the vectors "value1" and "value2"
  2470. * @param value1 defines the first operand
  2471. * @param value2 defines the second operand
  2472. * @returns the squared distance
  2473. */
  2474. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2475. /**
  2476. * Returns a new Vector3 located at the center between "value1" and "value2"
  2477. * @param value1 defines the first operand
  2478. * @param value2 defines the second operand
  2479. * @returns the new Vector3
  2480. */
  2481. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2482. /**
  2483. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2484. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2485. * to something in order to rotate it from its local system to the given target system
  2486. * Note: axis1, axis2 and axis3 are normalized during this operation
  2487. * @param axis1 defines the first axis
  2488. * @param axis2 defines the second axis
  2489. * @param axis3 defines the third axis
  2490. * @returns a new Vector3
  2491. */
  2492. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2493. /**
  2494. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2495. * @param axis1 defines the first axis
  2496. * @param axis2 defines the second axis
  2497. * @param axis3 defines the third axis
  2498. * @param ref defines the Vector3 where to store the result
  2499. */
  2500. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2501. }
  2502. /**
  2503. * Vector4 class created for EulerAngle class conversion to Quaternion
  2504. */
  2505. export class Vector4 {
  2506. /** x value of the vector */
  2507. x: number;
  2508. /** y value of the vector */
  2509. y: number;
  2510. /** z value of the vector */
  2511. z: number;
  2512. /** w value of the vector */
  2513. w: number;
  2514. /**
  2515. * Creates a Vector4 object from the given floats.
  2516. * @param x x value of the vector
  2517. * @param y y value of the vector
  2518. * @param z z value of the vector
  2519. * @param w w value of the vector
  2520. */
  2521. constructor(
  2522. /** x value of the vector */
  2523. x: number,
  2524. /** y value of the vector */
  2525. y: number,
  2526. /** z value of the vector */
  2527. z: number,
  2528. /** w value of the vector */
  2529. w: number);
  2530. /**
  2531. * Returns the string with the Vector4 coordinates.
  2532. * @returns a string containing all the vector values
  2533. */
  2534. toString(): string;
  2535. /**
  2536. * Returns the string "Vector4".
  2537. * @returns "Vector4"
  2538. */
  2539. getClassName(): string;
  2540. /**
  2541. * Returns the Vector4 hash code.
  2542. * @returns a unique hash code
  2543. */
  2544. getHashCode(): number;
  2545. /**
  2546. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2547. * @returns the resulting array
  2548. */
  2549. asArray(): number[];
  2550. /**
  2551. * Populates the given array from the given index with the Vector4 coordinates.
  2552. * @param array array to populate
  2553. * @param index index of the array to start at (default: 0)
  2554. * @returns the Vector4.
  2555. */
  2556. toArray(array: FloatArray, index?: number): Vector4;
  2557. /**
  2558. * Adds the given vector to the current Vector4.
  2559. * @param otherVector the vector to add
  2560. * @returns the updated Vector4.
  2561. */
  2562. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2563. /**
  2564. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2565. * @param otherVector the vector to add
  2566. * @returns the resulting vector
  2567. */
  2568. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2569. /**
  2570. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2571. * @param otherVector the vector to add
  2572. * @param result the vector to store the result
  2573. * @returns the current Vector4.
  2574. */
  2575. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2576. /**
  2577. * Subtract in place the given vector from the current Vector4.
  2578. * @param otherVector the vector to subtract
  2579. * @returns the updated Vector4.
  2580. */
  2581. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2582. /**
  2583. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2584. * @param otherVector the vector to add
  2585. * @returns the new vector with the result
  2586. */
  2587. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2588. /**
  2589. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2590. * @param otherVector the vector to subtract
  2591. * @param result the vector to store the result
  2592. * @returns the current Vector4.
  2593. */
  2594. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2595. /**
  2596. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2597. */
  2598. /**
  2599. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2600. * @param x value to subtract
  2601. * @param y value to subtract
  2602. * @param z value to subtract
  2603. * @param w value to subtract
  2604. * @returns new vector containing the result
  2605. */
  2606. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2607. /**
  2608. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2609. * @param x value to subtract
  2610. * @param y value to subtract
  2611. * @param z value to subtract
  2612. * @param w value to subtract
  2613. * @param result the vector to store the result in
  2614. * @returns the current Vector4.
  2615. */
  2616. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2617. /**
  2618. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2619. * @returns a new vector with the negated values
  2620. */
  2621. negate(): Vector4;
  2622. /**
  2623. * Multiplies the current Vector4 coordinates by scale (float).
  2624. * @param scale the number to scale with
  2625. * @returns the updated Vector4.
  2626. */
  2627. scaleInPlace(scale: number): Vector4;
  2628. /**
  2629. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2630. * @param scale the number to scale with
  2631. * @returns a new vector with the result
  2632. */
  2633. scale(scale: number): Vector4;
  2634. /**
  2635. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2636. * @param scale the number to scale with
  2637. * @param result a vector to store the result in
  2638. * @returns the current Vector4.
  2639. */
  2640. scaleToRef(scale: number, result: Vector4): Vector4;
  2641. /**
  2642. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2643. * @param scale defines the scale factor
  2644. * @param result defines the Vector4 object where to store the result
  2645. * @returns the unmodified current Vector4
  2646. */
  2647. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2648. /**
  2649. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2650. * @param otherVector the vector to compare against
  2651. * @returns true if they are equal
  2652. */
  2653. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2654. /**
  2655. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2656. * @param otherVector vector to compare against
  2657. * @param epsilon (Default: very small number)
  2658. * @returns true if they are equal
  2659. */
  2660. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2661. /**
  2662. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2663. * @param x x value to compare against
  2664. * @param y y value to compare against
  2665. * @param z z value to compare against
  2666. * @param w w value to compare against
  2667. * @returns true if equal
  2668. */
  2669. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2670. /**
  2671. * Multiplies in place the current Vector4 by the given one.
  2672. * @param otherVector vector to multiple with
  2673. * @returns the updated Vector4.
  2674. */
  2675. multiplyInPlace(otherVector: Vector4): Vector4;
  2676. /**
  2677. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2678. * @param otherVector vector to multiple with
  2679. * @returns resulting new vector
  2680. */
  2681. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2682. /**
  2683. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2684. * @param otherVector vector to multiple with
  2685. * @param result vector to store the result
  2686. * @returns the current Vector4.
  2687. */
  2688. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2689. /**
  2690. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2691. * @param x x value multiply with
  2692. * @param y y value multiply with
  2693. * @param z z value multiply with
  2694. * @param w w value multiply with
  2695. * @returns resulting new vector
  2696. */
  2697. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2698. /**
  2699. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2700. * @param otherVector vector to devide with
  2701. * @returns resulting new vector
  2702. */
  2703. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2704. /**
  2705. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2706. * @param otherVector vector to devide with
  2707. * @param result vector to store the result
  2708. * @returns the current Vector4.
  2709. */
  2710. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2711. /**
  2712. * Divides the current Vector3 coordinates by the given ones.
  2713. * @param otherVector vector to devide with
  2714. * @returns the updated Vector3.
  2715. */
  2716. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2717. /**
  2718. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2719. * @param other defines the second operand
  2720. * @returns the current updated Vector4
  2721. */
  2722. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2723. /**
  2724. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2725. * @param other defines the second operand
  2726. * @returns the current updated Vector4
  2727. */
  2728. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2729. /**
  2730. * Gets a new Vector4 from current Vector4 floored values
  2731. * @returns a new Vector4
  2732. */
  2733. floor(): Vector4;
  2734. /**
  2735. * Gets a new Vector4 from current Vector3 floored values
  2736. * @returns a new Vector4
  2737. */
  2738. fract(): Vector4;
  2739. /**
  2740. * Returns the Vector4 length (float).
  2741. * @returns the length
  2742. */
  2743. length(): number;
  2744. /**
  2745. * Returns the Vector4 squared length (float).
  2746. * @returns the length squared
  2747. */
  2748. lengthSquared(): number;
  2749. /**
  2750. * Normalizes in place the Vector4.
  2751. * @returns the updated Vector4.
  2752. */
  2753. normalize(): Vector4;
  2754. /**
  2755. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2756. * @returns this converted to a new vector3
  2757. */
  2758. toVector3(): Vector3;
  2759. /**
  2760. * Returns a new Vector4 copied from the current one.
  2761. * @returns the new cloned vector
  2762. */
  2763. clone(): Vector4;
  2764. /**
  2765. * Updates the current Vector4 with the given one coordinates.
  2766. * @param source the source vector to copy from
  2767. * @returns the updated Vector4.
  2768. */
  2769. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2770. /**
  2771. * Updates the current Vector4 coordinates with the given floats.
  2772. * @param x float to copy from
  2773. * @param y float to copy from
  2774. * @param z float to copy from
  2775. * @param w float to copy from
  2776. * @returns the updated Vector4.
  2777. */
  2778. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2779. /**
  2780. * Updates the current Vector4 coordinates with the given floats.
  2781. * @param x float to set from
  2782. * @param y float to set from
  2783. * @param z float to set from
  2784. * @param w float to set from
  2785. * @returns the updated Vector4.
  2786. */
  2787. set(x: number, y: number, z: number, w: number): Vector4;
  2788. /**
  2789. * Copies the given float to the current Vector3 coordinates
  2790. * @param v defines the x, y, z and w coordinates of the operand
  2791. * @returns the current updated Vector3
  2792. */
  2793. setAll(v: number): Vector4;
  2794. /**
  2795. * Returns a new Vector4 set from the starting index of the given array.
  2796. * @param array the array to pull values from
  2797. * @param offset the offset into the array to start at
  2798. * @returns the new vector
  2799. */
  2800. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2801. /**
  2802. * Updates the given vector "result" from the starting index of the given array.
  2803. * @param array the array to pull values from
  2804. * @param offset the offset into the array to start at
  2805. * @param result the vector to store the result in
  2806. */
  2807. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2808. /**
  2809. * Updates the given vector "result" from the starting index of the given Float32Array.
  2810. * @param array the array to pull values from
  2811. * @param offset the offset into the array to start at
  2812. * @param result the vector to store the result in
  2813. */
  2814. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2815. /**
  2816. * Updates the given vector "result" coordinates from the given floats.
  2817. * @param x float to set from
  2818. * @param y float to set from
  2819. * @param z float to set from
  2820. * @param w float to set from
  2821. * @param result the vector to the floats in
  2822. */
  2823. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2824. /**
  2825. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2826. * @returns the new vector
  2827. */
  2828. static Zero(): Vector4;
  2829. /**
  2830. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2831. * @returns the new vector
  2832. */
  2833. static One(): Vector4;
  2834. /**
  2835. * Returns a new normalized Vector4 from the given one.
  2836. * @param vector the vector to normalize
  2837. * @returns the vector
  2838. */
  2839. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2840. /**
  2841. * Updates the given vector "result" from the normalization of the given one.
  2842. * @param vector the vector to normalize
  2843. * @param result the vector to store the result in
  2844. */
  2845. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2846. /**
  2847. * Returns a vector with the minimum values from the left and right vectors
  2848. * @param left left vector to minimize
  2849. * @param right right vector to minimize
  2850. * @returns a new vector with the minimum of the left and right vector values
  2851. */
  2852. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2853. /**
  2854. * Returns a vector with the maximum values from the left and right vectors
  2855. * @param left left vector to maximize
  2856. * @param right right vector to maximize
  2857. * @returns a new vector with the maximum of the left and right vector values
  2858. */
  2859. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2860. /**
  2861. * Returns the distance (float) between the vectors "value1" and "value2".
  2862. * @param value1 value to calulate the distance between
  2863. * @param value2 value to calulate the distance between
  2864. * @return the distance between the two vectors
  2865. */
  2866. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2867. /**
  2868. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2869. * @param value1 value to calulate the distance between
  2870. * @param value2 value to calulate the distance between
  2871. * @return the distance between the two vectors squared
  2872. */
  2873. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2874. /**
  2875. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2876. * @param value1 value to calulate the center between
  2877. * @param value2 value to calulate the center between
  2878. * @return the center between the two vectors
  2879. */
  2880. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2881. /**
  2882. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2883. * This methods computes transformed normalized direction vectors only.
  2884. * @param vector the vector to transform
  2885. * @param transformation the transformation matrix to apply
  2886. * @returns the new vector
  2887. */
  2888. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2889. /**
  2890. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2891. * This methods computes transformed normalized direction vectors only.
  2892. * @param vector the vector to transform
  2893. * @param transformation the transformation matrix to apply
  2894. * @param result the vector to store the result in
  2895. */
  2896. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2897. /**
  2898. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2899. * This methods computes transformed normalized direction vectors only.
  2900. * @param x value to transform
  2901. * @param y value to transform
  2902. * @param z value to transform
  2903. * @param w value to transform
  2904. * @param transformation the transformation matrix to apply
  2905. * @param result the vector to store the results in
  2906. */
  2907. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2908. /**
  2909. * Creates a new Vector4 from a Vector3
  2910. * @param source defines the source data
  2911. * @param w defines the 4th component (default is 0)
  2912. * @returns a new Vector4
  2913. */
  2914. static FromVector3(source: Vector3, w?: number): Vector4;
  2915. }
  2916. /**
  2917. * Class used to store quaternion data
  2918. * @see https://en.wikipedia.org/wiki/Quaternion
  2919. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2920. */
  2921. export class Quaternion {
  2922. /** defines the first component (0 by default) */
  2923. x: number;
  2924. /** defines the second component (0 by default) */
  2925. y: number;
  2926. /** defines the third component (0 by default) */
  2927. z: number;
  2928. /** defines the fourth component (1.0 by default) */
  2929. w: number;
  2930. /**
  2931. * Creates a new Quaternion from the given floats
  2932. * @param x defines the first component (0 by default)
  2933. * @param y defines the second component (0 by default)
  2934. * @param z defines the third component (0 by default)
  2935. * @param w defines the fourth component (1.0 by default)
  2936. */
  2937. constructor(
  2938. /** defines the first component (0 by default) */
  2939. x?: number,
  2940. /** defines the second component (0 by default) */
  2941. y?: number,
  2942. /** defines the third component (0 by default) */
  2943. z?: number,
  2944. /** defines the fourth component (1.0 by default) */
  2945. w?: number);
  2946. /**
  2947. * Gets a string representation for the current quaternion
  2948. * @returns a string with the Quaternion coordinates
  2949. */
  2950. toString(): string;
  2951. /**
  2952. * Gets the class name of the quaternion
  2953. * @returns the string "Quaternion"
  2954. */
  2955. getClassName(): string;
  2956. /**
  2957. * Gets a hash code for this quaternion
  2958. * @returns the quaternion hash code
  2959. */
  2960. getHashCode(): number;
  2961. /**
  2962. * Copy the quaternion to an array
  2963. * @returns a new array populated with 4 elements from the quaternion coordinates
  2964. */
  2965. asArray(): number[];
  2966. /**
  2967. * Check if two quaternions are equals
  2968. * @param otherQuaternion defines the second operand
  2969. * @return true if the current quaternion and the given one coordinates are strictly equals
  2970. */
  2971. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2972. /**
  2973. * Clone the current quaternion
  2974. * @returns a new quaternion copied from the current one
  2975. */
  2976. clone(): Quaternion;
  2977. /**
  2978. * Copy a quaternion to the current one
  2979. * @param other defines the other quaternion
  2980. * @returns the updated current quaternion
  2981. */
  2982. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2983. /**
  2984. * Updates the current quaternion with the given float coordinates
  2985. * @param x defines the x coordinate
  2986. * @param y defines the y coordinate
  2987. * @param z defines the z coordinate
  2988. * @param w defines the w coordinate
  2989. * @returns the updated current quaternion
  2990. */
  2991. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2992. /**
  2993. * Updates the current quaternion from the given float coordinates
  2994. * @param x defines the x coordinate
  2995. * @param y defines the y coordinate
  2996. * @param z defines the z coordinate
  2997. * @param w defines the w coordinate
  2998. * @returns the updated current quaternion
  2999. */
  3000. set(x: number, y: number, z: number, w: number): Quaternion;
  3001. /**
  3002. * Adds two quaternions
  3003. * @param other defines the second operand
  3004. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3005. */
  3006. add(other: DeepImmutable<Quaternion>): Quaternion;
  3007. /**
  3008. * Add a quaternion to the current one
  3009. * @param other defines the quaternion to add
  3010. * @returns the current quaternion
  3011. */
  3012. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3013. /**
  3014. * Subtract two quaternions
  3015. * @param other defines the second operand
  3016. * @returns a new quaternion as the subtraction result of the given one from the current one
  3017. */
  3018. subtract(other: Quaternion): Quaternion;
  3019. /**
  3020. * Multiplies the current quaternion by a scale factor
  3021. * @param value defines the scale factor
  3022. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3023. */
  3024. scale(value: number): Quaternion;
  3025. /**
  3026. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3027. * @param scale defines the scale factor
  3028. * @param result defines the Quaternion object where to store the result
  3029. * @returns the unmodified current quaternion
  3030. */
  3031. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3032. /**
  3033. * Multiplies in place the current quaternion by a scale factor
  3034. * @param value defines the scale factor
  3035. * @returns the current modified quaternion
  3036. */
  3037. scaleInPlace(value: number): Quaternion;
  3038. /**
  3039. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3040. * @param scale defines the scale factor
  3041. * @param result defines the Quaternion object where to store the result
  3042. * @returns the unmodified current quaternion
  3043. */
  3044. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3045. /**
  3046. * Multiplies two quaternions
  3047. * @param q1 defines the second operand
  3048. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3049. */
  3050. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3051. /**
  3052. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3053. * @param q1 defines the second operand
  3054. * @param result defines the target quaternion
  3055. * @returns the current quaternion
  3056. */
  3057. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3058. /**
  3059. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3060. * @param q1 defines the second operand
  3061. * @returns the currentupdated quaternion
  3062. */
  3063. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3064. /**
  3065. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3066. * @param ref defines the target quaternion
  3067. * @returns the current quaternion
  3068. */
  3069. conjugateToRef(ref: Quaternion): Quaternion;
  3070. /**
  3071. * Conjugates in place (1-q) the current quaternion
  3072. * @returns the current updated quaternion
  3073. */
  3074. conjugateInPlace(): Quaternion;
  3075. /**
  3076. * Conjugates in place (1-q) the current quaternion
  3077. * @returns a new quaternion
  3078. */
  3079. conjugate(): Quaternion;
  3080. /**
  3081. * Gets length of current quaternion
  3082. * @returns the quaternion length (float)
  3083. */
  3084. length(): number;
  3085. /**
  3086. * Normalize in place the current quaternion
  3087. * @returns the current updated quaternion
  3088. */
  3089. normalize(): Quaternion;
  3090. /**
  3091. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3092. * @param order is a reserved parameter and is ignore for now
  3093. * @returns a new Vector3 containing the Euler angles
  3094. */
  3095. toEulerAngles(order?: string): Vector3;
  3096. /**
  3097. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3098. * @param result defines the vector which will be filled with the Euler angles
  3099. * @param order is a reserved parameter and is ignore for now
  3100. * @returns the current unchanged quaternion
  3101. */
  3102. toEulerAnglesToRef(result: Vector3): Quaternion;
  3103. /**
  3104. * Updates the given rotation matrix with the current quaternion values
  3105. * @param result defines the target matrix
  3106. * @returns the current unchanged quaternion
  3107. */
  3108. toRotationMatrix(result: Matrix): Quaternion;
  3109. /**
  3110. * Updates the current quaternion from the given rotation matrix values
  3111. * @param matrix defines the source matrix
  3112. * @returns the current updated quaternion
  3113. */
  3114. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3115. /**
  3116. * Creates a new quaternion from a rotation matrix
  3117. * @param matrix defines the source matrix
  3118. * @returns a new quaternion created from the given rotation matrix values
  3119. */
  3120. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3121. /**
  3122. * Updates the given quaternion with the given rotation matrix values
  3123. * @param matrix defines the source matrix
  3124. * @param result defines the target quaternion
  3125. */
  3126. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3127. /**
  3128. * Returns the dot product (float) between the quaternions "left" and "right"
  3129. * @param left defines the left operand
  3130. * @param right defines the right operand
  3131. * @returns the dot product
  3132. */
  3133. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3134. /**
  3135. * Checks if the two quaternions are close to each other
  3136. * @param quat0 defines the first quaternion to check
  3137. * @param quat1 defines the second quaternion to check
  3138. * @returns true if the two quaternions are close to each other
  3139. */
  3140. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3141. /**
  3142. * Creates an empty quaternion
  3143. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3144. */
  3145. static Zero(): Quaternion;
  3146. /**
  3147. * Inverse a given quaternion
  3148. * @param q defines the source quaternion
  3149. * @returns a new quaternion as the inverted current quaternion
  3150. */
  3151. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3152. /**
  3153. * Inverse a given quaternion
  3154. * @param q defines the source quaternion
  3155. * @param result the quaternion the result will be stored in
  3156. * @returns the result quaternion
  3157. */
  3158. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3159. /**
  3160. * Creates an identity quaternion
  3161. * @returns the identity quaternion
  3162. */
  3163. static Identity(): Quaternion;
  3164. /**
  3165. * Gets a boolean indicating if the given quaternion is identity
  3166. * @param quaternion defines the quaternion to check
  3167. * @returns true if the quaternion is identity
  3168. */
  3169. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3170. /**
  3171. * Creates a quaternion from a rotation around an axis
  3172. * @param axis defines the axis to use
  3173. * @param angle defines the angle to use
  3174. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3175. */
  3176. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3177. /**
  3178. * Creates a rotation around an axis and stores it into the given quaternion
  3179. * @param axis defines the axis to use
  3180. * @param angle defines the angle to use
  3181. * @param result defines the target quaternion
  3182. * @returns the target quaternion
  3183. */
  3184. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3185. /**
  3186. * Creates a new quaternion from data stored into an array
  3187. * @param array defines the data source
  3188. * @param offset defines the offset in the source array where the data starts
  3189. * @returns a new quaternion
  3190. */
  3191. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3192. /**
  3193. * Create a quaternion from Euler rotation angles
  3194. * @param x Pitch
  3195. * @param y Yaw
  3196. * @param z Roll
  3197. * @returns the new Quaternion
  3198. */
  3199. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3200. /**
  3201. * Updates a quaternion from Euler rotation angles
  3202. * @param x Pitch
  3203. * @param y Yaw
  3204. * @param z Roll
  3205. * @param result the quaternion to store the result
  3206. * @returns the updated quaternion
  3207. */
  3208. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3209. /**
  3210. * Create a quaternion from Euler rotation vector
  3211. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3212. * @returns the new Quaternion
  3213. */
  3214. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3215. /**
  3216. * Updates a quaternion from Euler rotation vector
  3217. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3218. * @param result the quaternion to store the result
  3219. * @returns the updated quaternion
  3220. */
  3221. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3222. /**
  3223. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3224. * @param yaw defines the rotation around Y axis
  3225. * @param pitch defines the rotation around X axis
  3226. * @param roll defines the rotation around Z axis
  3227. * @returns the new quaternion
  3228. */
  3229. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3230. /**
  3231. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3232. * @param yaw defines the rotation around Y axis
  3233. * @param pitch defines the rotation around X axis
  3234. * @param roll defines the rotation around Z axis
  3235. * @param result defines the target quaternion
  3236. */
  3237. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3238. /**
  3239. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3240. * @param alpha defines the rotation around first axis
  3241. * @param beta defines the rotation around second axis
  3242. * @param gamma defines the rotation around third axis
  3243. * @returns the new quaternion
  3244. */
  3245. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3246. /**
  3247. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3248. * @param alpha defines the rotation around first axis
  3249. * @param beta defines the rotation around second axis
  3250. * @param gamma defines the rotation around third axis
  3251. * @param result defines the target quaternion
  3252. */
  3253. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3254. /**
  3255. * 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)
  3256. * @param axis1 defines the first axis
  3257. * @param axis2 defines the second axis
  3258. * @param axis3 defines the third axis
  3259. * @returns the new quaternion
  3260. */
  3261. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3262. /**
  3263. * 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
  3264. * @param axis1 defines the first axis
  3265. * @param axis2 defines the second axis
  3266. * @param axis3 defines the third axis
  3267. * @param ref defines the target quaternion
  3268. */
  3269. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3270. /**
  3271. * Interpolates between two quaternions
  3272. * @param left defines first quaternion
  3273. * @param right defines second quaternion
  3274. * @param amount defines the gradient to use
  3275. * @returns the new interpolated quaternion
  3276. */
  3277. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3278. /**
  3279. * Interpolates between two quaternions and stores it into a target quaternion
  3280. * @param left defines first quaternion
  3281. * @param right defines second quaternion
  3282. * @param amount defines the gradient to use
  3283. * @param result defines the target quaternion
  3284. */
  3285. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3286. /**
  3287. * Interpolate between two quaternions using Hermite interpolation
  3288. * @param value1 defines first quaternion
  3289. * @param tangent1 defines the incoming tangent
  3290. * @param value2 defines second quaternion
  3291. * @param tangent2 defines the outgoing tangent
  3292. * @param amount defines the target quaternion
  3293. * @returns the new interpolated quaternion
  3294. */
  3295. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3296. }
  3297. /**
  3298. * Class used to store matrix data (4x4)
  3299. */
  3300. export class Matrix {
  3301. private static _updateFlagSeed;
  3302. private static _identityReadOnly;
  3303. private _isIdentity;
  3304. private _isIdentityDirty;
  3305. private _isIdentity3x2;
  3306. private _isIdentity3x2Dirty;
  3307. /**
  3308. * Gets the update flag of the matrix which is an unique number for the matrix.
  3309. * It will be incremented every time the matrix data change.
  3310. * You can use it to speed the comparison between two versions of the same matrix.
  3311. */
  3312. updateFlag: number;
  3313. private readonly _m;
  3314. /**
  3315. * Gets the internal data of the matrix
  3316. */
  3317. readonly m: DeepImmutable<Float32Array>;
  3318. /** @hidden */
  3319. _markAsUpdated(): void;
  3320. /** @hidden */
  3321. private _updateIdentityStatus;
  3322. /**
  3323. * Creates an empty matrix (filled with zeros)
  3324. */
  3325. constructor();
  3326. /**
  3327. * Check if the current matrix is identity
  3328. * @returns true is the matrix is the identity matrix
  3329. */
  3330. isIdentity(): boolean;
  3331. /**
  3332. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3333. * @returns true is the matrix is the identity matrix
  3334. */
  3335. isIdentityAs3x2(): boolean;
  3336. /**
  3337. * Gets the determinant of the matrix
  3338. * @returns the matrix determinant
  3339. */
  3340. determinant(): number;
  3341. /**
  3342. * Returns the matrix as a Float32Array
  3343. * @returns the matrix underlying array
  3344. */
  3345. toArray(): DeepImmutable<Float32Array>;
  3346. /**
  3347. * Returns the matrix as a Float32Array
  3348. * @returns the matrix underlying array.
  3349. */
  3350. asArray(): DeepImmutable<Float32Array>;
  3351. /**
  3352. * Inverts the current matrix in place
  3353. * @returns the current inverted matrix
  3354. */
  3355. invert(): Matrix;
  3356. /**
  3357. * Sets all the matrix elements to zero
  3358. * @returns the current matrix
  3359. */
  3360. reset(): Matrix;
  3361. /**
  3362. * Adds the current matrix with a second one
  3363. * @param other defines the matrix to add
  3364. * @returns a new matrix as the addition of the current matrix and the given one
  3365. */
  3366. add(other: DeepImmutable<Matrix>): Matrix;
  3367. /**
  3368. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3369. * @param other defines the matrix to add
  3370. * @param result defines the target matrix
  3371. * @returns the current matrix
  3372. */
  3373. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3374. /**
  3375. * Adds in place the given matrix to the current matrix
  3376. * @param other defines the second operand
  3377. * @returns the current updated matrix
  3378. */
  3379. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3380. /**
  3381. * Sets the given matrix to the current inverted Matrix
  3382. * @param other defines the target matrix
  3383. * @returns the unmodified current matrix
  3384. */
  3385. invertToRef(other: Matrix): Matrix;
  3386. /**
  3387. * add a value at the specified position in the current Matrix
  3388. * @param index the index of the value within the matrix. between 0 and 15.
  3389. * @param value the value to be added
  3390. * @returns the current updated matrix
  3391. */
  3392. addAtIndex(index: number, value: number): Matrix;
  3393. /**
  3394. * mutiply the specified position in the current Matrix by a value
  3395. * @param index the index of the value within the matrix. between 0 and 15.
  3396. * @param value the value to be added
  3397. * @returns the current updated matrix
  3398. */
  3399. multiplyAtIndex(index: number, value: number): Matrix;
  3400. /**
  3401. * Inserts the translation vector (using 3 floats) in the current matrix
  3402. * @param x defines the 1st component of the translation
  3403. * @param y defines the 2nd component of the translation
  3404. * @param z defines the 3rd component of the translation
  3405. * @returns the current updated matrix
  3406. */
  3407. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3408. /**
  3409. * Adds the translation vector (using 3 floats) in the current matrix
  3410. * @param x defines the 1st component of the translation
  3411. * @param y defines the 2nd component of the translation
  3412. * @param z defines the 3rd component of the translation
  3413. * @returns the current updated matrix
  3414. */
  3415. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3416. /**
  3417. * Inserts the translation vector in the current matrix
  3418. * @param vector3 defines the translation to insert
  3419. * @returns the current updated matrix
  3420. */
  3421. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3422. /**
  3423. * Gets the translation value of the current matrix
  3424. * @returns a new Vector3 as the extracted translation from the matrix
  3425. */
  3426. getTranslation(): Vector3;
  3427. /**
  3428. * Fill a Vector3 with the extracted translation from the matrix
  3429. * @param result defines the Vector3 where to store the translation
  3430. * @returns the current matrix
  3431. */
  3432. getTranslationToRef(result: Vector3): Matrix;
  3433. /**
  3434. * Remove rotation and scaling part from the matrix
  3435. * @returns the updated matrix
  3436. */
  3437. removeRotationAndScaling(): Matrix;
  3438. /**
  3439. * Multiply two matrices
  3440. * @param other defines the second operand
  3441. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3442. */
  3443. multiply(other: DeepImmutable<Matrix>): Matrix;
  3444. /**
  3445. * Copy the current matrix from the given one
  3446. * @param other defines the source matrix
  3447. * @returns the current updated matrix
  3448. */
  3449. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3450. /**
  3451. * Populates the given array from the starting index with the current matrix values
  3452. * @param array defines the target array
  3453. * @param offset defines the offset in the target array where to start storing values
  3454. * @returns the current matrix
  3455. */
  3456. copyToArray(array: Float32Array, offset?: number): Matrix;
  3457. /**
  3458. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3459. * @param other defines the second operand
  3460. * @param result defines the matrix where to store the multiplication
  3461. * @returns the current matrix
  3462. */
  3463. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3464. /**
  3465. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3466. * @param other defines the second operand
  3467. * @param result defines the array where to store the multiplication
  3468. * @param offset defines the offset in the target array where to start storing values
  3469. * @returns the current matrix
  3470. */
  3471. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3472. /**
  3473. * Check equality between this matrix and a second one
  3474. * @param value defines the second matrix to compare
  3475. * @returns true is the current matrix and the given one values are strictly equal
  3476. */
  3477. equals(value: DeepImmutable<Matrix>): boolean;
  3478. /**
  3479. * Clone the current matrix
  3480. * @returns a new matrix from the current matrix
  3481. */
  3482. clone(): Matrix;
  3483. /**
  3484. * Returns the name of the current matrix class
  3485. * @returns the string "Matrix"
  3486. */
  3487. getClassName(): string;
  3488. /**
  3489. * Gets the hash code of the current matrix
  3490. * @returns the hash code
  3491. */
  3492. getHashCode(): number;
  3493. /**
  3494. * Decomposes the current Matrix into a translation, rotation and scaling components
  3495. * @param scale defines the scale vector3 given as a reference to update
  3496. * @param rotation defines the rotation quaternion given as a reference to update
  3497. * @param translation defines the translation vector3 given as a reference to update
  3498. * @returns true if operation was successful
  3499. */
  3500. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3501. /**
  3502. * Gets specific row of the matrix
  3503. * @param index defines the number of the row to get
  3504. * @returns the index-th row of the current matrix as a new Vector4
  3505. */
  3506. getRow(index: number): Nullable<Vector4>;
  3507. /**
  3508. * Sets the index-th row of the current matrix to the vector4 values
  3509. * @param index defines the number of the row to set
  3510. * @param row defines the target vector4
  3511. * @returns the updated current matrix
  3512. */
  3513. setRow(index: number, row: Vector4): Matrix;
  3514. /**
  3515. * Compute the transpose of the matrix
  3516. * @returns the new transposed matrix
  3517. */
  3518. transpose(): Matrix;
  3519. /**
  3520. * Compute the transpose of the matrix and store it in a given matrix
  3521. * @param result defines the target matrix
  3522. * @returns the current matrix
  3523. */
  3524. transposeToRef(result: Matrix): Matrix;
  3525. /**
  3526. * Sets the index-th row of the current matrix with the given 4 x float values
  3527. * @param index defines the row index
  3528. * @param x defines the x component to set
  3529. * @param y defines the y component to set
  3530. * @param z defines the z component to set
  3531. * @param w defines the w component to set
  3532. * @returns the updated current matrix
  3533. */
  3534. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3535. /**
  3536. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3537. * @param scale defines the scale factor
  3538. * @returns a new matrix
  3539. */
  3540. scale(scale: number): Matrix;
  3541. /**
  3542. * Scale the current matrix values by a factor to a given result matrix
  3543. * @param scale defines the scale factor
  3544. * @param result defines the matrix to store the result
  3545. * @returns the current matrix
  3546. */
  3547. scaleToRef(scale: number, result: Matrix): Matrix;
  3548. /**
  3549. * Scale the current matrix values by a factor and add the result to a given matrix
  3550. * @param scale defines the scale factor
  3551. * @param result defines the Matrix to store the result
  3552. * @returns the current matrix
  3553. */
  3554. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3555. /**
  3556. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3557. * @param ref matrix to store the result
  3558. */
  3559. toNormalMatrix(ref: Matrix): void;
  3560. /**
  3561. * Gets only rotation part of the current matrix
  3562. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3563. */
  3564. getRotationMatrix(): Matrix;
  3565. /**
  3566. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3567. * @param result defines the target matrix to store data to
  3568. * @returns the current matrix
  3569. */
  3570. getRotationMatrixToRef(result: Matrix): Matrix;
  3571. /**
  3572. * Toggles model matrix from being right handed to left handed in place and vice versa
  3573. */
  3574. toggleModelMatrixHandInPlace(): void;
  3575. /**
  3576. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3577. */
  3578. toggleProjectionMatrixHandInPlace(): void;
  3579. /**
  3580. * Creates a matrix from an array
  3581. * @param array defines the source array
  3582. * @param offset defines an offset in the source array
  3583. * @returns a new Matrix set from the starting index of the given array
  3584. */
  3585. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3586. /**
  3587. * Copy the content of an array into a given matrix
  3588. * @param array defines the source array
  3589. * @param offset defines an offset in the source array
  3590. * @param result defines the target matrix
  3591. */
  3592. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3593. /**
  3594. * Stores an array into a matrix after having multiplied each component by a given factor
  3595. * @param array defines the source array
  3596. * @param offset defines the offset in the source array
  3597. * @param scale defines the scaling factor
  3598. * @param result defines the target matrix
  3599. */
  3600. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3601. /**
  3602. * Gets an identity matrix that must not be updated
  3603. */
  3604. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3605. /**
  3606. * Stores a list of values (16) inside a given matrix
  3607. * @param initialM11 defines 1st value of 1st row
  3608. * @param initialM12 defines 2nd value of 1st row
  3609. * @param initialM13 defines 3rd value of 1st row
  3610. * @param initialM14 defines 4th value of 1st row
  3611. * @param initialM21 defines 1st value of 2nd row
  3612. * @param initialM22 defines 2nd value of 2nd row
  3613. * @param initialM23 defines 3rd value of 2nd row
  3614. * @param initialM24 defines 4th value of 2nd row
  3615. * @param initialM31 defines 1st value of 3rd row
  3616. * @param initialM32 defines 2nd value of 3rd row
  3617. * @param initialM33 defines 3rd value of 3rd row
  3618. * @param initialM34 defines 4th value of 3rd row
  3619. * @param initialM41 defines 1st value of 4th row
  3620. * @param initialM42 defines 2nd value of 4th row
  3621. * @param initialM43 defines 3rd value of 4th row
  3622. * @param initialM44 defines 4th value of 4th row
  3623. * @param result defines the target matrix
  3624. */
  3625. 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;
  3626. /**
  3627. * Creates new matrix from a list of values (16)
  3628. * @param initialM11 defines 1st value of 1st row
  3629. * @param initialM12 defines 2nd value of 1st row
  3630. * @param initialM13 defines 3rd value of 1st row
  3631. * @param initialM14 defines 4th value of 1st row
  3632. * @param initialM21 defines 1st value of 2nd row
  3633. * @param initialM22 defines 2nd value of 2nd row
  3634. * @param initialM23 defines 3rd value of 2nd row
  3635. * @param initialM24 defines 4th value of 2nd row
  3636. * @param initialM31 defines 1st value of 3rd row
  3637. * @param initialM32 defines 2nd value of 3rd row
  3638. * @param initialM33 defines 3rd value of 3rd row
  3639. * @param initialM34 defines 4th value of 3rd row
  3640. * @param initialM41 defines 1st value of 4th row
  3641. * @param initialM42 defines 2nd value of 4th row
  3642. * @param initialM43 defines 3rd value of 4th row
  3643. * @param initialM44 defines 4th value of 4th row
  3644. * @returns the new matrix
  3645. */
  3646. 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;
  3647. /**
  3648. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3649. * @param scale defines the scale vector3
  3650. * @param rotation defines the rotation quaternion
  3651. * @param translation defines the translation vector3
  3652. * @returns a new matrix
  3653. */
  3654. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3655. /**
  3656. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3657. * @param scale defines the scale vector3
  3658. * @param rotation defines the rotation quaternion
  3659. * @param translation defines the translation vector3
  3660. * @param result defines the target matrix
  3661. */
  3662. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3663. /**
  3664. * Creates a new identity matrix
  3665. * @returns a new identity matrix
  3666. */
  3667. static Identity(): Matrix;
  3668. /**
  3669. * Creates a new identity matrix and stores the result in a given matrix
  3670. * @param result defines the target matrix
  3671. */
  3672. static IdentityToRef(result: Matrix): void;
  3673. /**
  3674. * Creates a new zero matrix
  3675. * @returns a new zero matrix
  3676. */
  3677. static Zero(): Matrix;
  3678. /**
  3679. * Creates a new rotation matrix for "angle" radians around the X axis
  3680. * @param angle defines the angle (in radians) to use
  3681. * @return the new matrix
  3682. */
  3683. static RotationX(angle: number): Matrix;
  3684. /**
  3685. * Creates a new matrix as the invert of a given matrix
  3686. * @param source defines the source matrix
  3687. * @returns the new matrix
  3688. */
  3689. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3690. /**
  3691. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3692. * @param angle defines the angle (in radians) to use
  3693. * @param result defines the target matrix
  3694. */
  3695. static RotationXToRef(angle: number, result: Matrix): void;
  3696. /**
  3697. * Creates a new rotation matrix for "angle" radians around the Y axis
  3698. * @param angle defines the angle (in radians) to use
  3699. * @return the new matrix
  3700. */
  3701. static RotationY(angle: number): Matrix;
  3702. /**
  3703. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3704. * @param angle defines the angle (in radians) to use
  3705. * @param result defines the target matrix
  3706. */
  3707. static RotationYToRef(angle: number, result: Matrix): void;
  3708. /**
  3709. * Creates a new rotation matrix for "angle" radians around the Z axis
  3710. * @param angle defines the angle (in radians) to use
  3711. * @return the new matrix
  3712. */
  3713. static RotationZ(angle: number): Matrix;
  3714. /**
  3715. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3716. * @param angle defines the angle (in radians) to use
  3717. * @param result defines the target matrix
  3718. */
  3719. static RotationZToRef(angle: number, result: Matrix): void;
  3720. /**
  3721. * Creates a new rotation matrix for "angle" radians around the given axis
  3722. * @param axis defines the axis to use
  3723. * @param angle defines the angle (in radians) to use
  3724. * @return the new matrix
  3725. */
  3726. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3727. /**
  3728. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3729. * @param axis defines the axis to use
  3730. * @param angle defines the angle (in radians) to use
  3731. * @param result defines the target matrix
  3732. */
  3733. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3734. /**
  3735. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3736. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3737. * @param from defines the vector to align
  3738. * @param to defines the vector to align to
  3739. * @param result defines the target matrix
  3740. */
  3741. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3742. /**
  3743. * Creates a rotation matrix
  3744. * @param yaw defines the yaw angle in radians (Y axis)
  3745. * @param pitch defines the pitch angle in radians (X axis)
  3746. * @param roll defines the roll angle in radians (X axis)
  3747. * @returns the new rotation matrix
  3748. */
  3749. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3750. /**
  3751. * Creates a rotation matrix and stores it in a given matrix
  3752. * @param yaw defines the yaw angle in radians (Y axis)
  3753. * @param pitch defines the pitch angle in radians (X axis)
  3754. * @param roll defines the roll angle in radians (X axis)
  3755. * @param result defines the target matrix
  3756. */
  3757. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3758. /**
  3759. * Creates a scaling matrix
  3760. * @param x defines the scale factor on X axis
  3761. * @param y defines the scale factor on Y axis
  3762. * @param z defines the scale factor on Z axis
  3763. * @returns the new matrix
  3764. */
  3765. static Scaling(x: number, y: number, z: number): Matrix;
  3766. /**
  3767. * Creates a scaling matrix and stores it in a given matrix
  3768. * @param x defines the scale factor on X axis
  3769. * @param y defines the scale factor on Y axis
  3770. * @param z defines the scale factor on Z axis
  3771. * @param result defines the target matrix
  3772. */
  3773. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3774. /**
  3775. * Creates a translation matrix
  3776. * @param x defines the translation on X axis
  3777. * @param y defines the translation on Y axis
  3778. * @param z defines the translationon Z axis
  3779. * @returns the new matrix
  3780. */
  3781. static Translation(x: number, y: number, z: number): Matrix;
  3782. /**
  3783. * Creates a translation matrix and stores it in a given matrix
  3784. * @param x defines the translation on X axis
  3785. * @param y defines the translation on Y axis
  3786. * @param z defines the translationon Z axis
  3787. * @param result defines the target matrix
  3788. */
  3789. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3790. /**
  3791. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3792. * @param startValue defines the start value
  3793. * @param endValue defines the end value
  3794. * @param gradient defines the gradient factor
  3795. * @returns the new matrix
  3796. */
  3797. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3798. /**
  3799. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3800. * @param startValue defines the start value
  3801. * @param endValue defines the end value
  3802. * @param gradient defines the gradient factor
  3803. * @param result defines the Matrix object where to store data
  3804. */
  3805. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3806. /**
  3807. * Builds a new matrix whose values are computed by:
  3808. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3809. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3810. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3811. * @param startValue defines the first matrix
  3812. * @param endValue defines the second matrix
  3813. * @param gradient defines the gradient between the two matrices
  3814. * @returns the new matrix
  3815. */
  3816. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3817. /**
  3818. * Update a matrix to values which are computed by:
  3819. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3820. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3821. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3822. * @param startValue defines the first matrix
  3823. * @param endValue defines the second matrix
  3824. * @param gradient defines the gradient between the two matrices
  3825. * @param result defines the target matrix
  3826. */
  3827. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3828. /**
  3829. * 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"
  3830. * This function works in left handed mode
  3831. * @param eye defines the final position of the entity
  3832. * @param target defines where the entity should look at
  3833. * @param up defines the up vector for the entity
  3834. * @returns the new matrix
  3835. */
  3836. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3837. /**
  3838. * 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".
  3839. * This function works in left handed mode
  3840. * @param eye defines the final position of the entity
  3841. * @param target defines where the entity should look at
  3842. * @param up defines the up vector for the entity
  3843. * @param result defines the target matrix
  3844. */
  3845. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3846. /**
  3847. * 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"
  3848. * This function works in right handed mode
  3849. * @param eye defines the final position of the entity
  3850. * @param target defines where the entity should look at
  3851. * @param up defines the up vector for the entity
  3852. * @returns the new matrix
  3853. */
  3854. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3855. /**
  3856. * 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".
  3857. * This function works in right handed mode
  3858. * @param eye defines the final position of the entity
  3859. * @param target defines where the entity should look at
  3860. * @param up defines the up vector for the entity
  3861. * @param result defines the target matrix
  3862. */
  3863. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3864. /**
  3865. * Create a left-handed orthographic projection matrix
  3866. * @param width defines the viewport width
  3867. * @param height defines the viewport height
  3868. * @param znear defines the near clip plane
  3869. * @param zfar defines the far clip plane
  3870. * @returns a new matrix as a left-handed orthographic projection matrix
  3871. */
  3872. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3873. /**
  3874. * Store a left-handed orthographic projection to a given matrix
  3875. * @param width defines the viewport width
  3876. * @param height defines the viewport height
  3877. * @param znear defines the near clip plane
  3878. * @param zfar defines the far clip plane
  3879. * @param result defines the target matrix
  3880. */
  3881. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3882. /**
  3883. * Create a left-handed orthographic projection matrix
  3884. * @param left defines the viewport left coordinate
  3885. * @param right defines the viewport right coordinate
  3886. * @param bottom defines the viewport bottom coordinate
  3887. * @param top defines the viewport top coordinate
  3888. * @param znear defines the near clip plane
  3889. * @param zfar defines the far clip plane
  3890. * @returns a new matrix as a left-handed orthographic projection matrix
  3891. */
  3892. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3893. /**
  3894. * Stores a left-handed orthographic projection into a given matrix
  3895. * @param left defines the viewport left coordinate
  3896. * @param right defines the viewport right coordinate
  3897. * @param bottom defines the viewport bottom coordinate
  3898. * @param top defines the viewport top coordinate
  3899. * @param znear defines the near clip plane
  3900. * @param zfar defines the far clip plane
  3901. * @param result defines the target matrix
  3902. */
  3903. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3904. /**
  3905. * Creates a right-handed orthographic projection matrix
  3906. * @param left defines the viewport left coordinate
  3907. * @param right defines the viewport right coordinate
  3908. * @param bottom defines the viewport bottom coordinate
  3909. * @param top defines the viewport top coordinate
  3910. * @param znear defines the near clip plane
  3911. * @param zfar defines the far clip plane
  3912. * @returns a new matrix as a right-handed orthographic projection matrix
  3913. */
  3914. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3915. /**
  3916. * Stores a right-handed orthographic projection into a given matrix
  3917. * @param left defines the viewport left coordinate
  3918. * @param right defines the viewport right coordinate
  3919. * @param bottom defines the viewport bottom coordinate
  3920. * @param top defines the viewport top coordinate
  3921. * @param znear defines the near clip plane
  3922. * @param zfar defines the far clip plane
  3923. * @param result defines the target matrix
  3924. */
  3925. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3926. /**
  3927. * Creates a left-handed perspective projection matrix
  3928. * @param width defines the viewport width
  3929. * @param height defines the viewport height
  3930. * @param znear defines the near clip plane
  3931. * @param zfar defines the far clip plane
  3932. * @returns a new matrix as a left-handed perspective projection matrix
  3933. */
  3934. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3935. /**
  3936. * Creates a left-handed perspective projection matrix
  3937. * @param fov defines the horizontal field of view
  3938. * @param aspect defines the aspect ratio
  3939. * @param znear defines the near clip plane
  3940. * @param zfar defines the far clip plane
  3941. * @returns a new matrix as a left-handed perspective projection matrix
  3942. */
  3943. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3944. /**
  3945. * Stores a left-handed perspective projection into a given matrix
  3946. * @param fov defines the horizontal field of view
  3947. * @param aspect defines the aspect ratio
  3948. * @param znear defines the near clip plane
  3949. * @param zfar defines the far clip plane
  3950. * @param result defines the target matrix
  3951. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3952. */
  3953. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3954. /**
  3955. * Creates a right-handed perspective projection matrix
  3956. * @param fov defines the horizontal field of view
  3957. * @param aspect defines the aspect ratio
  3958. * @param znear defines the near clip plane
  3959. * @param zfar defines the far clip plane
  3960. * @returns a new matrix as a right-handed perspective projection matrix
  3961. */
  3962. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3963. /**
  3964. * Stores a right-handed perspective projection into a given matrix
  3965. * @param fov defines the horizontal field of view
  3966. * @param aspect defines the aspect ratio
  3967. * @param znear defines the near clip plane
  3968. * @param zfar defines the far clip plane
  3969. * @param result defines the target matrix
  3970. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3971. */
  3972. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3973. /**
  3974. * Stores a perspective projection for WebVR info a given matrix
  3975. * @param fov defines the field of view
  3976. * @param znear defines the near clip plane
  3977. * @param zfar defines the far clip plane
  3978. * @param result defines the target matrix
  3979. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3980. */
  3981. static PerspectiveFovWebVRToRef(fov: {
  3982. upDegrees: number;
  3983. downDegrees: number;
  3984. leftDegrees: number;
  3985. rightDegrees: number;
  3986. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3987. /**
  3988. * Computes a complete transformation matrix
  3989. * @param viewport defines the viewport to use
  3990. * @param world defines the world matrix
  3991. * @param view defines the view matrix
  3992. * @param projection defines the projection matrix
  3993. * @param zmin defines the near clip plane
  3994. * @param zmax defines the far clip plane
  3995. * @returns the transformation matrix
  3996. */
  3997. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3998. /**
  3999. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4000. * @param matrix defines the matrix to use
  4001. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4002. */
  4003. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4004. /**
  4005. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4006. * @param matrix defines the matrix to use
  4007. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4008. */
  4009. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4010. /**
  4011. * Compute the transpose of a given matrix
  4012. * @param matrix defines the matrix to transpose
  4013. * @returns the new matrix
  4014. */
  4015. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4016. /**
  4017. * Compute the transpose of a matrix and store it in a target matrix
  4018. * @param matrix defines the matrix to transpose
  4019. * @param result defines the target matrix
  4020. */
  4021. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4022. /**
  4023. * Computes a reflection matrix from a plane
  4024. * @param plane defines the reflection plane
  4025. * @returns a new matrix
  4026. */
  4027. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4028. /**
  4029. * Computes a reflection matrix from a plane
  4030. * @param plane defines the reflection plane
  4031. * @param result defines the target matrix
  4032. */
  4033. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4034. /**
  4035. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4036. * @param xaxis defines the value of the 1st axis
  4037. * @param yaxis defines the value of the 2nd axis
  4038. * @param zaxis defines the value of the 3rd axis
  4039. * @param result defines the target matrix
  4040. */
  4041. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4042. /**
  4043. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4044. * @param quat defines the quaternion to use
  4045. * @param result defines the target matrix
  4046. */
  4047. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4048. }
  4049. /**
  4050. * @hidden
  4051. */
  4052. export class TmpVectors {
  4053. static Vector2: Vector2[];
  4054. static Vector3: Vector3[];
  4055. static Vector4: Vector4[];
  4056. static Quaternion: Quaternion[];
  4057. static Matrix: Matrix[];
  4058. }
  4059. }
  4060. declare module "babylonjs/Engines/constants" {
  4061. /** Defines the cross module used constants to avoid circular dependncies */
  4062. export class Constants {
  4063. /** Defines that alpha blending is disabled */
  4064. static readonly ALPHA_DISABLE: number;
  4065. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4066. static readonly ALPHA_ADD: number;
  4067. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4068. static readonly ALPHA_COMBINE: number;
  4069. /** Defines that alpha blending to DEST - SRC * DEST */
  4070. static readonly ALPHA_SUBTRACT: number;
  4071. /** Defines that alpha blending to SRC * DEST */
  4072. static readonly ALPHA_MULTIPLY: number;
  4073. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4074. static readonly ALPHA_MAXIMIZED: number;
  4075. /** Defines that alpha blending to SRC + DEST */
  4076. static readonly ALPHA_ONEONE: number;
  4077. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4078. static readonly ALPHA_PREMULTIPLIED: number;
  4079. /**
  4080. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4081. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4082. */
  4083. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4084. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4085. static readonly ALPHA_INTERPOLATE: number;
  4086. /**
  4087. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4088. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4089. */
  4090. static readonly ALPHA_SCREENMODE: number;
  4091. /** Defines that the ressource is not delayed*/
  4092. static readonly DELAYLOADSTATE_NONE: number;
  4093. /** Defines that the ressource was successfully delay loaded */
  4094. static readonly DELAYLOADSTATE_LOADED: number;
  4095. /** Defines that the ressource is currently delay loading */
  4096. static readonly DELAYLOADSTATE_LOADING: number;
  4097. /** Defines that the ressource is delayed and has not started loading */
  4098. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4099. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4100. static readonly NEVER: number;
  4101. /** 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 */
  4102. static readonly ALWAYS: number;
  4103. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4104. static readonly LESS: number;
  4105. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4106. static readonly EQUAL: number;
  4107. /** 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 */
  4108. static readonly LEQUAL: number;
  4109. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4110. static readonly GREATER: number;
  4111. /** 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 */
  4112. static readonly GEQUAL: number;
  4113. /** 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 */
  4114. static readonly NOTEQUAL: number;
  4115. /** Passed to stencilOperation to specify that stencil value must be kept */
  4116. static readonly KEEP: number;
  4117. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4118. static readonly REPLACE: number;
  4119. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4120. static readonly INCR: number;
  4121. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4122. static readonly DECR: number;
  4123. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4124. static readonly INVERT: number;
  4125. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4126. static readonly INCR_WRAP: number;
  4127. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4128. static readonly DECR_WRAP: number;
  4129. /** Texture is not repeating outside of 0..1 UVs */
  4130. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4131. /** Texture is repeating outside of 0..1 UVs */
  4132. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4133. /** Texture is repeating and mirrored */
  4134. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4135. /** ALPHA */
  4136. static readonly TEXTUREFORMAT_ALPHA: number;
  4137. /** LUMINANCE */
  4138. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4139. /** LUMINANCE_ALPHA */
  4140. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4141. /** RGB */
  4142. static readonly TEXTUREFORMAT_RGB: number;
  4143. /** RGBA */
  4144. static readonly TEXTUREFORMAT_RGBA: number;
  4145. /** RED */
  4146. static readonly TEXTUREFORMAT_RED: number;
  4147. /** RED (2nd reference) */
  4148. static readonly TEXTUREFORMAT_R: number;
  4149. /** RG */
  4150. static readonly TEXTUREFORMAT_RG: number;
  4151. /** RED_INTEGER */
  4152. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4153. /** RED_INTEGER (2nd reference) */
  4154. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4155. /** RG_INTEGER */
  4156. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4157. /** RGB_INTEGER */
  4158. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4159. /** RGBA_INTEGER */
  4160. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4161. /** UNSIGNED_BYTE */
  4162. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4163. /** UNSIGNED_BYTE (2nd reference) */
  4164. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4165. /** FLOAT */
  4166. static readonly TEXTURETYPE_FLOAT: number;
  4167. /** HALF_FLOAT */
  4168. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4169. /** BYTE */
  4170. static readonly TEXTURETYPE_BYTE: number;
  4171. /** SHORT */
  4172. static readonly TEXTURETYPE_SHORT: number;
  4173. /** UNSIGNED_SHORT */
  4174. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4175. /** INT */
  4176. static readonly TEXTURETYPE_INT: number;
  4177. /** UNSIGNED_INT */
  4178. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4179. /** UNSIGNED_SHORT_4_4_4_4 */
  4180. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4181. /** UNSIGNED_SHORT_5_5_5_1 */
  4182. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4183. /** UNSIGNED_SHORT_5_6_5 */
  4184. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4185. /** UNSIGNED_INT_2_10_10_10_REV */
  4186. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4187. /** UNSIGNED_INT_24_8 */
  4188. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4189. /** UNSIGNED_INT_10F_11F_11F_REV */
  4190. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4191. /** UNSIGNED_INT_5_9_9_9_REV */
  4192. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4193. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4194. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4195. /** nearest is mag = nearest and min = nearest and mip = linear */
  4196. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4197. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4198. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4199. /** Trilinear is mag = linear and min = linear and mip = linear */
  4200. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4201. /** nearest is mag = nearest and min = nearest and mip = linear */
  4202. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4203. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4204. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4205. /** Trilinear is mag = linear and min = linear and mip = linear */
  4206. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4207. /** mag = nearest and min = nearest and mip = nearest */
  4208. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4209. /** mag = nearest and min = linear and mip = nearest */
  4210. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4211. /** mag = nearest and min = linear and mip = linear */
  4212. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4213. /** mag = nearest and min = linear and mip = none */
  4214. static readonly TEXTURE_NEAREST_LINEAR: number;
  4215. /** mag = nearest and min = nearest and mip = none */
  4216. static readonly TEXTURE_NEAREST_NEAREST: number;
  4217. /** mag = linear and min = nearest and mip = nearest */
  4218. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4219. /** mag = linear and min = nearest and mip = linear */
  4220. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4221. /** mag = linear and min = linear and mip = none */
  4222. static readonly TEXTURE_LINEAR_LINEAR: number;
  4223. /** mag = linear and min = nearest and mip = none */
  4224. static readonly TEXTURE_LINEAR_NEAREST: number;
  4225. /** Explicit coordinates mode */
  4226. static readonly TEXTURE_EXPLICIT_MODE: number;
  4227. /** Spherical coordinates mode */
  4228. static readonly TEXTURE_SPHERICAL_MODE: number;
  4229. /** Planar coordinates mode */
  4230. static readonly TEXTURE_PLANAR_MODE: number;
  4231. /** Cubic coordinates mode */
  4232. static readonly TEXTURE_CUBIC_MODE: number;
  4233. /** Projection coordinates mode */
  4234. static readonly TEXTURE_PROJECTION_MODE: number;
  4235. /** Skybox coordinates mode */
  4236. static readonly TEXTURE_SKYBOX_MODE: number;
  4237. /** Inverse Cubic coordinates mode */
  4238. static readonly TEXTURE_INVCUBIC_MODE: number;
  4239. /** Equirectangular coordinates mode */
  4240. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4241. /** Equirectangular Fixed coordinates mode */
  4242. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4243. /** Equirectangular Fixed Mirrored coordinates mode */
  4244. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4245. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4246. static readonly SCALEMODE_FLOOR: number;
  4247. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4248. static readonly SCALEMODE_NEAREST: number;
  4249. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4250. static readonly SCALEMODE_CEILING: number;
  4251. /**
  4252. * The dirty texture flag value
  4253. */
  4254. static readonly MATERIAL_TextureDirtyFlag: number;
  4255. /**
  4256. * The dirty light flag value
  4257. */
  4258. static readonly MATERIAL_LightDirtyFlag: number;
  4259. /**
  4260. * The dirty fresnel flag value
  4261. */
  4262. static readonly MATERIAL_FresnelDirtyFlag: number;
  4263. /**
  4264. * The dirty attribute flag value
  4265. */
  4266. static readonly MATERIAL_AttributesDirtyFlag: number;
  4267. /**
  4268. * The dirty misc flag value
  4269. */
  4270. static readonly MATERIAL_MiscDirtyFlag: number;
  4271. /**
  4272. * The all dirty flag value
  4273. */
  4274. static readonly MATERIAL_AllDirtyFlag: number;
  4275. /**
  4276. * Returns the triangle fill mode
  4277. */
  4278. static readonly MATERIAL_TriangleFillMode: number;
  4279. /**
  4280. * Returns the wireframe mode
  4281. */
  4282. static readonly MATERIAL_WireFrameFillMode: number;
  4283. /**
  4284. * Returns the point fill mode
  4285. */
  4286. static readonly MATERIAL_PointFillMode: number;
  4287. /**
  4288. * Returns the point list draw mode
  4289. */
  4290. static readonly MATERIAL_PointListDrawMode: number;
  4291. /**
  4292. * Returns the line list draw mode
  4293. */
  4294. static readonly MATERIAL_LineListDrawMode: number;
  4295. /**
  4296. * Returns the line loop draw mode
  4297. */
  4298. static readonly MATERIAL_LineLoopDrawMode: number;
  4299. /**
  4300. * Returns the line strip draw mode
  4301. */
  4302. static readonly MATERIAL_LineStripDrawMode: number;
  4303. /**
  4304. * Returns the triangle strip draw mode
  4305. */
  4306. static readonly MATERIAL_TriangleStripDrawMode: number;
  4307. /**
  4308. * Returns the triangle fan draw mode
  4309. */
  4310. static readonly MATERIAL_TriangleFanDrawMode: number;
  4311. /**
  4312. * Stores the clock-wise side orientation
  4313. */
  4314. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4315. /**
  4316. * Stores the counter clock-wise side orientation
  4317. */
  4318. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4319. /**
  4320. * Nothing
  4321. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4322. */
  4323. static readonly ACTION_NothingTrigger: number;
  4324. /**
  4325. * On pick
  4326. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4327. */
  4328. static readonly ACTION_OnPickTrigger: number;
  4329. /**
  4330. * On left pick
  4331. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4332. */
  4333. static readonly ACTION_OnLeftPickTrigger: number;
  4334. /**
  4335. * On right pick
  4336. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4337. */
  4338. static readonly ACTION_OnRightPickTrigger: number;
  4339. /**
  4340. * On center pick
  4341. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4342. */
  4343. static readonly ACTION_OnCenterPickTrigger: number;
  4344. /**
  4345. * On pick down
  4346. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4347. */
  4348. static readonly ACTION_OnPickDownTrigger: number;
  4349. /**
  4350. * On double pick
  4351. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4352. */
  4353. static readonly ACTION_OnDoublePickTrigger: number;
  4354. /**
  4355. * On pick up
  4356. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4357. */
  4358. static readonly ACTION_OnPickUpTrigger: number;
  4359. /**
  4360. * On pick out.
  4361. * This trigger will only be raised if you also declared a OnPickDown
  4362. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4363. */
  4364. static readonly ACTION_OnPickOutTrigger: number;
  4365. /**
  4366. * On long press
  4367. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4368. */
  4369. static readonly ACTION_OnLongPressTrigger: number;
  4370. /**
  4371. * On pointer over
  4372. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4373. */
  4374. static readonly ACTION_OnPointerOverTrigger: number;
  4375. /**
  4376. * On pointer out
  4377. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4378. */
  4379. static readonly ACTION_OnPointerOutTrigger: number;
  4380. /**
  4381. * On every frame
  4382. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4383. */
  4384. static readonly ACTION_OnEveryFrameTrigger: number;
  4385. /**
  4386. * On intersection enter
  4387. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4388. */
  4389. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4390. /**
  4391. * On intersection exit
  4392. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4393. */
  4394. static readonly ACTION_OnIntersectionExitTrigger: number;
  4395. /**
  4396. * On key down
  4397. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4398. */
  4399. static readonly ACTION_OnKeyDownTrigger: number;
  4400. /**
  4401. * On key up
  4402. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4403. */
  4404. static readonly ACTION_OnKeyUpTrigger: number;
  4405. /**
  4406. * Billboard mode will only apply to Y axis
  4407. */
  4408. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4409. /**
  4410. * Billboard mode will apply to all axes
  4411. */
  4412. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4413. /**
  4414. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4415. */
  4416. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4417. /**
  4418. * Gets or sets base Assets URL
  4419. */
  4420. static PARTICLES_BaseAssetsUrl: string;
  4421. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4422. * Test order :
  4423. * Is the bounding sphere outside the frustum ?
  4424. * If not, are the bounding box vertices outside the frustum ?
  4425. * It not, then the cullable object is in the frustum.
  4426. */
  4427. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4428. /** Culling strategy : Bounding Sphere Only.
  4429. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4430. * It's also less accurate than the standard because some not visible objects can still be selected.
  4431. * Test : is the bounding sphere outside the frustum ?
  4432. * If not, then the cullable object is in the frustum.
  4433. */
  4434. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4435. /** Culling strategy : Optimistic Inclusion.
  4436. * This in an inclusion test first, then the standard exclusion test.
  4437. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4438. * 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.
  4439. * Anyway, it's as accurate as the standard strategy.
  4440. * Test :
  4441. * Is the cullable object bounding sphere center in the frustum ?
  4442. * If not, apply the default culling strategy.
  4443. */
  4444. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4445. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4446. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4447. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4448. * 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.
  4449. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4450. * Test :
  4451. * Is the cullable object bounding sphere center in the frustum ?
  4452. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4453. */
  4454. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4455. /**
  4456. * No logging while loading
  4457. */
  4458. static readonly SCENELOADER_NO_LOGGING: number;
  4459. /**
  4460. * Minimal logging while loading
  4461. */
  4462. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4463. /**
  4464. * Summary logging while loading
  4465. */
  4466. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4467. /**
  4468. * Detailled logging while loading
  4469. */
  4470. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4471. }
  4472. }
  4473. declare module "babylonjs/Engines/IPipelineContext" {
  4474. /**
  4475. * Class used to store and describe the pipeline context associated with an effect
  4476. */
  4477. export interface IPipelineContext {
  4478. /**
  4479. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4480. */
  4481. isAsync: boolean;
  4482. /**
  4483. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4484. */
  4485. isReady: boolean;
  4486. /** @hidden */
  4487. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4488. }
  4489. }
  4490. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  4491. /** @hidden */
  4492. export interface IShaderProcessor {
  4493. attributeProcessor?: (attribute: string) => string;
  4494. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4495. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4496. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4497. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4498. lineProcessor?: (line: string, isFragment: boolean) => string;
  4499. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4500. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4501. }
  4502. }
  4503. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  4504. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  4505. /** @hidden */
  4506. export interface ProcessingOptions {
  4507. defines: string[];
  4508. indexParameters: any;
  4509. isFragment: boolean;
  4510. shouldUseHighPrecisionShader: boolean;
  4511. supportsUniformBuffers: boolean;
  4512. shadersRepository: string;
  4513. includesShadersStore: {
  4514. [key: string]: string;
  4515. };
  4516. processor?: IShaderProcessor;
  4517. version: string;
  4518. platformName: string;
  4519. lookForClosingBracketForUniformBuffer?: boolean;
  4520. }
  4521. }
  4522. declare module "babylonjs/Misc/stringTools" {
  4523. /**
  4524. * Helper to manipulate strings
  4525. */
  4526. export class StringTools {
  4527. /**
  4528. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4529. * @param str Source string
  4530. * @param suffix Suffix to search for in the source string
  4531. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4532. */
  4533. static EndsWith(str: string, suffix: string): boolean;
  4534. /**
  4535. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4536. * @param str Source string
  4537. * @param suffix Suffix to search for in the source string
  4538. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4539. */
  4540. static StartsWith(str: string, suffix: string): boolean;
  4541. }
  4542. }
  4543. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  4544. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4545. /** @hidden */
  4546. export class ShaderCodeNode {
  4547. line: string;
  4548. children: ShaderCodeNode[];
  4549. additionalDefineKey?: string;
  4550. additionalDefineValue?: string;
  4551. isValid(preprocessors: {
  4552. [key: string]: string;
  4553. }): boolean;
  4554. process(preprocessors: {
  4555. [key: string]: string;
  4556. }, options: ProcessingOptions): string;
  4557. }
  4558. }
  4559. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  4560. /** @hidden */
  4561. export class ShaderCodeCursor {
  4562. private _lines;
  4563. lineIndex: number;
  4564. readonly currentLine: string;
  4565. readonly canRead: boolean;
  4566. lines: string[];
  4567. }
  4568. }
  4569. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  4570. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4571. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4572. /** @hidden */
  4573. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4574. process(preprocessors: {
  4575. [key: string]: string;
  4576. }, options: ProcessingOptions): string;
  4577. }
  4578. }
  4579. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  4580. /** @hidden */
  4581. export class ShaderDefineExpression {
  4582. isTrue(preprocessors: {
  4583. [key: string]: string;
  4584. }): boolean;
  4585. }
  4586. }
  4587. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  4588. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4589. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4590. /** @hidden */
  4591. export class ShaderCodeTestNode extends ShaderCodeNode {
  4592. testExpression: ShaderDefineExpression;
  4593. isValid(preprocessors: {
  4594. [key: string]: string;
  4595. }): boolean;
  4596. }
  4597. }
  4598. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  4599. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4600. /** @hidden */
  4601. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4602. define: string;
  4603. not: boolean;
  4604. constructor(define: string, not?: boolean);
  4605. isTrue(preprocessors: {
  4606. [key: string]: string;
  4607. }): boolean;
  4608. }
  4609. }
  4610. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  4611. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4612. /** @hidden */
  4613. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4614. leftOperand: ShaderDefineExpression;
  4615. rightOperand: ShaderDefineExpression;
  4616. isTrue(preprocessors: {
  4617. [key: string]: string;
  4618. }): boolean;
  4619. }
  4620. }
  4621. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  4622. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4623. /** @hidden */
  4624. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4625. leftOperand: ShaderDefineExpression;
  4626. rightOperand: ShaderDefineExpression;
  4627. isTrue(preprocessors: {
  4628. [key: string]: string;
  4629. }): boolean;
  4630. }
  4631. }
  4632. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  4633. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4634. /** @hidden */
  4635. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4636. define: string;
  4637. operand: string;
  4638. testValue: string;
  4639. constructor(define: string, operand: string, testValue: string);
  4640. isTrue(preprocessors: {
  4641. [key: string]: string;
  4642. }): boolean;
  4643. }
  4644. }
  4645. declare module "babylonjs/Misc/loadFileError" {
  4646. import { WebRequest } from "babylonjs/Misc/webRequest";
  4647. /**
  4648. * @ignore
  4649. * Application error to support additional information when loading a file
  4650. */
  4651. export class LoadFileError extends Error {
  4652. /** defines the optional web request */
  4653. request?: WebRequest | undefined;
  4654. private static _setPrototypeOf;
  4655. /**
  4656. * Creates a new LoadFileError
  4657. * @param message defines the message of the error
  4658. * @param request defines the optional web request
  4659. */
  4660. constructor(message: string,
  4661. /** defines the optional web request */
  4662. request?: WebRequest | undefined);
  4663. }
  4664. }
  4665. declare module "babylonjs/Offline/IOfflineProvider" {
  4666. /**
  4667. * Class used to enable access to offline support
  4668. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4669. */
  4670. export interface IOfflineProvider {
  4671. /**
  4672. * Gets a boolean indicating if scene must be saved in the database
  4673. */
  4674. enableSceneOffline: boolean;
  4675. /**
  4676. * Gets a boolean indicating if textures must be saved in the database
  4677. */
  4678. enableTexturesOffline: boolean;
  4679. /**
  4680. * Open the offline support and make it available
  4681. * @param successCallback defines the callback to call on success
  4682. * @param errorCallback defines the callback to call on error
  4683. */
  4684. open(successCallback: () => void, errorCallback: () => void): void;
  4685. /**
  4686. * Loads an image from the offline support
  4687. * @param url defines the url to load from
  4688. * @param image defines the target DOM image
  4689. */
  4690. loadImage(url: string, image: HTMLImageElement): void;
  4691. /**
  4692. * Loads a file from offline support
  4693. * @param url defines the URL to load from
  4694. * @param sceneLoaded defines a callback to call on success
  4695. * @param progressCallBack defines a callback to call when progress changed
  4696. * @param errorCallback defines a callback to call on error
  4697. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4698. */
  4699. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4700. }
  4701. }
  4702. declare module "babylonjs/Misc/filesInputStore" {
  4703. /**
  4704. * Class used to help managing file picking and drag'n'drop
  4705. * File Storage
  4706. */
  4707. export class FilesInputStore {
  4708. /**
  4709. * List of files ready to be loaded
  4710. */
  4711. static FilesToLoad: {
  4712. [key: string]: File;
  4713. };
  4714. }
  4715. }
  4716. declare module "babylonjs/Misc/retryStrategy" {
  4717. import { WebRequest } from "babylonjs/Misc/webRequest";
  4718. /**
  4719. * Class used to define a retry strategy when error happens while loading assets
  4720. */
  4721. export class RetryStrategy {
  4722. /**
  4723. * Function used to defines an exponential back off strategy
  4724. * @param maxRetries defines the maximum number of retries (3 by default)
  4725. * @param baseInterval defines the interval between retries
  4726. * @returns the strategy function to use
  4727. */
  4728. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  4729. }
  4730. }
  4731. declare module "babylonjs/Misc/fileTools" {
  4732. import { WebRequest } from "babylonjs/Misc/webRequest";
  4733. import { Nullable } from "babylonjs/types";
  4734. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  4735. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  4736. /**
  4737. * @hidden
  4738. */
  4739. export class FileTools {
  4740. /**
  4741. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  4742. */
  4743. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  4744. /**
  4745. * Gets or sets the base URL to use to load assets
  4746. */
  4747. static BaseUrl: string;
  4748. /**
  4749. * Default behaviour for cors in the application.
  4750. * It can be a string if the expected behavior is identical in the entire app.
  4751. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  4752. */
  4753. static CorsBehavior: string | ((url: string | string[]) => string);
  4754. /**
  4755. * Gets or sets a function used to pre-process url before using them to load assets
  4756. */
  4757. static PreprocessUrl: (url: string) => string;
  4758. /**
  4759. * Removes unwanted characters from an url
  4760. * @param url defines the url to clean
  4761. * @returns the cleaned url
  4762. */
  4763. private static _CleanUrl;
  4764. /**
  4765. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  4766. * @param url define the url we are trying
  4767. * @param element define the dom element where to configure the cors policy
  4768. */
  4769. static SetCorsBehavior(url: string | string[], element: {
  4770. crossOrigin: string | null;
  4771. }): void;
  4772. /**
  4773. * Loads an image as an HTMLImageElement.
  4774. * @param input url string, ArrayBuffer, or Blob to load
  4775. * @param onLoad callback called when the image successfully loads
  4776. * @param onError callback called when the image fails to load
  4777. * @param offlineProvider offline provider for caching
  4778. * @returns the HTMLImageElement of the loaded image
  4779. */
  4780. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  4781. /**
  4782. * Loads a file
  4783. * @param fileToLoad defines the file to load
  4784. * @param callback defines the callback to call when data is loaded
  4785. * @param progressCallBack defines the callback to call during loading process
  4786. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  4787. * @returns a file request object
  4788. */
  4789. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  4790. /**
  4791. * Loads a file
  4792. * @param url url string, ArrayBuffer, or Blob to load
  4793. * @param onSuccess callback called when the file successfully loads
  4794. * @param onProgress callback called while file is loading (if the server supports this mode)
  4795. * @param offlineProvider defines the offline provider for caching
  4796. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  4797. * @param onError callback called when the file fails to load
  4798. * @returns a file request object
  4799. */
  4800. 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;
  4801. /**
  4802. * Checks if the loaded document was accessed via `file:`-Protocol.
  4803. * @returns boolean
  4804. */
  4805. static IsFileURL(): boolean;
  4806. }
  4807. }
  4808. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  4809. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4810. /** @hidden */
  4811. export class ShaderProcessor {
  4812. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  4813. private static _ProcessPrecision;
  4814. private static _ExtractOperation;
  4815. private static _BuildSubExpression;
  4816. private static _BuildExpression;
  4817. private static _MoveCursorWithinIf;
  4818. private static _MoveCursor;
  4819. private static _EvaluatePreProcessors;
  4820. private static _PreparePreProcessors;
  4821. private static _ProcessShaderConversion;
  4822. private static _ProcessIncludes;
  4823. }
  4824. }
  4825. declare module "babylonjs/Maths/math.color" {
  4826. import { DeepImmutable, FloatArray } from "babylonjs/types";
  4827. /**
  4828. * Class used to hold a RBG color
  4829. */
  4830. export class Color3 {
  4831. /**
  4832. * Defines the red component (between 0 and 1, default is 0)
  4833. */
  4834. r: number;
  4835. /**
  4836. * Defines the green component (between 0 and 1, default is 0)
  4837. */
  4838. g: number;
  4839. /**
  4840. * Defines the blue component (between 0 and 1, default is 0)
  4841. */
  4842. b: number;
  4843. /**
  4844. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  4845. * @param r defines the red component (between 0 and 1, default is 0)
  4846. * @param g defines the green component (between 0 and 1, default is 0)
  4847. * @param b defines the blue component (between 0 and 1, default is 0)
  4848. */
  4849. constructor(
  4850. /**
  4851. * Defines the red component (between 0 and 1, default is 0)
  4852. */
  4853. r?: number,
  4854. /**
  4855. * Defines the green component (between 0 and 1, default is 0)
  4856. */
  4857. g?: number,
  4858. /**
  4859. * Defines the blue component (between 0 and 1, default is 0)
  4860. */
  4861. b?: number);
  4862. /**
  4863. * Creates a string with the Color3 current values
  4864. * @returns the string representation of the Color3 object
  4865. */
  4866. toString(): string;
  4867. /**
  4868. * Returns the string "Color3"
  4869. * @returns "Color3"
  4870. */
  4871. getClassName(): string;
  4872. /**
  4873. * Compute the Color3 hash code
  4874. * @returns an unique number that can be used to hash Color3 objects
  4875. */
  4876. getHashCode(): number;
  4877. /**
  4878. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  4879. * @param array defines the array where to store the r,g,b components
  4880. * @param index defines an optional index in the target array to define where to start storing values
  4881. * @returns the current Color3 object
  4882. */
  4883. toArray(array: FloatArray, index?: number): Color3;
  4884. /**
  4885. * Returns a new Color4 object from the current Color3 and the given alpha
  4886. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  4887. * @returns a new Color4 object
  4888. */
  4889. toColor4(alpha?: number): Color4;
  4890. /**
  4891. * Returns a new array populated with 3 numeric elements : red, green and blue values
  4892. * @returns the new array
  4893. */
  4894. asArray(): number[];
  4895. /**
  4896. * Returns the luminance value
  4897. * @returns a float value
  4898. */
  4899. toLuminance(): number;
  4900. /**
  4901. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  4902. * @param otherColor defines the second operand
  4903. * @returns the new Color3 object
  4904. */
  4905. multiply(otherColor: DeepImmutable<Color3>): Color3;
  4906. /**
  4907. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  4908. * @param otherColor defines the second operand
  4909. * @param result defines the Color3 object where to store the result
  4910. * @returns the current Color3
  4911. */
  4912. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4913. /**
  4914. * Determines equality between Color3 objects
  4915. * @param otherColor defines the second operand
  4916. * @returns true if the rgb values are equal to the given ones
  4917. */
  4918. equals(otherColor: DeepImmutable<Color3>): boolean;
  4919. /**
  4920. * Determines equality between the current Color3 object and a set of r,b,g values
  4921. * @param r defines the red component to check
  4922. * @param g defines the green component to check
  4923. * @param b defines the blue component to check
  4924. * @returns true if the rgb values are equal to the given ones
  4925. */
  4926. equalsFloats(r: number, g: number, b: number): boolean;
  4927. /**
  4928. * Multiplies in place each rgb value by scale
  4929. * @param scale defines the scaling factor
  4930. * @returns the updated Color3
  4931. */
  4932. scale(scale: number): Color3;
  4933. /**
  4934. * Multiplies the rgb values by scale and stores the result into "result"
  4935. * @param scale defines the scaling factor
  4936. * @param result defines the Color3 object where to store the result
  4937. * @returns the unmodified current Color3
  4938. */
  4939. scaleToRef(scale: number, result: Color3): Color3;
  4940. /**
  4941. * Scale the current Color3 values by a factor and add the result to a given Color3
  4942. * @param scale defines the scale factor
  4943. * @param result defines color to store the result into
  4944. * @returns the unmodified current Color3
  4945. */
  4946. scaleAndAddToRef(scale: number, result: Color3): Color3;
  4947. /**
  4948. * Clamps the rgb values by the min and max values and stores the result into "result"
  4949. * @param min defines minimum clamping value (default is 0)
  4950. * @param max defines maximum clamping value (default is 1)
  4951. * @param result defines color to store the result into
  4952. * @returns the original Color3
  4953. */
  4954. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  4955. /**
  4956. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  4957. * @param otherColor defines the second operand
  4958. * @returns the new Color3
  4959. */
  4960. add(otherColor: DeepImmutable<Color3>): Color3;
  4961. /**
  4962. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  4963. * @param otherColor defines the second operand
  4964. * @param result defines Color3 object to store the result into
  4965. * @returns the unmodified current Color3
  4966. */
  4967. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4968. /**
  4969. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  4970. * @param otherColor defines the second operand
  4971. * @returns the new Color3
  4972. */
  4973. subtract(otherColor: DeepImmutable<Color3>): Color3;
  4974. /**
  4975. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  4976. * @param otherColor defines the second operand
  4977. * @param result defines Color3 object to store the result into
  4978. * @returns the unmodified current Color3
  4979. */
  4980. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4981. /**
  4982. * Copy the current object
  4983. * @returns a new Color3 copied the current one
  4984. */
  4985. clone(): Color3;
  4986. /**
  4987. * Copies the rgb values from the source in the current Color3
  4988. * @param source defines the source Color3 object
  4989. * @returns the updated Color3 object
  4990. */
  4991. copyFrom(source: DeepImmutable<Color3>): Color3;
  4992. /**
  4993. * Updates the Color3 rgb values from the given floats
  4994. * @param r defines the red component to read from
  4995. * @param g defines the green component to read from
  4996. * @param b defines the blue component to read from
  4997. * @returns the current Color3 object
  4998. */
  4999. copyFromFloats(r: number, g: number, b: number): Color3;
  5000. /**
  5001. * Updates the Color3 rgb values from the given floats
  5002. * @param r defines the red component to read from
  5003. * @param g defines the green component to read from
  5004. * @param b defines the blue component to read from
  5005. * @returns the current Color3 object
  5006. */
  5007. set(r: number, g: number, b: number): Color3;
  5008. /**
  5009. * Compute the Color3 hexadecimal code as a string
  5010. * @returns a string containing the hexadecimal representation of the Color3 object
  5011. */
  5012. toHexString(): string;
  5013. /**
  5014. * Computes a new Color3 converted from the current one to linear space
  5015. * @returns a new Color3 object
  5016. */
  5017. toLinearSpace(): Color3;
  5018. /**
  5019. * Converts current color in rgb space to HSV values
  5020. * @returns a new color3 representing the HSV values
  5021. */
  5022. toHSV(): Color3;
  5023. /**
  5024. * Converts current color in rgb space to HSV values
  5025. * @param result defines the Color3 where to store the HSV values
  5026. */
  5027. toHSVToRef(result: Color3): void;
  5028. /**
  5029. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5030. * @param convertedColor defines the Color3 object where to store the linear space version
  5031. * @returns the unmodified Color3
  5032. */
  5033. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5034. /**
  5035. * Computes a new Color3 converted from the current one to gamma space
  5036. * @returns a new Color3 object
  5037. */
  5038. toGammaSpace(): Color3;
  5039. /**
  5040. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5041. * @param convertedColor defines the Color3 object where to store the gamma space version
  5042. * @returns the unmodified Color3
  5043. */
  5044. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5045. private static _BlackReadOnly;
  5046. /**
  5047. * Convert Hue, saturation and value to a Color3 (RGB)
  5048. * @param hue defines the hue
  5049. * @param saturation defines the saturation
  5050. * @param value defines the value
  5051. * @param result defines the Color3 where to store the RGB values
  5052. */
  5053. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5054. /**
  5055. * Creates a new Color3 from the string containing valid hexadecimal values
  5056. * @param hex defines a string containing valid hexadecimal values
  5057. * @returns a new Color3 object
  5058. */
  5059. static FromHexString(hex: string): Color3;
  5060. /**
  5061. * Creates a new Color3 from the starting index of the given array
  5062. * @param array defines the source array
  5063. * @param offset defines an offset in the source array
  5064. * @returns a new Color3 object
  5065. */
  5066. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5067. /**
  5068. * Creates a new Color3 from integer values (< 256)
  5069. * @param r defines the red component to read from (value between 0 and 255)
  5070. * @param g defines the green component to read from (value between 0 and 255)
  5071. * @param b defines the blue component to read from (value between 0 and 255)
  5072. * @returns a new Color3 object
  5073. */
  5074. static FromInts(r: number, g: number, b: number): Color3;
  5075. /**
  5076. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5077. * @param start defines the start Color3 value
  5078. * @param end defines the end Color3 value
  5079. * @param amount defines the gradient value between start and end
  5080. * @returns a new Color3 object
  5081. */
  5082. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5083. /**
  5084. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5085. * @param left defines the start value
  5086. * @param right defines the end value
  5087. * @param amount defines the gradient factor
  5088. * @param result defines the Color3 object where to store the result
  5089. */
  5090. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5091. /**
  5092. * Returns a Color3 value containing a red color
  5093. * @returns a new Color3 object
  5094. */
  5095. static Red(): Color3;
  5096. /**
  5097. * Returns a Color3 value containing a green color
  5098. * @returns a new Color3 object
  5099. */
  5100. static Green(): Color3;
  5101. /**
  5102. * Returns a Color3 value containing a blue color
  5103. * @returns a new Color3 object
  5104. */
  5105. static Blue(): Color3;
  5106. /**
  5107. * Returns a Color3 value containing a black color
  5108. * @returns a new Color3 object
  5109. */
  5110. static Black(): Color3;
  5111. /**
  5112. * Gets a Color3 value containing a black color that must not be updated
  5113. */
  5114. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5115. /**
  5116. * Returns a Color3 value containing a white color
  5117. * @returns a new Color3 object
  5118. */
  5119. static White(): Color3;
  5120. /**
  5121. * Returns a Color3 value containing a purple color
  5122. * @returns a new Color3 object
  5123. */
  5124. static Purple(): Color3;
  5125. /**
  5126. * Returns a Color3 value containing a magenta color
  5127. * @returns a new Color3 object
  5128. */
  5129. static Magenta(): Color3;
  5130. /**
  5131. * Returns a Color3 value containing a yellow color
  5132. * @returns a new Color3 object
  5133. */
  5134. static Yellow(): Color3;
  5135. /**
  5136. * Returns a Color3 value containing a gray color
  5137. * @returns a new Color3 object
  5138. */
  5139. static Gray(): Color3;
  5140. /**
  5141. * Returns a Color3 value containing a teal color
  5142. * @returns a new Color3 object
  5143. */
  5144. static Teal(): Color3;
  5145. /**
  5146. * Returns a Color3 value containing a random color
  5147. * @returns a new Color3 object
  5148. */
  5149. static Random(): Color3;
  5150. }
  5151. /**
  5152. * Class used to hold a RBGA color
  5153. */
  5154. export class Color4 {
  5155. /**
  5156. * Defines the red component (between 0 and 1, default is 0)
  5157. */
  5158. r: number;
  5159. /**
  5160. * Defines the green component (between 0 and 1, default is 0)
  5161. */
  5162. g: number;
  5163. /**
  5164. * Defines the blue component (between 0 and 1, default is 0)
  5165. */
  5166. b: number;
  5167. /**
  5168. * Defines the alpha component (between 0 and 1, default is 1)
  5169. */
  5170. a: number;
  5171. /**
  5172. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5173. * @param r defines the red component (between 0 and 1, default is 0)
  5174. * @param g defines the green component (between 0 and 1, default is 0)
  5175. * @param b defines the blue component (between 0 and 1, default is 0)
  5176. * @param a defines the alpha component (between 0 and 1, default is 1)
  5177. */
  5178. constructor(
  5179. /**
  5180. * Defines the red component (between 0 and 1, default is 0)
  5181. */
  5182. r?: number,
  5183. /**
  5184. * Defines the green component (between 0 and 1, default is 0)
  5185. */
  5186. g?: number,
  5187. /**
  5188. * Defines the blue component (between 0 and 1, default is 0)
  5189. */
  5190. b?: number,
  5191. /**
  5192. * Defines the alpha component (between 0 and 1, default is 1)
  5193. */
  5194. a?: number);
  5195. /**
  5196. * Adds in place the given Color4 values to the current Color4 object
  5197. * @param right defines the second operand
  5198. * @returns the current updated Color4 object
  5199. */
  5200. addInPlace(right: DeepImmutable<Color4>): Color4;
  5201. /**
  5202. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5203. * @returns the new array
  5204. */
  5205. asArray(): number[];
  5206. /**
  5207. * Stores from the starting index in the given array the Color4 successive values
  5208. * @param array defines the array where to store the r,g,b components
  5209. * @param index defines an optional index in the target array to define where to start storing values
  5210. * @returns the current Color4 object
  5211. */
  5212. toArray(array: number[], index?: number): Color4;
  5213. /**
  5214. * Determines equality between Color4 objects
  5215. * @param otherColor defines the second operand
  5216. * @returns true if the rgba values are equal to the given ones
  5217. */
  5218. equals(otherColor: DeepImmutable<Color4>): boolean;
  5219. /**
  5220. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5221. * @param right defines the second operand
  5222. * @returns a new Color4 object
  5223. */
  5224. add(right: DeepImmutable<Color4>): Color4;
  5225. /**
  5226. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5227. * @param right defines the second operand
  5228. * @returns a new Color4 object
  5229. */
  5230. subtract(right: DeepImmutable<Color4>): Color4;
  5231. /**
  5232. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5233. * @param right defines the second operand
  5234. * @param result defines the Color4 object where to store the result
  5235. * @returns the current Color4 object
  5236. */
  5237. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5238. /**
  5239. * Creates a new Color4 with the current Color4 values multiplied by scale
  5240. * @param scale defines the scaling factor to apply
  5241. * @returns a new Color4 object
  5242. */
  5243. scale(scale: number): Color4;
  5244. /**
  5245. * Multiplies the current Color4 values by scale and stores the result in "result"
  5246. * @param scale defines the scaling factor to apply
  5247. * @param result defines the Color4 object where to store the result
  5248. * @returns the current unmodified Color4
  5249. */
  5250. scaleToRef(scale: number, result: Color4): Color4;
  5251. /**
  5252. * Scale the current Color4 values by a factor and add the result to a given Color4
  5253. * @param scale defines the scale factor
  5254. * @param result defines the Color4 object where to store the result
  5255. * @returns the unmodified current Color4
  5256. */
  5257. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5258. /**
  5259. * Clamps the rgb values by the min and max values and stores the result into "result"
  5260. * @param min defines minimum clamping value (default is 0)
  5261. * @param max defines maximum clamping value (default is 1)
  5262. * @param result defines color to store the result into.
  5263. * @returns the cuurent Color4
  5264. */
  5265. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5266. /**
  5267. * Multipy an Color4 value by another and return a new Color4 object
  5268. * @param color defines the Color4 value to multiply by
  5269. * @returns a new Color4 object
  5270. */
  5271. multiply(color: Color4): Color4;
  5272. /**
  5273. * Multipy a Color4 value by another and push the result in a reference value
  5274. * @param color defines the Color4 value to multiply by
  5275. * @param result defines the Color4 to fill the result in
  5276. * @returns the result Color4
  5277. */
  5278. multiplyToRef(color: Color4, result: Color4): Color4;
  5279. /**
  5280. * Creates a string with the Color4 current values
  5281. * @returns the string representation of the Color4 object
  5282. */
  5283. toString(): string;
  5284. /**
  5285. * Returns the string "Color4"
  5286. * @returns "Color4"
  5287. */
  5288. getClassName(): string;
  5289. /**
  5290. * Compute the Color4 hash code
  5291. * @returns an unique number that can be used to hash Color4 objects
  5292. */
  5293. getHashCode(): number;
  5294. /**
  5295. * Creates a new Color4 copied from the current one
  5296. * @returns a new Color4 object
  5297. */
  5298. clone(): Color4;
  5299. /**
  5300. * Copies the given Color4 values into the current one
  5301. * @param source defines the source Color4 object
  5302. * @returns the current updated Color4 object
  5303. */
  5304. copyFrom(source: Color4): Color4;
  5305. /**
  5306. * Copies the given float values into the current one
  5307. * @param r defines the red component to read from
  5308. * @param g defines the green component to read from
  5309. * @param b defines the blue component to read from
  5310. * @param a defines the alpha component to read from
  5311. * @returns the current updated Color4 object
  5312. */
  5313. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5314. /**
  5315. * Copies the given float values into the current one
  5316. * @param r defines the red component to read from
  5317. * @param g defines the green component to read from
  5318. * @param b defines the blue component to read from
  5319. * @param a defines the alpha component to read from
  5320. * @returns the current updated Color4 object
  5321. */
  5322. set(r: number, g: number, b: number, a: number): Color4;
  5323. /**
  5324. * Compute the Color4 hexadecimal code as a string
  5325. * @returns a string containing the hexadecimal representation of the Color4 object
  5326. */
  5327. toHexString(): string;
  5328. /**
  5329. * Computes a new Color4 converted from the current one to linear space
  5330. * @returns a new Color4 object
  5331. */
  5332. toLinearSpace(): Color4;
  5333. /**
  5334. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5335. * @param convertedColor defines the Color4 object where to store the linear space version
  5336. * @returns the unmodified Color4
  5337. */
  5338. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5339. /**
  5340. * Computes a new Color4 converted from the current one to gamma space
  5341. * @returns a new Color4 object
  5342. */
  5343. toGammaSpace(): Color4;
  5344. /**
  5345. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5346. * @param convertedColor defines the Color4 object where to store the gamma space version
  5347. * @returns the unmodified Color4
  5348. */
  5349. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5350. /**
  5351. * Creates a new Color4 from the string containing valid hexadecimal values
  5352. * @param hex defines a string containing valid hexadecimal values
  5353. * @returns a new Color4 object
  5354. */
  5355. static FromHexString(hex: string): Color4;
  5356. /**
  5357. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5358. * @param left defines the start value
  5359. * @param right defines the end value
  5360. * @param amount defines the gradient factor
  5361. * @returns a new Color4 object
  5362. */
  5363. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5364. /**
  5365. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5366. * @param left defines the start value
  5367. * @param right defines the end value
  5368. * @param amount defines the gradient factor
  5369. * @param result defines the Color4 object where to store data
  5370. */
  5371. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5372. /**
  5373. * Creates a new Color4 from a Color3 and an alpha value
  5374. * @param color3 defines the source Color3 to read from
  5375. * @param alpha defines the alpha component (1.0 by default)
  5376. * @returns a new Color4 object
  5377. */
  5378. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5379. /**
  5380. * Creates a new Color4 from the starting index element of the given array
  5381. * @param array defines the source array to read from
  5382. * @param offset defines the offset in the source array
  5383. * @returns a new Color4 object
  5384. */
  5385. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5386. /**
  5387. * Creates a new Color3 from integer values (< 256)
  5388. * @param r defines the red component to read from (value between 0 and 255)
  5389. * @param g defines the green component to read from (value between 0 and 255)
  5390. * @param b defines the blue component to read from (value between 0 and 255)
  5391. * @param a defines the alpha component to read from (value between 0 and 255)
  5392. * @returns a new Color3 object
  5393. */
  5394. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5395. /**
  5396. * Check the content of a given array and convert it to an array containing RGBA data
  5397. * If the original array was already containing count * 4 values then it is returned directly
  5398. * @param colors defines the array to check
  5399. * @param count defines the number of RGBA data to expect
  5400. * @returns an array containing count * 4 values (RGBA)
  5401. */
  5402. static CheckColors4(colors: number[], count: number): number[];
  5403. }
  5404. /**
  5405. * @hidden
  5406. */
  5407. export class TmpColors {
  5408. static Color3: Color3[];
  5409. static Color4: Color4[];
  5410. }
  5411. }
  5412. declare module "babylonjs/Maths/sphericalPolynomial" {
  5413. import { Vector3 } from "babylonjs/Maths/math.vector";
  5414. import { Color3 } from "babylonjs/Maths/math.color";
  5415. /**
  5416. * Class representing spherical harmonics coefficients to the 3rd degree
  5417. */
  5418. export class SphericalHarmonics {
  5419. /**
  5420. * Defines whether or not the harmonics have been prescaled for rendering.
  5421. */
  5422. preScaled: boolean;
  5423. /**
  5424. * The l0,0 coefficients of the spherical harmonics
  5425. */
  5426. l00: Vector3;
  5427. /**
  5428. * The l1,-1 coefficients of the spherical harmonics
  5429. */
  5430. l1_1: Vector3;
  5431. /**
  5432. * The l1,0 coefficients of the spherical harmonics
  5433. */
  5434. l10: Vector3;
  5435. /**
  5436. * The l1,1 coefficients of the spherical harmonics
  5437. */
  5438. l11: Vector3;
  5439. /**
  5440. * The l2,-2 coefficients of the spherical harmonics
  5441. */
  5442. l2_2: Vector3;
  5443. /**
  5444. * The l2,-1 coefficients of the spherical harmonics
  5445. */
  5446. l2_1: Vector3;
  5447. /**
  5448. * The l2,0 coefficients of the spherical harmonics
  5449. */
  5450. l20: Vector3;
  5451. /**
  5452. * The l2,1 coefficients of the spherical harmonics
  5453. */
  5454. l21: Vector3;
  5455. /**
  5456. * The l2,2 coefficients of the spherical harmonics
  5457. */
  5458. l22: Vector3;
  5459. /**
  5460. * Adds a light to the spherical harmonics
  5461. * @param direction the direction of the light
  5462. * @param color the color of the light
  5463. * @param deltaSolidAngle the delta solid angle of the light
  5464. */
  5465. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5466. /**
  5467. * Scales the spherical harmonics by the given amount
  5468. * @param scale the amount to scale
  5469. */
  5470. scaleInPlace(scale: number): void;
  5471. /**
  5472. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5473. *
  5474. * ```
  5475. * E_lm = A_l * L_lm
  5476. * ```
  5477. *
  5478. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5479. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5480. * the scaling factors are given in equation 9.
  5481. */
  5482. convertIncidentRadianceToIrradiance(): void;
  5483. /**
  5484. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5485. *
  5486. * ```
  5487. * L = (1/pi) * E * rho
  5488. * ```
  5489. *
  5490. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5491. */
  5492. convertIrradianceToLambertianRadiance(): void;
  5493. /**
  5494. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5495. * required operations at run time.
  5496. *
  5497. * This is simply done by scaling back the SH with Ylm constants parameter.
  5498. * The trigonometric part being applied by the shader at run time.
  5499. */
  5500. preScaleForRendering(): void;
  5501. /**
  5502. * Constructs a spherical harmonics from an array.
  5503. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5504. * @returns the spherical harmonics
  5505. */
  5506. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5507. /**
  5508. * Gets the spherical harmonics from polynomial
  5509. * @param polynomial the spherical polynomial
  5510. * @returns the spherical harmonics
  5511. */
  5512. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5513. }
  5514. /**
  5515. * Class representing spherical polynomial coefficients to the 3rd degree
  5516. */
  5517. export class SphericalPolynomial {
  5518. private _harmonics;
  5519. /**
  5520. * The spherical harmonics used to create the polynomials.
  5521. */
  5522. readonly preScaledHarmonics: SphericalHarmonics;
  5523. /**
  5524. * The x coefficients of the spherical polynomial
  5525. */
  5526. x: Vector3;
  5527. /**
  5528. * The y coefficients of the spherical polynomial
  5529. */
  5530. y: Vector3;
  5531. /**
  5532. * The z coefficients of the spherical polynomial
  5533. */
  5534. z: Vector3;
  5535. /**
  5536. * The xx coefficients of the spherical polynomial
  5537. */
  5538. xx: Vector3;
  5539. /**
  5540. * The yy coefficients of the spherical polynomial
  5541. */
  5542. yy: Vector3;
  5543. /**
  5544. * The zz coefficients of the spherical polynomial
  5545. */
  5546. zz: Vector3;
  5547. /**
  5548. * The xy coefficients of the spherical polynomial
  5549. */
  5550. xy: Vector3;
  5551. /**
  5552. * The yz coefficients of the spherical polynomial
  5553. */
  5554. yz: Vector3;
  5555. /**
  5556. * The zx coefficients of the spherical polynomial
  5557. */
  5558. zx: Vector3;
  5559. /**
  5560. * Adds an ambient color to the spherical polynomial
  5561. * @param color the color to add
  5562. */
  5563. addAmbient(color: Color3): void;
  5564. /**
  5565. * Scales the spherical polynomial by the given amount
  5566. * @param scale the amount to scale
  5567. */
  5568. scaleInPlace(scale: number): void;
  5569. /**
  5570. * Gets the spherical polynomial from harmonics
  5571. * @param harmonics the spherical harmonics
  5572. * @returns the spherical polynomial
  5573. */
  5574. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5575. /**
  5576. * Constructs a spherical polynomial from an array.
  5577. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5578. * @returns the spherical polynomial
  5579. */
  5580. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5581. }
  5582. }
  5583. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  5584. /**
  5585. * Define options used to create a render target texture
  5586. */
  5587. export class RenderTargetCreationOptions {
  5588. /**
  5589. * Specifies is mipmaps must be generated
  5590. */
  5591. generateMipMaps?: boolean;
  5592. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5593. generateDepthBuffer?: boolean;
  5594. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5595. generateStencilBuffer?: boolean;
  5596. /** Defines texture type (int by default) */
  5597. type?: number;
  5598. /** Defines sampling mode (trilinear by default) */
  5599. samplingMode?: number;
  5600. /** Defines format (RGBA by default) */
  5601. format?: number;
  5602. }
  5603. }
  5604. declare module "babylonjs/States/alphaCullingState" {
  5605. /**
  5606. * @hidden
  5607. **/
  5608. export class _AlphaState {
  5609. private _isAlphaBlendDirty;
  5610. private _isBlendFunctionParametersDirty;
  5611. private _isBlendEquationParametersDirty;
  5612. private _isBlendConstantsDirty;
  5613. private _alphaBlend;
  5614. private _blendFunctionParameters;
  5615. private _blendEquationParameters;
  5616. private _blendConstants;
  5617. /**
  5618. * Initializes the state.
  5619. */
  5620. constructor();
  5621. readonly isDirty: boolean;
  5622. alphaBlend: boolean;
  5623. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5624. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5625. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5626. reset(): void;
  5627. apply(gl: WebGLRenderingContext): void;
  5628. }
  5629. }
  5630. declare module "babylonjs/States/depthCullingState" {
  5631. import { Nullable } from "babylonjs/types";
  5632. /**
  5633. * @hidden
  5634. **/
  5635. export class _DepthCullingState {
  5636. private _isDepthTestDirty;
  5637. private _isDepthMaskDirty;
  5638. private _isDepthFuncDirty;
  5639. private _isCullFaceDirty;
  5640. private _isCullDirty;
  5641. private _isZOffsetDirty;
  5642. private _isFrontFaceDirty;
  5643. private _depthTest;
  5644. private _depthMask;
  5645. private _depthFunc;
  5646. private _cull;
  5647. private _cullFace;
  5648. private _zOffset;
  5649. private _frontFace;
  5650. /**
  5651. * Initializes the state.
  5652. */
  5653. constructor();
  5654. readonly isDirty: boolean;
  5655. zOffset: number;
  5656. cullFace: Nullable<number>;
  5657. cull: Nullable<boolean>;
  5658. depthFunc: Nullable<number>;
  5659. depthMask: boolean;
  5660. depthTest: boolean;
  5661. frontFace: Nullable<number>;
  5662. reset(): void;
  5663. apply(gl: WebGLRenderingContext): void;
  5664. }
  5665. }
  5666. declare module "babylonjs/States/stencilState" {
  5667. /**
  5668. * @hidden
  5669. **/
  5670. export class _StencilState {
  5671. /** 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 */
  5672. static readonly ALWAYS: number;
  5673. /** Passed to stencilOperation to specify that stencil value must be kept */
  5674. static readonly KEEP: number;
  5675. /** Passed to stencilOperation to specify that stencil value must be replaced */
  5676. static readonly REPLACE: number;
  5677. private _isStencilTestDirty;
  5678. private _isStencilMaskDirty;
  5679. private _isStencilFuncDirty;
  5680. private _isStencilOpDirty;
  5681. private _stencilTest;
  5682. private _stencilMask;
  5683. private _stencilFunc;
  5684. private _stencilFuncRef;
  5685. private _stencilFuncMask;
  5686. private _stencilOpStencilFail;
  5687. private _stencilOpDepthFail;
  5688. private _stencilOpStencilDepthPass;
  5689. readonly isDirty: boolean;
  5690. stencilFunc: number;
  5691. stencilFuncRef: number;
  5692. stencilFuncMask: number;
  5693. stencilOpStencilFail: number;
  5694. stencilOpDepthFail: number;
  5695. stencilOpStencilDepthPass: number;
  5696. stencilMask: number;
  5697. stencilTest: boolean;
  5698. constructor();
  5699. reset(): void;
  5700. apply(gl: WebGLRenderingContext): void;
  5701. }
  5702. }
  5703. declare module "babylonjs/States/index" {
  5704. export * from "babylonjs/States/alphaCullingState";
  5705. export * from "babylonjs/States/depthCullingState";
  5706. export * from "babylonjs/States/stencilState";
  5707. }
  5708. declare module "babylonjs/Instrumentation/timeToken" {
  5709. import { Nullable } from "babylonjs/types";
  5710. /**
  5711. * @hidden
  5712. **/
  5713. export class _TimeToken {
  5714. _startTimeQuery: Nullable<WebGLQuery>;
  5715. _endTimeQuery: Nullable<WebGLQuery>;
  5716. _timeElapsedQuery: Nullable<WebGLQuery>;
  5717. _timeElapsedQueryEnded: boolean;
  5718. }
  5719. }
  5720. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5721. /**
  5722. * Class used to evalaute queries containing `and` and `or` operators
  5723. */
  5724. export class AndOrNotEvaluator {
  5725. /**
  5726. * Evaluate a query
  5727. * @param query defines the query to evaluate
  5728. * @param evaluateCallback defines the callback used to filter result
  5729. * @returns true if the query matches
  5730. */
  5731. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5732. private static _HandleParenthesisContent;
  5733. private static _SimplifyNegation;
  5734. }
  5735. }
  5736. declare module "babylonjs/Misc/tags" {
  5737. /**
  5738. * Class used to store custom tags
  5739. */
  5740. export class Tags {
  5741. /**
  5742. * Adds support for tags on the given object
  5743. * @param obj defines the object to use
  5744. */
  5745. static EnableFor(obj: any): void;
  5746. /**
  5747. * Removes tags support
  5748. * @param obj defines the object to use
  5749. */
  5750. static DisableFor(obj: any): void;
  5751. /**
  5752. * Gets a boolean indicating if the given object has tags
  5753. * @param obj defines the object to use
  5754. * @returns a boolean
  5755. */
  5756. static HasTags(obj: any): boolean;
  5757. /**
  5758. * Gets the tags available on a given object
  5759. * @param obj defines the object to use
  5760. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5761. * @returns the tags
  5762. */
  5763. static GetTags(obj: any, asString?: boolean): any;
  5764. /**
  5765. * Adds tags to an object
  5766. * @param obj defines the object to use
  5767. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5768. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5769. */
  5770. static AddTagsTo(obj: any, tagsString: string): void;
  5771. /**
  5772. * @hidden
  5773. */
  5774. static _AddTagTo(obj: any, tag: string): void;
  5775. /**
  5776. * Removes specific tags from a specific object
  5777. * @param obj defines the object to use
  5778. * @param tagsString defines the tags to remove
  5779. */
  5780. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5781. /**
  5782. * @hidden
  5783. */
  5784. static _RemoveTagFrom(obj: any, tag: string): void;
  5785. /**
  5786. * Defines if tags hosted on an object match a given query
  5787. * @param obj defines the object to use
  5788. * @param tagsQuery defines the tag query
  5789. * @returns a boolean
  5790. */
  5791. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5792. }
  5793. }
  5794. declare module "babylonjs/Maths/math.path" {
  5795. import { DeepImmutable, Nullable } from "babylonjs/types";
  5796. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  5797. /**
  5798. * Defines potential orientation for back face culling
  5799. */
  5800. export enum Orientation {
  5801. /**
  5802. * Clockwise
  5803. */
  5804. CW = 0,
  5805. /** Counter clockwise */
  5806. CCW = 1
  5807. }
  5808. /** Class used to represent a Bezier curve */
  5809. export class BezierCurve {
  5810. /**
  5811. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5812. * @param t defines the time
  5813. * @param x1 defines the left coordinate on X axis
  5814. * @param y1 defines the left coordinate on Y axis
  5815. * @param x2 defines the right coordinate on X axis
  5816. * @param y2 defines the right coordinate on Y axis
  5817. * @returns the interpolated value
  5818. */
  5819. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5820. }
  5821. /**
  5822. * Defines angle representation
  5823. */
  5824. export class Angle {
  5825. private _radians;
  5826. /**
  5827. * Creates an Angle object of "radians" radians (float).
  5828. * @param radians the angle in radians
  5829. */
  5830. constructor(radians: number);
  5831. /**
  5832. * Get value in degrees
  5833. * @returns the Angle value in degrees (float)
  5834. */
  5835. degrees(): number;
  5836. /**
  5837. * Get value in radians
  5838. * @returns the Angle value in radians (float)
  5839. */
  5840. radians(): number;
  5841. /**
  5842. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5843. * @param a defines first vector
  5844. * @param b defines second vector
  5845. * @returns a new Angle
  5846. */
  5847. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5848. /**
  5849. * Gets a new Angle object from the given float in radians
  5850. * @param radians defines the angle value in radians
  5851. * @returns a new Angle
  5852. */
  5853. static FromRadians(radians: number): Angle;
  5854. /**
  5855. * Gets a new Angle object from the given float in degrees
  5856. * @param degrees defines the angle value in degrees
  5857. * @returns a new Angle
  5858. */
  5859. static FromDegrees(degrees: number): Angle;
  5860. }
  5861. /**
  5862. * This represents an arc in a 2d space.
  5863. */
  5864. export class Arc2 {
  5865. /** Defines the start point of the arc */
  5866. startPoint: Vector2;
  5867. /** Defines the mid point of the arc */
  5868. midPoint: Vector2;
  5869. /** Defines the end point of the arc */
  5870. endPoint: Vector2;
  5871. /**
  5872. * Defines the center point of the arc.
  5873. */
  5874. centerPoint: Vector2;
  5875. /**
  5876. * Defines the radius of the arc.
  5877. */
  5878. radius: number;
  5879. /**
  5880. * Defines the angle of the arc (from mid point to end point).
  5881. */
  5882. angle: Angle;
  5883. /**
  5884. * Defines the start angle of the arc (from start point to middle point).
  5885. */
  5886. startAngle: Angle;
  5887. /**
  5888. * Defines the orientation of the arc (clock wise/counter clock wise).
  5889. */
  5890. orientation: Orientation;
  5891. /**
  5892. * Creates an Arc object from the three given points : start, middle and end.
  5893. * @param startPoint Defines the start point of the arc
  5894. * @param midPoint Defines the midlle point of the arc
  5895. * @param endPoint Defines the end point of the arc
  5896. */
  5897. constructor(
  5898. /** Defines the start point of the arc */
  5899. startPoint: Vector2,
  5900. /** Defines the mid point of the arc */
  5901. midPoint: Vector2,
  5902. /** Defines the end point of the arc */
  5903. endPoint: Vector2);
  5904. }
  5905. /**
  5906. * Represents a 2D path made up of multiple 2D points
  5907. */
  5908. export class Path2 {
  5909. private _points;
  5910. private _length;
  5911. /**
  5912. * If the path start and end point are the same
  5913. */
  5914. closed: boolean;
  5915. /**
  5916. * Creates a Path2 object from the starting 2D coordinates x and y.
  5917. * @param x the starting points x value
  5918. * @param y the starting points y value
  5919. */
  5920. constructor(x: number, y: number);
  5921. /**
  5922. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5923. * @param x the added points x value
  5924. * @param y the added points y value
  5925. * @returns the updated Path2.
  5926. */
  5927. addLineTo(x: number, y: number): Path2;
  5928. /**
  5929. * 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.
  5930. * @param midX middle point x value
  5931. * @param midY middle point y value
  5932. * @param endX end point x value
  5933. * @param endY end point y value
  5934. * @param numberOfSegments (default: 36)
  5935. * @returns the updated Path2.
  5936. */
  5937. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5938. /**
  5939. * Closes the Path2.
  5940. * @returns the Path2.
  5941. */
  5942. close(): Path2;
  5943. /**
  5944. * Gets the sum of the distance between each sequential point in the path
  5945. * @returns the Path2 total length (float).
  5946. */
  5947. length(): number;
  5948. /**
  5949. * Gets the points which construct the path
  5950. * @returns the Path2 internal array of points.
  5951. */
  5952. getPoints(): Vector2[];
  5953. /**
  5954. * Retreives the point at the distance aways from the starting point
  5955. * @param normalizedLengthPosition the length along the path to retreive the point from
  5956. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5957. */
  5958. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5959. /**
  5960. * Creates a new path starting from an x and y position
  5961. * @param x starting x value
  5962. * @param y starting y value
  5963. * @returns a new Path2 starting at the coordinates (x, y).
  5964. */
  5965. static StartingAt(x: number, y: number): Path2;
  5966. }
  5967. /**
  5968. * Represents a 3D path made up of multiple 3D points
  5969. */
  5970. export class Path3D {
  5971. /**
  5972. * an array of Vector3, the curve axis of the Path3D
  5973. */
  5974. path: Vector3[];
  5975. private _curve;
  5976. private _distances;
  5977. private _tangents;
  5978. private _normals;
  5979. private _binormals;
  5980. private _raw;
  5981. /**
  5982. * new Path3D(path, normal, raw)
  5983. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5984. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5985. * @param path an array of Vector3, the curve axis of the Path3D
  5986. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5987. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5988. */
  5989. constructor(
  5990. /**
  5991. * an array of Vector3, the curve axis of the Path3D
  5992. */
  5993. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5994. /**
  5995. * Returns the Path3D array of successive Vector3 designing its curve.
  5996. * @returns the Path3D array of successive Vector3 designing its curve.
  5997. */
  5998. getCurve(): Vector3[];
  5999. /**
  6000. * Returns an array populated with tangent vectors on each Path3D curve point.
  6001. * @returns an array populated with tangent vectors on each Path3D curve point.
  6002. */
  6003. getTangents(): Vector3[];
  6004. /**
  6005. * Returns an array populated with normal vectors on each Path3D curve point.
  6006. * @returns an array populated with normal vectors on each Path3D curve point.
  6007. */
  6008. getNormals(): Vector3[];
  6009. /**
  6010. * Returns an array populated with binormal vectors on each Path3D curve point.
  6011. * @returns an array populated with binormal vectors on each Path3D curve point.
  6012. */
  6013. getBinormals(): Vector3[];
  6014. /**
  6015. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  6016. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  6017. */
  6018. getDistances(): number[];
  6019. /**
  6020. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  6021. * @param path path which all values are copied into the curves points
  6022. * @param firstNormal which should be projected onto the curve
  6023. * @returns the same object updated.
  6024. */
  6025. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  6026. private _compute;
  6027. private _getFirstNonNullVector;
  6028. private _getLastNonNullVector;
  6029. private _normalVector;
  6030. }
  6031. /**
  6032. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6033. * A Curve3 is designed from a series of successive Vector3.
  6034. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  6035. */
  6036. export class Curve3 {
  6037. private _points;
  6038. private _length;
  6039. /**
  6040. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  6041. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  6042. * @param v1 (Vector3) the control point
  6043. * @param v2 (Vector3) the end point of the Quadratic Bezier
  6044. * @param nbPoints (integer) the wanted number of points in the curve
  6045. * @returns the created Curve3
  6046. */
  6047. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6048. /**
  6049. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  6050. * @param v0 (Vector3) the origin point of the Cubic Bezier
  6051. * @param v1 (Vector3) the first control point
  6052. * @param v2 (Vector3) the second control point
  6053. * @param v3 (Vector3) the end point of the Cubic Bezier
  6054. * @param nbPoints (integer) the wanted number of points in the curve
  6055. * @returns the created Curve3
  6056. */
  6057. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6058. /**
  6059. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  6060. * @param p1 (Vector3) the origin point of the Hermite Spline
  6061. * @param t1 (Vector3) the tangent vector at the origin point
  6062. * @param p2 (Vector3) the end point of the Hermite Spline
  6063. * @param t2 (Vector3) the tangent vector at the end point
  6064. * @param nbPoints (integer) the wanted number of points in the curve
  6065. * @returns the created Curve3
  6066. */
  6067. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6068. /**
  6069. * Returns a Curve3 object along a CatmullRom Spline curve :
  6070. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  6071. * @param nbPoints (integer) the wanted number of points between each curve control points
  6072. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  6073. * @returns the created Curve3
  6074. */
  6075. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  6076. /**
  6077. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6078. * A Curve3 is designed from a series of successive Vector3.
  6079. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  6080. * @param points points which make up the curve
  6081. */
  6082. constructor(points: Vector3[]);
  6083. /**
  6084. * @returns the Curve3 stored array of successive Vector3
  6085. */
  6086. getPoints(): Vector3[];
  6087. /**
  6088. * @returns the computed length (float) of the curve.
  6089. */
  6090. length(): number;
  6091. /**
  6092. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  6093. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  6094. * curveA and curveB keep unchanged.
  6095. * @param curve the curve to continue from this curve
  6096. * @returns the newly constructed curve
  6097. */
  6098. continue(curve: DeepImmutable<Curve3>): Curve3;
  6099. private _computeLength;
  6100. }
  6101. }
  6102. declare module "babylonjs/Animations/easing" {
  6103. /**
  6104. * This represents the main contract an easing function should follow.
  6105. * Easing functions are used throughout the animation system.
  6106. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6107. */
  6108. export interface IEasingFunction {
  6109. /**
  6110. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6111. * of the easing function.
  6112. * The link below provides some of the most common examples of easing functions.
  6113. * @see https://easings.net/
  6114. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6115. * @returns the corresponding value on the curve defined by the easing function
  6116. */
  6117. ease(gradient: number): number;
  6118. }
  6119. /**
  6120. * Base class used for every default easing function.
  6121. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6122. */
  6123. export class EasingFunction implements IEasingFunction {
  6124. /**
  6125. * Interpolation follows the mathematical formula associated with the easing function.
  6126. */
  6127. static readonly EASINGMODE_EASEIN: number;
  6128. /**
  6129. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6130. */
  6131. static readonly EASINGMODE_EASEOUT: number;
  6132. /**
  6133. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6134. */
  6135. static readonly EASINGMODE_EASEINOUT: number;
  6136. private _easingMode;
  6137. /**
  6138. * Sets the easing mode of the current function.
  6139. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6140. */
  6141. setEasingMode(easingMode: number): void;
  6142. /**
  6143. * Gets the current easing mode.
  6144. * @returns the easing mode
  6145. */
  6146. getEasingMode(): number;
  6147. /**
  6148. * @hidden
  6149. */
  6150. easeInCore(gradient: number): number;
  6151. /**
  6152. * Given an input gradient between 0 and 1, this returns the corresponding value
  6153. * of the easing function.
  6154. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6155. * @returns the corresponding value on the curve defined by the easing function
  6156. */
  6157. ease(gradient: number): number;
  6158. }
  6159. /**
  6160. * Easing function with a circle shape (see link below).
  6161. * @see https://easings.net/#easeInCirc
  6162. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6163. */
  6164. export class CircleEase extends EasingFunction implements IEasingFunction {
  6165. /** @hidden */
  6166. easeInCore(gradient: number): number;
  6167. }
  6168. /**
  6169. * Easing function with a ease back shape (see link below).
  6170. * @see https://easings.net/#easeInBack
  6171. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6172. */
  6173. export class BackEase extends EasingFunction implements IEasingFunction {
  6174. /** Defines the amplitude of the function */
  6175. amplitude: number;
  6176. /**
  6177. * Instantiates a back ease easing
  6178. * @see https://easings.net/#easeInBack
  6179. * @param amplitude Defines the amplitude of the function
  6180. */
  6181. constructor(
  6182. /** Defines the amplitude of the function */
  6183. amplitude?: number);
  6184. /** @hidden */
  6185. easeInCore(gradient: number): number;
  6186. }
  6187. /**
  6188. * Easing function with a bouncing shape (see link below).
  6189. * @see https://easings.net/#easeInBounce
  6190. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6191. */
  6192. export class BounceEase extends EasingFunction implements IEasingFunction {
  6193. /** Defines the number of bounces */
  6194. bounces: number;
  6195. /** Defines the amplitude of the bounce */
  6196. bounciness: number;
  6197. /**
  6198. * Instantiates a bounce easing
  6199. * @see https://easings.net/#easeInBounce
  6200. * @param bounces Defines the number of bounces
  6201. * @param bounciness Defines the amplitude of the bounce
  6202. */
  6203. constructor(
  6204. /** Defines the number of bounces */
  6205. bounces?: number,
  6206. /** Defines the amplitude of the bounce */
  6207. bounciness?: number);
  6208. /** @hidden */
  6209. easeInCore(gradient: number): number;
  6210. }
  6211. /**
  6212. * Easing function with a power of 3 shape (see link below).
  6213. * @see https://easings.net/#easeInCubic
  6214. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6215. */
  6216. export class CubicEase extends EasingFunction implements IEasingFunction {
  6217. /** @hidden */
  6218. easeInCore(gradient: number): number;
  6219. }
  6220. /**
  6221. * Easing function with an elastic shape (see link below).
  6222. * @see https://easings.net/#easeInElastic
  6223. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6224. */
  6225. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6226. /** Defines the number of oscillations*/
  6227. oscillations: number;
  6228. /** Defines the amplitude of the oscillations*/
  6229. springiness: number;
  6230. /**
  6231. * Instantiates an elastic easing function
  6232. * @see https://easings.net/#easeInElastic
  6233. * @param oscillations Defines the number of oscillations
  6234. * @param springiness Defines the amplitude of the oscillations
  6235. */
  6236. constructor(
  6237. /** Defines the number of oscillations*/
  6238. oscillations?: number,
  6239. /** Defines the amplitude of the oscillations*/
  6240. springiness?: number);
  6241. /** @hidden */
  6242. easeInCore(gradient: number): number;
  6243. }
  6244. /**
  6245. * Easing function with an exponential shape (see link below).
  6246. * @see https://easings.net/#easeInExpo
  6247. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6248. */
  6249. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6250. /** Defines the exponent of the function */
  6251. exponent: number;
  6252. /**
  6253. * Instantiates an exponential easing function
  6254. * @see https://easings.net/#easeInExpo
  6255. * @param exponent Defines the exponent of the function
  6256. */
  6257. constructor(
  6258. /** Defines the exponent of the function */
  6259. exponent?: number);
  6260. /** @hidden */
  6261. easeInCore(gradient: number): number;
  6262. }
  6263. /**
  6264. * Easing function with a power shape (see link below).
  6265. * @see https://easings.net/#easeInQuad
  6266. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6267. */
  6268. export class PowerEase extends EasingFunction implements IEasingFunction {
  6269. /** Defines the power of the function */
  6270. power: number;
  6271. /**
  6272. * Instantiates an power base easing function
  6273. * @see https://easings.net/#easeInQuad
  6274. * @param power Defines the power of the function
  6275. */
  6276. constructor(
  6277. /** Defines the power of the function */
  6278. power?: number);
  6279. /** @hidden */
  6280. easeInCore(gradient: number): number;
  6281. }
  6282. /**
  6283. * Easing function with a power of 2 shape (see link below).
  6284. * @see https://easings.net/#easeInQuad
  6285. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6286. */
  6287. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6288. /** @hidden */
  6289. easeInCore(gradient: number): number;
  6290. }
  6291. /**
  6292. * Easing function with a power of 4 shape (see link below).
  6293. * @see https://easings.net/#easeInQuart
  6294. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6295. */
  6296. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6297. /** @hidden */
  6298. easeInCore(gradient: number): number;
  6299. }
  6300. /**
  6301. * Easing function with a power of 5 shape (see link below).
  6302. * @see https://easings.net/#easeInQuint
  6303. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6304. */
  6305. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6306. /** @hidden */
  6307. easeInCore(gradient: number): number;
  6308. }
  6309. /**
  6310. * Easing function with a sin shape (see link below).
  6311. * @see https://easings.net/#easeInSine
  6312. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6313. */
  6314. export class SineEase extends EasingFunction implements IEasingFunction {
  6315. /** @hidden */
  6316. easeInCore(gradient: number): number;
  6317. }
  6318. /**
  6319. * Easing function with a bezier shape (see link below).
  6320. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6321. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6322. */
  6323. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6324. /** Defines the x component of the start tangent in the bezier curve */
  6325. x1: number;
  6326. /** Defines the y component of the start tangent in the bezier curve */
  6327. y1: number;
  6328. /** Defines the x component of the end tangent in the bezier curve */
  6329. x2: number;
  6330. /** Defines the y component of the end tangent in the bezier curve */
  6331. y2: number;
  6332. /**
  6333. * Instantiates a bezier function
  6334. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6335. * @param x1 Defines the x component of the start tangent in the bezier curve
  6336. * @param y1 Defines the y component of the start tangent in the bezier curve
  6337. * @param x2 Defines the x component of the end tangent in the bezier curve
  6338. * @param y2 Defines the y component of the end tangent in the bezier curve
  6339. */
  6340. constructor(
  6341. /** Defines the x component of the start tangent in the bezier curve */
  6342. x1?: number,
  6343. /** Defines the y component of the start tangent in the bezier curve */
  6344. y1?: number,
  6345. /** Defines the x component of the end tangent in the bezier curve */
  6346. x2?: number,
  6347. /** Defines the y component of the end tangent in the bezier curve */
  6348. y2?: number);
  6349. /** @hidden */
  6350. easeInCore(gradient: number): number;
  6351. }
  6352. }
  6353. declare module "babylonjs/Animations/animationKey" {
  6354. /**
  6355. * Defines an interface which represents an animation key frame
  6356. */
  6357. export interface IAnimationKey {
  6358. /**
  6359. * Frame of the key frame
  6360. */
  6361. frame: number;
  6362. /**
  6363. * Value at the specifies key frame
  6364. */
  6365. value: any;
  6366. /**
  6367. * The input tangent for the cubic hermite spline
  6368. */
  6369. inTangent?: any;
  6370. /**
  6371. * The output tangent for the cubic hermite spline
  6372. */
  6373. outTangent?: any;
  6374. /**
  6375. * The animation interpolation type
  6376. */
  6377. interpolation?: AnimationKeyInterpolation;
  6378. }
  6379. /**
  6380. * Enum for the animation key frame interpolation type
  6381. */
  6382. export enum AnimationKeyInterpolation {
  6383. /**
  6384. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6385. */
  6386. STEP = 1
  6387. }
  6388. }
  6389. declare module "babylonjs/Animations/animationRange" {
  6390. /**
  6391. * Represents the range of an animation
  6392. */
  6393. export class AnimationRange {
  6394. /**The name of the animation range**/
  6395. name: string;
  6396. /**The starting frame of the animation */
  6397. from: number;
  6398. /**The ending frame of the animation*/
  6399. to: number;
  6400. /**
  6401. * Initializes the range of an animation
  6402. * @param name The name of the animation range
  6403. * @param from The starting frame of the animation
  6404. * @param to The ending frame of the animation
  6405. */
  6406. constructor(
  6407. /**The name of the animation range**/
  6408. name: string,
  6409. /**The starting frame of the animation */
  6410. from: number,
  6411. /**The ending frame of the animation*/
  6412. to: number);
  6413. /**
  6414. * Makes a copy of the animation range
  6415. * @returns A copy of the animation range
  6416. */
  6417. clone(): AnimationRange;
  6418. }
  6419. }
  6420. declare module "babylonjs/Animations/animationEvent" {
  6421. /**
  6422. * Composed of a frame, and an action function
  6423. */
  6424. export class AnimationEvent {
  6425. /** The frame for which the event is triggered **/
  6426. frame: number;
  6427. /** The event to perform when triggered **/
  6428. action: (currentFrame: number) => void;
  6429. /** Specifies if the event should be triggered only once**/
  6430. onlyOnce?: boolean | undefined;
  6431. /**
  6432. * Specifies if the animation event is done
  6433. */
  6434. isDone: boolean;
  6435. /**
  6436. * Initializes the animation event
  6437. * @param frame The frame for which the event is triggered
  6438. * @param action The event to perform when triggered
  6439. * @param onlyOnce Specifies if the event should be triggered only once
  6440. */
  6441. constructor(
  6442. /** The frame for which the event is triggered **/
  6443. frame: number,
  6444. /** The event to perform when triggered **/
  6445. action: (currentFrame: number) => void,
  6446. /** Specifies if the event should be triggered only once**/
  6447. onlyOnce?: boolean | undefined);
  6448. /** @hidden */
  6449. _clone(): AnimationEvent;
  6450. }
  6451. }
  6452. declare module "babylonjs/Behaviors/behavior" {
  6453. import { Nullable } from "babylonjs/types";
  6454. /**
  6455. * Interface used to define a behavior
  6456. */
  6457. export interface Behavior<T> {
  6458. /** gets or sets behavior's name */
  6459. name: string;
  6460. /**
  6461. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6462. */
  6463. init(): void;
  6464. /**
  6465. * Called when the behavior is attached to a target
  6466. * @param target defines the target where the behavior is attached to
  6467. */
  6468. attach(target: T): void;
  6469. /**
  6470. * Called when the behavior is detached from its target
  6471. */
  6472. detach(): void;
  6473. }
  6474. /**
  6475. * Interface implemented by classes supporting behaviors
  6476. */
  6477. export interface IBehaviorAware<T> {
  6478. /**
  6479. * Attach a behavior
  6480. * @param behavior defines the behavior to attach
  6481. * @returns the current host
  6482. */
  6483. addBehavior(behavior: Behavior<T>): T;
  6484. /**
  6485. * Remove a behavior from the current object
  6486. * @param behavior defines the behavior to detach
  6487. * @returns the current host
  6488. */
  6489. removeBehavior(behavior: Behavior<T>): T;
  6490. /**
  6491. * Gets a behavior using its name to search
  6492. * @param name defines the name to search
  6493. * @returns the behavior or null if not found
  6494. */
  6495. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6496. }
  6497. }
  6498. declare module "babylonjs/Misc/smartArray" {
  6499. /**
  6500. * Defines an array and its length.
  6501. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6502. */
  6503. export interface ISmartArrayLike<T> {
  6504. /**
  6505. * The data of the array.
  6506. */
  6507. data: Array<T>;
  6508. /**
  6509. * The active length of the array.
  6510. */
  6511. length: number;
  6512. }
  6513. /**
  6514. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6515. */
  6516. export class SmartArray<T> implements ISmartArrayLike<T> {
  6517. /**
  6518. * The full set of data from the array.
  6519. */
  6520. data: Array<T>;
  6521. /**
  6522. * The active length of the array.
  6523. */
  6524. length: number;
  6525. protected _id: number;
  6526. /**
  6527. * Instantiates a Smart Array.
  6528. * @param capacity defines the default capacity of the array.
  6529. */
  6530. constructor(capacity: number);
  6531. /**
  6532. * Pushes a value at the end of the active data.
  6533. * @param value defines the object to push in the array.
  6534. */
  6535. push(value: T): void;
  6536. /**
  6537. * Iterates over the active data and apply the lambda to them.
  6538. * @param func defines the action to apply on each value.
  6539. */
  6540. forEach(func: (content: T) => void): void;
  6541. /**
  6542. * Sorts the full sets of data.
  6543. * @param compareFn defines the comparison function to apply.
  6544. */
  6545. sort(compareFn: (a: T, b: T) => number): void;
  6546. /**
  6547. * Resets the active data to an empty array.
  6548. */
  6549. reset(): void;
  6550. /**
  6551. * Releases all the data from the array as well as the array.
  6552. */
  6553. dispose(): void;
  6554. /**
  6555. * Concats the active data with a given array.
  6556. * @param array defines the data to concatenate with.
  6557. */
  6558. concat(array: any): void;
  6559. /**
  6560. * Returns the position of a value in the active data.
  6561. * @param value defines the value to find the index for
  6562. * @returns the index if found in the active data otherwise -1
  6563. */
  6564. indexOf(value: T): number;
  6565. /**
  6566. * Returns whether an element is part of the active data.
  6567. * @param value defines the value to look for
  6568. * @returns true if found in the active data otherwise false
  6569. */
  6570. contains(value: T): boolean;
  6571. private static _GlobalId;
  6572. }
  6573. /**
  6574. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6575. * The data in this array can only be present once
  6576. */
  6577. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6578. private _duplicateId;
  6579. /**
  6580. * Pushes a value at the end of the active data.
  6581. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6582. * @param value defines the object to push in the array.
  6583. */
  6584. push(value: T): void;
  6585. /**
  6586. * Pushes a value at the end of the active data.
  6587. * If the data is already present, it won t be added again
  6588. * @param value defines the object to push in the array.
  6589. * @returns true if added false if it was already present
  6590. */
  6591. pushNoDuplicate(value: T): boolean;
  6592. /**
  6593. * Resets the active data to an empty array.
  6594. */
  6595. reset(): void;
  6596. /**
  6597. * Concats the active data with a given array.
  6598. * This ensures no dupplicate will be present in the result.
  6599. * @param array defines the data to concatenate with.
  6600. */
  6601. concatWithNoDuplicate(array: any): void;
  6602. }
  6603. }
  6604. declare module "babylonjs/Cameras/cameraInputsManager" {
  6605. import { Nullable } from "babylonjs/types";
  6606. import { Camera } from "babylonjs/Cameras/camera";
  6607. /**
  6608. * @ignore
  6609. * This is a list of all the different input types that are available in the application.
  6610. * Fo instance: ArcRotateCameraGamepadInput...
  6611. */
  6612. export var CameraInputTypes: {};
  6613. /**
  6614. * This is the contract to implement in order to create a new input class.
  6615. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6616. */
  6617. export interface ICameraInput<TCamera extends Camera> {
  6618. /**
  6619. * Defines the camera the input is attached to.
  6620. */
  6621. camera: Nullable<TCamera>;
  6622. /**
  6623. * Gets the class name of the current intput.
  6624. * @returns the class name
  6625. */
  6626. getClassName(): string;
  6627. /**
  6628. * Get the friendly name associated with the input class.
  6629. * @returns the input friendly name
  6630. */
  6631. getSimpleName(): string;
  6632. /**
  6633. * Attach the input controls to a specific dom element to get the input from.
  6634. * @param element Defines the element the controls should be listened from
  6635. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6636. */
  6637. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6638. /**
  6639. * Detach the current controls from the specified dom element.
  6640. * @param element Defines the element to stop listening the inputs from
  6641. */
  6642. detachControl(element: Nullable<HTMLElement>): void;
  6643. /**
  6644. * Update the current camera state depending on the inputs that have been used this frame.
  6645. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6646. */
  6647. checkInputs?: () => void;
  6648. }
  6649. /**
  6650. * Represents a map of input types to input instance or input index to input instance.
  6651. */
  6652. export interface CameraInputsMap<TCamera extends Camera> {
  6653. /**
  6654. * Accessor to the input by input type.
  6655. */
  6656. [name: string]: ICameraInput<TCamera>;
  6657. /**
  6658. * Accessor to the input by input index.
  6659. */
  6660. [idx: number]: ICameraInput<TCamera>;
  6661. }
  6662. /**
  6663. * This represents the input manager used within a camera.
  6664. * It helps dealing with all the different kind of input attached to a camera.
  6665. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6666. */
  6667. export class CameraInputsManager<TCamera extends Camera> {
  6668. /**
  6669. * Defines the list of inputs attahed to the camera.
  6670. */
  6671. attached: CameraInputsMap<TCamera>;
  6672. /**
  6673. * Defines the dom element the camera is collecting inputs from.
  6674. * This is null if the controls have not been attached.
  6675. */
  6676. attachedElement: Nullable<HTMLElement>;
  6677. /**
  6678. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6679. */
  6680. noPreventDefault: boolean;
  6681. /**
  6682. * Defined the camera the input manager belongs to.
  6683. */
  6684. camera: TCamera;
  6685. /**
  6686. * Update the current camera state depending on the inputs that have been used this frame.
  6687. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6688. */
  6689. checkInputs: () => void;
  6690. /**
  6691. * Instantiate a new Camera Input Manager.
  6692. * @param camera Defines the camera the input manager blongs to
  6693. */
  6694. constructor(camera: TCamera);
  6695. /**
  6696. * Add an input method to a camera
  6697. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6698. * @param input camera input method
  6699. */
  6700. add(input: ICameraInput<TCamera>): void;
  6701. /**
  6702. * Remove a specific input method from a camera
  6703. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6704. * @param inputToRemove camera input method
  6705. */
  6706. remove(inputToRemove: ICameraInput<TCamera>): void;
  6707. /**
  6708. * Remove a specific input type from a camera
  6709. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6710. * @param inputType the type of the input to remove
  6711. */
  6712. removeByType(inputType: string): void;
  6713. private _addCheckInputs;
  6714. /**
  6715. * Attach the input controls to the currently attached dom element to listen the events from.
  6716. * @param input Defines the input to attach
  6717. */
  6718. attachInput(input: ICameraInput<TCamera>): void;
  6719. /**
  6720. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6721. * @param element Defines the dom element to collect the events from
  6722. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6723. */
  6724. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6725. /**
  6726. * Detach the current manager inputs controls from a specific dom element.
  6727. * @param element Defines the dom element to collect the events from
  6728. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6729. */
  6730. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6731. /**
  6732. * Rebuild the dynamic inputCheck function from the current list of
  6733. * defined inputs in the manager.
  6734. */
  6735. rebuildInputCheck(): void;
  6736. /**
  6737. * Remove all attached input methods from a camera
  6738. */
  6739. clear(): void;
  6740. /**
  6741. * Serialize the current input manager attached to a camera.
  6742. * This ensures than once parsed,
  6743. * the input associated to the camera will be identical to the current ones
  6744. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6745. */
  6746. serialize(serializedCamera: any): void;
  6747. /**
  6748. * Parses an input manager serialized JSON to restore the previous list of inputs
  6749. * and states associated to a camera.
  6750. * @param parsedCamera Defines the JSON to parse
  6751. */
  6752. parse(parsedCamera: any): void;
  6753. }
  6754. }
  6755. declare module "babylonjs/Collisions/intersectionInfo" {
  6756. import { Nullable } from "babylonjs/types";
  6757. /**
  6758. * @hidden
  6759. */
  6760. export class IntersectionInfo {
  6761. bu: Nullable<number>;
  6762. bv: Nullable<number>;
  6763. distance: number;
  6764. faceId: number;
  6765. subMeshId: number;
  6766. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6767. }
  6768. }
  6769. declare module "babylonjs/Maths/math.plane" {
  6770. import { DeepImmutable } from "babylonjs/types";
  6771. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6772. /**
  6773. * Represens a plane by the equation ax + by + cz + d = 0
  6774. */
  6775. export class Plane {
  6776. private static _TmpMatrix;
  6777. /**
  6778. * Normal of the plane (a,b,c)
  6779. */
  6780. normal: Vector3;
  6781. /**
  6782. * d component of the plane
  6783. */
  6784. d: number;
  6785. /**
  6786. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6787. * @param a a component of the plane
  6788. * @param b b component of the plane
  6789. * @param c c component of the plane
  6790. * @param d d component of the plane
  6791. */
  6792. constructor(a: number, b: number, c: number, d: number);
  6793. /**
  6794. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6795. */
  6796. asArray(): number[];
  6797. /**
  6798. * @returns a new plane copied from the current Plane.
  6799. */
  6800. clone(): Plane;
  6801. /**
  6802. * @returns the string "Plane".
  6803. */
  6804. getClassName(): string;
  6805. /**
  6806. * @returns the Plane hash code.
  6807. */
  6808. getHashCode(): number;
  6809. /**
  6810. * Normalize the current Plane in place.
  6811. * @returns the updated Plane.
  6812. */
  6813. normalize(): Plane;
  6814. /**
  6815. * Applies a transformation the plane and returns the result
  6816. * @param transformation the transformation matrix to be applied to the plane
  6817. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6818. */
  6819. transform(transformation: DeepImmutable<Matrix>): Plane;
  6820. /**
  6821. * Calcualtte the dot product between the point and the plane normal
  6822. * @param point point to calculate the dot product with
  6823. * @returns the dot product (float) of the point coordinates and the plane normal.
  6824. */
  6825. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6826. /**
  6827. * Updates the current Plane from the plane defined by the three given points.
  6828. * @param point1 one of the points used to contruct the plane
  6829. * @param point2 one of the points used to contruct the plane
  6830. * @param point3 one of the points used to contruct the plane
  6831. * @returns the updated Plane.
  6832. */
  6833. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6834. /**
  6835. * Checks if the plane is facing a given direction
  6836. * @param direction the direction to check if the plane is facing
  6837. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6838. * @returns True is the vector "direction" is the same side than the plane normal.
  6839. */
  6840. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6841. /**
  6842. * Calculates the distance to a point
  6843. * @param point point to calculate distance to
  6844. * @returns the signed distance (float) from the given point to the Plane.
  6845. */
  6846. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6847. /**
  6848. * Creates a plane from an array
  6849. * @param array the array to create a plane from
  6850. * @returns a new Plane from the given array.
  6851. */
  6852. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6853. /**
  6854. * Creates a plane from three points
  6855. * @param point1 point used to create the plane
  6856. * @param point2 point used to create the plane
  6857. * @param point3 point used to create the plane
  6858. * @returns a new Plane defined by the three given points.
  6859. */
  6860. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6861. /**
  6862. * Creates a plane from an origin point and a normal
  6863. * @param origin origin of the plane to be constructed
  6864. * @param normal normal of the plane to be constructed
  6865. * @returns a new Plane the normal vector to this plane at the given origin point.
  6866. * Note : the vector "normal" is updated because normalized.
  6867. */
  6868. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6869. /**
  6870. * Calculates the distance from a plane and a point
  6871. * @param origin origin of the plane to be constructed
  6872. * @param normal normal of the plane to be constructed
  6873. * @param point point to calculate distance to
  6874. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6875. */
  6876. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6877. }
  6878. }
  6879. declare module "babylonjs/Culling/boundingSphere" {
  6880. import { DeepImmutable } from "babylonjs/types";
  6881. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6882. import { Plane } from "babylonjs/Maths/math.plane";
  6883. /**
  6884. * Class used to store bounding sphere information
  6885. */
  6886. export class BoundingSphere {
  6887. /**
  6888. * Gets the center of the bounding sphere in local space
  6889. */
  6890. readonly center: Vector3;
  6891. /**
  6892. * Radius of the bounding sphere in local space
  6893. */
  6894. radius: number;
  6895. /**
  6896. * Gets the center of the bounding sphere in world space
  6897. */
  6898. readonly centerWorld: Vector3;
  6899. /**
  6900. * Radius of the bounding sphere in world space
  6901. */
  6902. radiusWorld: number;
  6903. /**
  6904. * Gets the minimum vector in local space
  6905. */
  6906. readonly minimum: Vector3;
  6907. /**
  6908. * Gets the maximum vector in local space
  6909. */
  6910. readonly maximum: Vector3;
  6911. private _worldMatrix;
  6912. private static readonly TmpVector3;
  6913. /**
  6914. * Creates a new bounding sphere
  6915. * @param min defines the minimum vector (in local space)
  6916. * @param max defines the maximum vector (in local space)
  6917. * @param worldMatrix defines the new world matrix
  6918. */
  6919. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6920. /**
  6921. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6922. * @param min defines the new minimum vector (in local space)
  6923. * @param max defines the new maximum vector (in local space)
  6924. * @param worldMatrix defines the new world matrix
  6925. */
  6926. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6927. /**
  6928. * Scale the current bounding sphere by applying a scale factor
  6929. * @param factor defines the scale factor to apply
  6930. * @returns the current bounding box
  6931. */
  6932. scale(factor: number): BoundingSphere;
  6933. /**
  6934. * Gets the world matrix of the bounding box
  6935. * @returns a matrix
  6936. */
  6937. getWorldMatrix(): DeepImmutable<Matrix>;
  6938. /** @hidden */
  6939. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6940. /**
  6941. * Tests if the bounding sphere is intersecting the frustum planes
  6942. * @param frustumPlanes defines the frustum planes to test
  6943. * @returns true if there is an intersection
  6944. */
  6945. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6946. /**
  6947. * Tests if the bounding sphere center is in between the frustum planes.
  6948. * Used for optimistic fast inclusion.
  6949. * @param frustumPlanes defines the frustum planes to test
  6950. * @returns true if the sphere center is in between the frustum planes
  6951. */
  6952. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6953. /**
  6954. * Tests if a point is inside the bounding sphere
  6955. * @param point defines the point to test
  6956. * @returns true if the point is inside the bounding sphere
  6957. */
  6958. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6959. /**
  6960. * Checks if two sphere intersct
  6961. * @param sphere0 sphere 0
  6962. * @param sphere1 sphere 1
  6963. * @returns true if the speres intersect
  6964. */
  6965. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6966. }
  6967. }
  6968. declare module "babylonjs/Culling/boundingBox" {
  6969. import { DeepImmutable } from "babylonjs/types";
  6970. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6971. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6972. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6973. import { Plane } from "babylonjs/Maths/math.plane";
  6974. /**
  6975. * Class used to store bounding box information
  6976. */
  6977. export class BoundingBox implements ICullable {
  6978. /**
  6979. * Gets the 8 vectors representing the bounding box in local space
  6980. */
  6981. readonly vectors: Vector3[];
  6982. /**
  6983. * Gets the center of the bounding box in local space
  6984. */
  6985. readonly center: Vector3;
  6986. /**
  6987. * Gets the center of the bounding box in world space
  6988. */
  6989. readonly centerWorld: Vector3;
  6990. /**
  6991. * Gets the extend size in local space
  6992. */
  6993. readonly extendSize: Vector3;
  6994. /**
  6995. * Gets the extend size in world space
  6996. */
  6997. readonly extendSizeWorld: Vector3;
  6998. /**
  6999. * Gets the OBB (object bounding box) directions
  7000. */
  7001. readonly directions: Vector3[];
  7002. /**
  7003. * Gets the 8 vectors representing the bounding box in world space
  7004. */
  7005. readonly vectorsWorld: Vector3[];
  7006. /**
  7007. * Gets the minimum vector in world space
  7008. */
  7009. readonly minimumWorld: Vector3;
  7010. /**
  7011. * Gets the maximum vector in world space
  7012. */
  7013. readonly maximumWorld: Vector3;
  7014. /**
  7015. * Gets the minimum vector in local space
  7016. */
  7017. readonly minimum: Vector3;
  7018. /**
  7019. * Gets the maximum vector in local space
  7020. */
  7021. readonly maximum: Vector3;
  7022. private _worldMatrix;
  7023. private static readonly TmpVector3;
  7024. /**
  7025. * @hidden
  7026. */
  7027. _tag: number;
  7028. /**
  7029. * Creates a new bounding box
  7030. * @param min defines the minimum vector (in local space)
  7031. * @param max defines the maximum vector (in local space)
  7032. * @param worldMatrix defines the new world matrix
  7033. */
  7034. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7035. /**
  7036. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7037. * @param min defines the new minimum vector (in local space)
  7038. * @param max defines the new maximum vector (in local space)
  7039. * @param worldMatrix defines the new world matrix
  7040. */
  7041. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7042. /**
  7043. * Scale the current bounding box by applying a scale factor
  7044. * @param factor defines the scale factor to apply
  7045. * @returns the current bounding box
  7046. */
  7047. scale(factor: number): BoundingBox;
  7048. /**
  7049. * Gets the world matrix of the bounding box
  7050. * @returns a matrix
  7051. */
  7052. getWorldMatrix(): DeepImmutable<Matrix>;
  7053. /** @hidden */
  7054. _update(world: DeepImmutable<Matrix>): void;
  7055. /**
  7056. * Tests if the bounding box is intersecting the frustum planes
  7057. * @param frustumPlanes defines the frustum planes to test
  7058. * @returns true if there is an intersection
  7059. */
  7060. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7061. /**
  7062. * Tests if the bounding box is entirely inside the frustum planes
  7063. * @param frustumPlanes defines the frustum planes to test
  7064. * @returns true if there is an inclusion
  7065. */
  7066. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7067. /**
  7068. * Tests if a point is inside the bounding box
  7069. * @param point defines the point to test
  7070. * @returns true if the point is inside the bounding box
  7071. */
  7072. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7073. /**
  7074. * Tests if the bounding box intersects with a bounding sphere
  7075. * @param sphere defines the sphere to test
  7076. * @returns true if there is an intersection
  7077. */
  7078. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7079. /**
  7080. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7081. * @param min defines the min vector to use
  7082. * @param max defines the max vector to use
  7083. * @returns true if there is an intersection
  7084. */
  7085. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7086. /**
  7087. * Tests if two bounding boxes are intersections
  7088. * @param box0 defines the first box to test
  7089. * @param box1 defines the second box to test
  7090. * @returns true if there is an intersection
  7091. */
  7092. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7093. /**
  7094. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7095. * @param minPoint defines the minimum vector of the bounding box
  7096. * @param maxPoint defines the maximum vector of the bounding box
  7097. * @param sphereCenter defines the sphere center
  7098. * @param sphereRadius defines the sphere radius
  7099. * @returns true if there is an intersection
  7100. */
  7101. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7102. /**
  7103. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7104. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7105. * @param frustumPlanes defines the frustum planes to test
  7106. * @return true if there is an inclusion
  7107. */
  7108. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7109. /**
  7110. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7111. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7112. * @param frustumPlanes defines the frustum planes to test
  7113. * @return true if there is an intersection
  7114. */
  7115. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7116. }
  7117. }
  7118. declare module "babylonjs/Collisions/collider" {
  7119. import { Nullable, IndicesArray } from "babylonjs/types";
  7120. import { Vector3 } from "babylonjs/Maths/math.vector";
  7121. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7122. import { Plane } from "babylonjs/Maths/math.plane";
  7123. /** @hidden */
  7124. export class Collider {
  7125. /** Define if a collision was found */
  7126. collisionFound: boolean;
  7127. /**
  7128. * Define last intersection point in local space
  7129. */
  7130. intersectionPoint: Vector3;
  7131. /**
  7132. * Define last collided mesh
  7133. */
  7134. collidedMesh: Nullable<AbstractMesh>;
  7135. private _collisionPoint;
  7136. private _planeIntersectionPoint;
  7137. private _tempVector;
  7138. private _tempVector2;
  7139. private _tempVector3;
  7140. private _tempVector4;
  7141. private _edge;
  7142. private _baseToVertex;
  7143. private _destinationPoint;
  7144. private _slidePlaneNormal;
  7145. private _displacementVector;
  7146. /** @hidden */
  7147. _radius: Vector3;
  7148. /** @hidden */
  7149. _retry: number;
  7150. private _velocity;
  7151. private _basePoint;
  7152. private _epsilon;
  7153. /** @hidden */
  7154. _velocityWorldLength: number;
  7155. /** @hidden */
  7156. _basePointWorld: Vector3;
  7157. private _velocityWorld;
  7158. private _normalizedVelocity;
  7159. /** @hidden */
  7160. _initialVelocity: Vector3;
  7161. /** @hidden */
  7162. _initialPosition: Vector3;
  7163. private _nearestDistance;
  7164. private _collisionMask;
  7165. collisionMask: number;
  7166. /**
  7167. * Gets the plane normal used to compute the sliding response (in local space)
  7168. */
  7169. readonly slidePlaneNormal: Vector3;
  7170. /** @hidden */
  7171. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7172. /** @hidden */
  7173. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7174. /** @hidden */
  7175. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7176. /** @hidden */
  7177. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7178. /** @hidden */
  7179. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7180. /** @hidden */
  7181. _getResponse(pos: Vector3, vel: Vector3): void;
  7182. }
  7183. }
  7184. declare module "babylonjs/Culling/boundingInfo" {
  7185. import { DeepImmutable } from "babylonjs/types";
  7186. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7187. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7188. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7189. import { Plane } from "babylonjs/Maths/math.plane";
  7190. import { Collider } from "babylonjs/Collisions/collider";
  7191. /**
  7192. * Interface for cullable objects
  7193. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7194. */
  7195. export interface ICullable {
  7196. /**
  7197. * Checks if the object or part of the object is in the frustum
  7198. * @param frustumPlanes Camera near/planes
  7199. * @returns true if the object is in frustum otherwise false
  7200. */
  7201. isInFrustum(frustumPlanes: Plane[]): boolean;
  7202. /**
  7203. * Checks if a cullable object (mesh...) is in the camera frustum
  7204. * Unlike isInFrustum this cheks the full bounding box
  7205. * @param frustumPlanes Camera near/planes
  7206. * @returns true if the object is in frustum otherwise false
  7207. */
  7208. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7209. }
  7210. /**
  7211. * Info for a bounding data of a mesh
  7212. */
  7213. export class BoundingInfo implements ICullable {
  7214. /**
  7215. * Bounding box for the mesh
  7216. */
  7217. readonly boundingBox: BoundingBox;
  7218. /**
  7219. * Bounding sphere for the mesh
  7220. */
  7221. readonly boundingSphere: BoundingSphere;
  7222. private _isLocked;
  7223. private static readonly TmpVector3;
  7224. /**
  7225. * Constructs bounding info
  7226. * @param minimum min vector of the bounding box/sphere
  7227. * @param maximum max vector of the bounding box/sphere
  7228. * @param worldMatrix defines the new world matrix
  7229. */
  7230. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7231. /**
  7232. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7233. * @param min defines the new minimum vector (in local space)
  7234. * @param max defines the new maximum vector (in local space)
  7235. * @param worldMatrix defines the new world matrix
  7236. */
  7237. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7238. /**
  7239. * min vector of the bounding box/sphere
  7240. */
  7241. readonly minimum: Vector3;
  7242. /**
  7243. * max vector of the bounding box/sphere
  7244. */
  7245. readonly maximum: Vector3;
  7246. /**
  7247. * If the info is locked and won't be updated to avoid perf overhead
  7248. */
  7249. isLocked: boolean;
  7250. /**
  7251. * Updates the bounding sphere and box
  7252. * @param world world matrix to be used to update
  7253. */
  7254. update(world: DeepImmutable<Matrix>): void;
  7255. /**
  7256. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7257. * @param center New center of the bounding info
  7258. * @param extend New extend of the bounding info
  7259. * @returns the current bounding info
  7260. */
  7261. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7262. /**
  7263. * Scale the current bounding info by applying a scale factor
  7264. * @param factor defines the scale factor to apply
  7265. * @returns the current bounding info
  7266. */
  7267. scale(factor: number): BoundingInfo;
  7268. /**
  7269. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7270. * @param frustumPlanes defines the frustum to test
  7271. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7272. * @returns true if the bounding info is in the frustum planes
  7273. */
  7274. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7275. /**
  7276. * Gets the world distance between the min and max points of the bounding box
  7277. */
  7278. readonly diagonalLength: number;
  7279. /**
  7280. * Checks if a cullable object (mesh...) is in the camera frustum
  7281. * Unlike isInFrustum this cheks the full bounding box
  7282. * @param frustumPlanes Camera near/planes
  7283. * @returns true if the object is in frustum otherwise false
  7284. */
  7285. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7286. /** @hidden */
  7287. _checkCollision(collider: Collider): boolean;
  7288. /**
  7289. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7290. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7291. * @param point the point to check intersection with
  7292. * @returns if the point intersects
  7293. */
  7294. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7295. /**
  7296. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7297. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7298. * @param boundingInfo the bounding info to check intersection with
  7299. * @param precise if the intersection should be done using OBB
  7300. * @returns if the bounding info intersects
  7301. */
  7302. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7303. }
  7304. }
  7305. declare module "babylonjs/Maths/math.functions" {
  7306. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7307. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7308. /**
  7309. * Extracts minimum and maximum values from a list of indexed positions
  7310. * @param positions defines the positions to use
  7311. * @param indices defines the indices to the positions
  7312. * @param indexStart defines the start index
  7313. * @param indexCount defines the end index
  7314. * @param bias defines bias value to add to the result
  7315. * @return minimum and maximum values
  7316. */
  7317. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7318. minimum: Vector3;
  7319. maximum: Vector3;
  7320. };
  7321. /**
  7322. * Extracts minimum and maximum values from a list of positions
  7323. * @param positions defines the positions to use
  7324. * @param start defines the start index in the positions array
  7325. * @param count defines the number of positions to handle
  7326. * @param bias defines bias value to add to the result
  7327. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7328. * @return minimum and maximum values
  7329. */
  7330. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7331. minimum: Vector3;
  7332. maximum: Vector3;
  7333. };
  7334. }
  7335. declare module "babylonjs/Misc/iInspectable" {
  7336. /**
  7337. * Enum that determines the text-wrapping mode to use.
  7338. */
  7339. export enum InspectableType {
  7340. /**
  7341. * Checkbox for booleans
  7342. */
  7343. Checkbox = 0,
  7344. /**
  7345. * Sliders for numbers
  7346. */
  7347. Slider = 1,
  7348. /**
  7349. * Vector3
  7350. */
  7351. Vector3 = 2,
  7352. /**
  7353. * Quaternions
  7354. */
  7355. Quaternion = 3,
  7356. /**
  7357. * Color3
  7358. */
  7359. Color3 = 4,
  7360. /**
  7361. * String
  7362. */
  7363. String = 5
  7364. }
  7365. /**
  7366. * Interface used to define custom inspectable properties.
  7367. * This interface is used by the inspector to display custom property grids
  7368. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7369. */
  7370. export interface IInspectable {
  7371. /**
  7372. * Gets the label to display
  7373. */
  7374. label: string;
  7375. /**
  7376. * Gets the name of the property to edit
  7377. */
  7378. propertyName: string;
  7379. /**
  7380. * Gets the type of the editor to use
  7381. */
  7382. type: InspectableType;
  7383. /**
  7384. * Gets the minimum value of the property when using in "slider" mode
  7385. */
  7386. min?: number;
  7387. /**
  7388. * Gets the maximum value of the property when using in "slider" mode
  7389. */
  7390. max?: number;
  7391. /**
  7392. * Gets the setp to use when using in "slider" mode
  7393. */
  7394. step?: number;
  7395. }
  7396. }
  7397. declare module "babylonjs/Misc/timingTools" {
  7398. /**
  7399. * Class used to provide helper for timing
  7400. */
  7401. export class TimingTools {
  7402. /**
  7403. * Polyfill for setImmediate
  7404. * @param action defines the action to execute after the current execution block
  7405. */
  7406. static SetImmediate(action: () => void): void;
  7407. }
  7408. }
  7409. declare module "babylonjs/Misc/instantiationTools" {
  7410. /**
  7411. * Class used to enable instatition of objects by class name
  7412. */
  7413. export class InstantiationTools {
  7414. /**
  7415. * Use this object to register external classes like custom textures or material
  7416. * to allow the laoders to instantiate them
  7417. */
  7418. static RegisteredExternalClasses: {
  7419. [key: string]: Object;
  7420. };
  7421. /**
  7422. * Tries to instantiate a new object from a given class name
  7423. * @param className defines the class name to instantiate
  7424. * @returns the new object or null if the system was not able to do the instantiation
  7425. */
  7426. static Instantiate(className: string): any;
  7427. }
  7428. }
  7429. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  7430. import { Nullable } from "babylonjs/types";
  7431. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7432. /**
  7433. * This represents the required contract to create a new type of texture loader.
  7434. */
  7435. export interface IInternalTextureLoader {
  7436. /**
  7437. * Defines wether the loader supports cascade loading the different faces.
  7438. */
  7439. supportCascades: boolean;
  7440. /**
  7441. * This returns if the loader support the current file information.
  7442. * @param extension defines the file extension of the file being loaded
  7443. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7444. * @param fallback defines the fallback internal texture if any
  7445. * @param isBase64 defines whether the texture is encoded as a base64
  7446. * @param isBuffer defines whether the texture data are stored as a buffer
  7447. * @returns true if the loader can load the specified file
  7448. */
  7449. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7450. /**
  7451. * Transform the url before loading if required.
  7452. * @param rootUrl the url of the texture
  7453. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7454. * @returns the transformed texture
  7455. */
  7456. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7457. /**
  7458. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7459. * @param rootUrl the url of the texture
  7460. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7461. * @returns the fallback texture
  7462. */
  7463. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7464. /**
  7465. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7466. * @param data contains the texture data
  7467. * @param texture defines the BabylonJS internal texture
  7468. * @param createPolynomials will be true if polynomials have been requested
  7469. * @param onLoad defines the callback to trigger once the texture is ready
  7470. * @param onError defines the callback to trigger in case of error
  7471. */
  7472. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7473. /**
  7474. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7475. * @param data contains the texture data
  7476. * @param texture defines the BabylonJS internal texture
  7477. * @param callback defines the method to call once ready to upload
  7478. */
  7479. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7480. }
  7481. }
  7482. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7483. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7484. import { Nullable } from "babylonjs/types";
  7485. import { Scene } from "babylonjs/scene";
  7486. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7487. module "babylonjs/Engines/engine" {
  7488. interface Engine {
  7489. /**
  7490. * Creates a depth stencil cube texture.
  7491. * This is only available in WebGL 2.
  7492. * @param size The size of face edge in the cube texture.
  7493. * @param options The options defining the cube texture.
  7494. * @returns The cube texture
  7495. */
  7496. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7497. /**
  7498. * Creates a cube texture
  7499. * @param rootUrl defines the url where the files to load is located
  7500. * @param scene defines the current scene
  7501. * @param files defines the list of files to load (1 per face)
  7502. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7503. * @param onLoad defines an optional callback raised when the texture is loaded
  7504. * @param onError defines an optional callback raised if there is an issue to load the texture
  7505. * @param format defines the format of the data
  7506. * @param forcedExtension defines the extension to use to pick the right loader
  7507. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7508. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7509. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7510. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7511. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7512. * @returns the cube texture as an InternalTexture
  7513. */
  7514. 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;
  7515. /**
  7516. * Creates a cube texture
  7517. * @param rootUrl defines the url where the files to load is located
  7518. * @param scene defines the current scene
  7519. * @param files defines the list of files to load (1 per face)
  7520. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7521. * @param onLoad defines an optional callback raised when the texture is loaded
  7522. * @param onError defines an optional callback raised if there is an issue to load the texture
  7523. * @param format defines the format of the data
  7524. * @param forcedExtension defines the extension to use to pick the right loader
  7525. * @returns the cube texture as an InternalTexture
  7526. */
  7527. 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;
  7528. /**
  7529. * Creates a cube texture
  7530. * @param rootUrl defines the url where the files to load is located
  7531. * @param scene defines the current scene
  7532. * @param files defines the list of files to load (1 per face)
  7533. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7534. * @param onLoad defines an optional callback raised when the texture is loaded
  7535. * @param onError defines an optional callback raised if there is an issue to load the texture
  7536. * @param format defines the format of the data
  7537. * @param forcedExtension defines the extension to use to pick the right loader
  7538. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7539. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7540. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7541. * @returns the cube texture as an InternalTexture
  7542. */
  7543. 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;
  7544. /** @hidden */
  7545. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7546. /** @hidden */
  7547. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7548. /** @hidden */
  7549. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7550. /** @hidden */
  7551. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7552. }
  7553. }
  7554. }
  7555. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7556. import { Nullable } from "babylonjs/types";
  7557. import { Scene } from "babylonjs/scene";
  7558. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7559. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7560. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7561. /**
  7562. * Class for creating a cube texture
  7563. */
  7564. export class CubeTexture extends BaseTexture {
  7565. private _delayedOnLoad;
  7566. /**
  7567. * The url of the texture
  7568. */
  7569. url: string;
  7570. /**
  7571. * Gets or sets the center of the bounding box associated with the cube texture.
  7572. * It must define where the camera used to render the texture was set
  7573. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7574. */
  7575. boundingBoxPosition: Vector3;
  7576. private _boundingBoxSize;
  7577. /**
  7578. * Gets or sets the size of the bounding box associated with the cube texture
  7579. * When defined, the cubemap will switch to local mode
  7580. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7581. * @example https://www.babylonjs-playground.com/#RNASML
  7582. */
  7583. /**
  7584. * Returns the bounding box size
  7585. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7586. */
  7587. boundingBoxSize: Vector3;
  7588. protected _rotationY: number;
  7589. /**
  7590. * Sets texture matrix rotation angle around Y axis in radians.
  7591. */
  7592. /**
  7593. * Gets texture matrix rotation angle around Y axis radians.
  7594. */
  7595. rotationY: number;
  7596. /**
  7597. * Are mip maps generated for this texture or not.
  7598. */
  7599. readonly noMipmap: boolean;
  7600. private _noMipmap;
  7601. private _files;
  7602. private _extensions;
  7603. private _textureMatrix;
  7604. private _format;
  7605. private _createPolynomials;
  7606. /** @hidden */
  7607. _prefiltered: boolean;
  7608. /**
  7609. * Creates a cube texture from an array of image urls
  7610. * @param files defines an array of image urls
  7611. * @param scene defines the hosting scene
  7612. * @param noMipmap specifies if mip maps are not used
  7613. * @returns a cube texture
  7614. */
  7615. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7616. /**
  7617. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7618. * @param url defines the url of the prefiltered texture
  7619. * @param scene defines the scene the texture is attached to
  7620. * @param forcedExtension defines the extension of the file if different from the url
  7621. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7622. * @return the prefiltered texture
  7623. */
  7624. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7625. /**
  7626. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7627. * as prefiltered data.
  7628. * @param rootUrl defines the url of the texture or the root name of the six images
  7629. * @param scene defines the scene the texture is attached to
  7630. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7631. * @param noMipmap defines if mipmaps should be created or not
  7632. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7633. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7634. * @param onError defines a callback triggered in case of error during load
  7635. * @param format defines the internal format to use for the texture once loaded
  7636. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7637. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7638. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7639. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7640. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7641. * @return the cube texture
  7642. */
  7643. 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);
  7644. /**
  7645. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7646. */
  7647. readonly isPrefiltered: boolean;
  7648. /**
  7649. * Get the current class name of the texture useful for serialization or dynamic coding.
  7650. * @returns "CubeTexture"
  7651. */
  7652. getClassName(): string;
  7653. /**
  7654. * Update the url (and optional buffer) of this texture if url was null during construction.
  7655. * @param url the url of the texture
  7656. * @param forcedExtension defines the extension to use
  7657. * @param onLoad callback called when the texture is loaded (defaults to null)
  7658. */
  7659. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7660. /**
  7661. * Delays loading of the cube texture
  7662. * @param forcedExtension defines the extension to use
  7663. */
  7664. delayLoad(forcedExtension?: string): void;
  7665. /**
  7666. * Returns the reflection texture matrix
  7667. * @returns the reflection texture matrix
  7668. */
  7669. getReflectionTextureMatrix(): Matrix;
  7670. /**
  7671. * Sets the reflection texture matrix
  7672. * @param value Reflection texture matrix
  7673. */
  7674. setReflectionTextureMatrix(value: Matrix): void;
  7675. /**
  7676. * Parses text to create a cube texture
  7677. * @param parsedTexture define the serialized text to read from
  7678. * @param scene defines the hosting scene
  7679. * @param rootUrl defines the root url of the cube texture
  7680. * @returns a cube texture
  7681. */
  7682. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7683. /**
  7684. * Makes a clone, or deep copy, of the cube texture
  7685. * @returns a new cube texture
  7686. */
  7687. clone(): CubeTexture;
  7688. }
  7689. }
  7690. declare module "babylonjs/Materials/materialDefines" {
  7691. /**
  7692. * Manages the defines for the Material
  7693. */
  7694. export class MaterialDefines {
  7695. /** @hidden */
  7696. protected _keys: string[];
  7697. private _isDirty;
  7698. /** @hidden */
  7699. _renderId: number;
  7700. /** @hidden */
  7701. _areLightsDirty: boolean;
  7702. /** @hidden */
  7703. _areLightsDisposed: boolean;
  7704. /** @hidden */
  7705. _areAttributesDirty: boolean;
  7706. /** @hidden */
  7707. _areTexturesDirty: boolean;
  7708. /** @hidden */
  7709. _areFresnelDirty: boolean;
  7710. /** @hidden */
  7711. _areMiscDirty: boolean;
  7712. /** @hidden */
  7713. _areImageProcessingDirty: boolean;
  7714. /** @hidden */
  7715. _normals: boolean;
  7716. /** @hidden */
  7717. _uvs: boolean;
  7718. /** @hidden */
  7719. _needNormals: boolean;
  7720. /** @hidden */
  7721. _needUVs: boolean;
  7722. [id: string]: any;
  7723. /**
  7724. * Specifies if the material needs to be re-calculated
  7725. */
  7726. readonly isDirty: boolean;
  7727. /**
  7728. * Marks the material to indicate that it has been re-calculated
  7729. */
  7730. markAsProcessed(): void;
  7731. /**
  7732. * Marks the material to indicate that it needs to be re-calculated
  7733. */
  7734. markAsUnprocessed(): void;
  7735. /**
  7736. * Marks the material to indicate all of its defines need to be re-calculated
  7737. */
  7738. markAllAsDirty(): void;
  7739. /**
  7740. * Marks the material to indicate that image processing needs to be re-calculated
  7741. */
  7742. markAsImageProcessingDirty(): void;
  7743. /**
  7744. * Marks the material to indicate the lights need to be re-calculated
  7745. * @param disposed Defines whether the light is dirty due to dispose or not
  7746. */
  7747. markAsLightDirty(disposed?: boolean): void;
  7748. /**
  7749. * Marks the attribute state as changed
  7750. */
  7751. markAsAttributesDirty(): void;
  7752. /**
  7753. * Marks the texture state as changed
  7754. */
  7755. markAsTexturesDirty(): void;
  7756. /**
  7757. * Marks the fresnel state as changed
  7758. */
  7759. markAsFresnelDirty(): void;
  7760. /**
  7761. * Marks the misc state as changed
  7762. */
  7763. markAsMiscDirty(): void;
  7764. /**
  7765. * Rebuilds the material defines
  7766. */
  7767. rebuild(): void;
  7768. /**
  7769. * Specifies if two material defines are equal
  7770. * @param other - A material define instance to compare to
  7771. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7772. */
  7773. isEqual(other: MaterialDefines): boolean;
  7774. /**
  7775. * Clones this instance's defines to another instance
  7776. * @param other - material defines to clone values to
  7777. */
  7778. cloneTo(other: MaterialDefines): void;
  7779. /**
  7780. * Resets the material define values
  7781. */
  7782. reset(): void;
  7783. /**
  7784. * Converts the material define values to a string
  7785. * @returns - String of material define information
  7786. */
  7787. toString(): string;
  7788. }
  7789. }
  7790. declare module "babylonjs/Materials/colorCurves" {
  7791. import { Effect } from "babylonjs/Materials/effect";
  7792. /**
  7793. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7794. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7795. * 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;
  7796. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7797. */
  7798. export class ColorCurves {
  7799. private _dirty;
  7800. private _tempColor;
  7801. private _globalCurve;
  7802. private _highlightsCurve;
  7803. private _midtonesCurve;
  7804. private _shadowsCurve;
  7805. private _positiveCurve;
  7806. private _negativeCurve;
  7807. private _globalHue;
  7808. private _globalDensity;
  7809. private _globalSaturation;
  7810. private _globalExposure;
  7811. /**
  7812. * Gets the global Hue value.
  7813. * 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).
  7814. */
  7815. /**
  7816. * Sets the global Hue value.
  7817. * 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).
  7818. */
  7819. globalHue: number;
  7820. /**
  7821. * Gets the global Density value.
  7822. * 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.
  7823. * Values less than zero provide a filter of opposite hue.
  7824. */
  7825. /**
  7826. * Sets the global Density value.
  7827. * 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.
  7828. * Values less than zero provide a filter of opposite hue.
  7829. */
  7830. globalDensity: number;
  7831. /**
  7832. * Gets the global Saturation value.
  7833. * 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.
  7834. */
  7835. /**
  7836. * Sets the global Saturation value.
  7837. * 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.
  7838. */
  7839. globalSaturation: number;
  7840. /**
  7841. * Gets the global Exposure value.
  7842. * 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.
  7843. */
  7844. /**
  7845. * Sets the global Exposure value.
  7846. * 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.
  7847. */
  7848. globalExposure: number;
  7849. private _highlightsHue;
  7850. private _highlightsDensity;
  7851. private _highlightsSaturation;
  7852. private _highlightsExposure;
  7853. /**
  7854. * Gets the highlights Hue value.
  7855. * 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).
  7856. */
  7857. /**
  7858. * Sets the highlights Hue value.
  7859. * 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).
  7860. */
  7861. highlightsHue: number;
  7862. /**
  7863. * Gets the highlights Density value.
  7864. * 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.
  7865. * Values less than zero provide a filter of opposite hue.
  7866. */
  7867. /**
  7868. * Sets the highlights Density value.
  7869. * 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.
  7870. * Values less than zero provide a filter of opposite hue.
  7871. */
  7872. highlightsDensity: number;
  7873. /**
  7874. * Gets the highlights Saturation value.
  7875. * 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.
  7876. */
  7877. /**
  7878. * Sets the highlights Saturation value.
  7879. * 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.
  7880. */
  7881. highlightsSaturation: number;
  7882. /**
  7883. * Gets the highlights Exposure value.
  7884. * 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.
  7885. */
  7886. /**
  7887. * Sets the highlights Exposure value.
  7888. * 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.
  7889. */
  7890. highlightsExposure: number;
  7891. private _midtonesHue;
  7892. private _midtonesDensity;
  7893. private _midtonesSaturation;
  7894. private _midtonesExposure;
  7895. /**
  7896. * Gets the midtones Hue value.
  7897. * 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).
  7898. */
  7899. /**
  7900. * Sets the midtones Hue value.
  7901. * 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).
  7902. */
  7903. midtonesHue: number;
  7904. /**
  7905. * Gets the midtones Density value.
  7906. * 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.
  7907. * Values less than zero provide a filter of opposite hue.
  7908. */
  7909. /**
  7910. * Sets the midtones Density value.
  7911. * 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.
  7912. * Values less than zero provide a filter of opposite hue.
  7913. */
  7914. midtonesDensity: number;
  7915. /**
  7916. * Gets the midtones Saturation value.
  7917. * 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.
  7918. */
  7919. /**
  7920. * Sets the midtones Saturation value.
  7921. * 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.
  7922. */
  7923. midtonesSaturation: number;
  7924. /**
  7925. * Gets the midtones Exposure value.
  7926. * 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.
  7927. */
  7928. /**
  7929. * Sets the midtones Exposure value.
  7930. * 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.
  7931. */
  7932. midtonesExposure: number;
  7933. private _shadowsHue;
  7934. private _shadowsDensity;
  7935. private _shadowsSaturation;
  7936. private _shadowsExposure;
  7937. /**
  7938. * Gets the shadows Hue value.
  7939. * 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).
  7940. */
  7941. /**
  7942. * Sets the shadows Hue value.
  7943. * 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).
  7944. */
  7945. shadowsHue: number;
  7946. /**
  7947. * Gets the shadows Density value.
  7948. * 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.
  7949. * Values less than zero provide a filter of opposite hue.
  7950. */
  7951. /**
  7952. * Sets the shadows Density value.
  7953. * 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.
  7954. * Values less than zero provide a filter of opposite hue.
  7955. */
  7956. shadowsDensity: number;
  7957. /**
  7958. * Gets the shadows Saturation value.
  7959. * 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.
  7960. */
  7961. /**
  7962. * Sets the shadows Saturation value.
  7963. * 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.
  7964. */
  7965. shadowsSaturation: number;
  7966. /**
  7967. * Gets the shadows Exposure value.
  7968. * 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.
  7969. */
  7970. /**
  7971. * Sets the shadows Exposure value.
  7972. * 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.
  7973. */
  7974. shadowsExposure: number;
  7975. /**
  7976. * Returns the class name
  7977. * @returns The class name
  7978. */
  7979. getClassName(): string;
  7980. /**
  7981. * Binds the color curves to the shader.
  7982. * @param colorCurves The color curve to bind
  7983. * @param effect The effect to bind to
  7984. * @param positiveUniform The positive uniform shader parameter
  7985. * @param neutralUniform The neutral uniform shader parameter
  7986. * @param negativeUniform The negative uniform shader parameter
  7987. */
  7988. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7989. /**
  7990. * Prepare the list of uniforms associated with the ColorCurves effects.
  7991. * @param uniformsList The list of uniforms used in the effect
  7992. */
  7993. static PrepareUniforms(uniformsList: string[]): void;
  7994. /**
  7995. * Returns color grading data based on a hue, density, saturation and exposure value.
  7996. * @param filterHue The hue of the color filter.
  7997. * @param filterDensity The density of the color filter.
  7998. * @param saturation The saturation.
  7999. * @param exposure The exposure.
  8000. * @param result The result data container.
  8001. */
  8002. private getColorGradingDataToRef;
  8003. /**
  8004. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8005. * @param value The input slider value in range [-100,100].
  8006. * @returns Adjusted value.
  8007. */
  8008. private static applyColorGradingSliderNonlinear;
  8009. /**
  8010. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8011. * @param hue The hue (H) input.
  8012. * @param saturation The saturation (S) input.
  8013. * @param brightness The brightness (B) input.
  8014. * @result An RGBA color represented as Vector4.
  8015. */
  8016. private static fromHSBToRef;
  8017. /**
  8018. * Returns a value clamped between min and max
  8019. * @param value The value to clamp
  8020. * @param min The minimum of value
  8021. * @param max The maximum of value
  8022. * @returns The clamped value.
  8023. */
  8024. private static clamp;
  8025. /**
  8026. * Clones the current color curve instance.
  8027. * @return The cloned curves
  8028. */
  8029. clone(): ColorCurves;
  8030. /**
  8031. * Serializes the current color curve instance to a json representation.
  8032. * @return a JSON representation
  8033. */
  8034. serialize(): any;
  8035. /**
  8036. * Parses the color curve from a json representation.
  8037. * @param source the JSON source to parse
  8038. * @return The parsed curves
  8039. */
  8040. static Parse(source: any): ColorCurves;
  8041. }
  8042. }
  8043. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8044. import { Observable } from "babylonjs/Misc/observable";
  8045. import { Nullable } from "babylonjs/types";
  8046. import { Color4 } from "babylonjs/Maths/math.color";
  8047. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8048. import { Effect } from "babylonjs/Materials/effect";
  8049. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8050. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8051. /**
  8052. * Interface to follow in your material defines to integrate easily the
  8053. * Image proccessing functions.
  8054. * @hidden
  8055. */
  8056. export interface IImageProcessingConfigurationDefines {
  8057. IMAGEPROCESSING: boolean;
  8058. VIGNETTE: boolean;
  8059. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8060. VIGNETTEBLENDMODEOPAQUE: boolean;
  8061. TONEMAPPING: boolean;
  8062. TONEMAPPING_ACES: boolean;
  8063. CONTRAST: boolean;
  8064. EXPOSURE: boolean;
  8065. COLORCURVES: boolean;
  8066. COLORGRADING: boolean;
  8067. COLORGRADING3D: boolean;
  8068. SAMPLER3DGREENDEPTH: boolean;
  8069. SAMPLER3DBGRMAP: boolean;
  8070. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8071. }
  8072. /**
  8073. * @hidden
  8074. */
  8075. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8076. IMAGEPROCESSING: boolean;
  8077. VIGNETTE: boolean;
  8078. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8079. VIGNETTEBLENDMODEOPAQUE: boolean;
  8080. TONEMAPPING: boolean;
  8081. TONEMAPPING_ACES: boolean;
  8082. CONTRAST: boolean;
  8083. COLORCURVES: boolean;
  8084. COLORGRADING: boolean;
  8085. COLORGRADING3D: boolean;
  8086. SAMPLER3DGREENDEPTH: boolean;
  8087. SAMPLER3DBGRMAP: boolean;
  8088. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8089. EXPOSURE: boolean;
  8090. constructor();
  8091. }
  8092. /**
  8093. * This groups together the common properties used for image processing either in direct forward pass
  8094. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8095. * or not.
  8096. */
  8097. export class ImageProcessingConfiguration {
  8098. /**
  8099. * Default tone mapping applied in BabylonJS.
  8100. */
  8101. static readonly TONEMAPPING_STANDARD: number;
  8102. /**
  8103. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8104. * to other engines rendering to increase portability.
  8105. */
  8106. static readonly TONEMAPPING_ACES: number;
  8107. /**
  8108. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8109. */
  8110. colorCurves: Nullable<ColorCurves>;
  8111. private _colorCurvesEnabled;
  8112. /**
  8113. * Gets wether the color curves effect is enabled.
  8114. */
  8115. /**
  8116. * Sets wether the color curves effect is enabled.
  8117. */
  8118. colorCurvesEnabled: boolean;
  8119. private _colorGradingTexture;
  8120. /**
  8121. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8122. */
  8123. /**
  8124. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8125. */
  8126. colorGradingTexture: Nullable<BaseTexture>;
  8127. private _colorGradingEnabled;
  8128. /**
  8129. * Gets wether the color grading effect is enabled.
  8130. */
  8131. /**
  8132. * Sets wether the color grading effect is enabled.
  8133. */
  8134. colorGradingEnabled: boolean;
  8135. private _colorGradingWithGreenDepth;
  8136. /**
  8137. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8138. */
  8139. /**
  8140. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8141. */
  8142. colorGradingWithGreenDepth: boolean;
  8143. private _colorGradingBGR;
  8144. /**
  8145. * Gets wether the color grading texture contains BGR values.
  8146. */
  8147. /**
  8148. * Sets wether the color grading texture contains BGR values.
  8149. */
  8150. colorGradingBGR: boolean;
  8151. /** @hidden */
  8152. _exposure: number;
  8153. /**
  8154. * Gets the Exposure used in the effect.
  8155. */
  8156. /**
  8157. * Sets the Exposure used in the effect.
  8158. */
  8159. exposure: number;
  8160. private _toneMappingEnabled;
  8161. /**
  8162. * Gets wether the tone mapping effect is enabled.
  8163. */
  8164. /**
  8165. * Sets wether the tone mapping effect is enabled.
  8166. */
  8167. toneMappingEnabled: boolean;
  8168. private _toneMappingType;
  8169. /**
  8170. * Gets the type of tone mapping effect.
  8171. */
  8172. /**
  8173. * Sets the type of tone mapping effect used in BabylonJS.
  8174. */
  8175. toneMappingType: number;
  8176. protected _contrast: number;
  8177. /**
  8178. * Gets the contrast used in the effect.
  8179. */
  8180. /**
  8181. * Sets the contrast used in the effect.
  8182. */
  8183. contrast: number;
  8184. /**
  8185. * Vignette stretch size.
  8186. */
  8187. vignetteStretch: number;
  8188. /**
  8189. * Vignette centre X Offset.
  8190. */
  8191. vignetteCentreX: number;
  8192. /**
  8193. * Vignette centre Y Offset.
  8194. */
  8195. vignetteCentreY: number;
  8196. /**
  8197. * Vignette weight or intensity of the vignette effect.
  8198. */
  8199. vignetteWeight: number;
  8200. /**
  8201. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8202. * if vignetteEnabled is set to true.
  8203. */
  8204. vignetteColor: Color4;
  8205. /**
  8206. * Camera field of view used by the Vignette effect.
  8207. */
  8208. vignetteCameraFov: number;
  8209. private _vignetteBlendMode;
  8210. /**
  8211. * Gets the vignette blend mode allowing different kind of effect.
  8212. */
  8213. /**
  8214. * Sets the vignette blend mode allowing different kind of effect.
  8215. */
  8216. vignetteBlendMode: number;
  8217. private _vignetteEnabled;
  8218. /**
  8219. * Gets wether the vignette effect is enabled.
  8220. */
  8221. /**
  8222. * Sets wether the vignette effect is enabled.
  8223. */
  8224. vignetteEnabled: boolean;
  8225. private _applyByPostProcess;
  8226. /**
  8227. * Gets wether the image processing is applied through a post process or not.
  8228. */
  8229. /**
  8230. * Sets wether the image processing is applied through a post process or not.
  8231. */
  8232. applyByPostProcess: boolean;
  8233. private _isEnabled;
  8234. /**
  8235. * Gets wether the image processing is enabled or not.
  8236. */
  8237. /**
  8238. * Sets wether the image processing is enabled or not.
  8239. */
  8240. isEnabled: boolean;
  8241. /**
  8242. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8243. */
  8244. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8245. /**
  8246. * Method called each time the image processing information changes requires to recompile the effect.
  8247. */
  8248. protected _updateParameters(): void;
  8249. /**
  8250. * Gets the current class name.
  8251. * @return "ImageProcessingConfiguration"
  8252. */
  8253. getClassName(): string;
  8254. /**
  8255. * Prepare the list of uniforms associated with the Image Processing effects.
  8256. * @param uniforms The list of uniforms used in the effect
  8257. * @param defines the list of defines currently in use
  8258. */
  8259. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8260. /**
  8261. * Prepare the list of samplers associated with the Image Processing effects.
  8262. * @param samplersList The list of uniforms used in the effect
  8263. * @param defines the list of defines currently in use
  8264. */
  8265. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8266. /**
  8267. * Prepare the list of defines associated to the shader.
  8268. * @param defines the list of defines to complete
  8269. * @param forPostProcess Define if we are currently in post process mode or not
  8270. */
  8271. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8272. /**
  8273. * Returns true if all the image processing information are ready.
  8274. * @returns True if ready, otherwise, false
  8275. */
  8276. isReady(): boolean;
  8277. /**
  8278. * Binds the image processing to the shader.
  8279. * @param effect The effect to bind to
  8280. * @param aspectRatio Define the current aspect ratio of the effect
  8281. */
  8282. bind(effect: Effect, aspectRatio?: number): void;
  8283. /**
  8284. * Clones the current image processing instance.
  8285. * @return The cloned image processing
  8286. */
  8287. clone(): ImageProcessingConfiguration;
  8288. /**
  8289. * Serializes the current image processing instance to a json representation.
  8290. * @return a JSON representation
  8291. */
  8292. serialize(): any;
  8293. /**
  8294. * Parses the image processing from a json representation.
  8295. * @param source the JSON source to parse
  8296. * @return The parsed image processing
  8297. */
  8298. static Parse(source: any): ImageProcessingConfiguration;
  8299. private static _VIGNETTEMODE_MULTIPLY;
  8300. private static _VIGNETTEMODE_OPAQUE;
  8301. /**
  8302. * Used to apply the vignette as a mix with the pixel color.
  8303. */
  8304. static readonly VIGNETTEMODE_MULTIPLY: number;
  8305. /**
  8306. * Used to apply the vignette as a replacement of the pixel color.
  8307. */
  8308. static readonly VIGNETTEMODE_OPAQUE: number;
  8309. }
  8310. }
  8311. declare module "babylonjs/Shaders/postprocess.vertex" {
  8312. /** @hidden */
  8313. export var postprocessVertexShader: {
  8314. name: string;
  8315. shader: string;
  8316. };
  8317. }
  8318. declare module "babylonjs/Maths/math.axis" {
  8319. import { Vector3 } from "babylonjs/Maths/math.vector";
  8320. /** Defines supported spaces */
  8321. export enum Space {
  8322. /** Local (object) space */
  8323. LOCAL = 0,
  8324. /** World space */
  8325. WORLD = 1,
  8326. /** Bone space */
  8327. BONE = 2
  8328. }
  8329. /** Defines the 3 main axes */
  8330. export class Axis {
  8331. /** X axis */
  8332. static X: Vector3;
  8333. /** Y axis */
  8334. static Y: Vector3;
  8335. /** Z axis */
  8336. static Z: Vector3;
  8337. }
  8338. }
  8339. declare module "babylonjs/Cameras/targetCamera" {
  8340. import { Nullable } from "babylonjs/types";
  8341. import { Camera } from "babylonjs/Cameras/camera";
  8342. import { Scene } from "babylonjs/scene";
  8343. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8344. /**
  8345. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8346. * This is the base of the follow, arc rotate cameras and Free camera
  8347. * @see http://doc.babylonjs.com/features/cameras
  8348. */
  8349. export class TargetCamera extends Camera {
  8350. private static _RigCamTransformMatrix;
  8351. private static _TargetTransformMatrix;
  8352. private static _TargetFocalPoint;
  8353. /**
  8354. * Define the current direction the camera is moving to
  8355. */
  8356. cameraDirection: Vector3;
  8357. /**
  8358. * Define the current rotation the camera is rotating to
  8359. */
  8360. cameraRotation: Vector2;
  8361. /**
  8362. * When set, the up vector of the camera will be updated by the rotation of the camera
  8363. */
  8364. updateUpVectorFromRotation: boolean;
  8365. private _tmpQuaternion;
  8366. /**
  8367. * Define the current rotation of the camera
  8368. */
  8369. rotation: Vector3;
  8370. /**
  8371. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8372. */
  8373. rotationQuaternion: Quaternion;
  8374. /**
  8375. * Define the current speed of the camera
  8376. */
  8377. speed: number;
  8378. /**
  8379. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8380. * around all axis.
  8381. */
  8382. noRotationConstraint: boolean;
  8383. /**
  8384. * Define the current target of the camera as an object or a position.
  8385. */
  8386. lockedTarget: any;
  8387. /** @hidden */
  8388. _currentTarget: Vector3;
  8389. /** @hidden */
  8390. _initialFocalDistance: number;
  8391. /** @hidden */
  8392. _viewMatrix: Matrix;
  8393. /** @hidden */
  8394. _camMatrix: Matrix;
  8395. /** @hidden */
  8396. _cameraTransformMatrix: Matrix;
  8397. /** @hidden */
  8398. _cameraRotationMatrix: Matrix;
  8399. /** @hidden */
  8400. _referencePoint: Vector3;
  8401. /** @hidden */
  8402. _transformedReferencePoint: Vector3;
  8403. protected _globalCurrentTarget: Vector3;
  8404. protected _globalCurrentUpVector: Vector3;
  8405. /** @hidden */
  8406. _reset: () => void;
  8407. private _defaultUp;
  8408. /**
  8409. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8410. * This is the base of the follow, arc rotate cameras and Free camera
  8411. * @see http://doc.babylonjs.com/features/cameras
  8412. * @param name Defines the name of the camera in the scene
  8413. * @param position Defines the start position of the camera in the scene
  8414. * @param scene Defines the scene the camera belongs to
  8415. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8416. */
  8417. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8418. /**
  8419. * Gets the position in front of the camera at a given distance.
  8420. * @param distance The distance from the camera we want the position to be
  8421. * @returns the position
  8422. */
  8423. getFrontPosition(distance: number): Vector3;
  8424. /** @hidden */
  8425. _getLockedTargetPosition(): Nullable<Vector3>;
  8426. private _storedPosition;
  8427. private _storedRotation;
  8428. private _storedRotationQuaternion;
  8429. /**
  8430. * Store current camera state of the camera (fov, position, rotation, etc..)
  8431. * @returns the camera
  8432. */
  8433. storeState(): Camera;
  8434. /**
  8435. * Restored camera state. You must call storeState() first
  8436. * @returns whether it was successful or not
  8437. * @hidden
  8438. */
  8439. _restoreStateValues(): boolean;
  8440. /** @hidden */
  8441. _initCache(): void;
  8442. /** @hidden */
  8443. _updateCache(ignoreParentClass?: boolean): void;
  8444. /** @hidden */
  8445. _isSynchronizedViewMatrix(): boolean;
  8446. /** @hidden */
  8447. _computeLocalCameraSpeed(): number;
  8448. /**
  8449. * Defines the target the camera should look at.
  8450. * @param target Defines the new target as a Vector or a mesh
  8451. */
  8452. setTarget(target: Vector3): void;
  8453. /**
  8454. * Return the current target position of the camera. This value is expressed in local space.
  8455. * @returns the target position
  8456. */
  8457. getTarget(): Vector3;
  8458. /** @hidden */
  8459. _decideIfNeedsToMove(): boolean;
  8460. /** @hidden */
  8461. _updatePosition(): void;
  8462. /** @hidden */
  8463. _checkInputs(): void;
  8464. protected _updateCameraRotationMatrix(): void;
  8465. /**
  8466. * 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)
  8467. * @returns the current camera
  8468. */
  8469. private _rotateUpVectorWithCameraRotationMatrix;
  8470. private _cachedRotationZ;
  8471. private _cachedQuaternionRotationZ;
  8472. /** @hidden */
  8473. _getViewMatrix(): Matrix;
  8474. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8475. /**
  8476. * @hidden
  8477. */
  8478. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8479. /**
  8480. * @hidden
  8481. */
  8482. _updateRigCameras(): void;
  8483. private _getRigCamPositionAndTarget;
  8484. /**
  8485. * Gets the current object class name.
  8486. * @return the class name
  8487. */
  8488. getClassName(): string;
  8489. }
  8490. }
  8491. declare module "babylonjs/Events/keyboardEvents" {
  8492. /**
  8493. * Gather the list of keyboard event types as constants.
  8494. */
  8495. export class KeyboardEventTypes {
  8496. /**
  8497. * The keydown event is fired when a key becomes active (pressed).
  8498. */
  8499. static readonly KEYDOWN: number;
  8500. /**
  8501. * The keyup event is fired when a key has been released.
  8502. */
  8503. static readonly KEYUP: number;
  8504. }
  8505. /**
  8506. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8507. */
  8508. export class KeyboardInfo {
  8509. /**
  8510. * Defines the type of event (KeyboardEventTypes)
  8511. */
  8512. type: number;
  8513. /**
  8514. * Defines the related dom event
  8515. */
  8516. event: KeyboardEvent;
  8517. /**
  8518. * Instantiates a new keyboard info.
  8519. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8520. * @param type Defines the type of event (KeyboardEventTypes)
  8521. * @param event Defines the related dom event
  8522. */
  8523. constructor(
  8524. /**
  8525. * Defines the type of event (KeyboardEventTypes)
  8526. */
  8527. type: number,
  8528. /**
  8529. * Defines the related dom event
  8530. */
  8531. event: KeyboardEvent);
  8532. }
  8533. /**
  8534. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8535. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8536. */
  8537. export class KeyboardInfoPre extends KeyboardInfo {
  8538. /**
  8539. * Defines the type of event (KeyboardEventTypes)
  8540. */
  8541. type: number;
  8542. /**
  8543. * Defines the related dom event
  8544. */
  8545. event: KeyboardEvent;
  8546. /**
  8547. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8548. */
  8549. skipOnPointerObservable: boolean;
  8550. /**
  8551. * Instantiates a new keyboard pre info.
  8552. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8553. * @param type Defines the type of event (KeyboardEventTypes)
  8554. * @param event Defines the related dom event
  8555. */
  8556. constructor(
  8557. /**
  8558. * Defines the type of event (KeyboardEventTypes)
  8559. */
  8560. type: number,
  8561. /**
  8562. * Defines the related dom event
  8563. */
  8564. event: KeyboardEvent);
  8565. }
  8566. }
  8567. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8568. import { Nullable } from "babylonjs/types";
  8569. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8570. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8571. /**
  8572. * Manage the keyboard inputs to control the movement of a free camera.
  8573. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8574. */
  8575. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8576. /**
  8577. * Defines the camera the input is attached to.
  8578. */
  8579. camera: FreeCamera;
  8580. /**
  8581. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8582. */
  8583. keysUp: number[];
  8584. /**
  8585. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8586. */
  8587. keysDown: number[];
  8588. /**
  8589. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8590. */
  8591. keysLeft: number[];
  8592. /**
  8593. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8594. */
  8595. keysRight: number[];
  8596. private _keys;
  8597. private _onCanvasBlurObserver;
  8598. private _onKeyboardObserver;
  8599. private _engine;
  8600. private _scene;
  8601. /**
  8602. * Attach the input controls to a specific dom element to get the input from.
  8603. * @param element Defines the element the controls should be listened from
  8604. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8605. */
  8606. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8607. /**
  8608. * Detach the current controls from the specified dom element.
  8609. * @param element Defines the element to stop listening the inputs from
  8610. */
  8611. detachControl(element: Nullable<HTMLElement>): void;
  8612. /**
  8613. * Update the current camera state depending on the inputs that have been used this frame.
  8614. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8615. */
  8616. checkInputs(): void;
  8617. /**
  8618. * Gets the class name of the current intput.
  8619. * @returns the class name
  8620. */
  8621. getClassName(): string;
  8622. /** @hidden */
  8623. _onLostFocus(): void;
  8624. /**
  8625. * Get the friendly name associated with the input class.
  8626. * @returns the input friendly name
  8627. */
  8628. getSimpleName(): string;
  8629. }
  8630. }
  8631. declare module "babylonjs/Lights/shadowLight" {
  8632. import { Camera } from "babylonjs/Cameras/camera";
  8633. import { Scene } from "babylonjs/scene";
  8634. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8635. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8636. import { Light } from "babylonjs/Lights/light";
  8637. /**
  8638. * Interface describing all the common properties and methods a shadow light needs to implement.
  8639. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8640. * as well as binding the different shadow properties to the effects.
  8641. */
  8642. export interface IShadowLight extends Light {
  8643. /**
  8644. * The light id in the scene (used in scene.findLighById for instance)
  8645. */
  8646. id: string;
  8647. /**
  8648. * The position the shdow will be casted from.
  8649. */
  8650. position: Vector3;
  8651. /**
  8652. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8653. */
  8654. direction: Vector3;
  8655. /**
  8656. * The transformed position. Position of the light in world space taking parenting in account.
  8657. */
  8658. transformedPosition: Vector3;
  8659. /**
  8660. * The transformed direction. Direction of the light in world space taking parenting in account.
  8661. */
  8662. transformedDirection: Vector3;
  8663. /**
  8664. * The friendly name of the light in the scene.
  8665. */
  8666. name: string;
  8667. /**
  8668. * Defines the shadow projection clipping minimum z value.
  8669. */
  8670. shadowMinZ: number;
  8671. /**
  8672. * Defines the shadow projection clipping maximum z value.
  8673. */
  8674. shadowMaxZ: number;
  8675. /**
  8676. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8677. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8678. */
  8679. computeTransformedInformation(): boolean;
  8680. /**
  8681. * Gets the scene the light belongs to.
  8682. * @returns The scene
  8683. */
  8684. getScene(): Scene;
  8685. /**
  8686. * Callback defining a custom Projection Matrix Builder.
  8687. * This can be used to override the default projection matrix computation.
  8688. */
  8689. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8690. /**
  8691. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8692. * @param matrix The materix to updated with the projection information
  8693. * @param viewMatrix The transform matrix of the light
  8694. * @param renderList The list of mesh to render in the map
  8695. * @returns The current light
  8696. */
  8697. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8698. /**
  8699. * Gets the current depth scale used in ESM.
  8700. * @returns The scale
  8701. */
  8702. getDepthScale(): number;
  8703. /**
  8704. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8705. * @returns true if a cube texture needs to be use
  8706. */
  8707. needCube(): boolean;
  8708. /**
  8709. * Detects if the projection matrix requires to be recomputed this frame.
  8710. * @returns true if it requires to be recomputed otherwise, false.
  8711. */
  8712. needProjectionMatrixCompute(): boolean;
  8713. /**
  8714. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8715. */
  8716. forceProjectionMatrixCompute(): void;
  8717. /**
  8718. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8719. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8720. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8721. */
  8722. getShadowDirection(faceIndex?: number): Vector3;
  8723. /**
  8724. * Gets the minZ used for shadow according to both the scene and the light.
  8725. * @param activeCamera The camera we are returning the min for
  8726. * @returns the depth min z
  8727. */
  8728. getDepthMinZ(activeCamera: Camera): number;
  8729. /**
  8730. * Gets the maxZ used for shadow according to both the scene and the light.
  8731. * @param activeCamera The camera we are returning the max for
  8732. * @returns the depth max z
  8733. */
  8734. getDepthMaxZ(activeCamera: Camera): number;
  8735. }
  8736. /**
  8737. * Base implementation IShadowLight
  8738. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8739. */
  8740. export abstract class ShadowLight extends Light implements IShadowLight {
  8741. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8742. protected _position: Vector3;
  8743. protected _setPosition(value: Vector3): void;
  8744. /**
  8745. * Sets the position the shadow will be casted from. Also use as the light position for both
  8746. * point and spot lights.
  8747. */
  8748. /**
  8749. * Sets the position the shadow will be casted from. Also use as the light position for both
  8750. * point and spot lights.
  8751. */
  8752. position: Vector3;
  8753. protected _direction: Vector3;
  8754. protected _setDirection(value: Vector3): void;
  8755. /**
  8756. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8757. * Also use as the light direction on spot and directional lights.
  8758. */
  8759. /**
  8760. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8761. * Also use as the light direction on spot and directional lights.
  8762. */
  8763. direction: Vector3;
  8764. private _shadowMinZ;
  8765. /**
  8766. * Gets the shadow projection clipping minimum z value.
  8767. */
  8768. /**
  8769. * Sets the shadow projection clipping minimum z value.
  8770. */
  8771. shadowMinZ: number;
  8772. private _shadowMaxZ;
  8773. /**
  8774. * Sets the shadow projection clipping maximum z value.
  8775. */
  8776. /**
  8777. * Gets the shadow projection clipping maximum z value.
  8778. */
  8779. shadowMaxZ: number;
  8780. /**
  8781. * Callback defining a custom Projection Matrix Builder.
  8782. * This can be used to override the default projection matrix computation.
  8783. */
  8784. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8785. /**
  8786. * The transformed position. Position of the light in world space taking parenting in account.
  8787. */
  8788. transformedPosition: Vector3;
  8789. /**
  8790. * The transformed direction. Direction of the light in world space taking parenting in account.
  8791. */
  8792. transformedDirection: Vector3;
  8793. private _needProjectionMatrixCompute;
  8794. /**
  8795. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8796. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8797. */
  8798. computeTransformedInformation(): boolean;
  8799. /**
  8800. * Return the depth scale used for the shadow map.
  8801. * @returns the depth scale.
  8802. */
  8803. getDepthScale(): number;
  8804. /**
  8805. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8806. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8807. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8808. */
  8809. getShadowDirection(faceIndex?: number): Vector3;
  8810. /**
  8811. * Returns the ShadowLight absolute position in the World.
  8812. * @returns the position vector in world space
  8813. */
  8814. getAbsolutePosition(): Vector3;
  8815. /**
  8816. * Sets the ShadowLight direction toward the passed target.
  8817. * @param target The point to target in local space
  8818. * @returns the updated ShadowLight direction
  8819. */
  8820. setDirectionToTarget(target: Vector3): Vector3;
  8821. /**
  8822. * Returns the light rotation in euler definition.
  8823. * @returns the x y z rotation in local space.
  8824. */
  8825. getRotation(): Vector3;
  8826. /**
  8827. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8828. * @returns true if a cube texture needs to be use
  8829. */
  8830. needCube(): boolean;
  8831. /**
  8832. * Detects if the projection matrix requires to be recomputed this frame.
  8833. * @returns true if it requires to be recomputed otherwise, false.
  8834. */
  8835. needProjectionMatrixCompute(): boolean;
  8836. /**
  8837. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8838. */
  8839. forceProjectionMatrixCompute(): void;
  8840. /** @hidden */
  8841. _initCache(): void;
  8842. /** @hidden */
  8843. _isSynchronized(): boolean;
  8844. /**
  8845. * Computes the world matrix of the node
  8846. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8847. * @returns the world matrix
  8848. */
  8849. computeWorldMatrix(force?: boolean): Matrix;
  8850. /**
  8851. * Gets the minZ used for shadow according to both the scene and the light.
  8852. * @param activeCamera The camera we are returning the min for
  8853. * @returns the depth min z
  8854. */
  8855. getDepthMinZ(activeCamera: Camera): number;
  8856. /**
  8857. * Gets the maxZ used for shadow according to both the scene and the light.
  8858. * @param activeCamera The camera we are returning the max for
  8859. * @returns the depth max z
  8860. */
  8861. getDepthMaxZ(activeCamera: Camera): number;
  8862. /**
  8863. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8864. * @param matrix The materix to updated with the projection information
  8865. * @param viewMatrix The transform matrix of the light
  8866. * @param renderList The list of mesh to render in the map
  8867. * @returns The current light
  8868. */
  8869. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8870. }
  8871. }
  8872. declare module "babylonjs/Materials/materialHelper" {
  8873. import { Nullable } from "babylonjs/types";
  8874. import { Scene } from "babylonjs/scene";
  8875. import { Engine } from "babylonjs/Engines/engine";
  8876. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8877. import { Light } from "babylonjs/Lights/light";
  8878. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8879. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  8880. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8881. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8882. /**
  8883. * "Static Class" containing the most commonly used helper while dealing with material for
  8884. * rendering purpose.
  8885. *
  8886. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8887. *
  8888. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8889. */
  8890. export class MaterialHelper {
  8891. /**
  8892. * Bind the current view position to an effect.
  8893. * @param effect The effect to be bound
  8894. * @param scene The scene the eyes position is used from
  8895. */
  8896. static BindEyePosition(effect: Effect, scene: Scene): void;
  8897. /**
  8898. * Helps preparing the defines values about the UVs in used in the effect.
  8899. * UVs are shared as much as we can accross channels in the shaders.
  8900. * @param texture The texture we are preparing the UVs for
  8901. * @param defines The defines to update
  8902. * @param key The channel key "diffuse", "specular"... used in the shader
  8903. */
  8904. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8905. /**
  8906. * Binds a texture matrix value to its corrsponding uniform
  8907. * @param texture The texture to bind the matrix for
  8908. * @param uniformBuffer The uniform buffer receivin the data
  8909. * @param key The channel key "diffuse", "specular"... used in the shader
  8910. */
  8911. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8912. /**
  8913. * Gets the current status of the fog (should it be enabled?)
  8914. * @param mesh defines the mesh to evaluate for fog support
  8915. * @param scene defines the hosting scene
  8916. * @returns true if fog must be enabled
  8917. */
  8918. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8919. /**
  8920. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8921. * @param mesh defines the current mesh
  8922. * @param scene defines the current scene
  8923. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8924. * @param pointsCloud defines if point cloud rendering has to be turned on
  8925. * @param fogEnabled defines if fog has to be turned on
  8926. * @param alphaTest defines if alpha testing has to be turned on
  8927. * @param defines defines the current list of defines
  8928. */
  8929. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8930. /**
  8931. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8932. * @param scene defines the current scene
  8933. * @param engine defines the current engine
  8934. * @param defines specifies the list of active defines
  8935. * @param useInstances defines if instances have to be turned on
  8936. * @param useClipPlane defines if clip plane have to be turned on
  8937. */
  8938. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8939. /**
  8940. * Prepares the defines for bones
  8941. * @param mesh The mesh containing the geometry data we will draw
  8942. * @param defines The defines to update
  8943. */
  8944. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8945. /**
  8946. * Prepares the defines for morph targets
  8947. * @param mesh The mesh containing the geometry data we will draw
  8948. * @param defines The defines to update
  8949. */
  8950. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8951. /**
  8952. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8953. * @param mesh The mesh containing the geometry data we will draw
  8954. * @param defines The defines to update
  8955. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8956. * @param useBones Precise whether bones should be used or not (override mesh info)
  8957. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8958. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8959. * @returns false if defines are considered not dirty and have not been checked
  8960. */
  8961. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8962. /**
  8963. * Prepares the defines related to multiview
  8964. * @param scene The scene we are intending to draw
  8965. * @param defines The defines to update
  8966. */
  8967. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8968. /**
  8969. * Prepares the defines related to the light information passed in parameter
  8970. * @param scene The scene we are intending to draw
  8971. * @param mesh The mesh the effect is compiling for
  8972. * @param light The light the effect is compiling for
  8973. * @param lightIndex The index of the light
  8974. * @param defines The defines to update
  8975. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8976. * @param state Defines the current state regarding what is needed (normals, etc...)
  8977. */
  8978. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8979. needNormals: boolean;
  8980. needRebuild: boolean;
  8981. shadowEnabled: boolean;
  8982. specularEnabled: boolean;
  8983. lightmapMode: boolean;
  8984. }): void;
  8985. /**
  8986. * Prepares the defines related to the light information passed in parameter
  8987. * @param scene The scene we are intending to draw
  8988. * @param mesh The mesh the effect is compiling for
  8989. * @param defines The defines to update
  8990. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8991. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8992. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8993. * @returns true if normals will be required for the rest of the effect
  8994. */
  8995. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8996. /**
  8997. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8998. * @param lightIndex defines the light index
  8999. * @param uniformsList The uniform list
  9000. * @param samplersList The sampler list
  9001. * @param projectedLightTexture defines if projected texture must be used
  9002. * @param uniformBuffersList defines an optional list of uniform buffers
  9003. */
  9004. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9005. /**
  9006. * Prepares the uniforms and samplers list to be used in the effect
  9007. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9008. * @param samplersList The sampler list
  9009. * @param defines The defines helping in the list generation
  9010. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9011. */
  9012. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9013. /**
  9014. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9015. * @param defines The defines to update while falling back
  9016. * @param fallbacks The authorized effect fallbacks
  9017. * @param maxSimultaneousLights The maximum number of lights allowed
  9018. * @param rank the current rank of the Effect
  9019. * @returns The newly affected rank
  9020. */
  9021. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9022. private static _TmpMorphInfluencers;
  9023. /**
  9024. * Prepares the list of attributes required for morph targets according to the effect defines.
  9025. * @param attribs The current list of supported attribs
  9026. * @param mesh The mesh to prepare the morph targets attributes for
  9027. * @param influencers The number of influencers
  9028. */
  9029. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9030. /**
  9031. * Prepares the list of attributes required for morph targets according to the effect defines.
  9032. * @param attribs The current list of supported attribs
  9033. * @param mesh The mesh to prepare the morph targets attributes for
  9034. * @param defines The current Defines of the effect
  9035. */
  9036. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9037. /**
  9038. * Prepares the list of attributes required for bones according to the effect defines.
  9039. * @param attribs The current list of supported attribs
  9040. * @param mesh The mesh to prepare the bones attributes for
  9041. * @param defines The current Defines of the effect
  9042. * @param fallbacks The current efffect fallback strategy
  9043. */
  9044. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9045. /**
  9046. * Check and prepare the list of attributes required for instances according to the effect defines.
  9047. * @param attribs The current list of supported attribs
  9048. * @param defines The current MaterialDefines of the effect
  9049. */
  9050. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9051. /**
  9052. * Add the list of attributes required for instances to the attribs array.
  9053. * @param attribs The current list of supported attribs
  9054. */
  9055. static PushAttributesForInstances(attribs: string[]): void;
  9056. /**
  9057. * Binds the light shadow information to the effect for the given mesh.
  9058. * @param light The light containing the generator
  9059. * @param scene The scene the lights belongs to
  9060. * @param mesh The mesh we are binding the information to render
  9061. * @param lightIndex The light index in the effect used to render the mesh
  9062. * @param effect The effect we are binding the data to
  9063. */
  9064. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9065. /**
  9066. * Binds the light information to the effect.
  9067. * @param light The light containing the generator
  9068. * @param effect The effect we are binding the data to
  9069. * @param lightIndex The light index in the effect used to render
  9070. */
  9071. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9072. /**
  9073. * Binds the lights information from the scene to the effect for the given mesh.
  9074. * @param light Light to bind
  9075. * @param lightIndex Light index
  9076. * @param scene The scene where the light belongs to
  9077. * @param mesh The mesh we are binding the information to render
  9078. * @param effect The effect we are binding the data to
  9079. * @param useSpecular Defines if specular is supported
  9080. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9081. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9082. */
  9083. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9084. /**
  9085. * Binds the lights information from the scene to the effect for the given mesh.
  9086. * @param scene The scene the lights belongs to
  9087. * @param mesh The mesh we are binding the information to render
  9088. * @param effect The effect we are binding the data to
  9089. * @param defines The generated defines for the effect
  9090. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9091. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9092. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9093. */
  9094. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9095. private static _tempFogColor;
  9096. /**
  9097. * Binds the fog information from the scene to the effect for the given mesh.
  9098. * @param scene The scene the lights belongs to
  9099. * @param mesh The mesh we are binding the information to render
  9100. * @param effect The effect we are binding the data to
  9101. * @param linearSpace Defines if the fog effect is applied in linear space
  9102. */
  9103. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9104. /**
  9105. * Binds the bones information from the mesh to the effect.
  9106. * @param mesh The mesh we are binding the information to render
  9107. * @param effect The effect we are binding the data to
  9108. */
  9109. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9110. /**
  9111. * Binds the morph targets information from the mesh to the effect.
  9112. * @param abstractMesh The mesh we are binding the information to render
  9113. * @param effect The effect we are binding the data to
  9114. */
  9115. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9116. /**
  9117. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9118. * @param defines The generated defines used in the effect
  9119. * @param effect The effect we are binding the data to
  9120. * @param scene The scene we are willing to render with logarithmic scale for
  9121. */
  9122. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9123. /**
  9124. * Binds the clip plane information from the scene to the effect.
  9125. * @param scene The scene the clip plane information are extracted from
  9126. * @param effect The effect we are binding the data to
  9127. */
  9128. static BindClipPlane(effect: Effect, scene: Scene): void;
  9129. }
  9130. }
  9131. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9132. /** @hidden */
  9133. export var packingFunctions: {
  9134. name: string;
  9135. shader: string;
  9136. };
  9137. }
  9138. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9139. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9140. /** @hidden */
  9141. export var shadowMapPixelShader: {
  9142. name: string;
  9143. shader: string;
  9144. };
  9145. }
  9146. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9147. /** @hidden */
  9148. export var bonesDeclaration: {
  9149. name: string;
  9150. shader: string;
  9151. };
  9152. }
  9153. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9154. /** @hidden */
  9155. export var morphTargetsVertexGlobalDeclaration: {
  9156. name: string;
  9157. shader: string;
  9158. };
  9159. }
  9160. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9161. /** @hidden */
  9162. export var morphTargetsVertexDeclaration: {
  9163. name: string;
  9164. shader: string;
  9165. };
  9166. }
  9167. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9168. /** @hidden */
  9169. export var instancesDeclaration: {
  9170. name: string;
  9171. shader: string;
  9172. };
  9173. }
  9174. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9175. /** @hidden */
  9176. export var helperFunctions: {
  9177. name: string;
  9178. shader: string;
  9179. };
  9180. }
  9181. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9182. /** @hidden */
  9183. export var morphTargetsVertex: {
  9184. name: string;
  9185. shader: string;
  9186. };
  9187. }
  9188. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9189. /** @hidden */
  9190. export var instancesVertex: {
  9191. name: string;
  9192. shader: string;
  9193. };
  9194. }
  9195. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9196. /** @hidden */
  9197. export var bonesVertex: {
  9198. name: string;
  9199. shader: string;
  9200. };
  9201. }
  9202. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9203. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9204. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9205. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9206. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9207. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9208. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9209. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9210. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9211. /** @hidden */
  9212. export var shadowMapVertexShader: {
  9213. name: string;
  9214. shader: string;
  9215. };
  9216. }
  9217. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9218. /** @hidden */
  9219. export var depthBoxBlurPixelShader: {
  9220. name: string;
  9221. shader: string;
  9222. };
  9223. }
  9224. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9225. import { Nullable } from "babylonjs/types";
  9226. import { Scene } from "babylonjs/scene";
  9227. import { Matrix } from "babylonjs/Maths/math.vector";
  9228. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9229. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9230. import { Mesh } from "babylonjs/Meshes/mesh";
  9231. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9232. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9233. import { Effect } from "babylonjs/Materials/effect";
  9234. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9235. import "babylonjs/Shaders/shadowMap.fragment";
  9236. import "babylonjs/Shaders/shadowMap.vertex";
  9237. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9238. import { Observable } from "babylonjs/Misc/observable";
  9239. /**
  9240. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9241. */
  9242. export interface ICustomShaderOptions {
  9243. /**
  9244. * Gets or sets the custom shader name to use
  9245. */
  9246. shaderName: string;
  9247. /**
  9248. * The list of attribute names used in the shader
  9249. */
  9250. attributes?: string[];
  9251. /**
  9252. * The list of unifrom names used in the shader
  9253. */
  9254. uniforms?: string[];
  9255. /**
  9256. * The list of sampler names used in the shader
  9257. */
  9258. samplers?: string[];
  9259. /**
  9260. * The list of defines used in the shader
  9261. */
  9262. defines?: string[];
  9263. }
  9264. /**
  9265. * Interface to implement to create a shadow generator compatible with BJS.
  9266. */
  9267. export interface IShadowGenerator {
  9268. /**
  9269. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9270. * @returns The render target texture if present otherwise, null
  9271. */
  9272. getShadowMap(): Nullable<RenderTargetTexture>;
  9273. /**
  9274. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9275. * @returns The render target texture if the shadow map is present otherwise, null
  9276. */
  9277. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9278. /**
  9279. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9280. * @param subMesh The submesh we want to render in the shadow map
  9281. * @param useInstances Defines wether will draw in the map using instances
  9282. * @returns true if ready otherwise, false
  9283. */
  9284. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9285. /**
  9286. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9287. * @param defines Defines of the material we want to update
  9288. * @param lightIndex Index of the light in the enabled light list of the material
  9289. */
  9290. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9291. /**
  9292. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9293. * defined in the generator but impacting the effect).
  9294. * It implies the unifroms available on the materials are the standard BJS ones.
  9295. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9296. * @param effect The effect we are binfing the information for
  9297. */
  9298. bindShadowLight(lightIndex: string, effect: Effect): void;
  9299. /**
  9300. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9301. * (eq to shadow prjection matrix * light transform matrix)
  9302. * @returns The transform matrix used to create the shadow map
  9303. */
  9304. getTransformMatrix(): Matrix;
  9305. /**
  9306. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9307. * Cube and 2D textures for instance.
  9308. */
  9309. recreateShadowMap(): void;
  9310. /**
  9311. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9312. * @param onCompiled Callback triggered at the and of the effects compilation
  9313. * @param options Sets of optional options forcing the compilation with different modes
  9314. */
  9315. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9316. useInstances: boolean;
  9317. }>): void;
  9318. /**
  9319. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9320. * @param options Sets of optional options forcing the compilation with different modes
  9321. * @returns A promise that resolves when the compilation completes
  9322. */
  9323. forceCompilationAsync(options?: Partial<{
  9324. useInstances: boolean;
  9325. }>): Promise<void>;
  9326. /**
  9327. * Serializes the shadow generator setup to a json object.
  9328. * @returns The serialized JSON object
  9329. */
  9330. serialize(): any;
  9331. /**
  9332. * Disposes the Shadow map and related Textures and effects.
  9333. */
  9334. dispose(): void;
  9335. }
  9336. /**
  9337. * Default implementation IShadowGenerator.
  9338. * This is the main object responsible of generating shadows in the framework.
  9339. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9340. */
  9341. export class ShadowGenerator implements IShadowGenerator {
  9342. /**
  9343. * Shadow generator mode None: no filtering applied.
  9344. */
  9345. static readonly FILTER_NONE: number;
  9346. /**
  9347. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9348. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9349. */
  9350. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9351. /**
  9352. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9353. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9354. */
  9355. static readonly FILTER_POISSONSAMPLING: number;
  9356. /**
  9357. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9358. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9359. */
  9360. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9361. /**
  9362. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9363. * edge artifacts on steep falloff.
  9364. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9365. */
  9366. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9367. /**
  9368. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9369. * edge artifacts on steep falloff.
  9370. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9371. */
  9372. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9373. /**
  9374. * Shadow generator mode PCF: Percentage Closer Filtering
  9375. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9376. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9377. */
  9378. static readonly FILTER_PCF: number;
  9379. /**
  9380. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9381. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9382. * Contact Hardening
  9383. */
  9384. static readonly FILTER_PCSS: number;
  9385. /**
  9386. * Reserved for PCF and PCSS
  9387. * Highest Quality.
  9388. *
  9389. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9390. *
  9391. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9392. */
  9393. static readonly QUALITY_HIGH: number;
  9394. /**
  9395. * Reserved for PCF and PCSS
  9396. * Good tradeoff for quality/perf cross devices
  9397. *
  9398. * Execute PCF on a 3*3 kernel.
  9399. *
  9400. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9401. */
  9402. static readonly QUALITY_MEDIUM: number;
  9403. /**
  9404. * Reserved for PCF and PCSS
  9405. * The lowest quality but the fastest.
  9406. *
  9407. * Execute PCF on a 1*1 kernel.
  9408. *
  9409. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9410. */
  9411. static readonly QUALITY_LOW: number;
  9412. /** Gets or sets the custom shader name to use */
  9413. customShaderOptions: ICustomShaderOptions;
  9414. /**
  9415. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9416. */
  9417. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9418. /**
  9419. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9420. */
  9421. onAfterShadowMapRenderObservable: Observable<Effect>;
  9422. /**
  9423. * Observable triggered before a mesh is rendered in the shadow map.
  9424. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9425. */
  9426. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9427. /**
  9428. * Observable triggered after a mesh is rendered in the shadow map.
  9429. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9430. */
  9431. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9432. private _bias;
  9433. /**
  9434. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9435. */
  9436. /**
  9437. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9438. */
  9439. bias: number;
  9440. private _normalBias;
  9441. /**
  9442. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9443. */
  9444. /**
  9445. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9446. */
  9447. normalBias: number;
  9448. private _blurBoxOffset;
  9449. /**
  9450. * Gets the blur box offset: offset applied during the blur pass.
  9451. * Only useful if useKernelBlur = false
  9452. */
  9453. /**
  9454. * Sets the blur box offset: offset applied during the blur pass.
  9455. * Only useful if useKernelBlur = false
  9456. */
  9457. blurBoxOffset: number;
  9458. private _blurScale;
  9459. /**
  9460. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9461. * 2 means half of the size.
  9462. */
  9463. /**
  9464. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9465. * 2 means half of the size.
  9466. */
  9467. blurScale: number;
  9468. private _blurKernel;
  9469. /**
  9470. * Gets the blur kernel: kernel size of the blur pass.
  9471. * Only useful if useKernelBlur = true
  9472. */
  9473. /**
  9474. * Sets the blur kernel: kernel size of the blur pass.
  9475. * Only useful if useKernelBlur = true
  9476. */
  9477. blurKernel: number;
  9478. private _useKernelBlur;
  9479. /**
  9480. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9481. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9482. */
  9483. /**
  9484. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9485. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9486. */
  9487. useKernelBlur: boolean;
  9488. private _depthScale;
  9489. /**
  9490. * Gets the depth scale used in ESM mode.
  9491. */
  9492. /**
  9493. * Sets the depth scale used in ESM mode.
  9494. * This can override the scale stored on the light.
  9495. */
  9496. depthScale: number;
  9497. private _filter;
  9498. /**
  9499. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9500. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9501. */
  9502. /**
  9503. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9504. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9505. */
  9506. filter: number;
  9507. /**
  9508. * Gets if the current filter is set to Poisson Sampling.
  9509. */
  9510. /**
  9511. * Sets the current filter to Poisson Sampling.
  9512. */
  9513. usePoissonSampling: boolean;
  9514. /**
  9515. * Gets if the current filter is set to ESM.
  9516. */
  9517. /**
  9518. * Sets the current filter is to ESM.
  9519. */
  9520. useExponentialShadowMap: boolean;
  9521. /**
  9522. * Gets if the current filter is set to filtered ESM.
  9523. */
  9524. /**
  9525. * Gets if the current filter is set to filtered ESM.
  9526. */
  9527. useBlurExponentialShadowMap: boolean;
  9528. /**
  9529. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9530. * exponential to prevent steep falloff artifacts).
  9531. */
  9532. /**
  9533. * Sets the current filter to "close ESM" (using the inverse of the
  9534. * exponential to prevent steep falloff artifacts).
  9535. */
  9536. useCloseExponentialShadowMap: boolean;
  9537. /**
  9538. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9539. * exponential to prevent steep falloff artifacts).
  9540. */
  9541. /**
  9542. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9543. * exponential to prevent steep falloff artifacts).
  9544. */
  9545. useBlurCloseExponentialShadowMap: boolean;
  9546. /**
  9547. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9548. */
  9549. /**
  9550. * Sets the current filter to "PCF" (percentage closer filtering).
  9551. */
  9552. usePercentageCloserFiltering: boolean;
  9553. private _filteringQuality;
  9554. /**
  9555. * Gets the PCF or PCSS Quality.
  9556. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9557. */
  9558. /**
  9559. * Sets the PCF or PCSS Quality.
  9560. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9561. */
  9562. filteringQuality: number;
  9563. /**
  9564. * Gets if the current filter is set to "PCSS" (contact hardening).
  9565. */
  9566. /**
  9567. * Sets the current filter to "PCSS" (contact hardening).
  9568. */
  9569. useContactHardeningShadow: boolean;
  9570. private _contactHardeningLightSizeUVRatio;
  9571. /**
  9572. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9573. * Using a ratio helps keeping shape stability independently of the map size.
  9574. *
  9575. * It does not account for the light projection as it was having too much
  9576. * instability during the light setup or during light position changes.
  9577. *
  9578. * Only valid if useContactHardeningShadow is true.
  9579. */
  9580. /**
  9581. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9582. * Using a ratio helps keeping shape stability independently of the map size.
  9583. *
  9584. * It does not account for the light projection as it was having too much
  9585. * instability during the light setup or during light position changes.
  9586. *
  9587. * Only valid if useContactHardeningShadow is true.
  9588. */
  9589. contactHardeningLightSizeUVRatio: number;
  9590. private _darkness;
  9591. /** Gets or sets the actual darkness of a shadow */
  9592. darkness: number;
  9593. /**
  9594. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9595. * 0 means strongest and 1 would means no shadow.
  9596. * @returns the darkness.
  9597. */
  9598. getDarkness(): number;
  9599. /**
  9600. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9601. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9602. * @returns the shadow generator allowing fluent coding.
  9603. */
  9604. setDarkness(darkness: number): ShadowGenerator;
  9605. private _transparencyShadow;
  9606. /** Gets or sets the ability to have transparent shadow */
  9607. transparencyShadow: boolean;
  9608. /**
  9609. * Sets the ability to have transparent shadow (boolean).
  9610. * @param transparent True if transparent else False
  9611. * @returns the shadow generator allowing fluent coding
  9612. */
  9613. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9614. private _shadowMap;
  9615. private _shadowMap2;
  9616. /**
  9617. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9618. * @returns The render target texture if present otherwise, null
  9619. */
  9620. getShadowMap(): Nullable<RenderTargetTexture>;
  9621. /**
  9622. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9623. * @returns The render target texture if the shadow map is present otherwise, null
  9624. */
  9625. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9626. /**
  9627. * Gets the class name of that object
  9628. * @returns "ShadowGenerator"
  9629. */
  9630. getClassName(): string;
  9631. /**
  9632. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9633. * @param mesh Mesh to add
  9634. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9635. * @returns the Shadow Generator itself
  9636. */
  9637. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9638. /**
  9639. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9640. * @param mesh Mesh to remove
  9641. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9642. * @returns the Shadow Generator itself
  9643. */
  9644. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9645. /**
  9646. * Controls the extent to which the shadows fade out at the edge of the frustum
  9647. * Used only by directionals and spots
  9648. */
  9649. frustumEdgeFalloff: number;
  9650. private _light;
  9651. /**
  9652. * Returns the associated light object.
  9653. * @returns the light generating the shadow
  9654. */
  9655. getLight(): IShadowLight;
  9656. /**
  9657. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9658. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9659. * It might on the other hand introduce peter panning.
  9660. */
  9661. forceBackFacesOnly: boolean;
  9662. private _scene;
  9663. private _lightDirection;
  9664. private _effect;
  9665. private _viewMatrix;
  9666. private _projectionMatrix;
  9667. private _transformMatrix;
  9668. private _cachedPosition;
  9669. private _cachedDirection;
  9670. private _cachedDefines;
  9671. private _currentRenderID;
  9672. private _boxBlurPostprocess;
  9673. private _kernelBlurXPostprocess;
  9674. private _kernelBlurYPostprocess;
  9675. private _blurPostProcesses;
  9676. private _mapSize;
  9677. private _currentFaceIndex;
  9678. private _currentFaceIndexCache;
  9679. private _textureType;
  9680. private _defaultTextureMatrix;
  9681. /** @hidden */
  9682. static _SceneComponentInitialization: (scene: Scene) => void;
  9683. /**
  9684. * Creates a ShadowGenerator object.
  9685. * A ShadowGenerator is the required tool to use the shadows.
  9686. * Each light casting shadows needs to use its own ShadowGenerator.
  9687. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9688. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9689. * @param light The light object generating the shadows.
  9690. * @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.
  9691. */
  9692. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9693. private _initializeGenerator;
  9694. private _initializeShadowMap;
  9695. private _initializeBlurRTTAndPostProcesses;
  9696. private _renderForShadowMap;
  9697. private _renderSubMeshForShadowMap;
  9698. private _applyFilterValues;
  9699. /**
  9700. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9701. * @param onCompiled Callback triggered at the and of the effects compilation
  9702. * @param options Sets of optional options forcing the compilation with different modes
  9703. */
  9704. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9705. useInstances: boolean;
  9706. }>): void;
  9707. /**
  9708. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9709. * @param options Sets of optional options forcing the compilation with different modes
  9710. * @returns A promise that resolves when the compilation completes
  9711. */
  9712. forceCompilationAsync(options?: Partial<{
  9713. useInstances: boolean;
  9714. }>): Promise<void>;
  9715. /**
  9716. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9717. * @param subMesh The submesh we want to render in the shadow map
  9718. * @param useInstances Defines wether will draw in the map using instances
  9719. * @returns true if ready otherwise, false
  9720. */
  9721. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9722. /**
  9723. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9724. * @param defines Defines of the material we want to update
  9725. * @param lightIndex Index of the light in the enabled light list of the material
  9726. */
  9727. prepareDefines(defines: any, lightIndex: number): void;
  9728. /**
  9729. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9730. * defined in the generator but impacting the effect).
  9731. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9732. * @param effect The effect we are binfing the information for
  9733. */
  9734. bindShadowLight(lightIndex: string, effect: Effect): void;
  9735. /**
  9736. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9737. * (eq to shadow prjection matrix * light transform matrix)
  9738. * @returns The transform matrix used to create the shadow map
  9739. */
  9740. getTransformMatrix(): Matrix;
  9741. /**
  9742. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9743. * Cube and 2D textures for instance.
  9744. */
  9745. recreateShadowMap(): void;
  9746. private _disposeBlurPostProcesses;
  9747. private _disposeRTTandPostProcesses;
  9748. /**
  9749. * Disposes the ShadowGenerator.
  9750. * Returns nothing.
  9751. */
  9752. dispose(): void;
  9753. /**
  9754. * Serializes the shadow generator setup to a json object.
  9755. * @returns The serialized JSON object
  9756. */
  9757. serialize(): any;
  9758. /**
  9759. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9760. * @param parsedShadowGenerator The JSON object to parse
  9761. * @param scene The scene to create the shadow map for
  9762. * @returns The parsed shadow generator
  9763. */
  9764. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9765. }
  9766. }
  9767. declare module "babylonjs/Lights/light" {
  9768. import { Nullable } from "babylonjs/types";
  9769. import { Scene } from "babylonjs/scene";
  9770. import { Vector3 } from "babylonjs/Maths/math.vector";
  9771. import { Color3 } from "babylonjs/Maths/math.color";
  9772. import { Node } from "babylonjs/node";
  9773. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9774. import { Effect } from "babylonjs/Materials/effect";
  9775. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9776. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9777. /**
  9778. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9779. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9780. * 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.
  9781. */
  9782. export abstract class Light extends Node {
  9783. /**
  9784. * Falloff Default: light is falling off following the material specification:
  9785. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9786. */
  9787. static readonly FALLOFF_DEFAULT: number;
  9788. /**
  9789. * Falloff Physical: light is falling off following the inverse squared distance law.
  9790. */
  9791. static readonly FALLOFF_PHYSICAL: number;
  9792. /**
  9793. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9794. * to enhance interoperability with other engines.
  9795. */
  9796. static readonly FALLOFF_GLTF: number;
  9797. /**
  9798. * Falloff Standard: light is falling off like in the standard material
  9799. * to enhance interoperability with other materials.
  9800. */
  9801. static readonly FALLOFF_STANDARD: number;
  9802. /**
  9803. * If every light affecting the material is in this lightmapMode,
  9804. * material.lightmapTexture adds or multiplies
  9805. * (depends on material.useLightmapAsShadowmap)
  9806. * after every other light calculations.
  9807. */
  9808. static readonly LIGHTMAP_DEFAULT: number;
  9809. /**
  9810. * material.lightmapTexture as only diffuse lighting from this light
  9811. * adds only specular lighting from this light
  9812. * adds dynamic shadows
  9813. */
  9814. static readonly LIGHTMAP_SPECULAR: number;
  9815. /**
  9816. * material.lightmapTexture as only lighting
  9817. * no light calculation from this light
  9818. * only adds dynamic shadows from this light
  9819. */
  9820. static readonly LIGHTMAP_SHADOWSONLY: number;
  9821. /**
  9822. * Each light type uses the default quantity according to its type:
  9823. * point/spot lights use luminous intensity
  9824. * directional lights use illuminance
  9825. */
  9826. static readonly INTENSITYMODE_AUTOMATIC: number;
  9827. /**
  9828. * lumen (lm)
  9829. */
  9830. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9831. /**
  9832. * candela (lm/sr)
  9833. */
  9834. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9835. /**
  9836. * lux (lm/m^2)
  9837. */
  9838. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9839. /**
  9840. * nit (cd/m^2)
  9841. */
  9842. static readonly INTENSITYMODE_LUMINANCE: number;
  9843. /**
  9844. * Light type const id of the point light.
  9845. */
  9846. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9847. /**
  9848. * Light type const id of the directional light.
  9849. */
  9850. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9851. /**
  9852. * Light type const id of the spot light.
  9853. */
  9854. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9855. /**
  9856. * Light type const id of the hemispheric light.
  9857. */
  9858. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9859. /**
  9860. * Diffuse gives the basic color to an object.
  9861. */
  9862. diffuse: Color3;
  9863. /**
  9864. * Specular produces a highlight color on an object.
  9865. * Note: This is note affecting PBR materials.
  9866. */
  9867. specular: Color3;
  9868. /**
  9869. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9870. * falling off base on range or angle.
  9871. * This can be set to any values in Light.FALLOFF_x.
  9872. *
  9873. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9874. * other types of materials.
  9875. */
  9876. falloffType: number;
  9877. /**
  9878. * Strength of the light.
  9879. * Note: By default it is define in the framework own unit.
  9880. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9881. */
  9882. intensity: number;
  9883. private _range;
  9884. protected _inverseSquaredRange: number;
  9885. /**
  9886. * Defines how far from the source the light is impacting in scene units.
  9887. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9888. */
  9889. /**
  9890. * Defines how far from the source the light is impacting in scene units.
  9891. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9892. */
  9893. range: number;
  9894. /**
  9895. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9896. * of light.
  9897. */
  9898. private _photometricScale;
  9899. private _intensityMode;
  9900. /**
  9901. * Gets the photometric scale used to interpret the intensity.
  9902. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9903. */
  9904. /**
  9905. * Sets the photometric scale used to interpret the intensity.
  9906. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9907. */
  9908. intensityMode: number;
  9909. private _radius;
  9910. /**
  9911. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9912. */
  9913. /**
  9914. * sets the light radius used by PBR Materials to simulate soft area lights.
  9915. */
  9916. radius: number;
  9917. private _renderPriority;
  9918. /**
  9919. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9920. * exceeding the number allowed of the materials.
  9921. */
  9922. renderPriority: number;
  9923. private _shadowEnabled;
  9924. /**
  9925. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9926. * the current shadow generator.
  9927. */
  9928. /**
  9929. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9930. * the current shadow generator.
  9931. */
  9932. shadowEnabled: boolean;
  9933. private _includedOnlyMeshes;
  9934. /**
  9935. * Gets the only meshes impacted by this light.
  9936. */
  9937. /**
  9938. * Sets the only meshes impacted by this light.
  9939. */
  9940. includedOnlyMeshes: AbstractMesh[];
  9941. private _excludedMeshes;
  9942. /**
  9943. * Gets the meshes not impacted by this light.
  9944. */
  9945. /**
  9946. * Sets the meshes not impacted by this light.
  9947. */
  9948. excludedMeshes: AbstractMesh[];
  9949. private _excludeWithLayerMask;
  9950. /**
  9951. * Gets the layer id use to find what meshes are not impacted by the light.
  9952. * Inactive if 0
  9953. */
  9954. /**
  9955. * Sets the layer id use to find what meshes are not impacted by the light.
  9956. * Inactive if 0
  9957. */
  9958. excludeWithLayerMask: number;
  9959. private _includeOnlyWithLayerMask;
  9960. /**
  9961. * Gets the layer id use to find what meshes are impacted by the light.
  9962. * Inactive if 0
  9963. */
  9964. /**
  9965. * Sets the layer id use to find what meshes are impacted by the light.
  9966. * Inactive if 0
  9967. */
  9968. includeOnlyWithLayerMask: number;
  9969. private _lightmapMode;
  9970. /**
  9971. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9972. */
  9973. /**
  9974. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9975. */
  9976. lightmapMode: number;
  9977. /**
  9978. * Shadow generator associted to the light.
  9979. * @hidden Internal use only.
  9980. */
  9981. _shadowGenerator: Nullable<IShadowGenerator>;
  9982. /**
  9983. * @hidden Internal use only.
  9984. */
  9985. _excludedMeshesIds: string[];
  9986. /**
  9987. * @hidden Internal use only.
  9988. */
  9989. _includedOnlyMeshesIds: string[];
  9990. /**
  9991. * The current light unifom buffer.
  9992. * @hidden Internal use only.
  9993. */
  9994. _uniformBuffer: UniformBuffer;
  9995. /**
  9996. * Creates a Light object in the scene.
  9997. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9998. * @param name The firendly name of the light
  9999. * @param scene The scene the light belongs too
  10000. */
  10001. constructor(name: string, scene: Scene);
  10002. protected abstract _buildUniformLayout(): void;
  10003. /**
  10004. * Sets the passed Effect "effect" with the Light information.
  10005. * @param effect The effect to update
  10006. * @param lightIndex The index of the light in the effect to update
  10007. * @returns The light
  10008. */
  10009. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10010. /**
  10011. * Sets the passed Effect "effect" with the Light information.
  10012. * @param effect The effect to update
  10013. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10014. * @returns The light
  10015. */
  10016. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10017. /**
  10018. * Returns the string "Light".
  10019. * @returns the class name
  10020. */
  10021. getClassName(): string;
  10022. /** @hidden */
  10023. readonly _isLight: boolean;
  10024. /**
  10025. * Converts the light information to a readable string for debug purpose.
  10026. * @param fullDetails Supports for multiple levels of logging within scene loading
  10027. * @returns the human readable light info
  10028. */
  10029. toString(fullDetails?: boolean): string;
  10030. /** @hidden */
  10031. protected _syncParentEnabledState(): void;
  10032. /**
  10033. * Set the enabled state of this node.
  10034. * @param value - the new enabled state
  10035. */
  10036. setEnabled(value: boolean): void;
  10037. /**
  10038. * Returns the Light associated shadow generator if any.
  10039. * @return the associated shadow generator.
  10040. */
  10041. getShadowGenerator(): Nullable<IShadowGenerator>;
  10042. /**
  10043. * Returns a Vector3, the absolute light position in the World.
  10044. * @returns the world space position of the light
  10045. */
  10046. getAbsolutePosition(): Vector3;
  10047. /**
  10048. * Specifies if the light will affect the passed mesh.
  10049. * @param mesh The mesh to test against the light
  10050. * @return true the mesh is affected otherwise, false.
  10051. */
  10052. canAffectMesh(mesh: AbstractMesh): boolean;
  10053. /**
  10054. * Sort function to order lights for rendering.
  10055. * @param a First Light object to compare to second.
  10056. * @param b Second Light object to compare first.
  10057. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10058. */
  10059. static CompareLightsPriority(a: Light, b: Light): number;
  10060. /**
  10061. * Releases resources associated with this node.
  10062. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10063. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10064. */
  10065. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10066. /**
  10067. * Returns the light type ID (integer).
  10068. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10069. */
  10070. getTypeID(): number;
  10071. /**
  10072. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10073. * @returns the scaled intensity in intensity mode unit
  10074. */
  10075. getScaledIntensity(): number;
  10076. /**
  10077. * Returns a new Light object, named "name", from the current one.
  10078. * @param name The name of the cloned light
  10079. * @returns the new created light
  10080. */
  10081. clone(name: string): Nullable<Light>;
  10082. /**
  10083. * Serializes the current light into a Serialization object.
  10084. * @returns the serialized object.
  10085. */
  10086. serialize(): any;
  10087. /**
  10088. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10089. * This new light is named "name" and added to the passed scene.
  10090. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10091. * @param name The friendly name of the light
  10092. * @param scene The scene the new light will belong to
  10093. * @returns the constructor function
  10094. */
  10095. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10096. /**
  10097. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10098. * @param parsedLight The JSON representation of the light
  10099. * @param scene The scene to create the parsed light in
  10100. * @returns the created light after parsing
  10101. */
  10102. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10103. private _hookArrayForExcluded;
  10104. private _hookArrayForIncludedOnly;
  10105. private _resyncMeshes;
  10106. /**
  10107. * Forces the meshes to update their light related information in their rendering used effects
  10108. * @hidden Internal Use Only
  10109. */
  10110. _markMeshesAsLightDirty(): void;
  10111. /**
  10112. * Recomputes the cached photometric scale if needed.
  10113. */
  10114. private _computePhotometricScale;
  10115. /**
  10116. * Returns the Photometric Scale according to the light type and intensity mode.
  10117. */
  10118. private _getPhotometricScale;
  10119. /**
  10120. * Reorder the light in the scene according to their defined priority.
  10121. * @hidden Internal Use Only
  10122. */
  10123. _reorderLightsInScene(): void;
  10124. /**
  10125. * Prepares the list of defines specific to the light type.
  10126. * @param defines the list of defines
  10127. * @param lightIndex defines the index of the light for the effect
  10128. */
  10129. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10130. }
  10131. }
  10132. declare module "babylonjs/Actions/action" {
  10133. import { Observable } from "babylonjs/Misc/observable";
  10134. import { Condition } from "babylonjs/Actions/condition";
  10135. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10136. import { ActionManager } from "babylonjs/Actions/actionManager";
  10137. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10138. /**
  10139. * Interface used to define Action
  10140. */
  10141. export interface IAction {
  10142. /**
  10143. * Trigger for the action
  10144. */
  10145. trigger: number;
  10146. /** Options of the trigger */
  10147. triggerOptions: any;
  10148. /**
  10149. * Gets the trigger parameters
  10150. * @returns the trigger parameters
  10151. */
  10152. getTriggerParameter(): any;
  10153. /**
  10154. * Internal only - executes current action event
  10155. * @hidden
  10156. */
  10157. _executeCurrent(evt?: ActionEvent): void;
  10158. /**
  10159. * Serialize placeholder for child classes
  10160. * @param parent of child
  10161. * @returns the serialized object
  10162. */
  10163. serialize(parent: any): any;
  10164. /**
  10165. * Internal only
  10166. * @hidden
  10167. */
  10168. _prepare(): void;
  10169. /**
  10170. * Internal only - manager for action
  10171. * @hidden
  10172. */
  10173. _actionManager: AbstractActionManager;
  10174. /**
  10175. * Adds action to chain of actions, may be a DoNothingAction
  10176. * @param action defines the next action to execute
  10177. * @returns The action passed in
  10178. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10179. */
  10180. then(action: IAction): IAction;
  10181. }
  10182. /**
  10183. * The action to be carried out following a trigger
  10184. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10185. */
  10186. export class Action implements IAction {
  10187. /** the trigger, with or without parameters, for the action */
  10188. triggerOptions: any;
  10189. /**
  10190. * Trigger for the action
  10191. */
  10192. trigger: number;
  10193. /**
  10194. * Internal only - manager for action
  10195. * @hidden
  10196. */
  10197. _actionManager: ActionManager;
  10198. private _nextActiveAction;
  10199. private _child;
  10200. private _condition?;
  10201. private _triggerParameter;
  10202. /**
  10203. * An event triggered prior to action being executed.
  10204. */
  10205. onBeforeExecuteObservable: Observable<Action>;
  10206. /**
  10207. * Creates a new Action
  10208. * @param triggerOptions the trigger, with or without parameters, for the action
  10209. * @param condition an optional determinant of action
  10210. */
  10211. constructor(
  10212. /** the trigger, with or without parameters, for the action */
  10213. triggerOptions: any, condition?: Condition);
  10214. /**
  10215. * Internal only
  10216. * @hidden
  10217. */
  10218. _prepare(): void;
  10219. /**
  10220. * Gets the trigger parameters
  10221. * @returns the trigger parameters
  10222. */
  10223. getTriggerParameter(): any;
  10224. /**
  10225. * Internal only - executes current action event
  10226. * @hidden
  10227. */
  10228. _executeCurrent(evt?: ActionEvent): void;
  10229. /**
  10230. * Execute placeholder for child classes
  10231. * @param evt optional action event
  10232. */
  10233. execute(evt?: ActionEvent): void;
  10234. /**
  10235. * Skips to next active action
  10236. */
  10237. skipToNextActiveAction(): void;
  10238. /**
  10239. * Adds action to chain of actions, may be a DoNothingAction
  10240. * @param action defines the next action to execute
  10241. * @returns The action passed in
  10242. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10243. */
  10244. then(action: Action): Action;
  10245. /**
  10246. * Internal only
  10247. * @hidden
  10248. */
  10249. _getProperty(propertyPath: string): string;
  10250. /**
  10251. * Internal only
  10252. * @hidden
  10253. */
  10254. _getEffectiveTarget(target: any, propertyPath: string): any;
  10255. /**
  10256. * Serialize placeholder for child classes
  10257. * @param parent of child
  10258. * @returns the serialized object
  10259. */
  10260. serialize(parent: any): any;
  10261. /**
  10262. * Internal only called by serialize
  10263. * @hidden
  10264. */
  10265. protected _serialize(serializedAction: any, parent?: any): any;
  10266. /**
  10267. * Internal only
  10268. * @hidden
  10269. */
  10270. static _SerializeValueAsString: (value: any) => string;
  10271. /**
  10272. * Internal only
  10273. * @hidden
  10274. */
  10275. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10276. name: string;
  10277. targetType: string;
  10278. value: string;
  10279. };
  10280. }
  10281. }
  10282. declare module "babylonjs/Actions/condition" {
  10283. import { ActionManager } from "babylonjs/Actions/actionManager";
  10284. /**
  10285. * A Condition applied to an Action
  10286. */
  10287. export class Condition {
  10288. /**
  10289. * Internal only - manager for action
  10290. * @hidden
  10291. */
  10292. _actionManager: ActionManager;
  10293. /**
  10294. * Internal only
  10295. * @hidden
  10296. */
  10297. _evaluationId: number;
  10298. /**
  10299. * Internal only
  10300. * @hidden
  10301. */
  10302. _currentResult: boolean;
  10303. /**
  10304. * Creates a new Condition
  10305. * @param actionManager the manager of the action the condition is applied to
  10306. */
  10307. constructor(actionManager: ActionManager);
  10308. /**
  10309. * Check if the current condition is valid
  10310. * @returns a boolean
  10311. */
  10312. isValid(): boolean;
  10313. /**
  10314. * Internal only
  10315. * @hidden
  10316. */
  10317. _getProperty(propertyPath: string): string;
  10318. /**
  10319. * Internal only
  10320. * @hidden
  10321. */
  10322. _getEffectiveTarget(target: any, propertyPath: string): any;
  10323. /**
  10324. * Serialize placeholder for child classes
  10325. * @returns the serialized object
  10326. */
  10327. serialize(): any;
  10328. /**
  10329. * Internal only
  10330. * @hidden
  10331. */
  10332. protected _serialize(serializedCondition: any): any;
  10333. }
  10334. /**
  10335. * Defines specific conditional operators as extensions of Condition
  10336. */
  10337. export class ValueCondition extends Condition {
  10338. /** path to specify the property of the target the conditional operator uses */
  10339. propertyPath: string;
  10340. /** the value compared by the conditional operator against the current value of the property */
  10341. value: any;
  10342. /** the conditional operator, default ValueCondition.IsEqual */
  10343. operator: number;
  10344. /**
  10345. * Internal only
  10346. * @hidden
  10347. */
  10348. private static _IsEqual;
  10349. /**
  10350. * Internal only
  10351. * @hidden
  10352. */
  10353. private static _IsDifferent;
  10354. /**
  10355. * Internal only
  10356. * @hidden
  10357. */
  10358. private static _IsGreater;
  10359. /**
  10360. * Internal only
  10361. * @hidden
  10362. */
  10363. private static _IsLesser;
  10364. /**
  10365. * returns the number for IsEqual
  10366. */
  10367. static readonly IsEqual: number;
  10368. /**
  10369. * Returns the number for IsDifferent
  10370. */
  10371. static readonly IsDifferent: number;
  10372. /**
  10373. * Returns the number for IsGreater
  10374. */
  10375. static readonly IsGreater: number;
  10376. /**
  10377. * Returns the number for IsLesser
  10378. */
  10379. static readonly IsLesser: number;
  10380. /**
  10381. * Internal only The action manager for the condition
  10382. * @hidden
  10383. */
  10384. _actionManager: ActionManager;
  10385. /**
  10386. * Internal only
  10387. * @hidden
  10388. */
  10389. private _target;
  10390. /**
  10391. * Internal only
  10392. * @hidden
  10393. */
  10394. private _effectiveTarget;
  10395. /**
  10396. * Internal only
  10397. * @hidden
  10398. */
  10399. private _property;
  10400. /**
  10401. * Creates a new ValueCondition
  10402. * @param actionManager manager for the action the condition applies to
  10403. * @param target for the action
  10404. * @param propertyPath path to specify the property of the target the conditional operator uses
  10405. * @param value the value compared by the conditional operator against the current value of the property
  10406. * @param operator the conditional operator, default ValueCondition.IsEqual
  10407. */
  10408. constructor(actionManager: ActionManager, target: any,
  10409. /** path to specify the property of the target the conditional operator uses */
  10410. propertyPath: string,
  10411. /** the value compared by the conditional operator against the current value of the property */
  10412. value: any,
  10413. /** the conditional operator, default ValueCondition.IsEqual */
  10414. operator?: number);
  10415. /**
  10416. * Compares the given value with the property value for the specified conditional operator
  10417. * @returns the result of the comparison
  10418. */
  10419. isValid(): boolean;
  10420. /**
  10421. * Serialize the ValueCondition into a JSON compatible object
  10422. * @returns serialization object
  10423. */
  10424. serialize(): any;
  10425. /**
  10426. * Gets the name of the conditional operator for the ValueCondition
  10427. * @param operator the conditional operator
  10428. * @returns the name
  10429. */
  10430. static GetOperatorName(operator: number): string;
  10431. }
  10432. /**
  10433. * Defines a predicate condition as an extension of Condition
  10434. */
  10435. export class PredicateCondition extends Condition {
  10436. /** defines the predicate function used to validate the condition */
  10437. predicate: () => boolean;
  10438. /**
  10439. * Internal only - manager for action
  10440. * @hidden
  10441. */
  10442. _actionManager: ActionManager;
  10443. /**
  10444. * Creates a new PredicateCondition
  10445. * @param actionManager manager for the action the condition applies to
  10446. * @param predicate defines the predicate function used to validate the condition
  10447. */
  10448. constructor(actionManager: ActionManager,
  10449. /** defines the predicate function used to validate the condition */
  10450. predicate: () => boolean);
  10451. /**
  10452. * @returns the validity of the predicate condition
  10453. */
  10454. isValid(): boolean;
  10455. }
  10456. /**
  10457. * Defines a state condition as an extension of Condition
  10458. */
  10459. export class StateCondition extends Condition {
  10460. /** Value to compare with target state */
  10461. value: string;
  10462. /**
  10463. * Internal only - manager for action
  10464. * @hidden
  10465. */
  10466. _actionManager: ActionManager;
  10467. /**
  10468. * Internal only
  10469. * @hidden
  10470. */
  10471. private _target;
  10472. /**
  10473. * Creates a new StateCondition
  10474. * @param actionManager manager for the action the condition applies to
  10475. * @param target of the condition
  10476. * @param value to compare with target state
  10477. */
  10478. constructor(actionManager: ActionManager, target: any,
  10479. /** Value to compare with target state */
  10480. value: string);
  10481. /**
  10482. * Gets a boolean indicating if the current condition is met
  10483. * @returns the validity of the state
  10484. */
  10485. isValid(): boolean;
  10486. /**
  10487. * Serialize the StateCondition into a JSON compatible object
  10488. * @returns serialization object
  10489. */
  10490. serialize(): any;
  10491. }
  10492. }
  10493. declare module "babylonjs/Actions/directActions" {
  10494. import { Action } from "babylonjs/Actions/action";
  10495. import { Condition } from "babylonjs/Actions/condition";
  10496. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10497. /**
  10498. * This defines an action responsible to toggle a boolean once triggered.
  10499. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10500. */
  10501. export class SwitchBooleanAction extends Action {
  10502. /**
  10503. * The path to the boolean property in the target object
  10504. */
  10505. propertyPath: string;
  10506. private _target;
  10507. private _effectiveTarget;
  10508. private _property;
  10509. /**
  10510. * Instantiate the action
  10511. * @param triggerOptions defines the trigger options
  10512. * @param target defines the object containing the boolean
  10513. * @param propertyPath defines the path to the boolean property in the target object
  10514. * @param condition defines the trigger related conditions
  10515. */
  10516. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10517. /** @hidden */
  10518. _prepare(): void;
  10519. /**
  10520. * Execute the action toggle the boolean value.
  10521. */
  10522. execute(): void;
  10523. /**
  10524. * Serializes the actions and its related information.
  10525. * @param parent defines the object to serialize in
  10526. * @returns the serialized object
  10527. */
  10528. serialize(parent: any): any;
  10529. }
  10530. /**
  10531. * This defines an action responsible to set a the state field of the target
  10532. * to a desired value once triggered.
  10533. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10534. */
  10535. export class SetStateAction extends Action {
  10536. /**
  10537. * The value to store in the state field.
  10538. */
  10539. value: string;
  10540. private _target;
  10541. /**
  10542. * Instantiate the action
  10543. * @param triggerOptions defines the trigger options
  10544. * @param target defines the object containing the state property
  10545. * @param value defines the value to store in the state field
  10546. * @param condition defines the trigger related conditions
  10547. */
  10548. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10549. /**
  10550. * Execute the action and store the value on the target state property.
  10551. */
  10552. execute(): void;
  10553. /**
  10554. * Serializes the actions and its related information.
  10555. * @param parent defines the object to serialize in
  10556. * @returns the serialized object
  10557. */
  10558. serialize(parent: any): any;
  10559. }
  10560. /**
  10561. * This defines an action responsible to set a property of the target
  10562. * to a desired value once triggered.
  10563. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10564. */
  10565. export class SetValueAction extends Action {
  10566. /**
  10567. * The path of the property to set in the target.
  10568. */
  10569. propertyPath: string;
  10570. /**
  10571. * The value to set in the property
  10572. */
  10573. value: any;
  10574. private _target;
  10575. private _effectiveTarget;
  10576. private _property;
  10577. /**
  10578. * Instantiate the action
  10579. * @param triggerOptions defines the trigger options
  10580. * @param target defines the object containing the property
  10581. * @param propertyPath defines the path of the property to set in the target
  10582. * @param value defines the value to set in the property
  10583. * @param condition defines the trigger related conditions
  10584. */
  10585. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10586. /** @hidden */
  10587. _prepare(): void;
  10588. /**
  10589. * Execute the action and set the targetted property to the desired value.
  10590. */
  10591. execute(): void;
  10592. /**
  10593. * Serializes the actions and its related information.
  10594. * @param parent defines the object to serialize in
  10595. * @returns the serialized object
  10596. */
  10597. serialize(parent: any): any;
  10598. }
  10599. /**
  10600. * This defines an action responsible to increment the target value
  10601. * to a desired value once triggered.
  10602. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10603. */
  10604. export class IncrementValueAction extends Action {
  10605. /**
  10606. * The path of the property to increment in the target.
  10607. */
  10608. propertyPath: string;
  10609. /**
  10610. * The value we should increment the property by.
  10611. */
  10612. value: any;
  10613. private _target;
  10614. private _effectiveTarget;
  10615. private _property;
  10616. /**
  10617. * Instantiate the action
  10618. * @param triggerOptions defines the trigger options
  10619. * @param target defines the object containing the property
  10620. * @param propertyPath defines the path of the property to increment in the target
  10621. * @param value defines the value value we should increment the property by
  10622. * @param condition defines the trigger related conditions
  10623. */
  10624. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10625. /** @hidden */
  10626. _prepare(): void;
  10627. /**
  10628. * Execute the action and increment the target of the value amount.
  10629. */
  10630. execute(): void;
  10631. /**
  10632. * Serializes the actions and its related information.
  10633. * @param parent defines the object to serialize in
  10634. * @returns the serialized object
  10635. */
  10636. serialize(parent: any): any;
  10637. }
  10638. /**
  10639. * This defines an action responsible to start an animation once triggered.
  10640. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10641. */
  10642. export class PlayAnimationAction extends Action {
  10643. /**
  10644. * Where the animation should start (animation frame)
  10645. */
  10646. from: number;
  10647. /**
  10648. * Where the animation should stop (animation frame)
  10649. */
  10650. to: number;
  10651. /**
  10652. * Define if the animation should loop or stop after the first play.
  10653. */
  10654. loop?: boolean;
  10655. private _target;
  10656. /**
  10657. * Instantiate the action
  10658. * @param triggerOptions defines the trigger options
  10659. * @param target defines the target animation or animation name
  10660. * @param from defines from where the animation should start (animation frame)
  10661. * @param end defines where the animation should stop (animation frame)
  10662. * @param loop defines if the animation should loop or stop after the first play
  10663. * @param condition defines the trigger related conditions
  10664. */
  10665. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10666. /** @hidden */
  10667. _prepare(): void;
  10668. /**
  10669. * Execute the action and play the animation.
  10670. */
  10671. execute(): void;
  10672. /**
  10673. * Serializes the actions and its related information.
  10674. * @param parent defines the object to serialize in
  10675. * @returns the serialized object
  10676. */
  10677. serialize(parent: any): any;
  10678. }
  10679. /**
  10680. * This defines an action responsible to stop an animation once triggered.
  10681. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10682. */
  10683. export class StopAnimationAction extends Action {
  10684. private _target;
  10685. /**
  10686. * Instantiate the action
  10687. * @param triggerOptions defines the trigger options
  10688. * @param target defines the target animation or animation name
  10689. * @param condition defines the trigger related conditions
  10690. */
  10691. constructor(triggerOptions: any, target: any, condition?: Condition);
  10692. /** @hidden */
  10693. _prepare(): void;
  10694. /**
  10695. * Execute the action and stop the animation.
  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 that does nothing once triggered.
  10707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10708. */
  10709. export class DoNothingAction extends Action {
  10710. /**
  10711. * Instantiate the action
  10712. * @param triggerOptions defines the trigger options
  10713. * @param condition defines the trigger related conditions
  10714. */
  10715. constructor(triggerOptions?: any, condition?: Condition);
  10716. /**
  10717. * Execute the action and do nothing.
  10718. */
  10719. execute(): void;
  10720. /**
  10721. * Serializes the actions and its related information.
  10722. * @param parent defines the object to serialize in
  10723. * @returns the serialized object
  10724. */
  10725. serialize(parent: any): any;
  10726. }
  10727. /**
  10728. * This defines an action responsible to trigger several actions once triggered.
  10729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10730. */
  10731. export class CombineAction extends Action {
  10732. /**
  10733. * The list of aggregated animations to run.
  10734. */
  10735. children: Action[];
  10736. /**
  10737. * Instantiate the action
  10738. * @param triggerOptions defines the trigger options
  10739. * @param children defines the list of aggregated animations to run
  10740. * @param condition defines the trigger related conditions
  10741. */
  10742. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10743. /** @hidden */
  10744. _prepare(): void;
  10745. /**
  10746. * Execute the action and executes all the aggregated actions.
  10747. */
  10748. execute(evt: ActionEvent): void;
  10749. /**
  10750. * Serializes the actions and its related information.
  10751. * @param parent defines the object to serialize in
  10752. * @returns the serialized object
  10753. */
  10754. serialize(parent: any): any;
  10755. }
  10756. /**
  10757. * This defines an action responsible to run code (external event) once triggered.
  10758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10759. */
  10760. export class ExecuteCodeAction extends Action {
  10761. /**
  10762. * The callback function to run.
  10763. */
  10764. func: (evt: ActionEvent) => void;
  10765. /**
  10766. * Instantiate the action
  10767. * @param triggerOptions defines the trigger options
  10768. * @param func defines the callback function to run
  10769. * @param condition defines the trigger related conditions
  10770. */
  10771. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10772. /**
  10773. * Execute the action and run the attached code.
  10774. */
  10775. execute(evt: ActionEvent): void;
  10776. }
  10777. /**
  10778. * This defines an action responsible to set the parent property of the target once triggered.
  10779. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10780. */
  10781. export class SetParentAction extends Action {
  10782. private _parent;
  10783. private _target;
  10784. /**
  10785. * Instantiate the action
  10786. * @param triggerOptions defines the trigger options
  10787. * @param target defines the target containing the parent property
  10788. * @param parent defines from where the animation should start (animation frame)
  10789. * @param condition defines the trigger related conditions
  10790. */
  10791. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10792. /** @hidden */
  10793. _prepare(): void;
  10794. /**
  10795. * Execute the action and set the parent property.
  10796. */
  10797. execute(): void;
  10798. /**
  10799. * Serializes the actions and its related information.
  10800. * @param parent defines the object to serialize in
  10801. * @returns the serialized object
  10802. */
  10803. serialize(parent: any): any;
  10804. }
  10805. }
  10806. declare module "babylonjs/Actions/actionManager" {
  10807. import { Nullable } from "babylonjs/types";
  10808. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10809. import { Scene } from "babylonjs/scene";
  10810. import { IAction } from "babylonjs/Actions/action";
  10811. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10812. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10813. /**
  10814. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10815. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10816. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10817. */
  10818. export class ActionManager extends AbstractActionManager {
  10819. /**
  10820. * Nothing
  10821. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10822. */
  10823. static readonly NothingTrigger: number;
  10824. /**
  10825. * On pick
  10826. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10827. */
  10828. static readonly OnPickTrigger: number;
  10829. /**
  10830. * On left pick
  10831. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10832. */
  10833. static readonly OnLeftPickTrigger: number;
  10834. /**
  10835. * On right pick
  10836. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10837. */
  10838. static readonly OnRightPickTrigger: number;
  10839. /**
  10840. * On center pick
  10841. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10842. */
  10843. static readonly OnCenterPickTrigger: number;
  10844. /**
  10845. * On pick down
  10846. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10847. */
  10848. static readonly OnPickDownTrigger: number;
  10849. /**
  10850. * On double pick
  10851. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10852. */
  10853. static readonly OnDoublePickTrigger: number;
  10854. /**
  10855. * On pick up
  10856. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10857. */
  10858. static readonly OnPickUpTrigger: number;
  10859. /**
  10860. * On pick out.
  10861. * This trigger will only be raised if you also declared a OnPickDown
  10862. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10863. */
  10864. static readonly OnPickOutTrigger: number;
  10865. /**
  10866. * On long press
  10867. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10868. */
  10869. static readonly OnLongPressTrigger: number;
  10870. /**
  10871. * On pointer over
  10872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10873. */
  10874. static readonly OnPointerOverTrigger: number;
  10875. /**
  10876. * On pointer out
  10877. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10878. */
  10879. static readonly OnPointerOutTrigger: number;
  10880. /**
  10881. * On every frame
  10882. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10883. */
  10884. static readonly OnEveryFrameTrigger: number;
  10885. /**
  10886. * On intersection enter
  10887. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10888. */
  10889. static readonly OnIntersectionEnterTrigger: number;
  10890. /**
  10891. * On intersection exit
  10892. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10893. */
  10894. static readonly OnIntersectionExitTrigger: number;
  10895. /**
  10896. * On key down
  10897. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10898. */
  10899. static readonly OnKeyDownTrigger: number;
  10900. /**
  10901. * On key up
  10902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10903. */
  10904. static readonly OnKeyUpTrigger: number;
  10905. private _scene;
  10906. /**
  10907. * Creates a new action manager
  10908. * @param scene defines the hosting scene
  10909. */
  10910. constructor(scene: Scene);
  10911. /**
  10912. * Releases all associated resources
  10913. */
  10914. dispose(): void;
  10915. /**
  10916. * Gets hosting scene
  10917. * @returns the hosting scene
  10918. */
  10919. getScene(): Scene;
  10920. /**
  10921. * Does this action manager handles actions of any of the given triggers
  10922. * @param triggers defines the triggers to be tested
  10923. * @return a boolean indicating whether one (or more) of the triggers is handled
  10924. */
  10925. hasSpecificTriggers(triggers: number[]): boolean;
  10926. /**
  10927. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10928. * speed.
  10929. * @param triggerA defines the trigger to be tested
  10930. * @param triggerB defines the trigger to be tested
  10931. * @return a boolean indicating whether one (or more) of the triggers is handled
  10932. */
  10933. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10934. /**
  10935. * Does this action manager handles actions of a given trigger
  10936. * @param trigger defines the trigger to be tested
  10937. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10938. * @return whether the trigger is handled
  10939. */
  10940. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10941. /**
  10942. * Does this action manager has pointer triggers
  10943. */
  10944. readonly hasPointerTriggers: boolean;
  10945. /**
  10946. * Does this action manager has pick triggers
  10947. */
  10948. readonly hasPickTriggers: boolean;
  10949. /**
  10950. * Registers an action to this action manager
  10951. * @param action defines the action to be registered
  10952. * @return the action amended (prepared) after registration
  10953. */
  10954. registerAction(action: IAction): Nullable<IAction>;
  10955. /**
  10956. * Unregisters an action to this action manager
  10957. * @param action defines the action to be unregistered
  10958. * @return a boolean indicating whether the action has been unregistered
  10959. */
  10960. unregisterAction(action: IAction): Boolean;
  10961. /**
  10962. * Process a specific trigger
  10963. * @param trigger defines the trigger to process
  10964. * @param evt defines the event details to be processed
  10965. */
  10966. processTrigger(trigger: number, evt?: IActionEvent): void;
  10967. /** @hidden */
  10968. _getEffectiveTarget(target: any, propertyPath: string): any;
  10969. /** @hidden */
  10970. _getProperty(propertyPath: string): string;
  10971. /**
  10972. * Serialize this manager to a JSON object
  10973. * @param name defines the property name to store this manager
  10974. * @returns a JSON representation of this manager
  10975. */
  10976. serialize(name: string): any;
  10977. /**
  10978. * Creates a new ActionManager from a JSON data
  10979. * @param parsedActions defines the JSON data to read from
  10980. * @param object defines the hosting mesh
  10981. * @param scene defines the hosting scene
  10982. */
  10983. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10984. /**
  10985. * Get a trigger name by index
  10986. * @param trigger defines the trigger index
  10987. * @returns a trigger name
  10988. */
  10989. static GetTriggerName(trigger: number): string;
  10990. }
  10991. }
  10992. declare module "babylonjs/Culling/ray" {
  10993. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10994. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10995. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10996. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10997. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10998. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10999. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11000. import { Plane } from "babylonjs/Maths/math.plane";
  11001. /**
  11002. * Class representing a ray with position and direction
  11003. */
  11004. export class Ray {
  11005. /** origin point */
  11006. origin: Vector3;
  11007. /** direction */
  11008. direction: Vector3;
  11009. /** length of the ray */
  11010. length: number;
  11011. private static readonly TmpVector3;
  11012. private _tmpRay;
  11013. /**
  11014. * Creates a new ray
  11015. * @param origin origin point
  11016. * @param direction direction
  11017. * @param length length of the ray
  11018. */
  11019. constructor(
  11020. /** origin point */
  11021. origin: Vector3,
  11022. /** direction */
  11023. direction: Vector3,
  11024. /** length of the ray */
  11025. length?: number);
  11026. /**
  11027. * Checks if the ray intersects a box
  11028. * @param minimum bound of the box
  11029. * @param maximum bound of the box
  11030. * @param intersectionTreshold extra extend to be added to the box in all direction
  11031. * @returns if the box was hit
  11032. */
  11033. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11034. /**
  11035. * Checks if the ray intersects a box
  11036. * @param box the bounding box to check
  11037. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11038. * @returns if the box was hit
  11039. */
  11040. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11041. /**
  11042. * If the ray hits a sphere
  11043. * @param sphere the bounding sphere to check
  11044. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11045. * @returns true if it hits the sphere
  11046. */
  11047. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11048. /**
  11049. * If the ray hits a triange
  11050. * @param vertex0 triangle vertex
  11051. * @param vertex1 triangle vertex
  11052. * @param vertex2 triangle vertex
  11053. * @returns intersection information if hit
  11054. */
  11055. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11056. /**
  11057. * Checks if ray intersects a plane
  11058. * @param plane the plane to check
  11059. * @returns the distance away it was hit
  11060. */
  11061. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11062. /**
  11063. * Calculate the intercept of a ray on a given axis
  11064. * @param axis to check 'x' | 'y' | 'z'
  11065. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11066. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11067. */
  11068. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11069. /**
  11070. * Checks if ray intersects a mesh
  11071. * @param mesh the mesh to check
  11072. * @param fastCheck if only the bounding box should checked
  11073. * @returns picking info of the intersecton
  11074. */
  11075. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11076. /**
  11077. * Checks if ray intersects a mesh
  11078. * @param meshes the meshes to check
  11079. * @param fastCheck if only the bounding box should checked
  11080. * @param results array to store result in
  11081. * @returns Array of picking infos
  11082. */
  11083. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11084. private _comparePickingInfo;
  11085. private static smallnum;
  11086. private static rayl;
  11087. /**
  11088. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11089. * @param sega the first point of the segment to test the intersection against
  11090. * @param segb the second point of the segment to test the intersection against
  11091. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11092. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11093. */
  11094. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11095. /**
  11096. * Update the ray from viewport position
  11097. * @param x position
  11098. * @param y y position
  11099. * @param viewportWidth viewport width
  11100. * @param viewportHeight viewport height
  11101. * @param world world matrix
  11102. * @param view view matrix
  11103. * @param projection projection matrix
  11104. * @returns this ray updated
  11105. */
  11106. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11107. /**
  11108. * Creates a ray with origin and direction of 0,0,0
  11109. * @returns the new ray
  11110. */
  11111. static Zero(): Ray;
  11112. /**
  11113. * Creates a new ray from screen space and viewport
  11114. * @param x position
  11115. * @param y y position
  11116. * @param viewportWidth viewport width
  11117. * @param viewportHeight viewport height
  11118. * @param world world matrix
  11119. * @param view view matrix
  11120. * @param projection projection matrix
  11121. * @returns new ray
  11122. */
  11123. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11124. /**
  11125. * 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
  11126. * transformed to the given world matrix.
  11127. * @param origin The origin point
  11128. * @param end The end point
  11129. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11130. * @returns the new ray
  11131. */
  11132. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11133. /**
  11134. * Transforms a ray by a matrix
  11135. * @param ray ray to transform
  11136. * @param matrix matrix to apply
  11137. * @returns the resulting new ray
  11138. */
  11139. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11140. /**
  11141. * Transforms a ray by a matrix
  11142. * @param ray ray to transform
  11143. * @param matrix matrix to apply
  11144. * @param result ray to store result in
  11145. */
  11146. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11147. /**
  11148. * Unproject a ray from screen space to object space
  11149. * @param sourceX defines the screen space x coordinate to use
  11150. * @param sourceY defines the screen space y coordinate to use
  11151. * @param viewportWidth defines the current width of the viewport
  11152. * @param viewportHeight defines the current height of the viewport
  11153. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11154. * @param view defines the view matrix to use
  11155. * @param projection defines the projection matrix to use
  11156. */
  11157. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11158. }
  11159. /**
  11160. * Type used to define predicate used to select faces when a mesh intersection is detected
  11161. */
  11162. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11163. module "babylonjs/scene" {
  11164. interface Scene {
  11165. /** @hidden */
  11166. _tempPickingRay: Nullable<Ray>;
  11167. /** @hidden */
  11168. _cachedRayForTransform: Ray;
  11169. /** @hidden */
  11170. _pickWithRayInverseMatrix: Matrix;
  11171. /** @hidden */
  11172. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11173. /** @hidden */
  11174. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11175. }
  11176. }
  11177. }
  11178. declare module "babylonjs/sceneComponent" {
  11179. import { Scene } from "babylonjs/scene";
  11180. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11181. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11182. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11183. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11184. import { Nullable } from "babylonjs/types";
  11185. import { Camera } from "babylonjs/Cameras/camera";
  11186. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11187. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11188. import { AbstractScene } from "babylonjs/abstractScene";
  11189. /**
  11190. * Groups all the scene component constants in one place to ease maintenance.
  11191. * @hidden
  11192. */
  11193. export class SceneComponentConstants {
  11194. static readonly NAME_EFFECTLAYER: string;
  11195. static readonly NAME_LAYER: string;
  11196. static readonly NAME_LENSFLARESYSTEM: string;
  11197. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11198. static readonly NAME_PARTICLESYSTEM: string;
  11199. static readonly NAME_GAMEPAD: string;
  11200. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11201. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11202. static readonly NAME_DEPTHRENDERER: string;
  11203. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11204. static readonly NAME_SPRITE: string;
  11205. static readonly NAME_OUTLINERENDERER: string;
  11206. static readonly NAME_PROCEDURALTEXTURE: string;
  11207. static readonly NAME_SHADOWGENERATOR: string;
  11208. static readonly NAME_OCTREE: string;
  11209. static readonly NAME_PHYSICSENGINE: string;
  11210. static readonly NAME_AUDIO: string;
  11211. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11212. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11213. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11214. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11215. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11216. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11217. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11218. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11219. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11220. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11221. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11222. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11223. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11224. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11225. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11226. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11227. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11228. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11229. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11230. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11231. static readonly STEP_AFTERRENDER_AUDIO: number;
  11232. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11233. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11234. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11235. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11236. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11237. static readonly STEP_POINTERMOVE_SPRITE: number;
  11238. static readonly STEP_POINTERDOWN_SPRITE: number;
  11239. static readonly STEP_POINTERUP_SPRITE: number;
  11240. }
  11241. /**
  11242. * This represents a scene component.
  11243. *
  11244. * This is used to decouple the dependency the scene is having on the different workloads like
  11245. * layers, post processes...
  11246. */
  11247. export interface ISceneComponent {
  11248. /**
  11249. * The name of the component. Each component must have a unique name.
  11250. */
  11251. name: string;
  11252. /**
  11253. * The scene the component belongs to.
  11254. */
  11255. scene: Scene;
  11256. /**
  11257. * Register the component to one instance of a scene.
  11258. */
  11259. register(): void;
  11260. /**
  11261. * Rebuilds the elements related to this component in case of
  11262. * context lost for instance.
  11263. */
  11264. rebuild(): void;
  11265. /**
  11266. * Disposes the component and the associated ressources.
  11267. */
  11268. dispose(): void;
  11269. }
  11270. /**
  11271. * This represents a SERIALIZABLE scene component.
  11272. *
  11273. * This extends Scene Component to add Serialization methods on top.
  11274. */
  11275. export interface ISceneSerializableComponent extends ISceneComponent {
  11276. /**
  11277. * Adds all the elements from the container to the scene
  11278. * @param container the container holding the elements
  11279. */
  11280. addFromContainer(container: AbstractScene): void;
  11281. /**
  11282. * Removes all the elements in the container from the scene
  11283. * @param container contains the elements to remove
  11284. * @param dispose if the removed element should be disposed (default: false)
  11285. */
  11286. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11287. /**
  11288. * Serializes the component data to the specified json object
  11289. * @param serializationObject The object to serialize to
  11290. */
  11291. serialize(serializationObject: any): void;
  11292. }
  11293. /**
  11294. * Strong typing of a Mesh related stage step action
  11295. */
  11296. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11297. /**
  11298. * Strong typing of a Evaluate Sub Mesh related stage step action
  11299. */
  11300. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11301. /**
  11302. * Strong typing of a Active Mesh related stage step action
  11303. */
  11304. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11305. /**
  11306. * Strong typing of a Camera related stage step action
  11307. */
  11308. export type CameraStageAction = (camera: Camera) => void;
  11309. /**
  11310. * Strong typing of a Camera Frame buffer related stage step action
  11311. */
  11312. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11313. /**
  11314. * Strong typing of a Render Target related stage step action
  11315. */
  11316. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11317. /**
  11318. * Strong typing of a RenderingGroup related stage step action
  11319. */
  11320. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11321. /**
  11322. * Strong typing of a Mesh Render related stage step action
  11323. */
  11324. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11325. /**
  11326. * Strong typing of a simple stage step action
  11327. */
  11328. export type SimpleStageAction = () => void;
  11329. /**
  11330. * Strong typing of a render target action.
  11331. */
  11332. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11333. /**
  11334. * Strong typing of a pointer move action.
  11335. */
  11336. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11337. /**
  11338. * Strong typing of a pointer up/down action.
  11339. */
  11340. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11341. /**
  11342. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11343. * @hidden
  11344. */
  11345. export class Stage<T extends Function> extends Array<{
  11346. index: number;
  11347. component: ISceneComponent;
  11348. action: T;
  11349. }> {
  11350. /**
  11351. * Hide ctor from the rest of the world.
  11352. * @param items The items to add.
  11353. */
  11354. private constructor();
  11355. /**
  11356. * Creates a new Stage.
  11357. * @returns A new instance of a Stage
  11358. */
  11359. static Create<T extends Function>(): Stage<T>;
  11360. /**
  11361. * Registers a step in an ordered way in the targeted stage.
  11362. * @param index Defines the position to register the step in
  11363. * @param component Defines the component attached to the step
  11364. * @param action Defines the action to launch during the step
  11365. */
  11366. registerStep(index: number, component: ISceneComponent, action: T): void;
  11367. /**
  11368. * Clears all the steps from the stage.
  11369. */
  11370. clear(): void;
  11371. }
  11372. }
  11373. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11374. import { Nullable } from "babylonjs/types";
  11375. import { Observable } from "babylonjs/Misc/observable";
  11376. import { Scene } from "babylonjs/scene";
  11377. import { Sprite } from "babylonjs/Sprites/sprite";
  11378. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11379. import { Ray } from "babylonjs/Culling/ray";
  11380. import { Camera } from "babylonjs/Cameras/camera";
  11381. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11382. import { ISceneComponent } from "babylonjs/sceneComponent";
  11383. module "babylonjs/scene" {
  11384. interface Scene {
  11385. /** @hidden */
  11386. _pointerOverSprite: Nullable<Sprite>;
  11387. /** @hidden */
  11388. _pickedDownSprite: Nullable<Sprite>;
  11389. /** @hidden */
  11390. _tempSpritePickingRay: Nullable<Ray>;
  11391. /**
  11392. * All of the sprite managers added to this scene
  11393. * @see http://doc.babylonjs.com/babylon101/sprites
  11394. */
  11395. spriteManagers: Array<ISpriteManager>;
  11396. /**
  11397. * An event triggered when sprites rendering is about to start
  11398. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11399. */
  11400. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11401. /**
  11402. * An event triggered when sprites rendering is done
  11403. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11404. */
  11405. onAfterSpritesRenderingObservable: Observable<Scene>;
  11406. /** @hidden */
  11407. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11408. /** Launch a ray to try to pick a sprite in the scene
  11409. * @param x position on screen
  11410. * @param y position on screen
  11411. * @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
  11412. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11413. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11414. * @returns a PickingInfo
  11415. */
  11416. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11417. /** Use the given ray to pick a sprite in the scene
  11418. * @param ray The ray (in world space) to use to pick meshes
  11419. * @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
  11420. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11421. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11422. * @returns a PickingInfo
  11423. */
  11424. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11425. /** @hidden */
  11426. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11427. /** Launch a ray to try to pick sprites in the scene
  11428. * @param x position on screen
  11429. * @param y position on screen
  11430. * @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
  11431. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11432. * @returns a PickingInfo array
  11433. */
  11434. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11435. /** Use the given ray to pick sprites in the scene
  11436. * @param ray The ray (in world space) to use to pick meshes
  11437. * @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
  11438. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11439. * @returns a PickingInfo array
  11440. */
  11441. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11442. /**
  11443. * Force the sprite under the pointer
  11444. * @param sprite defines the sprite to use
  11445. */
  11446. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11447. /**
  11448. * Gets the sprite under the pointer
  11449. * @returns a Sprite or null if no sprite is under the pointer
  11450. */
  11451. getPointerOverSprite(): Nullable<Sprite>;
  11452. }
  11453. }
  11454. /**
  11455. * Defines the sprite scene component responsible to manage sprites
  11456. * in a given scene.
  11457. */
  11458. export class SpriteSceneComponent implements ISceneComponent {
  11459. /**
  11460. * The component name helpfull to identify the component in the list of scene components.
  11461. */
  11462. readonly name: string;
  11463. /**
  11464. * The scene the component belongs to.
  11465. */
  11466. scene: Scene;
  11467. /** @hidden */
  11468. private _spritePredicate;
  11469. /**
  11470. * Creates a new instance of the component for the given scene
  11471. * @param scene Defines the scene to register the component in
  11472. */
  11473. constructor(scene: Scene);
  11474. /**
  11475. * Registers the component in a given scene
  11476. */
  11477. register(): void;
  11478. /**
  11479. * Rebuilds the elements related to this component in case of
  11480. * context lost for instance.
  11481. */
  11482. rebuild(): void;
  11483. /**
  11484. * Disposes the component and the associated ressources.
  11485. */
  11486. dispose(): void;
  11487. private _pickSpriteButKeepRay;
  11488. private _pointerMove;
  11489. private _pointerDown;
  11490. private _pointerUp;
  11491. }
  11492. }
  11493. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11494. /** @hidden */
  11495. export var fogFragmentDeclaration: {
  11496. name: string;
  11497. shader: string;
  11498. };
  11499. }
  11500. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11501. /** @hidden */
  11502. export var fogFragment: {
  11503. name: string;
  11504. shader: string;
  11505. };
  11506. }
  11507. declare module "babylonjs/Shaders/sprites.fragment" {
  11508. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11509. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11510. /** @hidden */
  11511. export var spritesPixelShader: {
  11512. name: string;
  11513. shader: string;
  11514. };
  11515. }
  11516. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11517. /** @hidden */
  11518. export var fogVertexDeclaration: {
  11519. name: string;
  11520. shader: string;
  11521. };
  11522. }
  11523. declare module "babylonjs/Shaders/sprites.vertex" {
  11524. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11525. /** @hidden */
  11526. export var spritesVertexShader: {
  11527. name: string;
  11528. shader: string;
  11529. };
  11530. }
  11531. declare module "babylonjs/Sprites/spriteManager" {
  11532. import { IDisposable, Scene } from "babylonjs/scene";
  11533. import { Nullable } from "babylonjs/types";
  11534. import { Observable } from "babylonjs/Misc/observable";
  11535. import { Sprite } from "babylonjs/Sprites/sprite";
  11536. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11537. import { Camera } from "babylonjs/Cameras/camera";
  11538. import { Texture } from "babylonjs/Materials/Textures/texture";
  11539. import "babylonjs/Shaders/sprites.fragment";
  11540. import "babylonjs/Shaders/sprites.vertex";
  11541. import { Ray } from "babylonjs/Culling/ray";
  11542. /**
  11543. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11544. */
  11545. export interface ISpriteManager extends IDisposable {
  11546. /**
  11547. * Restricts the camera to viewing objects with the same layerMask.
  11548. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11549. */
  11550. layerMask: number;
  11551. /**
  11552. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11553. */
  11554. isPickable: boolean;
  11555. /**
  11556. * Specifies the rendering group id for this mesh (0 by default)
  11557. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11558. */
  11559. renderingGroupId: number;
  11560. /**
  11561. * Defines the list of sprites managed by the manager.
  11562. */
  11563. sprites: Array<Sprite>;
  11564. /**
  11565. * Tests the intersection of a sprite with a specific ray.
  11566. * @param ray The ray we are sending to test the collision
  11567. * @param camera The camera space we are sending rays in
  11568. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11569. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11570. * @returns picking info or null.
  11571. */
  11572. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11573. /**
  11574. * Intersects the sprites with a ray
  11575. * @param ray defines the ray to intersect with
  11576. * @param camera defines the current active camera
  11577. * @param predicate defines a predicate used to select candidate sprites
  11578. * @returns null if no hit or a PickingInfo array
  11579. */
  11580. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11581. /**
  11582. * Renders the list of sprites on screen.
  11583. */
  11584. render(): void;
  11585. }
  11586. /**
  11587. * Class used to manage multiple sprites on the same spritesheet
  11588. * @see http://doc.babylonjs.com/babylon101/sprites
  11589. */
  11590. export class SpriteManager implements ISpriteManager {
  11591. /** defines the manager's name */
  11592. name: string;
  11593. /** Gets the list of sprites */
  11594. sprites: Sprite[];
  11595. /** Gets or sets the rendering group id (0 by default) */
  11596. renderingGroupId: number;
  11597. /** Gets or sets camera layer mask */
  11598. layerMask: number;
  11599. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11600. fogEnabled: boolean;
  11601. /** Gets or sets a boolean indicating if the sprites are pickable */
  11602. isPickable: boolean;
  11603. /** Defines the default width of a cell in the spritesheet */
  11604. cellWidth: number;
  11605. /** Defines the default height of a cell in the spritesheet */
  11606. cellHeight: number;
  11607. /** Associative array from JSON sprite data file */
  11608. private _cellData;
  11609. /** Array of sprite names from JSON sprite data file */
  11610. private _spriteMap;
  11611. /** True when packed cell data from JSON file is ready*/
  11612. private _packedAndReady;
  11613. /**
  11614. * An event triggered when the manager is disposed.
  11615. */
  11616. onDisposeObservable: Observable<SpriteManager>;
  11617. private _onDisposeObserver;
  11618. /**
  11619. * Callback called when the manager is disposed
  11620. */
  11621. onDispose: () => void;
  11622. private _capacity;
  11623. private _fromPacked;
  11624. private _spriteTexture;
  11625. private _epsilon;
  11626. private _scene;
  11627. private _vertexData;
  11628. private _buffer;
  11629. private _vertexBuffers;
  11630. private _indexBuffer;
  11631. private _effectBase;
  11632. private _effectFog;
  11633. /**
  11634. * Gets or sets the spritesheet texture
  11635. */
  11636. texture: Texture;
  11637. /**
  11638. * Creates a new sprite manager
  11639. * @param name defines the manager's name
  11640. * @param imgUrl defines the sprite sheet url
  11641. * @param capacity defines the maximum allowed number of sprites
  11642. * @param cellSize defines the size of a sprite cell
  11643. * @param scene defines the hosting scene
  11644. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11645. * @param samplingMode defines the smapling mode to use with spritesheet
  11646. * @param fromPacked set to false; do not alter
  11647. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11648. */
  11649. constructor(
  11650. /** defines the manager's name */
  11651. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11652. private _makePacked;
  11653. private _appendSpriteVertex;
  11654. /**
  11655. * Intersects the sprites with a ray
  11656. * @param ray defines the ray to intersect with
  11657. * @param camera defines the current active camera
  11658. * @param predicate defines a predicate used to select candidate sprites
  11659. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11660. * @returns null if no hit or a PickingInfo
  11661. */
  11662. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11663. /**
  11664. * Intersects the sprites with a ray
  11665. * @param ray defines the ray to intersect with
  11666. * @param camera defines the current active camera
  11667. * @param predicate defines a predicate used to select candidate sprites
  11668. * @returns null if no hit or a PickingInfo array
  11669. */
  11670. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11671. /**
  11672. * Render all child sprites
  11673. */
  11674. render(): void;
  11675. /**
  11676. * Release associated resources
  11677. */
  11678. dispose(): void;
  11679. }
  11680. }
  11681. declare module "babylonjs/Sprites/sprite" {
  11682. import { Vector3 } from "babylonjs/Maths/math.vector";
  11683. import { Nullable } from "babylonjs/types";
  11684. import { ActionManager } from "babylonjs/Actions/actionManager";
  11685. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11686. import { Color4 } from "babylonjs/Maths/math.color";
  11687. /**
  11688. * Class used to represent a sprite
  11689. * @see http://doc.babylonjs.com/babylon101/sprites
  11690. */
  11691. export class Sprite {
  11692. /** defines the name */
  11693. name: string;
  11694. /** Gets or sets the current world position */
  11695. position: Vector3;
  11696. /** Gets or sets the main color */
  11697. color: Color4;
  11698. /** Gets or sets the width */
  11699. width: number;
  11700. /** Gets or sets the height */
  11701. height: number;
  11702. /** Gets or sets rotation angle */
  11703. angle: number;
  11704. /** Gets or sets the cell index in the sprite sheet */
  11705. cellIndex: number;
  11706. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11707. cellRef: string;
  11708. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11709. invertU: number;
  11710. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11711. invertV: number;
  11712. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11713. disposeWhenFinishedAnimating: boolean;
  11714. /** Gets the list of attached animations */
  11715. animations: Animation[];
  11716. /** Gets or sets a boolean indicating if the sprite can be picked */
  11717. isPickable: boolean;
  11718. /**
  11719. * Gets or sets the associated action manager
  11720. */
  11721. actionManager: Nullable<ActionManager>;
  11722. private _animationStarted;
  11723. private _loopAnimation;
  11724. private _fromIndex;
  11725. private _toIndex;
  11726. private _delay;
  11727. private _direction;
  11728. private _manager;
  11729. private _time;
  11730. private _onAnimationEnd;
  11731. /**
  11732. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11733. */
  11734. isVisible: boolean;
  11735. /**
  11736. * Gets or sets the sprite size
  11737. */
  11738. size: number;
  11739. /**
  11740. * Creates a new Sprite
  11741. * @param name defines the name
  11742. * @param manager defines the manager
  11743. */
  11744. constructor(
  11745. /** defines the name */
  11746. name: string, manager: ISpriteManager);
  11747. /**
  11748. * Starts an animation
  11749. * @param from defines the initial key
  11750. * @param to defines the end key
  11751. * @param loop defines if the animation must loop
  11752. * @param delay defines the start delay (in ms)
  11753. * @param onAnimationEnd defines a callback to call when animation ends
  11754. */
  11755. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11756. /** Stops current animation (if any) */
  11757. stopAnimation(): void;
  11758. /** @hidden */
  11759. _animate(deltaTime: number): void;
  11760. /** Release associated resources */
  11761. dispose(): void;
  11762. }
  11763. }
  11764. declare module "babylonjs/Collisions/pickingInfo" {
  11765. import { Nullable } from "babylonjs/types";
  11766. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11767. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11768. import { Sprite } from "babylonjs/Sprites/sprite";
  11769. import { Ray } from "babylonjs/Culling/ray";
  11770. /**
  11771. * Information about the result of picking within a scene
  11772. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11773. */
  11774. export class PickingInfo {
  11775. /** @hidden */
  11776. _pickingUnavailable: boolean;
  11777. /**
  11778. * If the pick collided with an object
  11779. */
  11780. hit: boolean;
  11781. /**
  11782. * Distance away where the pick collided
  11783. */
  11784. distance: number;
  11785. /**
  11786. * The location of pick collision
  11787. */
  11788. pickedPoint: Nullable<Vector3>;
  11789. /**
  11790. * The mesh corresponding the the pick collision
  11791. */
  11792. pickedMesh: Nullable<AbstractMesh>;
  11793. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11794. bu: number;
  11795. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11796. bv: number;
  11797. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11798. faceId: number;
  11799. /** Id of the the submesh that was picked */
  11800. subMeshId: number;
  11801. /** If a sprite was picked, this will be the sprite the pick collided with */
  11802. pickedSprite: Nullable<Sprite>;
  11803. /**
  11804. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11805. */
  11806. originMesh: Nullable<AbstractMesh>;
  11807. /**
  11808. * The ray that was used to perform the picking.
  11809. */
  11810. ray: Nullable<Ray>;
  11811. /**
  11812. * Gets the normal correspodning to the face the pick collided with
  11813. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11814. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11815. * @returns The normal correspodning to the face the pick collided with
  11816. */
  11817. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11818. /**
  11819. * Gets the texture coordinates of where the pick occured
  11820. * @returns the vector containing the coordnates of the texture
  11821. */
  11822. getTextureCoordinates(): Nullable<Vector2>;
  11823. }
  11824. }
  11825. declare module "babylonjs/Events/pointerEvents" {
  11826. import { Nullable } from "babylonjs/types";
  11827. import { Vector2 } from "babylonjs/Maths/math.vector";
  11828. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11829. import { Ray } from "babylonjs/Culling/ray";
  11830. /**
  11831. * Gather the list of pointer event types as constants.
  11832. */
  11833. export class PointerEventTypes {
  11834. /**
  11835. * 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.
  11836. */
  11837. static readonly POINTERDOWN: number;
  11838. /**
  11839. * The pointerup event is fired when a pointer is no longer active.
  11840. */
  11841. static readonly POINTERUP: number;
  11842. /**
  11843. * The pointermove event is fired when a pointer changes coordinates.
  11844. */
  11845. static readonly POINTERMOVE: number;
  11846. /**
  11847. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11848. */
  11849. static readonly POINTERWHEEL: number;
  11850. /**
  11851. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11852. */
  11853. static readonly POINTERPICK: number;
  11854. /**
  11855. * The pointertap event is fired when a the object has been touched and released without drag.
  11856. */
  11857. static readonly POINTERTAP: number;
  11858. /**
  11859. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11860. */
  11861. static readonly POINTERDOUBLETAP: number;
  11862. }
  11863. /**
  11864. * Base class of pointer info types.
  11865. */
  11866. export class PointerInfoBase {
  11867. /**
  11868. * Defines the type of event (PointerEventTypes)
  11869. */
  11870. type: number;
  11871. /**
  11872. * Defines the related dom event
  11873. */
  11874. event: PointerEvent | MouseWheelEvent;
  11875. /**
  11876. * Instantiates the base class of pointers info.
  11877. * @param type Defines the type of event (PointerEventTypes)
  11878. * @param event Defines the related dom event
  11879. */
  11880. constructor(
  11881. /**
  11882. * Defines the type of event (PointerEventTypes)
  11883. */
  11884. type: number,
  11885. /**
  11886. * Defines the related dom event
  11887. */
  11888. event: PointerEvent | MouseWheelEvent);
  11889. }
  11890. /**
  11891. * This class is used to store pointer related info for the onPrePointerObservable event.
  11892. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11893. */
  11894. export class PointerInfoPre extends PointerInfoBase {
  11895. /**
  11896. * Ray from a pointer if availible (eg. 6dof controller)
  11897. */
  11898. ray: Nullable<Ray>;
  11899. /**
  11900. * Defines the local position of the pointer on the canvas.
  11901. */
  11902. localPosition: Vector2;
  11903. /**
  11904. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11905. */
  11906. skipOnPointerObservable: boolean;
  11907. /**
  11908. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11909. * @param type Defines the type of event (PointerEventTypes)
  11910. * @param event Defines the related dom event
  11911. * @param localX Defines the local x coordinates of the pointer when the event occured
  11912. * @param localY Defines the local y coordinates of the pointer when the event occured
  11913. */
  11914. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11915. }
  11916. /**
  11917. * This type contains all the data related to a pointer event in Babylon.js.
  11918. * 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.
  11919. */
  11920. export class PointerInfo extends PointerInfoBase {
  11921. /**
  11922. * Defines the picking info associated to the info (if any)\
  11923. */
  11924. pickInfo: Nullable<PickingInfo>;
  11925. /**
  11926. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11927. * @param type Defines the type of event (PointerEventTypes)
  11928. * @param event Defines the related dom event
  11929. * @param pickInfo Defines the picking info associated to the info (if any)\
  11930. */
  11931. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11932. /**
  11933. * Defines the picking info associated to the info (if any)\
  11934. */
  11935. pickInfo: Nullable<PickingInfo>);
  11936. }
  11937. /**
  11938. * Data relating to a touch event on the screen.
  11939. */
  11940. export interface PointerTouch {
  11941. /**
  11942. * X coordinate of touch.
  11943. */
  11944. x: number;
  11945. /**
  11946. * Y coordinate of touch.
  11947. */
  11948. y: number;
  11949. /**
  11950. * Id of touch. Unique for each finger.
  11951. */
  11952. pointerId: number;
  11953. /**
  11954. * Event type passed from DOM.
  11955. */
  11956. type: any;
  11957. }
  11958. }
  11959. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  11960. import { Observable } from "babylonjs/Misc/observable";
  11961. import { Nullable } from "babylonjs/types";
  11962. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  11963. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11964. /**
  11965. * Manage the mouse inputs to control the movement of a free camera.
  11966. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11967. */
  11968. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11969. /**
  11970. * Define if touch is enabled in the mouse input
  11971. */
  11972. touchEnabled: boolean;
  11973. /**
  11974. * Defines the camera the input is attached to.
  11975. */
  11976. camera: FreeCamera;
  11977. /**
  11978. * Defines the buttons associated with the input to handle camera move.
  11979. */
  11980. buttons: number[];
  11981. /**
  11982. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11983. */
  11984. angularSensibility: number;
  11985. private _pointerInput;
  11986. private _onMouseMove;
  11987. private _observer;
  11988. private previousPosition;
  11989. /**
  11990. * Observable for when a pointer move event occurs containing the move offset
  11991. */
  11992. onPointerMovedObservable: Observable<{
  11993. offsetX: number;
  11994. offsetY: number;
  11995. }>;
  11996. /**
  11997. * @hidden
  11998. * If the camera should be rotated automatically based on pointer movement
  11999. */
  12000. _allowCameraRotation: boolean;
  12001. /**
  12002. * Manage the mouse inputs to control the movement of a free camera.
  12003. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12004. * @param touchEnabled Defines if touch is enabled or not
  12005. */
  12006. constructor(
  12007. /**
  12008. * Define if touch is enabled in the mouse input
  12009. */
  12010. touchEnabled?: boolean);
  12011. /**
  12012. * Attach the input controls to a specific dom element to get the input from.
  12013. * @param element Defines the element the controls should be listened from
  12014. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12015. */
  12016. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12017. /**
  12018. * Called on JS contextmenu event.
  12019. * Override this method to provide functionality.
  12020. */
  12021. protected onContextMenu(evt: PointerEvent): void;
  12022. /**
  12023. * Detach the current controls from the specified dom element.
  12024. * @param element Defines the element to stop listening the inputs from
  12025. */
  12026. detachControl(element: Nullable<HTMLElement>): void;
  12027. /**
  12028. * Gets the class name of the current intput.
  12029. * @returns the class name
  12030. */
  12031. getClassName(): string;
  12032. /**
  12033. * Get the friendly name associated with the input class.
  12034. * @returns the input friendly name
  12035. */
  12036. getSimpleName(): string;
  12037. }
  12038. }
  12039. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12040. import { Nullable } from "babylonjs/types";
  12041. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12042. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12043. /**
  12044. * Manage the touch inputs to control the movement of a free camera.
  12045. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12046. */
  12047. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12048. /**
  12049. * Defines the camera the input is attached to.
  12050. */
  12051. camera: FreeCamera;
  12052. /**
  12053. * Defines the touch sensibility for rotation.
  12054. * The higher the faster.
  12055. */
  12056. touchAngularSensibility: number;
  12057. /**
  12058. * Defines the touch sensibility for move.
  12059. * The higher the faster.
  12060. */
  12061. touchMoveSensibility: number;
  12062. private _offsetX;
  12063. private _offsetY;
  12064. private _pointerPressed;
  12065. private _pointerInput;
  12066. private _observer;
  12067. private _onLostFocus;
  12068. /**
  12069. * Attach the input controls to a specific dom element to get the input from.
  12070. * @param element Defines the element the controls should be listened from
  12071. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12072. */
  12073. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12074. /**
  12075. * Detach the current controls from the specified dom element.
  12076. * @param element Defines the element to stop listening the inputs from
  12077. */
  12078. detachControl(element: Nullable<HTMLElement>): void;
  12079. /**
  12080. * Update the current camera state depending on the inputs that have been used this frame.
  12081. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12082. */
  12083. checkInputs(): void;
  12084. /**
  12085. * Gets the class name of the current intput.
  12086. * @returns the class name
  12087. */
  12088. getClassName(): string;
  12089. /**
  12090. * Get the friendly name associated with the input class.
  12091. * @returns the input friendly name
  12092. */
  12093. getSimpleName(): string;
  12094. }
  12095. }
  12096. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12097. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12098. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12099. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12100. import { Nullable } from "babylonjs/types";
  12101. /**
  12102. * Default Inputs manager for the FreeCamera.
  12103. * It groups all the default supported inputs for ease of use.
  12104. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12105. */
  12106. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12107. /**
  12108. * @hidden
  12109. */
  12110. _mouseInput: Nullable<FreeCameraMouseInput>;
  12111. /**
  12112. * Instantiates a new FreeCameraInputsManager.
  12113. * @param camera Defines the camera the inputs belong to
  12114. */
  12115. constructor(camera: FreeCamera);
  12116. /**
  12117. * Add keyboard input support to the input manager.
  12118. * @returns the current input manager
  12119. */
  12120. addKeyboard(): FreeCameraInputsManager;
  12121. /**
  12122. * Add mouse input support to the input manager.
  12123. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12124. * @returns the current input manager
  12125. */
  12126. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12127. /**
  12128. * Removes the mouse input support from the manager
  12129. * @returns the current input manager
  12130. */
  12131. removeMouse(): FreeCameraInputsManager;
  12132. /**
  12133. * Add touch input support to the input manager.
  12134. * @returns the current input manager
  12135. */
  12136. addTouch(): FreeCameraInputsManager;
  12137. /**
  12138. * Remove all attached input methods from a camera
  12139. */
  12140. clear(): void;
  12141. }
  12142. }
  12143. declare module "babylonjs/Cameras/freeCamera" {
  12144. import { Vector3 } from "babylonjs/Maths/math.vector";
  12145. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12146. import { Scene } from "babylonjs/scene";
  12147. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12148. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12149. /**
  12150. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12151. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12152. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12153. */
  12154. export class FreeCamera extends TargetCamera {
  12155. /**
  12156. * Define the collision ellipsoid of the camera.
  12157. * This is helpful to simulate a camera body like the player body around the camera
  12158. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12159. */
  12160. ellipsoid: Vector3;
  12161. /**
  12162. * Define an offset for the position of the ellipsoid around the camera.
  12163. * This can be helpful to determine the center of the body near the gravity center of the body
  12164. * instead of its head.
  12165. */
  12166. ellipsoidOffset: Vector3;
  12167. /**
  12168. * Enable or disable collisions of the camera with the rest of the scene objects.
  12169. */
  12170. checkCollisions: boolean;
  12171. /**
  12172. * Enable or disable gravity on the camera.
  12173. */
  12174. applyGravity: boolean;
  12175. /**
  12176. * Define the input manager associated to the camera.
  12177. */
  12178. inputs: FreeCameraInputsManager;
  12179. /**
  12180. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12181. * Higher values reduce sensitivity.
  12182. */
  12183. /**
  12184. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12185. * Higher values reduce sensitivity.
  12186. */
  12187. angularSensibility: number;
  12188. /**
  12189. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12190. */
  12191. keysUp: number[];
  12192. /**
  12193. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12194. */
  12195. keysDown: number[];
  12196. /**
  12197. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12198. */
  12199. keysLeft: number[];
  12200. /**
  12201. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12202. */
  12203. keysRight: number[];
  12204. /**
  12205. * Event raised when the camera collide with a mesh in the scene.
  12206. */
  12207. onCollide: (collidedMesh: AbstractMesh) => void;
  12208. private _collider;
  12209. private _needMoveForGravity;
  12210. private _oldPosition;
  12211. private _diffPosition;
  12212. private _newPosition;
  12213. /** @hidden */
  12214. _localDirection: Vector3;
  12215. /** @hidden */
  12216. _transformedDirection: Vector3;
  12217. /**
  12218. * Instantiates a Free Camera.
  12219. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12220. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12221. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12222. * @param name Define the name of the camera in the scene
  12223. * @param position Define the start position of the camera in the scene
  12224. * @param scene Define the scene the camera belongs to
  12225. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12226. */
  12227. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12228. /**
  12229. * Attached controls to the current camera.
  12230. * @param element Defines the element the controls should be listened from
  12231. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12232. */
  12233. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12234. /**
  12235. * Detach the current controls from the camera.
  12236. * The camera will stop reacting to inputs.
  12237. * @param element Defines the element to stop listening the inputs from
  12238. */
  12239. detachControl(element: HTMLElement): void;
  12240. private _collisionMask;
  12241. /**
  12242. * Define a collision mask to limit the list of object the camera can collide with
  12243. */
  12244. collisionMask: number;
  12245. /** @hidden */
  12246. _collideWithWorld(displacement: Vector3): void;
  12247. private _onCollisionPositionChange;
  12248. /** @hidden */
  12249. _checkInputs(): void;
  12250. /** @hidden */
  12251. _decideIfNeedsToMove(): boolean;
  12252. /** @hidden */
  12253. _updatePosition(): void;
  12254. /**
  12255. * Destroy the camera and release the current resources hold by it.
  12256. */
  12257. dispose(): void;
  12258. /**
  12259. * Gets the current object class name.
  12260. * @return the class name
  12261. */
  12262. getClassName(): string;
  12263. }
  12264. }
  12265. declare module "babylonjs/Gamepads/gamepad" {
  12266. import { Observable } from "babylonjs/Misc/observable";
  12267. /**
  12268. * Represents a gamepad control stick position
  12269. */
  12270. export class StickValues {
  12271. /**
  12272. * The x component of the control stick
  12273. */
  12274. x: number;
  12275. /**
  12276. * The y component of the control stick
  12277. */
  12278. y: number;
  12279. /**
  12280. * Initializes the gamepad x and y control stick values
  12281. * @param x The x component of the gamepad control stick value
  12282. * @param y The y component of the gamepad control stick value
  12283. */
  12284. constructor(
  12285. /**
  12286. * The x component of the control stick
  12287. */
  12288. x: number,
  12289. /**
  12290. * The y component of the control stick
  12291. */
  12292. y: number);
  12293. }
  12294. /**
  12295. * An interface which manages callbacks for gamepad button changes
  12296. */
  12297. export interface GamepadButtonChanges {
  12298. /**
  12299. * Called when a gamepad has been changed
  12300. */
  12301. changed: boolean;
  12302. /**
  12303. * Called when a gamepad press event has been triggered
  12304. */
  12305. pressChanged: boolean;
  12306. /**
  12307. * Called when a touch event has been triggered
  12308. */
  12309. touchChanged: boolean;
  12310. /**
  12311. * Called when a value has changed
  12312. */
  12313. valueChanged: boolean;
  12314. }
  12315. /**
  12316. * Represents a gamepad
  12317. */
  12318. export class Gamepad {
  12319. /**
  12320. * The id of the gamepad
  12321. */
  12322. id: string;
  12323. /**
  12324. * The index of the gamepad
  12325. */
  12326. index: number;
  12327. /**
  12328. * The browser gamepad
  12329. */
  12330. browserGamepad: any;
  12331. /**
  12332. * Specifies what type of gamepad this represents
  12333. */
  12334. type: number;
  12335. private _leftStick;
  12336. private _rightStick;
  12337. /** @hidden */
  12338. _isConnected: boolean;
  12339. private _leftStickAxisX;
  12340. private _leftStickAxisY;
  12341. private _rightStickAxisX;
  12342. private _rightStickAxisY;
  12343. /**
  12344. * Triggered when the left control stick has been changed
  12345. */
  12346. private _onleftstickchanged;
  12347. /**
  12348. * Triggered when the right control stick has been changed
  12349. */
  12350. private _onrightstickchanged;
  12351. /**
  12352. * Represents a gamepad controller
  12353. */
  12354. static GAMEPAD: number;
  12355. /**
  12356. * Represents a generic controller
  12357. */
  12358. static GENERIC: number;
  12359. /**
  12360. * Represents an XBox controller
  12361. */
  12362. static XBOX: number;
  12363. /**
  12364. * Represents a pose-enabled controller
  12365. */
  12366. static POSE_ENABLED: number;
  12367. /**
  12368. * Represents an Dual Shock controller
  12369. */
  12370. static DUALSHOCK: number;
  12371. /**
  12372. * Specifies whether the left control stick should be Y-inverted
  12373. */
  12374. protected _invertLeftStickY: boolean;
  12375. /**
  12376. * Specifies if the gamepad has been connected
  12377. */
  12378. readonly isConnected: boolean;
  12379. /**
  12380. * Initializes the gamepad
  12381. * @param id The id of the gamepad
  12382. * @param index The index of the gamepad
  12383. * @param browserGamepad The browser gamepad
  12384. * @param leftStickX The x component of the left joystick
  12385. * @param leftStickY The y component of the left joystick
  12386. * @param rightStickX The x component of the right joystick
  12387. * @param rightStickY The y component of the right joystick
  12388. */
  12389. constructor(
  12390. /**
  12391. * The id of the gamepad
  12392. */
  12393. id: string,
  12394. /**
  12395. * The index of the gamepad
  12396. */
  12397. index: number,
  12398. /**
  12399. * The browser gamepad
  12400. */
  12401. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12402. /**
  12403. * Callback triggered when the left joystick has changed
  12404. * @param callback
  12405. */
  12406. onleftstickchanged(callback: (values: StickValues) => void): void;
  12407. /**
  12408. * Callback triggered when the right joystick has changed
  12409. * @param callback
  12410. */
  12411. onrightstickchanged(callback: (values: StickValues) => void): void;
  12412. /**
  12413. * Gets the left joystick
  12414. */
  12415. /**
  12416. * Sets the left joystick values
  12417. */
  12418. leftStick: StickValues;
  12419. /**
  12420. * Gets the right joystick
  12421. */
  12422. /**
  12423. * Sets the right joystick value
  12424. */
  12425. rightStick: StickValues;
  12426. /**
  12427. * Updates the gamepad joystick positions
  12428. */
  12429. update(): void;
  12430. /**
  12431. * Disposes the gamepad
  12432. */
  12433. dispose(): void;
  12434. }
  12435. /**
  12436. * Represents a generic gamepad
  12437. */
  12438. export class GenericPad extends Gamepad {
  12439. private _buttons;
  12440. private _onbuttondown;
  12441. private _onbuttonup;
  12442. /**
  12443. * Observable triggered when a button has been pressed
  12444. */
  12445. onButtonDownObservable: Observable<number>;
  12446. /**
  12447. * Observable triggered when a button has been released
  12448. */
  12449. onButtonUpObservable: Observable<number>;
  12450. /**
  12451. * Callback triggered when a button has been pressed
  12452. * @param callback Called when a button has been pressed
  12453. */
  12454. onbuttondown(callback: (buttonPressed: number) => void): void;
  12455. /**
  12456. * Callback triggered when a button has been released
  12457. * @param callback Called when a button has been released
  12458. */
  12459. onbuttonup(callback: (buttonReleased: number) => void): void;
  12460. /**
  12461. * Initializes the generic gamepad
  12462. * @param id The id of the generic gamepad
  12463. * @param index The index of the generic gamepad
  12464. * @param browserGamepad The browser gamepad
  12465. */
  12466. constructor(id: string, index: number, browserGamepad: any);
  12467. private _setButtonValue;
  12468. /**
  12469. * Updates the generic gamepad
  12470. */
  12471. update(): void;
  12472. /**
  12473. * Disposes the generic gamepad
  12474. */
  12475. dispose(): void;
  12476. }
  12477. }
  12478. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12479. import { Nullable } from "babylonjs/types";
  12480. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12481. import { Scene } from "babylonjs/scene";
  12482. module "babylonjs/Engines/engine" {
  12483. interface Engine {
  12484. /**
  12485. * Creates a raw texture
  12486. * @param data defines the data to store in the texture
  12487. * @param width defines the width of the texture
  12488. * @param height defines the height of the texture
  12489. * @param format defines the format of the data
  12490. * @param generateMipMaps defines if the engine should generate the mip levels
  12491. * @param invertY defines if data must be stored with Y axis inverted
  12492. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12493. * @param compression defines the compression used (null by default)
  12494. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12495. * @returns the raw texture inside an InternalTexture
  12496. */
  12497. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12498. /**
  12499. * Update a raw texture
  12500. * @param texture defines the texture to update
  12501. * @param data defines the data to store in the texture
  12502. * @param format defines the format of the data
  12503. * @param invertY defines if data must be stored with Y axis inverted
  12504. */
  12505. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12506. /**
  12507. * Update a raw texture
  12508. * @param texture defines the texture to update
  12509. * @param data defines the data to store in the texture
  12510. * @param format defines the format of the data
  12511. * @param invertY defines if data must be stored with Y axis inverted
  12512. * @param compression defines the compression used (null by default)
  12513. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12514. */
  12515. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12516. /**
  12517. * Creates a new raw cube texture
  12518. * @param data defines the array of data to use to create each face
  12519. * @param size defines the size of the textures
  12520. * @param format defines the format of the data
  12521. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12522. * @param generateMipMaps defines if the engine should generate the mip levels
  12523. * @param invertY defines if data must be stored with Y axis inverted
  12524. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12525. * @param compression defines the compression used (null by default)
  12526. * @returns the cube texture as an InternalTexture
  12527. */
  12528. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12529. /**
  12530. * Update a raw cube texture
  12531. * @param texture defines the texture to udpdate
  12532. * @param data defines the data to store
  12533. * @param format defines the data format
  12534. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12535. * @param invertY defines if data must be stored with Y axis inverted
  12536. */
  12537. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12538. /**
  12539. * Update a raw cube texture
  12540. * @param texture defines the texture to udpdate
  12541. * @param data defines the data to store
  12542. * @param format defines the data format
  12543. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12544. * @param invertY defines if data must be stored with Y axis inverted
  12545. * @param compression defines the compression used (null by default)
  12546. */
  12547. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12548. /**
  12549. * Update a raw cube texture
  12550. * @param texture defines the texture to udpdate
  12551. * @param data defines the data to store
  12552. * @param format defines the data format
  12553. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12554. * @param invertY defines if data must be stored with Y axis inverted
  12555. * @param compression defines the compression used (null by default)
  12556. * @param level defines which level of the texture to update
  12557. */
  12558. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12559. /**
  12560. * Creates a new raw cube texture from a specified url
  12561. * @param url defines the url where the data is located
  12562. * @param scene defines the current scene
  12563. * @param size defines the size of the textures
  12564. * @param format defines the format of the data
  12565. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12566. * @param noMipmap defines if the engine should avoid generating the mip levels
  12567. * @param callback defines a callback used to extract texture data from loaded data
  12568. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12569. * @param onLoad defines a callback called when texture is loaded
  12570. * @param onError defines a callback called if there is an error
  12571. * @returns the cube texture as an InternalTexture
  12572. */
  12573. 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;
  12574. /**
  12575. * Creates a new raw cube texture from a specified url
  12576. * @param url defines the url where the data is located
  12577. * @param scene defines the current scene
  12578. * @param size defines the size of the textures
  12579. * @param format defines the format of the data
  12580. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12581. * @param noMipmap defines if the engine should avoid generating the mip levels
  12582. * @param callback defines a callback used to extract texture data from loaded data
  12583. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12584. * @param onLoad defines a callback called when texture is loaded
  12585. * @param onError defines a callback called if there is an error
  12586. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12587. * @param invertY defines if data must be stored with Y axis inverted
  12588. * @returns the cube texture as an InternalTexture
  12589. */
  12590. 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;
  12591. /**
  12592. * Creates a new raw 3D texture
  12593. * @param data defines the data used to create the texture
  12594. * @param width defines the width of the texture
  12595. * @param height defines the height of the texture
  12596. * @param depth defines the depth of the texture
  12597. * @param format defines the format of the texture
  12598. * @param generateMipMaps defines if the engine must generate mip levels
  12599. * @param invertY defines if data must be stored with Y axis inverted
  12600. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12601. * @param compression defines the compressed used (can be null)
  12602. * @param textureType defines the compressed used (can be null)
  12603. * @returns a new raw 3D texture (stored in an InternalTexture)
  12604. */
  12605. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12606. /**
  12607. * Update a raw 3D texture
  12608. * @param texture defines the texture to update
  12609. * @param data defines the data to store
  12610. * @param format defines the data format
  12611. * @param invertY defines if data must be stored with Y axis inverted
  12612. */
  12613. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12614. /**
  12615. * Update a raw 3D texture
  12616. * @param texture defines the texture to update
  12617. * @param data defines the data to store
  12618. * @param format defines the data format
  12619. * @param invertY defines if data must be stored with Y axis inverted
  12620. * @param compression defines the used compression (can be null)
  12621. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12622. */
  12623. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12624. }
  12625. }
  12626. }
  12627. declare module "babylonjs/Materials/Textures/rawTexture" {
  12628. import { Scene } from "babylonjs/scene";
  12629. import { Texture } from "babylonjs/Materials/Textures/texture";
  12630. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12631. /**
  12632. * Raw texture can help creating a texture directly from an array of data.
  12633. * This can be super useful if you either get the data from an uncompressed source or
  12634. * if you wish to create your texture pixel by pixel.
  12635. */
  12636. export class RawTexture extends Texture {
  12637. /**
  12638. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12639. */
  12640. format: number;
  12641. private _engine;
  12642. /**
  12643. * Instantiates a new RawTexture.
  12644. * Raw texture can help creating a texture directly from an array of data.
  12645. * This can be super useful if you either get the data from an uncompressed source or
  12646. * if you wish to create your texture pixel by pixel.
  12647. * @param data define the array of data to use to create the texture
  12648. * @param width define the width of the texture
  12649. * @param height define the height of the texture
  12650. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12651. * @param scene define the scene the texture belongs to
  12652. * @param generateMipMaps define whether mip maps should be generated or not
  12653. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12654. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12655. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12656. */
  12657. constructor(data: ArrayBufferView, width: number, height: number,
  12658. /**
  12659. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12660. */
  12661. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12662. /**
  12663. * Updates the texture underlying data.
  12664. * @param data Define the new data of the texture
  12665. */
  12666. update(data: ArrayBufferView): void;
  12667. /**
  12668. * Creates a luminance texture from some data.
  12669. * @param data Define the texture data
  12670. * @param width Define the width of the texture
  12671. * @param height Define the height of the texture
  12672. * @param scene Define the scene the texture belongs to
  12673. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12674. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12675. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12676. * @returns the luminance texture
  12677. */
  12678. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12679. /**
  12680. * Creates a luminance alpha texture from some data.
  12681. * @param data Define the texture data
  12682. * @param width Define the width of the texture
  12683. * @param height Define the height of the texture
  12684. * @param scene Define the scene the texture belongs to
  12685. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12686. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12687. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12688. * @returns the luminance alpha texture
  12689. */
  12690. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12691. /**
  12692. * Creates an alpha texture from some data.
  12693. * @param data Define the texture data
  12694. * @param width Define the width of the texture
  12695. * @param height Define the height of the texture
  12696. * @param scene Define the scene the texture belongs to
  12697. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12698. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12699. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12700. * @returns the alpha texture
  12701. */
  12702. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12703. /**
  12704. * Creates a RGB texture from some data.
  12705. * @param data Define the texture data
  12706. * @param width Define the width of the texture
  12707. * @param height Define the height of the texture
  12708. * @param scene Define the scene the texture belongs to
  12709. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12710. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12711. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12712. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12713. * @returns the RGB alpha texture
  12714. */
  12715. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12716. /**
  12717. * Creates a RGBA texture from some data.
  12718. * @param data Define the texture data
  12719. * @param width Define the width of the texture
  12720. * @param height Define the height of the texture
  12721. * @param scene Define the scene the texture belongs to
  12722. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12723. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12724. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12725. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12726. * @returns the RGBA texture
  12727. */
  12728. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12729. /**
  12730. * Creates a R texture from some data.
  12731. * @param data Define the texture data
  12732. * @param width Define the width of the texture
  12733. * @param height Define the height of the texture
  12734. * @param scene Define the scene the texture belongs to
  12735. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12736. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12737. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12738. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12739. * @returns the R texture
  12740. */
  12741. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12742. }
  12743. }
  12744. declare module "babylonjs/Maths/math.size" {
  12745. /**
  12746. * Interface for the size containing width and height
  12747. */
  12748. export interface ISize {
  12749. /**
  12750. * Width
  12751. */
  12752. width: number;
  12753. /**
  12754. * Heighht
  12755. */
  12756. height: number;
  12757. }
  12758. /**
  12759. * Size containing widht and height
  12760. */
  12761. export class Size implements ISize {
  12762. /**
  12763. * Width
  12764. */
  12765. width: number;
  12766. /**
  12767. * Height
  12768. */
  12769. height: number;
  12770. /**
  12771. * Creates a Size object from the given width and height (floats).
  12772. * @param width width of the new size
  12773. * @param height height of the new size
  12774. */
  12775. constructor(width: number, height: number);
  12776. /**
  12777. * Returns a string with the Size width and height
  12778. * @returns a string with the Size width and height
  12779. */
  12780. toString(): string;
  12781. /**
  12782. * "Size"
  12783. * @returns the string "Size"
  12784. */
  12785. getClassName(): string;
  12786. /**
  12787. * Returns the Size hash code.
  12788. * @returns a hash code for a unique width and height
  12789. */
  12790. getHashCode(): number;
  12791. /**
  12792. * Updates the current size from the given one.
  12793. * @param src the given size
  12794. */
  12795. copyFrom(src: Size): void;
  12796. /**
  12797. * Updates in place the current Size from the given floats.
  12798. * @param width width of the new size
  12799. * @param height height of the new size
  12800. * @returns the updated Size.
  12801. */
  12802. copyFromFloats(width: number, height: number): Size;
  12803. /**
  12804. * Updates in place the current Size from the given floats.
  12805. * @param width width to set
  12806. * @param height height to set
  12807. * @returns the updated Size.
  12808. */
  12809. set(width: number, height: number): Size;
  12810. /**
  12811. * Multiplies the width and height by numbers
  12812. * @param w factor to multiple the width by
  12813. * @param h factor to multiple the height by
  12814. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12815. */
  12816. multiplyByFloats(w: number, h: number): Size;
  12817. /**
  12818. * Clones the size
  12819. * @returns a new Size copied from the given one.
  12820. */
  12821. clone(): Size;
  12822. /**
  12823. * True if the current Size and the given one width and height are strictly equal.
  12824. * @param other the other size to compare against
  12825. * @returns True if the current Size and the given one width and height are strictly equal.
  12826. */
  12827. equals(other: Size): boolean;
  12828. /**
  12829. * The surface of the Size : width * height (float).
  12830. */
  12831. readonly surface: number;
  12832. /**
  12833. * Create a new size of zero
  12834. * @returns a new Size set to (0.0, 0.0)
  12835. */
  12836. static Zero(): Size;
  12837. /**
  12838. * Sums the width and height of two sizes
  12839. * @param otherSize size to add to this size
  12840. * @returns a new Size set as the addition result of the current Size and the given one.
  12841. */
  12842. add(otherSize: Size): Size;
  12843. /**
  12844. * Subtracts the width and height of two
  12845. * @param otherSize size to subtract to this size
  12846. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12847. */
  12848. subtract(otherSize: Size): Size;
  12849. /**
  12850. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12851. * @param start starting size to lerp between
  12852. * @param end end size to lerp between
  12853. * @param amount amount to lerp between the start and end values
  12854. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12855. */
  12856. static Lerp(start: Size, end: Size, amount: number): Size;
  12857. }
  12858. }
  12859. declare module "babylonjs/Animations/runtimeAnimation" {
  12860. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  12861. import { Animatable } from "babylonjs/Animations/animatable";
  12862. import { Scene } from "babylonjs/scene";
  12863. /**
  12864. * Defines a runtime animation
  12865. */
  12866. export class RuntimeAnimation {
  12867. private _events;
  12868. /**
  12869. * The current frame of the runtime animation
  12870. */
  12871. private _currentFrame;
  12872. /**
  12873. * The animation used by the runtime animation
  12874. */
  12875. private _animation;
  12876. /**
  12877. * The target of the runtime animation
  12878. */
  12879. private _target;
  12880. /**
  12881. * The initiating animatable
  12882. */
  12883. private _host;
  12884. /**
  12885. * The original value of the runtime animation
  12886. */
  12887. private _originalValue;
  12888. /**
  12889. * The original blend value of the runtime animation
  12890. */
  12891. private _originalBlendValue;
  12892. /**
  12893. * The offsets cache of the runtime animation
  12894. */
  12895. private _offsetsCache;
  12896. /**
  12897. * The high limits cache of the runtime animation
  12898. */
  12899. private _highLimitsCache;
  12900. /**
  12901. * Specifies if the runtime animation has been stopped
  12902. */
  12903. private _stopped;
  12904. /**
  12905. * The blending factor of the runtime animation
  12906. */
  12907. private _blendingFactor;
  12908. /**
  12909. * The BabylonJS scene
  12910. */
  12911. private _scene;
  12912. /**
  12913. * The current value of the runtime animation
  12914. */
  12915. private _currentValue;
  12916. /** @hidden */
  12917. _animationState: _IAnimationState;
  12918. /**
  12919. * The active target of the runtime animation
  12920. */
  12921. private _activeTargets;
  12922. private _currentActiveTarget;
  12923. private _directTarget;
  12924. /**
  12925. * The target path of the runtime animation
  12926. */
  12927. private _targetPath;
  12928. /**
  12929. * The weight of the runtime animation
  12930. */
  12931. private _weight;
  12932. /**
  12933. * The ratio offset of the runtime animation
  12934. */
  12935. private _ratioOffset;
  12936. /**
  12937. * The previous delay of the runtime animation
  12938. */
  12939. private _previousDelay;
  12940. /**
  12941. * The previous ratio of the runtime animation
  12942. */
  12943. private _previousRatio;
  12944. private _enableBlending;
  12945. private _keys;
  12946. private _minFrame;
  12947. private _maxFrame;
  12948. private _minValue;
  12949. private _maxValue;
  12950. private _targetIsArray;
  12951. /**
  12952. * Gets the current frame of the runtime animation
  12953. */
  12954. readonly currentFrame: number;
  12955. /**
  12956. * Gets the weight of the runtime animation
  12957. */
  12958. readonly weight: number;
  12959. /**
  12960. * Gets the current value of the runtime animation
  12961. */
  12962. readonly currentValue: any;
  12963. /**
  12964. * Gets the target path of the runtime animation
  12965. */
  12966. readonly targetPath: string;
  12967. /**
  12968. * Gets the actual target of the runtime animation
  12969. */
  12970. readonly target: any;
  12971. /** @hidden */
  12972. _onLoop: () => void;
  12973. /**
  12974. * Create a new RuntimeAnimation object
  12975. * @param target defines the target of the animation
  12976. * @param animation defines the source animation object
  12977. * @param scene defines the hosting scene
  12978. * @param host defines the initiating Animatable
  12979. */
  12980. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12981. private _preparePath;
  12982. /**
  12983. * Gets the animation from the runtime animation
  12984. */
  12985. readonly animation: Animation;
  12986. /**
  12987. * Resets the runtime animation to the beginning
  12988. * @param restoreOriginal defines whether to restore the target property to the original value
  12989. */
  12990. reset(restoreOriginal?: boolean): void;
  12991. /**
  12992. * Specifies if the runtime animation is stopped
  12993. * @returns Boolean specifying if the runtime animation is stopped
  12994. */
  12995. isStopped(): boolean;
  12996. /**
  12997. * Disposes of the runtime animation
  12998. */
  12999. dispose(): void;
  13000. /**
  13001. * Apply the interpolated value to the target
  13002. * @param currentValue defines the value computed by the animation
  13003. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13004. */
  13005. setValue(currentValue: any, weight: number): void;
  13006. private _getOriginalValues;
  13007. private _setValue;
  13008. /**
  13009. * Gets the loop pmode of the runtime animation
  13010. * @returns Loop Mode
  13011. */
  13012. private _getCorrectLoopMode;
  13013. /**
  13014. * Move the current animation to a given frame
  13015. * @param frame defines the frame to move to
  13016. */
  13017. goToFrame(frame: number): void;
  13018. /**
  13019. * @hidden Internal use only
  13020. */
  13021. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13022. /**
  13023. * Execute the current animation
  13024. * @param delay defines the delay to add to the current frame
  13025. * @param from defines the lower bound of the animation range
  13026. * @param to defines the upper bound of the animation range
  13027. * @param loop defines if the current animation must loop
  13028. * @param speedRatio defines the current speed ratio
  13029. * @param weight defines the weight of the animation (default is -1 so no weight)
  13030. * @param onLoop optional callback called when animation loops
  13031. * @returns a boolean indicating if the animation is running
  13032. */
  13033. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13034. }
  13035. }
  13036. declare module "babylonjs/Animations/animatable" {
  13037. import { Animation } from "babylonjs/Animations/animation";
  13038. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13039. import { Nullable } from "babylonjs/types";
  13040. import { Observable } from "babylonjs/Misc/observable";
  13041. import { Scene } from "babylonjs/scene";
  13042. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13043. import { Node } from "babylonjs/node";
  13044. /**
  13045. * Class used to store an actual running animation
  13046. */
  13047. export class Animatable {
  13048. /** defines the target object */
  13049. target: any;
  13050. /** defines the starting frame number (default is 0) */
  13051. fromFrame: number;
  13052. /** defines the ending frame number (default is 100) */
  13053. toFrame: number;
  13054. /** defines if the animation must loop (default is false) */
  13055. loopAnimation: boolean;
  13056. /** defines a callback to call when animation ends if it is not looping */
  13057. onAnimationEnd?: (() => void) | null | undefined;
  13058. /** defines a callback to call when animation loops */
  13059. onAnimationLoop?: (() => void) | null | undefined;
  13060. private _localDelayOffset;
  13061. private _pausedDelay;
  13062. private _runtimeAnimations;
  13063. private _paused;
  13064. private _scene;
  13065. private _speedRatio;
  13066. private _weight;
  13067. private _syncRoot;
  13068. /**
  13069. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13070. * This will only apply for non looping animation (default is true)
  13071. */
  13072. disposeOnEnd: boolean;
  13073. /**
  13074. * Gets a boolean indicating if the animation has started
  13075. */
  13076. animationStarted: boolean;
  13077. /**
  13078. * Observer raised when the animation ends
  13079. */
  13080. onAnimationEndObservable: Observable<Animatable>;
  13081. /**
  13082. * Observer raised when the animation loops
  13083. */
  13084. onAnimationLoopObservable: Observable<Animatable>;
  13085. /**
  13086. * Gets the root Animatable used to synchronize and normalize animations
  13087. */
  13088. readonly syncRoot: Nullable<Animatable>;
  13089. /**
  13090. * Gets the current frame of the first RuntimeAnimation
  13091. * Used to synchronize Animatables
  13092. */
  13093. readonly masterFrame: number;
  13094. /**
  13095. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13096. */
  13097. weight: number;
  13098. /**
  13099. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13100. */
  13101. speedRatio: number;
  13102. /**
  13103. * Creates a new Animatable
  13104. * @param scene defines the hosting scene
  13105. * @param target defines the target object
  13106. * @param fromFrame defines the starting frame number (default is 0)
  13107. * @param toFrame defines the ending frame number (default is 100)
  13108. * @param loopAnimation defines if the animation must loop (default is false)
  13109. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13110. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13111. * @param animations defines a group of animation to add to the new Animatable
  13112. * @param onAnimationLoop defines a callback to call when animation loops
  13113. */
  13114. constructor(scene: Scene,
  13115. /** defines the target object */
  13116. target: any,
  13117. /** defines the starting frame number (default is 0) */
  13118. fromFrame?: number,
  13119. /** defines the ending frame number (default is 100) */
  13120. toFrame?: number,
  13121. /** defines if the animation must loop (default is false) */
  13122. loopAnimation?: boolean, speedRatio?: number,
  13123. /** defines a callback to call when animation ends if it is not looping */
  13124. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13125. /** defines a callback to call when animation loops */
  13126. onAnimationLoop?: (() => void) | null | undefined);
  13127. /**
  13128. * Synchronize and normalize current Animatable with a source Animatable
  13129. * This is useful when using animation weights and when animations are not of the same length
  13130. * @param root defines the root Animatable to synchronize with
  13131. * @returns the current Animatable
  13132. */
  13133. syncWith(root: Animatable): Animatable;
  13134. /**
  13135. * Gets the list of runtime animations
  13136. * @returns an array of RuntimeAnimation
  13137. */
  13138. getAnimations(): RuntimeAnimation[];
  13139. /**
  13140. * Adds more animations to the current animatable
  13141. * @param target defines the target of the animations
  13142. * @param animations defines the new animations to add
  13143. */
  13144. appendAnimations(target: any, animations: Animation[]): void;
  13145. /**
  13146. * Gets the source animation for a specific property
  13147. * @param property defines the propertyu to look for
  13148. * @returns null or the source animation for the given property
  13149. */
  13150. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13151. /**
  13152. * Gets the runtime animation for a specific property
  13153. * @param property defines the propertyu to look for
  13154. * @returns null or the runtime animation for the given property
  13155. */
  13156. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13157. /**
  13158. * Resets the animatable to its original state
  13159. */
  13160. reset(): void;
  13161. /**
  13162. * Allows the animatable to blend with current running animations
  13163. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13164. * @param blendingSpeed defines the blending speed to use
  13165. */
  13166. enableBlending(blendingSpeed: number): void;
  13167. /**
  13168. * Disable animation blending
  13169. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13170. */
  13171. disableBlending(): void;
  13172. /**
  13173. * Jump directly to a given frame
  13174. * @param frame defines the frame to jump to
  13175. */
  13176. goToFrame(frame: number): void;
  13177. /**
  13178. * Pause the animation
  13179. */
  13180. pause(): void;
  13181. /**
  13182. * Restart the animation
  13183. */
  13184. restart(): void;
  13185. private _raiseOnAnimationEnd;
  13186. /**
  13187. * Stop and delete the current animation
  13188. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13189. * @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)
  13190. */
  13191. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13192. /**
  13193. * Wait asynchronously for the animation to end
  13194. * @returns a promise which will be fullfilled when the animation ends
  13195. */
  13196. waitAsync(): Promise<Animatable>;
  13197. /** @hidden */
  13198. _animate(delay: number): boolean;
  13199. }
  13200. module "babylonjs/scene" {
  13201. interface Scene {
  13202. /** @hidden */
  13203. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13204. /** @hidden */
  13205. _processLateAnimationBindingsForMatrices(holder: {
  13206. totalWeight: number;
  13207. animations: RuntimeAnimation[];
  13208. originalValue: Matrix;
  13209. }): any;
  13210. /** @hidden */
  13211. _processLateAnimationBindingsForQuaternions(holder: {
  13212. totalWeight: number;
  13213. animations: RuntimeAnimation[];
  13214. originalValue: Quaternion;
  13215. }, refQuaternion: Quaternion): Quaternion;
  13216. /** @hidden */
  13217. _processLateAnimationBindings(): void;
  13218. /**
  13219. * Will start the animation sequence of a given target
  13220. * @param target defines the target
  13221. * @param from defines from which frame should animation start
  13222. * @param to defines until which frame should animation run.
  13223. * @param weight defines the weight to apply to the animation (1.0 by default)
  13224. * @param loop defines if the animation loops
  13225. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13226. * @param onAnimationEnd defines the function to be executed when the animation ends
  13227. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13228. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13229. * @param onAnimationLoop defines the callback to call when an animation loops
  13230. * @returns the animatable object created for this animation
  13231. */
  13232. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13233. /**
  13234. * Will start the animation sequence of a given target
  13235. * @param target defines the target
  13236. * @param from defines from which frame should animation start
  13237. * @param to defines until which frame should animation run.
  13238. * @param loop defines if the animation loops
  13239. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13240. * @param onAnimationEnd defines the function to be executed when the animation ends
  13241. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13242. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13243. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13244. * @param onAnimationLoop defines the callback to call when an animation loops
  13245. * @returns the animatable object created for this animation
  13246. */
  13247. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13248. /**
  13249. * Will start the animation sequence of a given target and its hierarchy
  13250. * @param target defines the target
  13251. * @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.
  13252. * @param from defines from which frame should animation start
  13253. * @param to defines until which frame should animation run.
  13254. * @param loop defines if the animation loops
  13255. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13256. * @param onAnimationEnd defines the function to be executed when the animation ends
  13257. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13258. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13259. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13260. * @param onAnimationLoop defines the callback to call when an animation loops
  13261. * @returns the list of created animatables
  13262. */
  13263. 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[];
  13264. /**
  13265. * Begin a new animation on a given node
  13266. * @param target defines the target where the animation will take place
  13267. * @param animations defines the list of animations to start
  13268. * @param from defines the initial value
  13269. * @param to defines the final value
  13270. * @param loop defines if you want animation to loop (off by default)
  13271. * @param speedRatio defines the speed ratio to apply to all animations
  13272. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13273. * @param onAnimationLoop defines the callback to call when an animation loops
  13274. * @returns the list of created animatables
  13275. */
  13276. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13277. /**
  13278. * Begin a new animation on a given node and its hierarchy
  13279. * @param target defines the root node where the animation will take place
  13280. * @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.
  13281. * @param animations defines the list of animations to start
  13282. * @param from defines the initial value
  13283. * @param to defines the final value
  13284. * @param loop defines if you want animation to loop (off by default)
  13285. * @param speedRatio defines the speed ratio to apply to all animations
  13286. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13287. * @param onAnimationLoop defines the callback to call when an animation loops
  13288. * @returns the list of animatables created for all nodes
  13289. */
  13290. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13291. /**
  13292. * Gets the animatable associated with a specific target
  13293. * @param target defines the target of the animatable
  13294. * @returns the required animatable if found
  13295. */
  13296. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13297. /**
  13298. * Gets all animatables associated with a given target
  13299. * @param target defines the target to look animatables for
  13300. * @returns an array of Animatables
  13301. */
  13302. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13303. /**
  13304. * Stops and removes all animations that have been applied to the scene
  13305. */
  13306. stopAllAnimations(): void;
  13307. }
  13308. }
  13309. module "babylonjs/Bones/bone" {
  13310. interface Bone {
  13311. /**
  13312. * Copy an animation range from another bone
  13313. * @param source defines the source bone
  13314. * @param rangeName defines the range name to copy
  13315. * @param frameOffset defines the frame offset
  13316. * @param rescaleAsRequired defines if rescaling must be applied if required
  13317. * @param skelDimensionsRatio defines the scaling ratio
  13318. * @returns true if operation was successful
  13319. */
  13320. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13321. }
  13322. }
  13323. }
  13324. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13325. /**
  13326. * Class used to override all child animations of a given target
  13327. */
  13328. export class AnimationPropertiesOverride {
  13329. /**
  13330. * Gets or sets a value indicating if animation blending must be used
  13331. */
  13332. enableBlending: boolean;
  13333. /**
  13334. * Gets or sets the blending speed to use when enableBlending is true
  13335. */
  13336. blendingSpeed: number;
  13337. /**
  13338. * Gets or sets the default loop mode to use
  13339. */
  13340. loopMode: number;
  13341. }
  13342. }
  13343. declare module "babylonjs/Bones/skeleton" {
  13344. import { Bone } from "babylonjs/Bones/bone";
  13345. import { Observable } from "babylonjs/Misc/observable";
  13346. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13347. import { Scene } from "babylonjs/scene";
  13348. import { Nullable } from "babylonjs/types";
  13349. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13350. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13351. import { Animatable } from "babylonjs/Animations/animatable";
  13352. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13353. import { Animation } from "babylonjs/Animations/animation";
  13354. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13355. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13356. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13357. /**
  13358. * Class used to handle skinning animations
  13359. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13360. */
  13361. export class Skeleton implements IAnimatable {
  13362. /** defines the skeleton name */
  13363. name: string;
  13364. /** defines the skeleton Id */
  13365. id: string;
  13366. /**
  13367. * Defines the list of child bones
  13368. */
  13369. bones: Bone[];
  13370. /**
  13371. * Defines an estimate of the dimension of the skeleton at rest
  13372. */
  13373. dimensionsAtRest: Vector3;
  13374. /**
  13375. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13376. */
  13377. needInitialSkinMatrix: boolean;
  13378. /**
  13379. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13380. */
  13381. overrideMesh: Nullable<AbstractMesh>;
  13382. /**
  13383. * Gets the list of animations attached to this skeleton
  13384. */
  13385. animations: Array<Animation>;
  13386. private _scene;
  13387. private _isDirty;
  13388. private _transformMatrices;
  13389. private _transformMatrixTexture;
  13390. private _meshesWithPoseMatrix;
  13391. private _animatables;
  13392. private _identity;
  13393. private _synchronizedWithMesh;
  13394. private _ranges;
  13395. private _lastAbsoluteTransformsUpdateId;
  13396. private _canUseTextureForBones;
  13397. private _uniqueId;
  13398. /** @hidden */
  13399. _numBonesWithLinkedTransformNode: number;
  13400. /** @hidden */
  13401. _hasWaitingData: Nullable<boolean>;
  13402. /**
  13403. * Specifies if the skeleton should be serialized
  13404. */
  13405. doNotSerialize: boolean;
  13406. private _useTextureToStoreBoneMatrices;
  13407. /**
  13408. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13409. * Please note that this option is not available if the hardware does not support it
  13410. */
  13411. useTextureToStoreBoneMatrices: boolean;
  13412. private _animationPropertiesOverride;
  13413. /**
  13414. * Gets or sets the animation properties override
  13415. */
  13416. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13417. /**
  13418. * List of inspectable custom properties (used by the Inspector)
  13419. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13420. */
  13421. inspectableCustomProperties: IInspectable[];
  13422. /**
  13423. * An observable triggered before computing the skeleton's matrices
  13424. */
  13425. onBeforeComputeObservable: Observable<Skeleton>;
  13426. /**
  13427. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13428. */
  13429. readonly isUsingTextureForMatrices: boolean;
  13430. /**
  13431. * Gets the unique ID of this skeleton
  13432. */
  13433. readonly uniqueId: number;
  13434. /**
  13435. * Creates a new skeleton
  13436. * @param name defines the skeleton name
  13437. * @param id defines the skeleton Id
  13438. * @param scene defines the hosting scene
  13439. */
  13440. constructor(
  13441. /** defines the skeleton name */
  13442. name: string,
  13443. /** defines the skeleton Id */
  13444. id: string, scene: Scene);
  13445. /**
  13446. * Gets the current object class name.
  13447. * @return the class name
  13448. */
  13449. getClassName(): string;
  13450. /**
  13451. * Returns an array containing the root bones
  13452. * @returns an array containing the root bones
  13453. */
  13454. getChildren(): Array<Bone>;
  13455. /**
  13456. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13457. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13458. * @returns a Float32Array containing matrices data
  13459. */
  13460. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13461. /**
  13462. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13463. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13464. * @returns a raw texture containing the data
  13465. */
  13466. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13467. /**
  13468. * Gets the current hosting scene
  13469. * @returns a scene object
  13470. */
  13471. getScene(): Scene;
  13472. /**
  13473. * Gets a string representing the current skeleton data
  13474. * @param fullDetails defines a boolean indicating if we want a verbose version
  13475. * @returns a string representing the current skeleton data
  13476. */
  13477. toString(fullDetails?: boolean): string;
  13478. /**
  13479. * Get bone's index searching by name
  13480. * @param name defines bone's name to search for
  13481. * @return the indice of the bone. Returns -1 if not found
  13482. */
  13483. getBoneIndexByName(name: string): number;
  13484. /**
  13485. * Creater a new animation range
  13486. * @param name defines the name of the range
  13487. * @param from defines the start key
  13488. * @param to defines the end key
  13489. */
  13490. createAnimationRange(name: string, from: number, to: number): void;
  13491. /**
  13492. * Delete a specific animation range
  13493. * @param name defines the name of the range
  13494. * @param deleteFrames defines if frames must be removed as well
  13495. */
  13496. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13497. /**
  13498. * Gets a specific animation range
  13499. * @param name defines the name of the range to look for
  13500. * @returns the requested animation range or null if not found
  13501. */
  13502. getAnimationRange(name: string): Nullable<AnimationRange>;
  13503. /**
  13504. * Gets the list of all animation ranges defined on this skeleton
  13505. * @returns an array
  13506. */
  13507. getAnimationRanges(): Nullable<AnimationRange>[];
  13508. /**
  13509. * Copy animation range from a source skeleton.
  13510. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13511. * @param source defines the source skeleton
  13512. * @param name defines the name of the range to copy
  13513. * @param rescaleAsRequired defines if rescaling must be applied if required
  13514. * @returns true if operation was successful
  13515. */
  13516. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13517. /**
  13518. * Forces the skeleton to go to rest pose
  13519. */
  13520. returnToRest(): void;
  13521. private _getHighestAnimationFrame;
  13522. /**
  13523. * Begin a specific animation range
  13524. * @param name defines the name of the range to start
  13525. * @param loop defines if looping must be turned on (false by default)
  13526. * @param speedRatio defines the speed ratio to apply (1 by default)
  13527. * @param onAnimationEnd defines a callback which will be called when animation will end
  13528. * @returns a new animatable
  13529. */
  13530. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13531. /** @hidden */
  13532. _markAsDirty(): void;
  13533. /** @hidden */
  13534. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13535. /** @hidden */
  13536. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13537. private _computeTransformMatrices;
  13538. /**
  13539. * Build all resources required to render a skeleton
  13540. */
  13541. prepare(): void;
  13542. /**
  13543. * Gets the list of animatables currently running for this skeleton
  13544. * @returns an array of animatables
  13545. */
  13546. getAnimatables(): IAnimatable[];
  13547. /**
  13548. * Clone the current skeleton
  13549. * @param name defines the name of the new skeleton
  13550. * @param id defines the id of the new skeleton
  13551. * @returns the new skeleton
  13552. */
  13553. clone(name: string, id: string): Skeleton;
  13554. /**
  13555. * Enable animation blending for this skeleton
  13556. * @param blendingSpeed defines the blending speed to apply
  13557. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13558. */
  13559. enableBlending(blendingSpeed?: number): void;
  13560. /**
  13561. * Releases all resources associated with the current skeleton
  13562. */
  13563. dispose(): void;
  13564. /**
  13565. * Serialize the skeleton in a JSON object
  13566. * @returns a JSON object
  13567. */
  13568. serialize(): any;
  13569. /**
  13570. * Creates a new skeleton from serialized data
  13571. * @param parsedSkeleton defines the serialized data
  13572. * @param scene defines the hosting scene
  13573. * @returns a new skeleton
  13574. */
  13575. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13576. /**
  13577. * Compute all node absolute transforms
  13578. * @param forceUpdate defines if computation must be done even if cache is up to date
  13579. */
  13580. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13581. /**
  13582. * Gets the root pose matrix
  13583. * @returns a matrix
  13584. */
  13585. getPoseMatrix(): Nullable<Matrix>;
  13586. /**
  13587. * Sorts bones per internal index
  13588. */
  13589. sortBones(): void;
  13590. private _sortBones;
  13591. }
  13592. }
  13593. declare module "babylonjs/Bones/bone" {
  13594. import { Skeleton } from "babylonjs/Bones/skeleton";
  13595. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13596. import { Nullable } from "babylonjs/types";
  13597. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13598. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13599. import { Node } from "babylonjs/node";
  13600. import { Space } from "babylonjs/Maths/math.axis";
  13601. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13602. /**
  13603. * Class used to store bone information
  13604. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13605. */
  13606. export class Bone extends Node {
  13607. /**
  13608. * defines the bone name
  13609. */
  13610. name: string;
  13611. private static _tmpVecs;
  13612. private static _tmpQuat;
  13613. private static _tmpMats;
  13614. /**
  13615. * Gets the list of child bones
  13616. */
  13617. children: Bone[];
  13618. /** Gets the animations associated with this bone */
  13619. animations: import("babylonjs/Animations/animation").Animation[];
  13620. /**
  13621. * Gets or sets bone length
  13622. */
  13623. length: number;
  13624. /**
  13625. * @hidden Internal only
  13626. * Set this value to map this bone to a different index in the transform matrices
  13627. * Set this value to -1 to exclude the bone from the transform matrices
  13628. */
  13629. _index: Nullable<number>;
  13630. private _skeleton;
  13631. private _localMatrix;
  13632. private _restPose;
  13633. private _baseMatrix;
  13634. private _absoluteTransform;
  13635. private _invertedAbsoluteTransform;
  13636. private _parent;
  13637. private _scalingDeterminant;
  13638. private _worldTransform;
  13639. private _localScaling;
  13640. private _localRotation;
  13641. private _localPosition;
  13642. private _needToDecompose;
  13643. private _needToCompose;
  13644. /** @hidden */
  13645. _linkedTransformNode: Nullable<TransformNode>;
  13646. /** @hidden */
  13647. _waitingTransformNodeId: Nullable<string>;
  13648. /** @hidden */
  13649. /** @hidden */
  13650. _matrix: Matrix;
  13651. /**
  13652. * Create a new bone
  13653. * @param name defines the bone name
  13654. * @param skeleton defines the parent skeleton
  13655. * @param parentBone defines the parent (can be null if the bone is the root)
  13656. * @param localMatrix defines the local matrix
  13657. * @param restPose defines the rest pose matrix
  13658. * @param baseMatrix defines the base matrix
  13659. * @param index defines index of the bone in the hiearchy
  13660. */
  13661. constructor(
  13662. /**
  13663. * defines the bone name
  13664. */
  13665. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13666. /**
  13667. * Gets the current object class name.
  13668. * @return the class name
  13669. */
  13670. getClassName(): string;
  13671. /**
  13672. * Gets the parent skeleton
  13673. * @returns a skeleton
  13674. */
  13675. getSkeleton(): Skeleton;
  13676. /**
  13677. * Gets parent bone
  13678. * @returns a bone or null if the bone is the root of the bone hierarchy
  13679. */
  13680. getParent(): Nullable<Bone>;
  13681. /**
  13682. * Returns an array containing the root bones
  13683. * @returns an array containing the root bones
  13684. */
  13685. getChildren(): Array<Bone>;
  13686. /**
  13687. * Sets the parent bone
  13688. * @param parent defines the parent (can be null if the bone is the root)
  13689. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13690. */
  13691. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13692. /**
  13693. * Gets the local matrix
  13694. * @returns a matrix
  13695. */
  13696. getLocalMatrix(): Matrix;
  13697. /**
  13698. * Gets the base matrix (initial matrix which remains unchanged)
  13699. * @returns a matrix
  13700. */
  13701. getBaseMatrix(): Matrix;
  13702. /**
  13703. * Gets the rest pose matrix
  13704. * @returns a matrix
  13705. */
  13706. getRestPose(): Matrix;
  13707. /**
  13708. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13709. */
  13710. getWorldMatrix(): Matrix;
  13711. /**
  13712. * Sets the local matrix to rest pose matrix
  13713. */
  13714. returnToRest(): void;
  13715. /**
  13716. * Gets the inverse of the absolute transform matrix.
  13717. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13718. * @returns a matrix
  13719. */
  13720. getInvertedAbsoluteTransform(): Matrix;
  13721. /**
  13722. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13723. * @returns a matrix
  13724. */
  13725. getAbsoluteTransform(): Matrix;
  13726. /**
  13727. * Links with the given transform node.
  13728. * The local matrix of this bone is copied from the transform node every frame.
  13729. * @param transformNode defines the transform node to link to
  13730. */
  13731. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13732. /**
  13733. * Gets the node used to drive the bone's transformation
  13734. * @returns a transform node or null
  13735. */
  13736. getTransformNode(): Nullable<TransformNode>;
  13737. /** Gets or sets current position (in local space) */
  13738. position: Vector3;
  13739. /** Gets or sets current rotation (in local space) */
  13740. rotation: Vector3;
  13741. /** Gets or sets current rotation quaternion (in local space) */
  13742. rotationQuaternion: Quaternion;
  13743. /** Gets or sets current scaling (in local space) */
  13744. scaling: Vector3;
  13745. /**
  13746. * Gets the animation properties override
  13747. */
  13748. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13749. private _decompose;
  13750. private _compose;
  13751. /**
  13752. * Update the base and local matrices
  13753. * @param matrix defines the new base or local matrix
  13754. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13755. * @param updateLocalMatrix defines if the local matrix should be updated
  13756. */
  13757. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13758. /** @hidden */
  13759. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13760. /**
  13761. * Flag the bone as dirty (Forcing it to update everything)
  13762. */
  13763. markAsDirty(): void;
  13764. /** @hidden */
  13765. _markAsDirtyAndCompose(): void;
  13766. private _markAsDirtyAndDecompose;
  13767. /**
  13768. * Translate the bone in local or world space
  13769. * @param vec The amount to translate the bone
  13770. * @param space The space that the translation is in
  13771. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13772. */
  13773. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13774. /**
  13775. * Set the postion of the bone in local or world space
  13776. * @param position The position to set the bone
  13777. * @param space The space that the position is in
  13778. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13779. */
  13780. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13781. /**
  13782. * Set the absolute position of the bone (world space)
  13783. * @param position The position to set the bone
  13784. * @param mesh The mesh that this bone is attached to
  13785. */
  13786. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13787. /**
  13788. * Scale the bone on the x, y and z axes (in local space)
  13789. * @param x The amount to scale the bone on the x axis
  13790. * @param y The amount to scale the bone on the y axis
  13791. * @param z The amount to scale the bone on the z axis
  13792. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13793. */
  13794. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13795. /**
  13796. * Set the bone scaling in local space
  13797. * @param scale defines the scaling vector
  13798. */
  13799. setScale(scale: Vector3): void;
  13800. /**
  13801. * Gets the current scaling in local space
  13802. * @returns the current scaling vector
  13803. */
  13804. getScale(): Vector3;
  13805. /**
  13806. * Gets the current scaling in local space and stores it in a target vector
  13807. * @param result defines the target vector
  13808. */
  13809. getScaleToRef(result: Vector3): void;
  13810. /**
  13811. * Set the yaw, pitch, and roll of the bone in local or world space
  13812. * @param yaw The rotation of the bone on the y axis
  13813. * @param pitch The rotation of the bone on the x axis
  13814. * @param roll The rotation of the bone on the z axis
  13815. * @param space The space that the axes of rotation are in
  13816. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13817. */
  13818. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13819. /**
  13820. * Add a rotation to the bone on an axis in local or world space
  13821. * @param axis The axis to rotate the bone on
  13822. * @param amount The amount to rotate the bone
  13823. * @param space The space that the axis is in
  13824. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13825. */
  13826. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13827. /**
  13828. * Set the rotation of the bone to a particular axis angle in local or world space
  13829. * @param axis The axis to rotate the bone on
  13830. * @param angle The angle that the bone should be rotated to
  13831. * @param space The space that the axis is in
  13832. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13833. */
  13834. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13835. /**
  13836. * Set the euler rotation of the bone in local of world space
  13837. * @param rotation The euler rotation that the bone should be set to
  13838. * @param space The space that the rotation is in
  13839. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13840. */
  13841. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13842. /**
  13843. * Set the quaternion rotation of the bone in local of world space
  13844. * @param quat The quaternion rotation that the bone should be set to
  13845. * @param space The space that the rotation is in
  13846. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13847. */
  13848. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13849. /**
  13850. * Set the rotation matrix of the bone in local of world space
  13851. * @param rotMat The rotation matrix that the bone should be set to
  13852. * @param space The space that the rotation is in
  13853. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13854. */
  13855. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13856. private _rotateWithMatrix;
  13857. private _getNegativeRotationToRef;
  13858. /**
  13859. * Get the position of the bone in local or world space
  13860. * @param space The space that the returned position is in
  13861. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13862. * @returns The position of the bone
  13863. */
  13864. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13865. /**
  13866. * Copy the position of the bone to a vector3 in local or world space
  13867. * @param space The space that the returned position is in
  13868. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13869. * @param result The vector3 to copy the position to
  13870. */
  13871. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13872. /**
  13873. * Get the absolute position of the bone (world space)
  13874. * @param mesh The mesh that this bone is attached to
  13875. * @returns The absolute position of the bone
  13876. */
  13877. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13878. /**
  13879. * Copy the absolute position of the bone (world space) to the result param
  13880. * @param mesh The mesh that this bone is attached to
  13881. * @param result The vector3 to copy the absolute position to
  13882. */
  13883. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13884. /**
  13885. * Compute the absolute transforms of this bone and its children
  13886. */
  13887. computeAbsoluteTransforms(): void;
  13888. /**
  13889. * Get the world direction from an axis that is in the local space of the bone
  13890. * @param localAxis The local direction that is used to compute the world direction
  13891. * @param mesh The mesh that this bone is attached to
  13892. * @returns The world direction
  13893. */
  13894. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13895. /**
  13896. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13897. * @param localAxis The local direction that is used to compute the world direction
  13898. * @param mesh The mesh that this bone is attached to
  13899. * @param result The vector3 that the world direction will be copied to
  13900. */
  13901. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13902. /**
  13903. * Get the euler rotation of the bone in local or world space
  13904. * @param space The space that the rotation should be in
  13905. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13906. * @returns The euler rotation
  13907. */
  13908. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13909. /**
  13910. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13911. * @param space The space that the rotation should be in
  13912. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13913. * @param result The vector3 that the rotation should be copied to
  13914. */
  13915. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13916. /**
  13917. * Get the quaternion rotation of the bone in either local or world space
  13918. * @param space The space that the rotation should be in
  13919. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13920. * @returns The quaternion rotation
  13921. */
  13922. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13923. /**
  13924. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13925. * @param space The space that the rotation should be in
  13926. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13927. * @param result The quaternion that the rotation should be copied to
  13928. */
  13929. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13930. /**
  13931. * Get the rotation matrix of the bone in local or world space
  13932. * @param space The space that the rotation should be in
  13933. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13934. * @returns The rotation matrix
  13935. */
  13936. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13937. /**
  13938. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13939. * @param space The space that the rotation should be in
  13940. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13941. * @param result The quaternion that the rotation should be copied to
  13942. */
  13943. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13944. /**
  13945. * Get the world position of a point that is in the local space of the bone
  13946. * @param position The local position
  13947. * @param mesh The mesh that this bone is attached to
  13948. * @returns The world position
  13949. */
  13950. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13951. /**
  13952. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13953. * @param position The local position
  13954. * @param mesh The mesh that this bone is attached to
  13955. * @param result The vector3 that the world position should be copied to
  13956. */
  13957. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13958. /**
  13959. * Get the local position of a point that is in world space
  13960. * @param position The world position
  13961. * @param mesh The mesh that this bone is attached to
  13962. * @returns The local position
  13963. */
  13964. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13965. /**
  13966. * Get the local position of a point that is in world space and copy it to the result param
  13967. * @param position The world position
  13968. * @param mesh The mesh that this bone is attached to
  13969. * @param result The vector3 that the local position should be copied to
  13970. */
  13971. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13972. }
  13973. }
  13974. declare module "babylonjs/Meshes/transformNode" {
  13975. import { DeepImmutable } from "babylonjs/types";
  13976. import { Observable } from "babylonjs/Misc/observable";
  13977. import { Nullable } from "babylonjs/types";
  13978. import { Camera } from "babylonjs/Cameras/camera";
  13979. import { Scene } from "babylonjs/scene";
  13980. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13981. import { Node } from "babylonjs/node";
  13982. import { Bone } from "babylonjs/Bones/bone";
  13983. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13984. import { Space } from "babylonjs/Maths/math.axis";
  13985. /**
  13986. * 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.
  13987. * @see https://doc.babylonjs.com/how_to/transformnode
  13988. */
  13989. export class TransformNode extends Node {
  13990. /**
  13991. * Object will not rotate to face the camera
  13992. */
  13993. static BILLBOARDMODE_NONE: number;
  13994. /**
  13995. * Object will rotate to face the camera but only on the x axis
  13996. */
  13997. static BILLBOARDMODE_X: number;
  13998. /**
  13999. * Object will rotate to face the camera but only on the y axis
  14000. */
  14001. static BILLBOARDMODE_Y: number;
  14002. /**
  14003. * Object will rotate to face the camera but only on the z axis
  14004. */
  14005. static BILLBOARDMODE_Z: number;
  14006. /**
  14007. * Object will rotate to face the camera
  14008. */
  14009. static BILLBOARDMODE_ALL: number;
  14010. /**
  14011. * Object will rotate to face the camera's position instead of orientation
  14012. */
  14013. static BILLBOARDMODE_USE_POSITION: number;
  14014. private _forward;
  14015. private _forwardInverted;
  14016. private _up;
  14017. private _right;
  14018. private _rightInverted;
  14019. private _position;
  14020. private _rotation;
  14021. private _rotationQuaternion;
  14022. protected _scaling: Vector3;
  14023. protected _isDirty: boolean;
  14024. private _transformToBoneReferal;
  14025. private _isAbsoluteSynced;
  14026. private _billboardMode;
  14027. /**
  14028. * Gets or sets the billboard mode. Default is 0.
  14029. *
  14030. * | Value | Type | Description |
  14031. * | --- | --- | --- |
  14032. * | 0 | BILLBOARDMODE_NONE | |
  14033. * | 1 | BILLBOARDMODE_X | |
  14034. * | 2 | BILLBOARDMODE_Y | |
  14035. * | 4 | BILLBOARDMODE_Z | |
  14036. * | 7 | BILLBOARDMODE_ALL | |
  14037. *
  14038. */
  14039. billboardMode: number;
  14040. private _preserveParentRotationForBillboard;
  14041. /**
  14042. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14043. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14044. */
  14045. preserveParentRotationForBillboard: boolean;
  14046. /**
  14047. * 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
  14048. */
  14049. scalingDeterminant: number;
  14050. private _infiniteDistance;
  14051. /**
  14052. * Gets or sets the distance of the object to max, often used by skybox
  14053. */
  14054. infiniteDistance: boolean;
  14055. /**
  14056. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14057. * By default the system will update normals to compensate
  14058. */
  14059. ignoreNonUniformScaling: boolean;
  14060. /**
  14061. * 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
  14062. */
  14063. reIntegrateRotationIntoRotationQuaternion: boolean;
  14064. /** @hidden */
  14065. _poseMatrix: Nullable<Matrix>;
  14066. /** @hidden */
  14067. _localMatrix: Matrix;
  14068. private _usePivotMatrix;
  14069. private _absolutePosition;
  14070. private _absoluteScaling;
  14071. private _absoluteRotationQuaternion;
  14072. private _pivotMatrix;
  14073. private _pivotMatrixInverse;
  14074. protected _postMultiplyPivotMatrix: boolean;
  14075. protected _isWorldMatrixFrozen: boolean;
  14076. /** @hidden */
  14077. _indexInSceneTransformNodesArray: number;
  14078. /**
  14079. * An event triggered after the world matrix is updated
  14080. */
  14081. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14082. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14083. /**
  14084. * Gets a string identifying the name of the class
  14085. * @returns "TransformNode" string
  14086. */
  14087. getClassName(): string;
  14088. /**
  14089. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14090. */
  14091. position: Vector3;
  14092. /**
  14093. * 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)).
  14094. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14095. */
  14096. rotation: Vector3;
  14097. /**
  14098. * 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)).
  14099. */
  14100. scaling: Vector3;
  14101. /**
  14102. * 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).
  14103. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14104. */
  14105. rotationQuaternion: Nullable<Quaternion>;
  14106. /**
  14107. * The forward direction of that transform in world space.
  14108. */
  14109. readonly forward: Vector3;
  14110. /**
  14111. * The up direction of that transform in world space.
  14112. */
  14113. readonly up: Vector3;
  14114. /**
  14115. * The right direction of that transform in world space.
  14116. */
  14117. readonly right: Vector3;
  14118. /**
  14119. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14120. * @param matrix the matrix to copy the pose from
  14121. * @returns this TransformNode.
  14122. */
  14123. updatePoseMatrix(matrix: Matrix): TransformNode;
  14124. /**
  14125. * Returns the mesh Pose matrix.
  14126. * @returns the pose matrix
  14127. */
  14128. getPoseMatrix(): Matrix;
  14129. /** @hidden */
  14130. _isSynchronized(): boolean;
  14131. /** @hidden */
  14132. _initCache(): void;
  14133. /**
  14134. * Flag the transform node as dirty (Forcing it to update everything)
  14135. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14136. * @returns this transform node
  14137. */
  14138. markAsDirty(property: string): TransformNode;
  14139. /**
  14140. * Returns the current mesh absolute position.
  14141. * Returns a Vector3.
  14142. */
  14143. readonly absolutePosition: Vector3;
  14144. /**
  14145. * Returns the current mesh absolute scaling.
  14146. * Returns a Vector3.
  14147. */
  14148. readonly absoluteScaling: Vector3;
  14149. /**
  14150. * Returns the current mesh absolute rotation.
  14151. * Returns a Quaternion.
  14152. */
  14153. readonly absoluteRotationQuaternion: Quaternion;
  14154. /**
  14155. * Sets a new matrix to apply before all other transformation
  14156. * @param matrix defines the transform matrix
  14157. * @returns the current TransformNode
  14158. */
  14159. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14160. /**
  14161. * Sets a new pivot matrix to the current node
  14162. * @param matrix defines the new pivot matrix to use
  14163. * @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
  14164. * @returns the current TransformNode
  14165. */
  14166. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14167. /**
  14168. * Returns the mesh pivot matrix.
  14169. * Default : Identity.
  14170. * @returns the matrix
  14171. */
  14172. getPivotMatrix(): Matrix;
  14173. /**
  14174. * Instantiate (when possible) or clone that node with its hierarchy
  14175. * @param newParent defines the new parent to use for the instance (or clone)
  14176. * @returns an instance (or a clone) of the current node with its hiearchy
  14177. */
  14178. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  14179. /**
  14180. * Prevents the World matrix to be computed any longer
  14181. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14182. * @returns the TransformNode.
  14183. */
  14184. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14185. /**
  14186. * Allows back the World matrix computation.
  14187. * @returns the TransformNode.
  14188. */
  14189. unfreezeWorldMatrix(): this;
  14190. /**
  14191. * True if the World matrix has been frozen.
  14192. */
  14193. readonly isWorldMatrixFrozen: boolean;
  14194. /**
  14195. * Retuns the mesh absolute position in the World.
  14196. * @returns a Vector3.
  14197. */
  14198. getAbsolutePosition(): Vector3;
  14199. /**
  14200. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14201. * @param absolutePosition the absolute position to set
  14202. * @returns the TransformNode.
  14203. */
  14204. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14205. /**
  14206. * Sets the mesh position in its local space.
  14207. * @param vector3 the position to set in localspace
  14208. * @returns the TransformNode.
  14209. */
  14210. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14211. /**
  14212. * Returns the mesh position in the local space from the current World matrix values.
  14213. * @returns a new Vector3.
  14214. */
  14215. getPositionExpressedInLocalSpace(): Vector3;
  14216. /**
  14217. * Translates the mesh along the passed Vector3 in its local space.
  14218. * @param vector3 the distance to translate in localspace
  14219. * @returns the TransformNode.
  14220. */
  14221. locallyTranslate(vector3: Vector3): TransformNode;
  14222. private static _lookAtVectorCache;
  14223. /**
  14224. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14225. * @param targetPoint the position (must be in same space as current mesh) to look at
  14226. * @param yawCor optional yaw (y-axis) correction in radians
  14227. * @param pitchCor optional pitch (x-axis) correction in radians
  14228. * @param rollCor optional roll (z-axis) correction in radians
  14229. * @param space the choosen space of the target
  14230. * @returns the TransformNode.
  14231. */
  14232. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14233. /**
  14234. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14235. * This Vector3 is expressed in the World space.
  14236. * @param localAxis axis to rotate
  14237. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14238. */
  14239. getDirection(localAxis: Vector3): Vector3;
  14240. /**
  14241. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14242. * localAxis is expressed in the mesh local space.
  14243. * result is computed in the Wordl space from the mesh World matrix.
  14244. * @param localAxis axis to rotate
  14245. * @param result the resulting transformnode
  14246. * @returns this TransformNode.
  14247. */
  14248. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14249. /**
  14250. * Sets this transform node rotation to the given local axis.
  14251. * @param localAxis the axis in local space
  14252. * @param yawCor optional yaw (y-axis) correction in radians
  14253. * @param pitchCor optional pitch (x-axis) correction in radians
  14254. * @param rollCor optional roll (z-axis) correction in radians
  14255. * @returns this TransformNode
  14256. */
  14257. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14258. /**
  14259. * Sets a new pivot point to the current node
  14260. * @param point defines the new pivot point to use
  14261. * @param space defines if the point is in world or local space (local by default)
  14262. * @returns the current TransformNode
  14263. */
  14264. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14265. /**
  14266. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14267. * @returns the pivot point
  14268. */
  14269. getPivotPoint(): Vector3;
  14270. /**
  14271. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14272. * @param result the vector3 to store the result
  14273. * @returns this TransformNode.
  14274. */
  14275. getPivotPointToRef(result: Vector3): TransformNode;
  14276. /**
  14277. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14278. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14279. */
  14280. getAbsolutePivotPoint(): Vector3;
  14281. /**
  14282. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14283. * @param result vector3 to store the result
  14284. * @returns this TransformNode.
  14285. */
  14286. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14287. /**
  14288. * Defines the passed node as the parent of the current node.
  14289. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14290. * @see https://doc.babylonjs.com/how_to/parenting
  14291. * @param node the node ot set as the parent
  14292. * @returns this TransformNode.
  14293. */
  14294. setParent(node: Nullable<Node>): TransformNode;
  14295. private _nonUniformScaling;
  14296. /**
  14297. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14298. */
  14299. readonly nonUniformScaling: boolean;
  14300. /** @hidden */
  14301. _updateNonUniformScalingState(value: boolean): boolean;
  14302. /**
  14303. * Attach the current TransformNode to another TransformNode associated with a bone
  14304. * @param bone Bone affecting the TransformNode
  14305. * @param affectedTransformNode TransformNode associated with the bone
  14306. * @returns this object
  14307. */
  14308. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14309. /**
  14310. * Detach the transform node if its associated with a bone
  14311. * @returns this object
  14312. */
  14313. detachFromBone(): TransformNode;
  14314. private static _rotationAxisCache;
  14315. /**
  14316. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14317. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14318. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14319. * The passed axis is also normalized.
  14320. * @param axis the axis to rotate around
  14321. * @param amount the amount to rotate in radians
  14322. * @param space Space to rotate in (Default: local)
  14323. * @returns the TransformNode.
  14324. */
  14325. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14326. /**
  14327. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14328. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14329. * The passed axis is also normalized. .
  14330. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14331. * @param point the point to rotate around
  14332. * @param axis the axis to rotate around
  14333. * @param amount the amount to rotate in radians
  14334. * @returns the TransformNode
  14335. */
  14336. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14337. /**
  14338. * Translates the mesh along the axis vector for the passed distance in the given space.
  14339. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14340. * @param axis the axis to translate in
  14341. * @param distance the distance to translate
  14342. * @param space Space to rotate in (Default: local)
  14343. * @returns the TransformNode.
  14344. */
  14345. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14346. /**
  14347. * Adds a rotation step to the mesh current rotation.
  14348. * x, y, z are Euler angles expressed in radians.
  14349. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14350. * This means this rotation is made in the mesh local space only.
  14351. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14352. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14353. * ```javascript
  14354. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14355. * ```
  14356. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14357. * 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.
  14358. * @param x Rotation to add
  14359. * @param y Rotation to add
  14360. * @param z Rotation to add
  14361. * @returns the TransformNode.
  14362. */
  14363. addRotation(x: number, y: number, z: number): TransformNode;
  14364. /**
  14365. * @hidden
  14366. */
  14367. protected _getEffectiveParent(): Nullable<Node>;
  14368. /**
  14369. * Computes the world matrix of the node
  14370. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14371. * @returns the world matrix
  14372. */
  14373. computeWorldMatrix(force?: boolean): Matrix;
  14374. protected _afterComputeWorldMatrix(): void;
  14375. /**
  14376. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14377. * @param func callback function to add
  14378. *
  14379. * @returns the TransformNode.
  14380. */
  14381. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14382. /**
  14383. * Removes a registered callback function.
  14384. * @param func callback function to remove
  14385. * @returns the TransformNode.
  14386. */
  14387. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14388. /**
  14389. * Gets the position of the current mesh in camera space
  14390. * @param camera defines the camera to use
  14391. * @returns a position
  14392. */
  14393. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14394. /**
  14395. * Returns the distance from the mesh to the active camera
  14396. * @param camera defines the camera to use
  14397. * @returns the distance
  14398. */
  14399. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14400. /**
  14401. * Clone the current transform node
  14402. * @param name Name of the new clone
  14403. * @param newParent New parent for the clone
  14404. * @param doNotCloneChildren Do not clone children hierarchy
  14405. * @returns the new transform node
  14406. */
  14407. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14408. /**
  14409. * Serializes the objects information.
  14410. * @param currentSerializationObject defines the object to serialize in
  14411. * @returns the serialized object
  14412. */
  14413. serialize(currentSerializationObject?: any): any;
  14414. /**
  14415. * Returns a new TransformNode object parsed from the source provided.
  14416. * @param parsedTransformNode is the source.
  14417. * @param scene the scne the object belongs to
  14418. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14419. * @returns a new TransformNode object parsed from the source provided.
  14420. */
  14421. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14422. /**
  14423. * Get all child-transformNodes of this node
  14424. * @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
  14425. * @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
  14426. * @returns an array of TransformNode
  14427. */
  14428. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14429. /**
  14430. * Releases resources associated with this transform node.
  14431. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14432. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14433. */
  14434. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14435. /**
  14436. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14437. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14438. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14439. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14440. * @returns the current mesh
  14441. */
  14442. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14443. private _syncAbsoluteScalingAndRotation;
  14444. }
  14445. }
  14446. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14447. import { Observable } from "babylonjs/Misc/observable";
  14448. import { Nullable } from "babylonjs/types";
  14449. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14450. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14451. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14452. import { Ray } from "babylonjs/Culling/ray";
  14453. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14454. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14455. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14456. /**
  14457. * Defines the types of pose enabled controllers that are supported
  14458. */
  14459. export enum PoseEnabledControllerType {
  14460. /**
  14461. * HTC Vive
  14462. */
  14463. VIVE = 0,
  14464. /**
  14465. * Oculus Rift
  14466. */
  14467. OCULUS = 1,
  14468. /**
  14469. * Windows mixed reality
  14470. */
  14471. WINDOWS = 2,
  14472. /**
  14473. * Samsung gear VR
  14474. */
  14475. GEAR_VR = 3,
  14476. /**
  14477. * Google Daydream
  14478. */
  14479. DAYDREAM = 4,
  14480. /**
  14481. * Generic
  14482. */
  14483. GENERIC = 5
  14484. }
  14485. /**
  14486. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14487. */
  14488. export interface MutableGamepadButton {
  14489. /**
  14490. * Value of the button/trigger
  14491. */
  14492. value: number;
  14493. /**
  14494. * If the button/trigger is currently touched
  14495. */
  14496. touched: boolean;
  14497. /**
  14498. * If the button/trigger is currently pressed
  14499. */
  14500. pressed: boolean;
  14501. }
  14502. /**
  14503. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14504. * @hidden
  14505. */
  14506. export interface ExtendedGamepadButton extends GamepadButton {
  14507. /**
  14508. * If the button/trigger is currently pressed
  14509. */
  14510. readonly pressed: boolean;
  14511. /**
  14512. * If the button/trigger is currently touched
  14513. */
  14514. readonly touched: boolean;
  14515. /**
  14516. * Value of the button/trigger
  14517. */
  14518. readonly value: number;
  14519. }
  14520. /** @hidden */
  14521. export interface _GamePadFactory {
  14522. /**
  14523. * Returns wether or not the current gamepad can be created for this type of controller.
  14524. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14525. * @returns true if it can be created, otherwise false
  14526. */
  14527. canCreate(gamepadInfo: any): boolean;
  14528. /**
  14529. * Creates a new instance of the Gamepad.
  14530. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14531. * @returns the new gamepad instance
  14532. */
  14533. create(gamepadInfo: any): Gamepad;
  14534. }
  14535. /**
  14536. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14537. */
  14538. export class PoseEnabledControllerHelper {
  14539. /** @hidden */
  14540. static _ControllerFactories: _GamePadFactory[];
  14541. /** @hidden */
  14542. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14543. /**
  14544. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14545. * @param vrGamepad the gamepad to initialized
  14546. * @returns a vr controller of the type the gamepad identified as
  14547. */
  14548. static InitiateController(vrGamepad: any): Gamepad;
  14549. }
  14550. /**
  14551. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14552. */
  14553. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14554. /**
  14555. * If the controller is used in a webXR session
  14556. */
  14557. isXR: boolean;
  14558. private _deviceRoomPosition;
  14559. private _deviceRoomRotationQuaternion;
  14560. /**
  14561. * The device position in babylon space
  14562. */
  14563. devicePosition: Vector3;
  14564. /**
  14565. * The device rotation in babylon space
  14566. */
  14567. deviceRotationQuaternion: Quaternion;
  14568. /**
  14569. * The scale factor of the device in babylon space
  14570. */
  14571. deviceScaleFactor: number;
  14572. /**
  14573. * (Likely devicePosition should be used instead) The device position in its room space
  14574. */
  14575. position: Vector3;
  14576. /**
  14577. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14578. */
  14579. rotationQuaternion: Quaternion;
  14580. /**
  14581. * The type of controller (Eg. Windows mixed reality)
  14582. */
  14583. controllerType: PoseEnabledControllerType;
  14584. protected _calculatedPosition: Vector3;
  14585. private _calculatedRotation;
  14586. /**
  14587. * The raw pose from the device
  14588. */
  14589. rawPose: DevicePose;
  14590. private _trackPosition;
  14591. private _maxRotationDistFromHeadset;
  14592. private _draggedRoomRotation;
  14593. /**
  14594. * @hidden
  14595. */
  14596. _disableTrackPosition(fixedPosition: Vector3): void;
  14597. /**
  14598. * Internal, the mesh attached to the controller
  14599. * @hidden
  14600. */
  14601. _mesh: Nullable<AbstractMesh>;
  14602. private _poseControlledCamera;
  14603. private _leftHandSystemQuaternion;
  14604. /**
  14605. * Internal, matrix used to convert room space to babylon space
  14606. * @hidden
  14607. */
  14608. _deviceToWorld: Matrix;
  14609. /**
  14610. * Node to be used when casting a ray from the controller
  14611. * @hidden
  14612. */
  14613. _pointingPoseNode: Nullable<TransformNode>;
  14614. /**
  14615. * Name of the child mesh that can be used to cast a ray from the controller
  14616. */
  14617. static readonly POINTING_POSE: string;
  14618. /**
  14619. * Creates a new PoseEnabledController from a gamepad
  14620. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14621. */
  14622. constructor(browserGamepad: any);
  14623. private _workingMatrix;
  14624. /**
  14625. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14626. */
  14627. update(): void;
  14628. /**
  14629. * Updates only the pose device and mesh without doing any button event checking
  14630. */
  14631. protected _updatePoseAndMesh(): void;
  14632. /**
  14633. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14634. * @param poseData raw pose fromthe device
  14635. */
  14636. updateFromDevice(poseData: DevicePose): void;
  14637. /**
  14638. * @hidden
  14639. */
  14640. _meshAttachedObservable: Observable<AbstractMesh>;
  14641. /**
  14642. * Attaches a mesh to the controller
  14643. * @param mesh the mesh to be attached
  14644. */
  14645. attachToMesh(mesh: AbstractMesh): void;
  14646. /**
  14647. * Attaches the controllers mesh to a camera
  14648. * @param camera the camera the mesh should be attached to
  14649. */
  14650. attachToPoseControlledCamera(camera: TargetCamera): void;
  14651. /**
  14652. * Disposes of the controller
  14653. */
  14654. dispose(): void;
  14655. /**
  14656. * The mesh that is attached to the controller
  14657. */
  14658. readonly mesh: Nullable<AbstractMesh>;
  14659. /**
  14660. * Gets the ray of the controller in the direction the controller is pointing
  14661. * @param length the length the resulting ray should be
  14662. * @returns a ray in the direction the controller is pointing
  14663. */
  14664. getForwardRay(length?: number): Ray;
  14665. }
  14666. }
  14667. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14668. import { Observable } from "babylonjs/Misc/observable";
  14669. import { Scene } from "babylonjs/scene";
  14670. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14671. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14672. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14673. /**
  14674. * Defines the WebVRController object that represents controllers tracked in 3D space
  14675. */
  14676. export abstract class WebVRController extends PoseEnabledController {
  14677. /**
  14678. * Internal, the default controller model for the controller
  14679. */
  14680. protected _defaultModel: AbstractMesh;
  14681. /**
  14682. * Fired when the trigger state has changed
  14683. */
  14684. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14685. /**
  14686. * Fired when the main button state has changed
  14687. */
  14688. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14689. /**
  14690. * Fired when the secondary button state has changed
  14691. */
  14692. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14693. /**
  14694. * Fired when the pad state has changed
  14695. */
  14696. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14697. /**
  14698. * Fired when controllers stick values have changed
  14699. */
  14700. onPadValuesChangedObservable: Observable<StickValues>;
  14701. /**
  14702. * Array of button availible on the controller
  14703. */
  14704. protected _buttons: Array<MutableGamepadButton>;
  14705. private _onButtonStateChange;
  14706. /**
  14707. * Fired when a controller button's state has changed
  14708. * @param callback the callback containing the button that was modified
  14709. */
  14710. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14711. /**
  14712. * X and Y axis corresponding to the controllers joystick
  14713. */
  14714. pad: StickValues;
  14715. /**
  14716. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14717. */
  14718. hand: string;
  14719. /**
  14720. * The default controller model for the controller
  14721. */
  14722. readonly defaultModel: AbstractMesh;
  14723. /**
  14724. * Creates a new WebVRController from a gamepad
  14725. * @param vrGamepad the gamepad that the WebVRController should be created from
  14726. */
  14727. constructor(vrGamepad: any);
  14728. /**
  14729. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14730. */
  14731. update(): void;
  14732. /**
  14733. * Function to be called when a button is modified
  14734. */
  14735. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14736. /**
  14737. * Loads a mesh and attaches it to the controller
  14738. * @param scene the scene the mesh should be added to
  14739. * @param meshLoaded callback for when the mesh has been loaded
  14740. */
  14741. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14742. private _setButtonValue;
  14743. private _changes;
  14744. private _checkChanges;
  14745. /**
  14746. * Disposes of th webVRCOntroller
  14747. */
  14748. dispose(): void;
  14749. }
  14750. }
  14751. declare module "babylonjs/Lights/hemisphericLight" {
  14752. import { Nullable } from "babylonjs/types";
  14753. import { Scene } from "babylonjs/scene";
  14754. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14755. import { Color3 } from "babylonjs/Maths/math.color";
  14756. import { Effect } from "babylonjs/Materials/effect";
  14757. import { Light } from "babylonjs/Lights/light";
  14758. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14759. /**
  14760. * The HemisphericLight simulates the ambient environment light,
  14761. * so the passed direction is the light reflection direction, not the incoming direction.
  14762. */
  14763. export class HemisphericLight extends Light {
  14764. /**
  14765. * The groundColor is the light in the opposite direction to the one specified during creation.
  14766. * 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.
  14767. */
  14768. groundColor: Color3;
  14769. /**
  14770. * The light reflection direction, not the incoming direction.
  14771. */
  14772. direction: Vector3;
  14773. /**
  14774. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14775. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14776. * The HemisphericLight can't cast shadows.
  14777. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14778. * @param name The friendly name of the light
  14779. * @param direction The direction of the light reflection
  14780. * @param scene The scene the light belongs to
  14781. */
  14782. constructor(name: string, direction: Vector3, scene: Scene);
  14783. protected _buildUniformLayout(): void;
  14784. /**
  14785. * Returns the string "HemisphericLight".
  14786. * @return The class name
  14787. */
  14788. getClassName(): string;
  14789. /**
  14790. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14791. * Returns the updated direction.
  14792. * @param target The target the direction should point to
  14793. * @return The computed direction
  14794. */
  14795. setDirectionToTarget(target: Vector3): Vector3;
  14796. /**
  14797. * Returns the shadow generator associated to the light.
  14798. * @returns Always null for hemispheric lights because it does not support shadows.
  14799. */
  14800. getShadowGenerator(): Nullable<IShadowGenerator>;
  14801. /**
  14802. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14803. * @param effect The effect to update
  14804. * @param lightIndex The index of the light in the effect to update
  14805. * @returns The hemispheric light
  14806. */
  14807. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14808. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14809. /**
  14810. * Computes the world matrix of the node
  14811. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14812. * @param useWasUpdatedFlag defines a reserved property
  14813. * @returns the world matrix
  14814. */
  14815. computeWorldMatrix(): Matrix;
  14816. /**
  14817. * Returns the integer 3.
  14818. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14819. */
  14820. getTypeID(): number;
  14821. /**
  14822. * Prepares the list of defines specific to the light type.
  14823. * @param defines the list of defines
  14824. * @param lightIndex defines the index of the light for the effect
  14825. */
  14826. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14827. }
  14828. }
  14829. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14830. /** @hidden */
  14831. export var vrMultiviewToSingleviewPixelShader: {
  14832. name: string;
  14833. shader: string;
  14834. };
  14835. }
  14836. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  14837. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14838. import { Scene } from "babylonjs/scene";
  14839. /**
  14840. * Renders to multiple views with a single draw call
  14841. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14842. */
  14843. export class MultiviewRenderTarget extends RenderTargetTexture {
  14844. /**
  14845. * Creates a multiview render target
  14846. * @param scene scene used with the render target
  14847. * @param size the size of the render target (used for each view)
  14848. */
  14849. constructor(scene: Scene, size?: number | {
  14850. width: number;
  14851. height: number;
  14852. } | {
  14853. ratio: number;
  14854. });
  14855. /**
  14856. * @hidden
  14857. * @param faceIndex the face index, if its a cube texture
  14858. */
  14859. _bindFrameBuffer(faceIndex?: number): void;
  14860. /**
  14861. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14862. * @returns the view count
  14863. */
  14864. getViewCount(): number;
  14865. }
  14866. }
  14867. declare module "babylonjs/Maths/math.frustum" {
  14868. import { Matrix } from "babylonjs/Maths/math.vector";
  14869. import { DeepImmutable } from "babylonjs/types";
  14870. import { Plane } from "babylonjs/Maths/math.plane";
  14871. /**
  14872. * Represents a camera frustum
  14873. */
  14874. export class Frustum {
  14875. /**
  14876. * Gets the planes representing the frustum
  14877. * @param transform matrix to be applied to the returned planes
  14878. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14879. */
  14880. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14881. /**
  14882. * Gets the near frustum plane transformed by the transform matrix
  14883. * @param transform transformation matrix to be applied to the resulting frustum plane
  14884. * @param frustumPlane the resuling frustum plane
  14885. */
  14886. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14887. /**
  14888. * Gets the far frustum plane transformed by the transform matrix
  14889. * @param transform transformation matrix to be applied to the resulting frustum plane
  14890. * @param frustumPlane the resuling frustum plane
  14891. */
  14892. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14893. /**
  14894. * Gets the left frustum plane transformed by the transform matrix
  14895. * @param transform transformation matrix to be applied to the resulting frustum plane
  14896. * @param frustumPlane the resuling frustum plane
  14897. */
  14898. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14899. /**
  14900. * Gets the right frustum plane transformed by the transform matrix
  14901. * @param transform transformation matrix to be applied to the resulting frustum plane
  14902. * @param frustumPlane the resuling frustum plane
  14903. */
  14904. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14905. /**
  14906. * Gets the top frustum plane transformed by the transform matrix
  14907. * @param transform transformation matrix to be applied to the resulting frustum plane
  14908. * @param frustumPlane the resuling frustum plane
  14909. */
  14910. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14911. /**
  14912. * Gets the bottom frustum plane transformed by the transform matrix
  14913. * @param transform transformation matrix to be applied to the resulting frustum plane
  14914. * @param frustumPlane the resuling frustum plane
  14915. */
  14916. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14917. /**
  14918. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14919. * @param transform transformation matrix to be applied to the resulting frustum planes
  14920. * @param frustumPlanes the resuling frustum planes
  14921. */
  14922. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14923. }
  14924. }
  14925. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  14926. import { Camera } from "babylonjs/Cameras/camera";
  14927. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14928. import { Nullable } from "babylonjs/types";
  14929. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14930. import { Matrix } from "babylonjs/Maths/math.vector";
  14931. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  14932. module "babylonjs/Engines/engine" {
  14933. interface Engine {
  14934. /**
  14935. * Creates a new multiview render target
  14936. * @param width defines the width of the texture
  14937. * @param height defines the height of the texture
  14938. * @returns the created multiview texture
  14939. */
  14940. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14941. /**
  14942. * Binds a multiview framebuffer to be drawn to
  14943. * @param multiviewTexture texture to bind
  14944. */
  14945. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14946. }
  14947. }
  14948. module "babylonjs/Cameras/camera" {
  14949. interface Camera {
  14950. /**
  14951. * @hidden
  14952. * 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)
  14953. */
  14954. _useMultiviewToSingleView: boolean;
  14955. /**
  14956. * @hidden
  14957. * 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)
  14958. */
  14959. _multiviewTexture: Nullable<RenderTargetTexture>;
  14960. /**
  14961. * @hidden
  14962. * ensures the multiview texture of the camera exists and has the specified width/height
  14963. * @param width height to set on the multiview texture
  14964. * @param height width to set on the multiview texture
  14965. */
  14966. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14967. }
  14968. }
  14969. module "babylonjs/scene" {
  14970. interface Scene {
  14971. /** @hidden */
  14972. _transformMatrixR: Matrix;
  14973. /** @hidden */
  14974. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14975. /** @hidden */
  14976. _createMultiviewUbo(): void;
  14977. /** @hidden */
  14978. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14979. /** @hidden */
  14980. _renderMultiviewToSingleView(camera: Camera): void;
  14981. }
  14982. }
  14983. }
  14984. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  14985. import { Camera } from "babylonjs/Cameras/camera";
  14986. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  14987. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  14988. import "babylonjs/Engines/Extensions/engine.multiview";
  14989. /**
  14990. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14991. * This will not be used for webXR as it supports displaying texture arrays directly
  14992. */
  14993. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14994. /**
  14995. * Initializes a VRMultiviewToSingleview
  14996. * @param name name of the post process
  14997. * @param camera camera to be applied to
  14998. * @param scaleFactor scaling factor to the size of the output texture
  14999. */
  15000. constructor(name: string, camera: Camera, scaleFactor: number);
  15001. }
  15002. }
  15003. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15004. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15005. import { Nullable } from "babylonjs/types";
  15006. import { Size } from "babylonjs/Maths/math.size";
  15007. import { Observable } from "babylonjs/Misc/observable";
  15008. module "babylonjs/Engines/engine" {
  15009. interface Engine {
  15010. /** @hidden */
  15011. _vrDisplay: any;
  15012. /** @hidden */
  15013. _vrSupported: boolean;
  15014. /** @hidden */
  15015. _oldSize: Size;
  15016. /** @hidden */
  15017. _oldHardwareScaleFactor: number;
  15018. /** @hidden */
  15019. _vrExclusivePointerMode: boolean;
  15020. /** @hidden */
  15021. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15022. /** @hidden */
  15023. _onVRDisplayPointerRestricted: () => void;
  15024. /** @hidden */
  15025. _onVRDisplayPointerUnrestricted: () => void;
  15026. /** @hidden */
  15027. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15028. /** @hidden */
  15029. _onVrDisplayDisconnect: Nullable<() => void>;
  15030. /** @hidden */
  15031. _onVrDisplayPresentChange: Nullable<() => void>;
  15032. /**
  15033. * Observable signaled when VR display mode changes
  15034. */
  15035. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15036. /**
  15037. * Observable signaled when VR request present is complete
  15038. */
  15039. onVRRequestPresentComplete: Observable<boolean>;
  15040. /**
  15041. * Observable signaled when VR request present starts
  15042. */
  15043. onVRRequestPresentStart: Observable<Engine>;
  15044. /**
  15045. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15046. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15047. */
  15048. isInVRExclusivePointerMode: boolean;
  15049. /**
  15050. * Gets a boolean indicating if a webVR device was detected
  15051. * @returns true if a webVR device was detected
  15052. */
  15053. isVRDevicePresent(): boolean;
  15054. /**
  15055. * Gets the current webVR device
  15056. * @returns the current webVR device (or null)
  15057. */
  15058. getVRDevice(): any;
  15059. /**
  15060. * Initializes a webVR display and starts listening to display change events
  15061. * The onVRDisplayChangedObservable will be notified upon these changes
  15062. * @returns A promise containing a VRDisplay and if vr is supported
  15063. */
  15064. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15065. /** @hidden */
  15066. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15067. /**
  15068. * Call this function to switch to webVR mode
  15069. * Will do nothing if webVR is not supported or if there is no webVR device
  15070. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15071. */
  15072. enableVR(): void;
  15073. /** @hidden */
  15074. _onVRFullScreenTriggered(): void;
  15075. }
  15076. }
  15077. }
  15078. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15079. import { Nullable } from "babylonjs/types";
  15080. import { Observable } from "babylonjs/Misc/observable";
  15081. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15082. import { Scene } from "babylonjs/scene";
  15083. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15084. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15085. import { Node } from "babylonjs/node";
  15086. import { Ray } from "babylonjs/Culling/ray";
  15087. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15088. import "babylonjs/Engines/Extensions/engine.webVR";
  15089. /**
  15090. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15091. * IMPORTANT!! The data is right-hand data.
  15092. * @export
  15093. * @interface DevicePose
  15094. */
  15095. export interface DevicePose {
  15096. /**
  15097. * The position of the device, values in array are [x,y,z].
  15098. */
  15099. readonly position: Nullable<Float32Array>;
  15100. /**
  15101. * The linearVelocity of the device, values in array are [x,y,z].
  15102. */
  15103. readonly linearVelocity: Nullable<Float32Array>;
  15104. /**
  15105. * The linearAcceleration of the device, values in array are [x,y,z].
  15106. */
  15107. readonly linearAcceleration: Nullable<Float32Array>;
  15108. /**
  15109. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15110. */
  15111. readonly orientation: Nullable<Float32Array>;
  15112. /**
  15113. * The angularVelocity of the device, values in array are [x,y,z].
  15114. */
  15115. readonly angularVelocity: Nullable<Float32Array>;
  15116. /**
  15117. * The angularAcceleration of the device, values in array are [x,y,z].
  15118. */
  15119. readonly angularAcceleration: Nullable<Float32Array>;
  15120. }
  15121. /**
  15122. * Interface representing a pose controlled object in Babylon.
  15123. * A pose controlled object has both regular pose values as well as pose values
  15124. * from an external device such as a VR head mounted display
  15125. */
  15126. export interface PoseControlled {
  15127. /**
  15128. * The position of the object in babylon space.
  15129. */
  15130. position: Vector3;
  15131. /**
  15132. * The rotation quaternion of the object in babylon space.
  15133. */
  15134. rotationQuaternion: Quaternion;
  15135. /**
  15136. * The position of the device in babylon space.
  15137. */
  15138. devicePosition?: Vector3;
  15139. /**
  15140. * The rotation quaternion of the device in babylon space.
  15141. */
  15142. deviceRotationQuaternion: Quaternion;
  15143. /**
  15144. * The raw pose coming from the device.
  15145. */
  15146. rawPose: Nullable<DevicePose>;
  15147. /**
  15148. * The scale of the device to be used when translating from device space to babylon space.
  15149. */
  15150. deviceScaleFactor: number;
  15151. /**
  15152. * Updates the poseControlled values based on the input device pose.
  15153. * @param poseData the pose data to update the object with
  15154. */
  15155. updateFromDevice(poseData: DevicePose): void;
  15156. }
  15157. /**
  15158. * Set of options to customize the webVRCamera
  15159. */
  15160. export interface WebVROptions {
  15161. /**
  15162. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15163. */
  15164. trackPosition?: boolean;
  15165. /**
  15166. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15167. */
  15168. positionScale?: number;
  15169. /**
  15170. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15171. */
  15172. displayName?: string;
  15173. /**
  15174. * Should the native controller meshes be initialized. (default: true)
  15175. */
  15176. controllerMeshes?: boolean;
  15177. /**
  15178. * Creating a default HemiLight only on controllers. (default: true)
  15179. */
  15180. defaultLightingOnControllers?: boolean;
  15181. /**
  15182. * If you don't want to use the default VR button of the helper. (default: false)
  15183. */
  15184. useCustomVRButton?: boolean;
  15185. /**
  15186. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15187. */
  15188. customVRButton?: HTMLButtonElement;
  15189. /**
  15190. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15191. */
  15192. rayLength?: number;
  15193. /**
  15194. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15195. */
  15196. defaultHeight?: number;
  15197. /**
  15198. * If multiview should be used if availible (default: false)
  15199. */
  15200. useMultiview?: boolean;
  15201. }
  15202. /**
  15203. * This represents a WebVR camera.
  15204. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15205. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15206. */
  15207. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15208. private webVROptions;
  15209. /**
  15210. * @hidden
  15211. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15212. */
  15213. _vrDevice: any;
  15214. /**
  15215. * The rawPose of the vrDevice.
  15216. */
  15217. rawPose: Nullable<DevicePose>;
  15218. private _onVREnabled;
  15219. private _specsVersion;
  15220. private _attached;
  15221. private _frameData;
  15222. protected _descendants: Array<Node>;
  15223. private _deviceRoomPosition;
  15224. /** @hidden */
  15225. _deviceRoomRotationQuaternion: Quaternion;
  15226. private _standingMatrix;
  15227. /**
  15228. * Represents device position in babylon space.
  15229. */
  15230. devicePosition: Vector3;
  15231. /**
  15232. * Represents device rotation in babylon space.
  15233. */
  15234. deviceRotationQuaternion: Quaternion;
  15235. /**
  15236. * The scale of the device to be used when translating from device space to babylon space.
  15237. */
  15238. deviceScaleFactor: number;
  15239. private _deviceToWorld;
  15240. private _worldToDevice;
  15241. /**
  15242. * References to the webVR controllers for the vrDevice.
  15243. */
  15244. controllers: Array<WebVRController>;
  15245. /**
  15246. * Emits an event when a controller is attached.
  15247. */
  15248. onControllersAttachedObservable: Observable<WebVRController[]>;
  15249. /**
  15250. * Emits an event when a controller's mesh has been loaded;
  15251. */
  15252. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15253. /**
  15254. * Emits an event when the HMD's pose has been updated.
  15255. */
  15256. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15257. private _poseSet;
  15258. /**
  15259. * If the rig cameras be used as parent instead of this camera.
  15260. */
  15261. rigParenting: boolean;
  15262. private _lightOnControllers;
  15263. private _defaultHeight?;
  15264. /**
  15265. * Instantiates a WebVRFreeCamera.
  15266. * @param name The name of the WebVRFreeCamera
  15267. * @param position The starting anchor position for the camera
  15268. * @param scene The scene the camera belongs to
  15269. * @param webVROptions a set of customizable options for the webVRCamera
  15270. */
  15271. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15272. /**
  15273. * Gets the device distance from the ground in meters.
  15274. * @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.
  15275. */
  15276. deviceDistanceToRoomGround(): number;
  15277. /**
  15278. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15279. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15280. */
  15281. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15282. /**
  15283. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15284. * @returns A promise with a boolean set to if the standing matrix is supported.
  15285. */
  15286. useStandingMatrixAsync(): Promise<boolean>;
  15287. /**
  15288. * Disposes the camera
  15289. */
  15290. dispose(): void;
  15291. /**
  15292. * Gets a vrController by name.
  15293. * @param name The name of the controller to retreive
  15294. * @returns the controller matching the name specified or null if not found
  15295. */
  15296. getControllerByName(name: string): Nullable<WebVRController>;
  15297. private _leftController;
  15298. /**
  15299. * The controller corresponding to the users left hand.
  15300. */
  15301. readonly leftController: Nullable<WebVRController>;
  15302. private _rightController;
  15303. /**
  15304. * The controller corresponding to the users right hand.
  15305. */
  15306. readonly rightController: Nullable<WebVRController>;
  15307. /**
  15308. * Casts a ray forward from the vrCamera's gaze.
  15309. * @param length Length of the ray (default: 100)
  15310. * @returns the ray corresponding to the gaze
  15311. */
  15312. getForwardRay(length?: number): Ray;
  15313. /**
  15314. * @hidden
  15315. * Updates the camera based on device's frame data
  15316. */
  15317. _checkInputs(): void;
  15318. /**
  15319. * Updates the poseControlled values based on the input device pose.
  15320. * @param poseData Pose coming from the device
  15321. */
  15322. updateFromDevice(poseData: DevicePose): void;
  15323. private _htmlElementAttached;
  15324. private _detachIfAttached;
  15325. /**
  15326. * WebVR's attach control will start broadcasting frames to the device.
  15327. * Note that in certain browsers (chrome for example) this function must be called
  15328. * within a user-interaction callback. Example:
  15329. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15330. *
  15331. * @param element html element to attach the vrDevice to
  15332. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15333. */
  15334. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15335. /**
  15336. * Detaches the camera from the html element and disables VR
  15337. *
  15338. * @param element html element to detach from
  15339. */
  15340. detachControl(element: HTMLElement): void;
  15341. /**
  15342. * @returns the name of this class
  15343. */
  15344. getClassName(): string;
  15345. /**
  15346. * Calls resetPose on the vrDisplay
  15347. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15348. */
  15349. resetToCurrentRotation(): void;
  15350. /**
  15351. * @hidden
  15352. * Updates the rig cameras (left and right eye)
  15353. */
  15354. _updateRigCameras(): void;
  15355. private _workingVector;
  15356. private _oneVector;
  15357. private _workingMatrix;
  15358. private updateCacheCalled;
  15359. private _correctPositionIfNotTrackPosition;
  15360. /**
  15361. * @hidden
  15362. * Updates the cached values of the camera
  15363. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15364. */
  15365. _updateCache(ignoreParentClass?: boolean): void;
  15366. /**
  15367. * @hidden
  15368. * Get current device position in babylon world
  15369. */
  15370. _computeDevicePosition(): void;
  15371. /**
  15372. * Updates the current device position and rotation in the babylon world
  15373. */
  15374. update(): void;
  15375. /**
  15376. * @hidden
  15377. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15378. * @returns an identity matrix
  15379. */
  15380. _getViewMatrix(): Matrix;
  15381. private _tmpMatrix;
  15382. /**
  15383. * This function is called by the two RIG cameras.
  15384. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15385. * @hidden
  15386. */
  15387. _getWebVRViewMatrix(): Matrix;
  15388. /** @hidden */
  15389. _getWebVRProjectionMatrix(): Matrix;
  15390. private _onGamepadConnectedObserver;
  15391. private _onGamepadDisconnectedObserver;
  15392. private _updateCacheWhenTrackingDisabledObserver;
  15393. /**
  15394. * Initializes the controllers and their meshes
  15395. */
  15396. initControllers(): void;
  15397. }
  15398. }
  15399. declare module "babylonjs/PostProcesses/postProcess" {
  15400. import { Nullable } from "babylonjs/types";
  15401. import { SmartArray } from "babylonjs/Misc/smartArray";
  15402. import { Observable } from "babylonjs/Misc/observable";
  15403. import { Vector2 } from "babylonjs/Maths/math.vector";
  15404. import { Camera } from "babylonjs/Cameras/camera";
  15405. import { Effect } from "babylonjs/Materials/effect";
  15406. import "babylonjs/Shaders/postprocess.vertex";
  15407. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15408. import { Engine } from "babylonjs/Engines/engine";
  15409. import { Color4 } from "babylonjs/Maths/math.color";
  15410. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15411. /**
  15412. * Size options for a post process
  15413. */
  15414. export type PostProcessOptions = {
  15415. width: number;
  15416. height: number;
  15417. };
  15418. /**
  15419. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15420. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15421. */
  15422. export class PostProcess {
  15423. /** Name of the PostProcess. */
  15424. name: string;
  15425. /**
  15426. * Gets or sets the unique id of the post process
  15427. */
  15428. uniqueId: number;
  15429. /**
  15430. * Width of the texture to apply the post process on
  15431. */
  15432. width: number;
  15433. /**
  15434. * Height of the texture to apply the post process on
  15435. */
  15436. height: number;
  15437. /**
  15438. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15439. * @hidden
  15440. */
  15441. _outputTexture: Nullable<InternalTexture>;
  15442. /**
  15443. * Sampling mode used by the shader
  15444. * See https://doc.babylonjs.com/classes/3.1/texture
  15445. */
  15446. renderTargetSamplingMode: number;
  15447. /**
  15448. * Clear color to use when screen clearing
  15449. */
  15450. clearColor: Color4;
  15451. /**
  15452. * If the buffer needs to be cleared before applying the post process. (default: true)
  15453. * Should be set to false if shader will overwrite all previous pixels.
  15454. */
  15455. autoClear: boolean;
  15456. /**
  15457. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15458. */
  15459. alphaMode: number;
  15460. /**
  15461. * Sets the setAlphaBlendConstants of the babylon engine
  15462. */
  15463. alphaConstants: Color4;
  15464. /**
  15465. * Animations to be used for the post processing
  15466. */
  15467. animations: import("babylonjs/Animations/animation").Animation[];
  15468. /**
  15469. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15470. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15471. */
  15472. enablePixelPerfectMode: boolean;
  15473. /**
  15474. * Force the postprocess to be applied without taking in account viewport
  15475. */
  15476. forceFullscreenViewport: boolean;
  15477. /**
  15478. * List of inspectable custom properties (used by the Inspector)
  15479. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15480. */
  15481. inspectableCustomProperties: IInspectable[];
  15482. /**
  15483. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15484. *
  15485. * | Value | Type | Description |
  15486. * | ----- | ----------------------------------- | ----------- |
  15487. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15488. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15489. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15490. *
  15491. */
  15492. scaleMode: number;
  15493. /**
  15494. * Force textures to be a power of two (default: false)
  15495. */
  15496. alwaysForcePOT: boolean;
  15497. private _samples;
  15498. /**
  15499. * Number of sample textures (default: 1)
  15500. */
  15501. samples: number;
  15502. /**
  15503. * Modify the scale of the post process to be the same as the viewport (default: false)
  15504. */
  15505. adaptScaleToCurrentViewport: boolean;
  15506. private _camera;
  15507. private _scene;
  15508. private _engine;
  15509. private _options;
  15510. private _reusable;
  15511. private _textureType;
  15512. /**
  15513. * Smart array of input and output textures for the post process.
  15514. * @hidden
  15515. */
  15516. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15517. /**
  15518. * The index in _textures that corresponds to the output texture.
  15519. * @hidden
  15520. */
  15521. _currentRenderTextureInd: number;
  15522. private _effect;
  15523. private _samplers;
  15524. private _fragmentUrl;
  15525. private _vertexUrl;
  15526. private _parameters;
  15527. private _scaleRatio;
  15528. protected _indexParameters: any;
  15529. private _shareOutputWithPostProcess;
  15530. private _texelSize;
  15531. private _forcedOutputTexture;
  15532. /**
  15533. * Returns the fragment url or shader name used in the post process.
  15534. * @returns the fragment url or name in the shader store.
  15535. */
  15536. getEffectName(): string;
  15537. /**
  15538. * An event triggered when the postprocess is activated.
  15539. */
  15540. onActivateObservable: Observable<Camera>;
  15541. private _onActivateObserver;
  15542. /**
  15543. * A function that is added to the onActivateObservable
  15544. */
  15545. onActivate: Nullable<(camera: Camera) => void>;
  15546. /**
  15547. * An event triggered when the postprocess changes its size.
  15548. */
  15549. onSizeChangedObservable: Observable<PostProcess>;
  15550. private _onSizeChangedObserver;
  15551. /**
  15552. * A function that is added to the onSizeChangedObservable
  15553. */
  15554. onSizeChanged: (postProcess: PostProcess) => void;
  15555. /**
  15556. * An event triggered when the postprocess applies its effect.
  15557. */
  15558. onApplyObservable: Observable<Effect>;
  15559. private _onApplyObserver;
  15560. /**
  15561. * A function that is added to the onApplyObservable
  15562. */
  15563. onApply: (effect: Effect) => void;
  15564. /**
  15565. * An event triggered before rendering the postprocess
  15566. */
  15567. onBeforeRenderObservable: Observable<Effect>;
  15568. private _onBeforeRenderObserver;
  15569. /**
  15570. * A function that is added to the onBeforeRenderObservable
  15571. */
  15572. onBeforeRender: (effect: Effect) => void;
  15573. /**
  15574. * An event triggered after rendering the postprocess
  15575. */
  15576. onAfterRenderObservable: Observable<Effect>;
  15577. private _onAfterRenderObserver;
  15578. /**
  15579. * A function that is added to the onAfterRenderObservable
  15580. */
  15581. onAfterRender: (efect: Effect) => void;
  15582. /**
  15583. * 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
  15584. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15585. */
  15586. inputTexture: InternalTexture;
  15587. /**
  15588. * Gets the camera which post process is applied to.
  15589. * @returns The camera the post process is applied to.
  15590. */
  15591. getCamera(): Camera;
  15592. /**
  15593. * Gets the texel size of the postprocess.
  15594. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15595. */
  15596. readonly texelSize: Vector2;
  15597. /**
  15598. * Creates a new instance PostProcess
  15599. * @param name The name of the PostProcess.
  15600. * @param fragmentUrl The url of the fragment shader to be used.
  15601. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15602. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15603. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15604. * @param camera The camera to apply the render pass to.
  15605. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15606. * @param engine The engine which the post process will be applied. (default: current engine)
  15607. * @param reusable If the post process can be reused on the same frame. (default: false)
  15608. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15609. * @param textureType Type of textures used when performing the post process. (default: 0)
  15610. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15611. * @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
  15612. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15613. */
  15614. constructor(
  15615. /** Name of the PostProcess. */
  15616. 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);
  15617. /**
  15618. * Gets a string idenfifying the name of the class
  15619. * @returns "PostProcess" string
  15620. */
  15621. getClassName(): string;
  15622. /**
  15623. * Gets the engine which this post process belongs to.
  15624. * @returns The engine the post process was enabled with.
  15625. */
  15626. getEngine(): Engine;
  15627. /**
  15628. * The effect that is created when initializing the post process.
  15629. * @returns The created effect corresponding the the postprocess.
  15630. */
  15631. getEffect(): Effect;
  15632. /**
  15633. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15634. * @param postProcess The post process to share the output with.
  15635. * @returns This post process.
  15636. */
  15637. shareOutputWith(postProcess: PostProcess): PostProcess;
  15638. /**
  15639. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15640. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15641. */
  15642. useOwnOutput(): void;
  15643. /**
  15644. * Updates the effect with the current post process compile time values and recompiles the shader.
  15645. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15646. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15647. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15648. * @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
  15649. * @param onCompiled Called when the shader has been compiled.
  15650. * @param onError Called if there is an error when compiling a shader.
  15651. */
  15652. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15653. /**
  15654. * The post process is reusable if it can be used multiple times within one frame.
  15655. * @returns If the post process is reusable
  15656. */
  15657. isReusable(): boolean;
  15658. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15659. markTextureDirty(): void;
  15660. /**
  15661. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15662. * 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.
  15663. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15664. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15665. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15666. * @returns The target texture that was bound to be written to.
  15667. */
  15668. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15669. /**
  15670. * If the post process is supported.
  15671. */
  15672. readonly isSupported: boolean;
  15673. /**
  15674. * The aspect ratio of the output texture.
  15675. */
  15676. readonly aspectRatio: number;
  15677. /**
  15678. * Get a value indicating if the post-process is ready to be used
  15679. * @returns true if the post-process is ready (shader is compiled)
  15680. */
  15681. isReady(): boolean;
  15682. /**
  15683. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15684. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15685. */
  15686. apply(): Nullable<Effect>;
  15687. private _disposeTextures;
  15688. /**
  15689. * Disposes the post process.
  15690. * @param camera The camera to dispose the post process on.
  15691. */
  15692. dispose(camera?: Camera): void;
  15693. }
  15694. }
  15695. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15696. /** @hidden */
  15697. export var kernelBlurVaryingDeclaration: {
  15698. name: string;
  15699. shader: string;
  15700. };
  15701. }
  15702. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15703. /** @hidden */
  15704. export var kernelBlurFragment: {
  15705. name: string;
  15706. shader: string;
  15707. };
  15708. }
  15709. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15710. /** @hidden */
  15711. export var kernelBlurFragment2: {
  15712. name: string;
  15713. shader: string;
  15714. };
  15715. }
  15716. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15717. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15718. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15719. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15720. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15721. /** @hidden */
  15722. export var kernelBlurPixelShader: {
  15723. name: string;
  15724. shader: string;
  15725. };
  15726. }
  15727. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15728. /** @hidden */
  15729. export var kernelBlurVertex: {
  15730. name: string;
  15731. shader: string;
  15732. };
  15733. }
  15734. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15735. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15736. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15737. /** @hidden */
  15738. export var kernelBlurVertexShader: {
  15739. name: string;
  15740. shader: string;
  15741. };
  15742. }
  15743. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15744. import { Vector2 } from "babylonjs/Maths/math.vector";
  15745. import { Nullable } from "babylonjs/types";
  15746. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15747. import { Camera } from "babylonjs/Cameras/camera";
  15748. import { Effect } from "babylonjs/Materials/effect";
  15749. import { Engine } from "babylonjs/Engines/engine";
  15750. import "babylonjs/Shaders/kernelBlur.fragment";
  15751. import "babylonjs/Shaders/kernelBlur.vertex";
  15752. /**
  15753. * The Blur Post Process which blurs an image based on a kernel and direction.
  15754. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15755. */
  15756. export class BlurPostProcess extends PostProcess {
  15757. /** The direction in which to blur the image. */
  15758. direction: Vector2;
  15759. private blockCompilation;
  15760. protected _kernel: number;
  15761. protected _idealKernel: number;
  15762. protected _packedFloat: boolean;
  15763. private _staticDefines;
  15764. /**
  15765. * Sets the length in pixels of the blur sample region
  15766. */
  15767. /**
  15768. * Gets the length in pixels of the blur sample region
  15769. */
  15770. kernel: number;
  15771. /**
  15772. * Sets wether or not the blur needs to unpack/repack floats
  15773. */
  15774. /**
  15775. * Gets wether or not the blur is unpacking/repacking floats
  15776. */
  15777. packedFloat: boolean;
  15778. /**
  15779. * Creates a new instance BlurPostProcess
  15780. * @param name The name of the effect.
  15781. * @param direction The direction in which to blur the image.
  15782. * @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.
  15783. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15784. * @param camera The camera to apply the render pass to.
  15785. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15786. * @param engine The engine which the post process will be applied. (default: current engine)
  15787. * @param reusable If the post process can be reused on the same frame. (default: false)
  15788. * @param textureType Type of textures used when performing the post process. (default: 0)
  15789. * @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)
  15790. */
  15791. constructor(name: string,
  15792. /** The direction in which to blur the image. */
  15793. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15794. /**
  15795. * Updates the effect with the current post process compile time values and recompiles the shader.
  15796. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15797. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15798. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15799. * @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
  15800. * @param onCompiled Called when the shader has been compiled.
  15801. * @param onError Called if there is an error when compiling a shader.
  15802. */
  15803. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15804. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15805. /**
  15806. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15807. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15808. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15809. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15810. * The gaps between physical kernels are compensated for in the weighting of the samples
  15811. * @param idealKernel Ideal blur kernel.
  15812. * @return Nearest best kernel.
  15813. */
  15814. protected _nearestBestKernel(idealKernel: number): number;
  15815. /**
  15816. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15817. * @param x The point on the Gaussian distribution to sample.
  15818. * @return the value of the Gaussian function at x.
  15819. */
  15820. protected _gaussianWeight(x: number): number;
  15821. /**
  15822. * Generates a string that can be used as a floating point number in GLSL.
  15823. * @param x Value to print.
  15824. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15825. * @return GLSL float string.
  15826. */
  15827. protected _glslFloat(x: number, decimalFigures?: number): string;
  15828. }
  15829. }
  15830. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  15831. import { Scene } from "babylonjs/scene";
  15832. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15833. import { Plane } from "babylonjs/Maths/math.plane";
  15834. /**
  15835. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15836. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15837. * You can then easily use it as a reflectionTexture on a flat surface.
  15838. * In case the surface is not a plane, please consider relying on reflection probes.
  15839. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15840. */
  15841. export class MirrorTexture extends RenderTargetTexture {
  15842. private scene;
  15843. /**
  15844. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15845. * 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.
  15846. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15847. */
  15848. mirrorPlane: Plane;
  15849. /**
  15850. * Define the blur ratio used to blur the reflection if needed.
  15851. */
  15852. blurRatio: number;
  15853. /**
  15854. * Define the adaptive blur kernel used to blur the reflection if needed.
  15855. * This will autocompute the closest best match for the `blurKernel`
  15856. */
  15857. adaptiveBlurKernel: number;
  15858. /**
  15859. * Define the blur kernel used to blur the reflection if needed.
  15860. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15861. */
  15862. blurKernel: number;
  15863. /**
  15864. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15865. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15866. */
  15867. blurKernelX: number;
  15868. /**
  15869. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15870. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15871. */
  15872. blurKernelY: number;
  15873. private _autoComputeBlurKernel;
  15874. protected _onRatioRescale(): void;
  15875. private _updateGammaSpace;
  15876. private _imageProcessingConfigChangeObserver;
  15877. private _transformMatrix;
  15878. private _mirrorMatrix;
  15879. private _savedViewMatrix;
  15880. private _blurX;
  15881. private _blurY;
  15882. private _adaptiveBlurKernel;
  15883. private _blurKernelX;
  15884. private _blurKernelY;
  15885. private _blurRatio;
  15886. /**
  15887. * Instantiates a Mirror Texture.
  15888. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15889. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15890. * You can then easily use it as a reflectionTexture on a flat surface.
  15891. * In case the surface is not a plane, please consider relying on reflection probes.
  15892. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15893. * @param name
  15894. * @param size
  15895. * @param scene
  15896. * @param generateMipMaps
  15897. * @param type
  15898. * @param samplingMode
  15899. * @param generateDepthBuffer
  15900. */
  15901. constructor(name: string, size: number | {
  15902. width: number;
  15903. height: number;
  15904. } | {
  15905. ratio: number;
  15906. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15907. private _preparePostProcesses;
  15908. /**
  15909. * Clone the mirror texture.
  15910. * @returns the cloned texture
  15911. */
  15912. clone(): MirrorTexture;
  15913. /**
  15914. * Serialize the texture to a JSON representation you could use in Parse later on
  15915. * @returns the serialized JSON representation
  15916. */
  15917. serialize(): any;
  15918. /**
  15919. * Dispose the texture and release its associated resources.
  15920. */
  15921. dispose(): void;
  15922. }
  15923. }
  15924. declare module "babylonjs/Materials/Textures/texture" {
  15925. import { Observable } from "babylonjs/Misc/observable";
  15926. import { Nullable } from "babylonjs/types";
  15927. import { Scene } from "babylonjs/scene";
  15928. import { Matrix } from "babylonjs/Maths/math.vector";
  15929. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15930. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15931. import { Engine } from "babylonjs/Engines/engine";
  15932. /**
  15933. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15934. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15935. */
  15936. export class Texture extends BaseTexture {
  15937. /**
  15938. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15939. */
  15940. static SerializeBuffers: boolean;
  15941. /** @hidden */
  15942. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  15943. /** @hidden */
  15944. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  15945. /** @hidden */
  15946. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  15947. /** nearest is mag = nearest and min = nearest and mip = linear */
  15948. static readonly NEAREST_SAMPLINGMODE: number;
  15949. /** nearest is mag = nearest and min = nearest and mip = linear */
  15950. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15951. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15952. static readonly BILINEAR_SAMPLINGMODE: number;
  15953. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15954. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15955. /** Trilinear is mag = linear and min = linear and mip = linear */
  15956. static readonly TRILINEAR_SAMPLINGMODE: number;
  15957. /** Trilinear is mag = linear and min = linear and mip = linear */
  15958. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15959. /** mag = nearest and min = nearest and mip = nearest */
  15960. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15961. /** mag = nearest and min = linear and mip = nearest */
  15962. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15963. /** mag = nearest and min = linear and mip = linear */
  15964. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15965. /** mag = nearest and min = linear and mip = none */
  15966. static readonly NEAREST_LINEAR: number;
  15967. /** mag = nearest and min = nearest and mip = none */
  15968. static readonly NEAREST_NEAREST: number;
  15969. /** mag = linear and min = nearest and mip = nearest */
  15970. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15971. /** mag = linear and min = nearest and mip = linear */
  15972. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15973. /** mag = linear and min = linear and mip = none */
  15974. static readonly LINEAR_LINEAR: number;
  15975. /** mag = linear and min = nearest and mip = none */
  15976. static readonly LINEAR_NEAREST: number;
  15977. /** Explicit coordinates mode */
  15978. static readonly EXPLICIT_MODE: number;
  15979. /** Spherical coordinates mode */
  15980. static readonly SPHERICAL_MODE: number;
  15981. /** Planar coordinates mode */
  15982. static readonly PLANAR_MODE: number;
  15983. /** Cubic coordinates mode */
  15984. static readonly CUBIC_MODE: number;
  15985. /** Projection coordinates mode */
  15986. static readonly PROJECTION_MODE: number;
  15987. /** Inverse Cubic coordinates mode */
  15988. static readonly SKYBOX_MODE: number;
  15989. /** Inverse Cubic coordinates mode */
  15990. static readonly INVCUBIC_MODE: number;
  15991. /** Equirectangular coordinates mode */
  15992. static readonly EQUIRECTANGULAR_MODE: number;
  15993. /** Equirectangular Fixed coordinates mode */
  15994. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15995. /** Equirectangular Fixed Mirrored coordinates mode */
  15996. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15997. /** Texture is not repeating outside of 0..1 UVs */
  15998. static readonly CLAMP_ADDRESSMODE: number;
  15999. /** Texture is repeating outside of 0..1 UVs */
  16000. static readonly WRAP_ADDRESSMODE: number;
  16001. /** Texture is repeating and mirrored */
  16002. static readonly MIRROR_ADDRESSMODE: number;
  16003. /**
  16004. * 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
  16005. */
  16006. static UseSerializedUrlIfAny: boolean;
  16007. /**
  16008. * Define the url of the texture.
  16009. */
  16010. url: Nullable<string>;
  16011. /**
  16012. * Define an offset on the texture to offset the u coordinates of the UVs
  16013. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16014. */
  16015. uOffset: number;
  16016. /**
  16017. * Define an offset on the texture to offset the v coordinates of the UVs
  16018. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16019. */
  16020. vOffset: number;
  16021. /**
  16022. * Define an offset on the texture to scale the u coordinates of the UVs
  16023. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16024. */
  16025. uScale: number;
  16026. /**
  16027. * Define an offset on the texture to scale the v coordinates of the UVs
  16028. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16029. */
  16030. vScale: number;
  16031. /**
  16032. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16033. * @see http://doc.babylonjs.com/how_to/more_materials
  16034. */
  16035. uAng: number;
  16036. /**
  16037. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16038. * @see http://doc.babylonjs.com/how_to/more_materials
  16039. */
  16040. vAng: number;
  16041. /**
  16042. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16043. * @see http://doc.babylonjs.com/how_to/more_materials
  16044. */
  16045. wAng: number;
  16046. /**
  16047. * Defines the center of rotation (U)
  16048. */
  16049. uRotationCenter: number;
  16050. /**
  16051. * Defines the center of rotation (V)
  16052. */
  16053. vRotationCenter: number;
  16054. /**
  16055. * Defines the center of rotation (W)
  16056. */
  16057. wRotationCenter: number;
  16058. /**
  16059. * Are mip maps generated for this texture or not.
  16060. */
  16061. readonly noMipmap: boolean;
  16062. /**
  16063. * List of inspectable custom properties (used by the Inspector)
  16064. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16065. */
  16066. inspectableCustomProperties: Nullable<IInspectable[]>;
  16067. private _noMipmap;
  16068. /** @hidden */
  16069. _invertY: boolean;
  16070. private _rowGenerationMatrix;
  16071. private _cachedTextureMatrix;
  16072. private _projectionModeMatrix;
  16073. private _t0;
  16074. private _t1;
  16075. private _t2;
  16076. private _cachedUOffset;
  16077. private _cachedVOffset;
  16078. private _cachedUScale;
  16079. private _cachedVScale;
  16080. private _cachedUAng;
  16081. private _cachedVAng;
  16082. private _cachedWAng;
  16083. private _cachedProjectionMatrixId;
  16084. private _cachedCoordinatesMode;
  16085. /** @hidden */
  16086. protected _initialSamplingMode: number;
  16087. /** @hidden */
  16088. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  16089. private _deleteBuffer;
  16090. protected _format: Nullable<number>;
  16091. private _delayedOnLoad;
  16092. private _delayedOnError;
  16093. /**
  16094. * Observable triggered once the texture has been loaded.
  16095. */
  16096. onLoadObservable: Observable<Texture>;
  16097. protected _isBlocking: boolean;
  16098. /**
  16099. * Is the texture preventing material to render while loading.
  16100. * If false, a default texture will be used instead of the loading one during the preparation step.
  16101. */
  16102. isBlocking: boolean;
  16103. /**
  16104. * Get the current sampling mode associated with the texture.
  16105. */
  16106. readonly samplingMode: number;
  16107. /**
  16108. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16109. */
  16110. readonly invertY: boolean;
  16111. /**
  16112. * Instantiates a new texture.
  16113. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16114. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16115. * @param url define the url of the picture to load as a texture
  16116. * @param scene define the scene or engine the texture will belong to
  16117. * @param noMipmap define if the texture will require mip maps or not
  16118. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16119. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16120. * @param onLoad define a callback triggered when the texture has been loaded
  16121. * @param onError define a callback triggered when an error occurred during the loading session
  16122. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16123. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16124. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16125. */
  16126. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  16127. /**
  16128. * Update the url (and optional buffer) of this texture if url was null during construction.
  16129. * @param url the url of the texture
  16130. * @param buffer the buffer of the texture (defaults to null)
  16131. * @param onLoad callback called when the texture is loaded (defaults to null)
  16132. */
  16133. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16134. /**
  16135. * Finish the loading sequence of a texture flagged as delayed load.
  16136. * @hidden
  16137. */
  16138. delayLoad(): void;
  16139. private _prepareRowForTextureGeneration;
  16140. /**
  16141. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16142. * @returns the transform matrix of the texture.
  16143. */
  16144. getTextureMatrix(): Matrix;
  16145. /**
  16146. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16147. * @returns The reflection texture transform
  16148. */
  16149. getReflectionTextureMatrix(): Matrix;
  16150. /**
  16151. * Clones the texture.
  16152. * @returns the cloned texture
  16153. */
  16154. clone(): Texture;
  16155. /**
  16156. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16157. * @returns The JSON representation of the texture
  16158. */
  16159. serialize(): any;
  16160. /**
  16161. * Get the current class name of the texture useful for serialization or dynamic coding.
  16162. * @returns "Texture"
  16163. */
  16164. getClassName(): string;
  16165. /**
  16166. * Dispose the texture and release its associated resources.
  16167. */
  16168. dispose(): void;
  16169. /**
  16170. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16171. * @param parsedTexture Define the JSON representation of the texture
  16172. * @param scene Define the scene the parsed texture should be instantiated in
  16173. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16174. * @returns The parsed texture if successful
  16175. */
  16176. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16177. /**
  16178. * Creates a texture from its base 64 representation.
  16179. * @param data Define the base64 payload without the data: prefix
  16180. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16181. * @param scene Define the scene the texture should belong to
  16182. * @param noMipmap Forces the texture to not create mip map information if true
  16183. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16184. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16185. * @param onLoad define a callback triggered when the texture has been loaded
  16186. * @param onError define a callback triggered when an error occurred during the loading session
  16187. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16188. * @returns the created texture
  16189. */
  16190. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16191. /**
  16192. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16193. * @param data Define the base64 payload without the data: prefix
  16194. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16195. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16196. * @param scene Define the scene the texture should belong to
  16197. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16198. * @param noMipmap Forces the texture to not create mip map information if true
  16199. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16200. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16201. * @param onLoad define a callback triggered when the texture has been loaded
  16202. * @param onError define a callback triggered when an error occurred during the loading session
  16203. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16204. * @returns the created texture
  16205. */
  16206. 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;
  16207. }
  16208. }
  16209. declare module "babylonjs/PostProcesses/postProcessManager" {
  16210. import { Nullable } from "babylonjs/types";
  16211. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16212. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16213. import { Scene } from "babylonjs/scene";
  16214. /**
  16215. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16216. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16217. */
  16218. export class PostProcessManager {
  16219. private _scene;
  16220. private _indexBuffer;
  16221. private _vertexBuffers;
  16222. /**
  16223. * Creates a new instance PostProcess
  16224. * @param scene The scene that the post process is associated with.
  16225. */
  16226. constructor(scene: Scene);
  16227. private _prepareBuffers;
  16228. private _buildIndexBuffer;
  16229. /**
  16230. * Rebuilds the vertex buffers of the manager.
  16231. * @hidden
  16232. */
  16233. _rebuild(): void;
  16234. /**
  16235. * Prepares a frame to be run through a post process.
  16236. * @param sourceTexture The input texture to the post procesess. (default: null)
  16237. * @param postProcesses An array of post processes to be run. (default: null)
  16238. * @returns True if the post processes were able to be run.
  16239. * @hidden
  16240. */
  16241. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16242. /**
  16243. * Manually render a set of post processes to a texture.
  16244. * @param postProcesses An array of post processes to be run.
  16245. * @param targetTexture The target texture to render to.
  16246. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16247. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16248. * @param lodLevel defines which lod of the texture to render to
  16249. */
  16250. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16251. /**
  16252. * Finalize the result of the output of the postprocesses.
  16253. * @param doNotPresent If true the result will not be displayed to the screen.
  16254. * @param targetTexture The target texture to render to.
  16255. * @param faceIndex The index of the face to bind the target texture to.
  16256. * @param postProcesses The array of post processes to render.
  16257. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16258. * @hidden
  16259. */
  16260. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16261. /**
  16262. * Disposes of the post process manager.
  16263. */
  16264. dispose(): void;
  16265. }
  16266. }
  16267. declare module "babylonjs/Misc/gradients" {
  16268. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16269. /** Interface used by value gradients (color, factor, ...) */
  16270. export interface IValueGradient {
  16271. /**
  16272. * Gets or sets the gradient value (between 0 and 1)
  16273. */
  16274. gradient: number;
  16275. }
  16276. /** Class used to store color4 gradient */
  16277. export class ColorGradient implements IValueGradient {
  16278. /**
  16279. * Gets or sets the gradient value (between 0 and 1)
  16280. */
  16281. gradient: number;
  16282. /**
  16283. * Gets or sets first associated color
  16284. */
  16285. color1: Color4;
  16286. /**
  16287. * Gets or sets second associated color
  16288. */
  16289. color2?: Color4;
  16290. /**
  16291. * Will get a color picked randomly between color1 and color2.
  16292. * If color2 is undefined then color1 will be used
  16293. * @param result defines the target Color4 to store the result in
  16294. */
  16295. getColorToRef(result: Color4): void;
  16296. }
  16297. /** Class used to store color 3 gradient */
  16298. export class Color3Gradient implements IValueGradient {
  16299. /**
  16300. * Gets or sets the gradient value (between 0 and 1)
  16301. */
  16302. gradient: number;
  16303. /**
  16304. * Gets or sets the associated color
  16305. */
  16306. color: Color3;
  16307. }
  16308. /** Class used to store factor gradient */
  16309. export class FactorGradient implements IValueGradient {
  16310. /**
  16311. * Gets or sets the gradient value (between 0 and 1)
  16312. */
  16313. gradient: number;
  16314. /**
  16315. * Gets or sets first associated factor
  16316. */
  16317. factor1: number;
  16318. /**
  16319. * Gets or sets second associated factor
  16320. */
  16321. factor2?: number;
  16322. /**
  16323. * Will get a number picked randomly between factor1 and factor2.
  16324. * If factor2 is undefined then factor1 will be used
  16325. * @returns the picked number
  16326. */
  16327. getFactor(): number;
  16328. }
  16329. /**
  16330. * Helper used to simplify some generic gradient tasks
  16331. */
  16332. export class GradientHelper {
  16333. /**
  16334. * Gets the current gradient from an array of IValueGradient
  16335. * @param ratio defines the current ratio to get
  16336. * @param gradients defines the array of IValueGradient
  16337. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16338. */
  16339. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16340. }
  16341. }
  16342. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16343. import { Scene } from "babylonjs/scene";
  16344. import { Texture } from "babylonjs/Materials/Textures/texture";
  16345. /**
  16346. * A class extending Texture allowing drawing on a texture
  16347. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16348. */
  16349. export class DynamicTexture extends Texture {
  16350. private _generateMipMaps;
  16351. private _canvas;
  16352. private _context;
  16353. private _engine;
  16354. /**
  16355. * Creates a DynamicTexture
  16356. * @param name defines the name of the texture
  16357. * @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
  16358. * @param scene defines the scene where you want the texture
  16359. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16360. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16361. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16362. */
  16363. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16364. /**
  16365. * Get the current class name of the texture useful for serialization or dynamic coding.
  16366. * @returns "DynamicTexture"
  16367. */
  16368. getClassName(): string;
  16369. /**
  16370. * Gets the current state of canRescale
  16371. */
  16372. readonly canRescale: boolean;
  16373. private _recreate;
  16374. /**
  16375. * Scales the texture
  16376. * @param ratio the scale factor to apply to both width and height
  16377. */
  16378. scale(ratio: number): void;
  16379. /**
  16380. * Resizes the texture
  16381. * @param width the new width
  16382. * @param height the new height
  16383. */
  16384. scaleTo(width: number, height: number): void;
  16385. /**
  16386. * Gets the context of the canvas used by the texture
  16387. * @returns the canvas context of the dynamic texture
  16388. */
  16389. getContext(): CanvasRenderingContext2D;
  16390. /**
  16391. * Clears the texture
  16392. */
  16393. clear(): void;
  16394. /**
  16395. * Updates the texture
  16396. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16397. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16398. */
  16399. update(invertY?: boolean, premulAlpha?: boolean): void;
  16400. /**
  16401. * Draws text onto the texture
  16402. * @param text defines the text to be drawn
  16403. * @param x defines the placement of the text from the left
  16404. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16405. * @param font defines the font to be used with font-style, font-size, font-name
  16406. * @param color defines the color used for the text
  16407. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16408. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16409. * @param update defines whether texture is immediately update (default is true)
  16410. */
  16411. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16412. /**
  16413. * Clones the texture
  16414. * @returns the clone of the texture.
  16415. */
  16416. clone(): DynamicTexture;
  16417. /**
  16418. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16419. * @returns a serialized dynamic texture object
  16420. */
  16421. serialize(): any;
  16422. /** @hidden */
  16423. _rebuild(): void;
  16424. }
  16425. }
  16426. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16427. import { Scene } from "babylonjs/scene";
  16428. import { ISceneComponent } from "babylonjs/sceneComponent";
  16429. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16430. module "babylonjs/abstractScene" {
  16431. interface AbstractScene {
  16432. /**
  16433. * The list of procedural textures added to the scene
  16434. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16435. */
  16436. proceduralTextures: Array<ProceduralTexture>;
  16437. }
  16438. }
  16439. /**
  16440. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16441. * in a given scene.
  16442. */
  16443. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16444. /**
  16445. * The component name helpfull to identify the component in the list of scene components.
  16446. */
  16447. readonly name: string;
  16448. /**
  16449. * The scene the component belongs to.
  16450. */
  16451. scene: Scene;
  16452. /**
  16453. * Creates a new instance of the component for the given scene
  16454. * @param scene Defines the scene to register the component in
  16455. */
  16456. constructor(scene: Scene);
  16457. /**
  16458. * Registers the component in a given scene
  16459. */
  16460. register(): void;
  16461. /**
  16462. * Rebuilds the elements related to this component in case of
  16463. * context lost for instance.
  16464. */
  16465. rebuild(): void;
  16466. /**
  16467. * Disposes the component and the associated ressources.
  16468. */
  16469. dispose(): void;
  16470. private _beforeClear;
  16471. }
  16472. }
  16473. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  16474. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16475. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16476. module "babylonjs/Engines/engine" {
  16477. interface Engine {
  16478. /**
  16479. * Creates a new render target cube texture
  16480. * @param size defines the size of the texture
  16481. * @param options defines the options used to create the texture
  16482. * @returns a new render target cube texture stored in an InternalTexture
  16483. */
  16484. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16485. }
  16486. }
  16487. }
  16488. declare module "babylonjs/Shaders/procedural.vertex" {
  16489. /** @hidden */
  16490. export var proceduralVertexShader: {
  16491. name: string;
  16492. shader: string;
  16493. };
  16494. }
  16495. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16496. import { Observable } from "babylonjs/Misc/observable";
  16497. import { Nullable } from "babylonjs/types";
  16498. import { Scene } from "babylonjs/scene";
  16499. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16500. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16501. import { Effect } from "babylonjs/Materials/effect";
  16502. import { Texture } from "babylonjs/Materials/Textures/texture";
  16503. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16504. import "babylonjs/Shaders/procedural.vertex";
  16505. /**
  16506. * 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.
  16507. * This is the base class of any Procedural texture and contains most of the shareable code.
  16508. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16509. */
  16510. export class ProceduralTexture extends Texture {
  16511. isCube: boolean;
  16512. /**
  16513. * Define if the texture is enabled or not (disabled texture will not render)
  16514. */
  16515. isEnabled: boolean;
  16516. /**
  16517. * Define if the texture must be cleared before rendering (default is true)
  16518. */
  16519. autoClear: boolean;
  16520. /**
  16521. * Callback called when the texture is generated
  16522. */
  16523. onGenerated: () => void;
  16524. /**
  16525. * Event raised when the texture is generated
  16526. */
  16527. onGeneratedObservable: Observable<ProceduralTexture>;
  16528. /** @hidden */
  16529. _generateMipMaps: boolean;
  16530. /** @hidden **/
  16531. _effect: Effect;
  16532. /** @hidden */
  16533. _textures: {
  16534. [key: string]: Texture;
  16535. };
  16536. private _size;
  16537. private _currentRefreshId;
  16538. private _refreshRate;
  16539. private _vertexBuffers;
  16540. private _indexBuffer;
  16541. private _uniforms;
  16542. private _samplers;
  16543. private _fragment;
  16544. private _floats;
  16545. private _ints;
  16546. private _floatsArrays;
  16547. private _colors3;
  16548. private _colors4;
  16549. private _vectors2;
  16550. private _vectors3;
  16551. private _matrices;
  16552. private _fallbackTexture;
  16553. private _fallbackTextureUsed;
  16554. private _engine;
  16555. private _cachedDefines;
  16556. private _contentUpdateId;
  16557. private _contentData;
  16558. /**
  16559. * Instantiates a new procedural texture.
  16560. * 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.
  16561. * This is the base class of any Procedural texture and contains most of the shareable code.
  16562. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16563. * @param name Define the name of the texture
  16564. * @param size Define the size of the texture to create
  16565. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16566. * @param scene Define the scene the texture belongs to
  16567. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16568. * @param generateMipMaps Define if the texture should creates mip maps or not
  16569. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16570. */
  16571. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16572. /**
  16573. * The effect that is created when initializing the post process.
  16574. * @returns The created effect corresponding the the postprocess.
  16575. */
  16576. getEffect(): Effect;
  16577. /**
  16578. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16579. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16580. */
  16581. getContent(): Nullable<ArrayBufferView>;
  16582. private _createIndexBuffer;
  16583. /** @hidden */
  16584. _rebuild(): void;
  16585. /**
  16586. * Resets the texture in order to recreate its associated resources.
  16587. * This can be called in case of context loss
  16588. */
  16589. reset(): void;
  16590. protected _getDefines(): string;
  16591. /**
  16592. * Is the texture ready to be used ? (rendered at least once)
  16593. * @returns true if ready, otherwise, false.
  16594. */
  16595. isReady(): boolean;
  16596. /**
  16597. * Resets the refresh counter of the texture and start bak from scratch.
  16598. * Could be useful to regenerate the texture if it is setup to render only once.
  16599. */
  16600. resetRefreshCounter(): void;
  16601. /**
  16602. * Set the fragment shader to use in order to render the texture.
  16603. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16604. */
  16605. setFragment(fragment: any): void;
  16606. /**
  16607. * Define the refresh rate of the texture or the rendering frequency.
  16608. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16609. */
  16610. refreshRate: number;
  16611. /** @hidden */
  16612. _shouldRender(): boolean;
  16613. /**
  16614. * Get the size the texture is rendering at.
  16615. * @returns the size (texture is always squared)
  16616. */
  16617. getRenderSize(): number;
  16618. /**
  16619. * Resize the texture to new value.
  16620. * @param size Define the new size the texture should have
  16621. * @param generateMipMaps Define whether the new texture should create mip maps
  16622. */
  16623. resize(size: number, generateMipMaps: boolean): void;
  16624. private _checkUniform;
  16625. /**
  16626. * Set a texture in the shader program used to render.
  16627. * @param name Define the name of the uniform samplers as defined in the shader
  16628. * @param texture Define the texture to bind to this sampler
  16629. * @return the texture itself allowing "fluent" like uniform updates
  16630. */
  16631. setTexture(name: string, texture: Texture): ProceduralTexture;
  16632. /**
  16633. * Set a float in the shader.
  16634. * @param name Define the name of the uniform as defined in the shader
  16635. * @param value Define the value to give to the uniform
  16636. * @return the texture itself allowing "fluent" like uniform updates
  16637. */
  16638. setFloat(name: string, value: number): ProceduralTexture;
  16639. /**
  16640. * Set a int in the shader.
  16641. * @param name Define the name of the uniform as defined in the shader
  16642. * @param value Define the value to give to the uniform
  16643. * @return the texture itself allowing "fluent" like uniform updates
  16644. */
  16645. setInt(name: string, value: number): ProceduralTexture;
  16646. /**
  16647. * Set an array of floats in the shader.
  16648. * @param name Define the name of the uniform as defined in the shader
  16649. * @param value Define the value to give to the uniform
  16650. * @return the texture itself allowing "fluent" like uniform updates
  16651. */
  16652. setFloats(name: string, value: number[]): ProceduralTexture;
  16653. /**
  16654. * Set a vec3 in the shader from a Color3.
  16655. * @param name Define the name of the uniform as defined in the shader
  16656. * @param value Define the value to give to the uniform
  16657. * @return the texture itself allowing "fluent" like uniform updates
  16658. */
  16659. setColor3(name: string, value: Color3): ProceduralTexture;
  16660. /**
  16661. * Set a vec4 in the shader from a Color4.
  16662. * @param name Define the name of the uniform as defined in the shader
  16663. * @param value Define the value to give to the uniform
  16664. * @return the texture itself allowing "fluent" like uniform updates
  16665. */
  16666. setColor4(name: string, value: Color4): ProceduralTexture;
  16667. /**
  16668. * Set a vec2 in the shader from a Vector2.
  16669. * @param name Define the name of the uniform as defined in the shader
  16670. * @param value Define the value to give to the uniform
  16671. * @return the texture itself allowing "fluent" like uniform updates
  16672. */
  16673. setVector2(name: string, value: Vector2): ProceduralTexture;
  16674. /**
  16675. * Set a vec3 in the shader from a Vector3.
  16676. * @param name Define the name of the uniform as defined in the shader
  16677. * @param value Define the value to give to the uniform
  16678. * @return the texture itself allowing "fluent" like uniform updates
  16679. */
  16680. setVector3(name: string, value: Vector3): ProceduralTexture;
  16681. /**
  16682. * Set a mat4 in the shader from a MAtrix.
  16683. * @param name Define the name of the uniform as defined in the shader
  16684. * @param value Define the value to give to the uniform
  16685. * @return the texture itself allowing "fluent" like uniform updates
  16686. */
  16687. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16688. /**
  16689. * Render the texture to its associated render target.
  16690. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16691. */
  16692. render(useCameraPostProcess?: boolean): void;
  16693. /**
  16694. * Clone the texture.
  16695. * @returns the cloned texture
  16696. */
  16697. clone(): ProceduralTexture;
  16698. /**
  16699. * Dispose the texture and release its asoociated resources.
  16700. */
  16701. dispose(): void;
  16702. }
  16703. }
  16704. declare module "babylonjs/Particles/baseParticleSystem" {
  16705. import { Nullable } from "babylonjs/types";
  16706. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16707. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16708. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16709. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16710. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16711. import { Scene } from "babylonjs/scene";
  16712. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16713. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16714. import { Texture } from "babylonjs/Materials/Textures/texture";
  16715. import { Color4 } from "babylonjs/Maths/math.color";
  16716. import { Animation } from "babylonjs/Animations/animation";
  16717. /**
  16718. * This represents the base class for particle system in Babylon.
  16719. * 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.
  16720. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16721. * @example https://doc.babylonjs.com/babylon101/particles
  16722. */
  16723. export class BaseParticleSystem {
  16724. /**
  16725. * Source color is added to the destination color without alpha affecting the result
  16726. */
  16727. static BLENDMODE_ONEONE: number;
  16728. /**
  16729. * Blend current color and particle color using particle’s alpha
  16730. */
  16731. static BLENDMODE_STANDARD: number;
  16732. /**
  16733. * Add current color and particle color multiplied by particle’s alpha
  16734. */
  16735. static BLENDMODE_ADD: number;
  16736. /**
  16737. * Multiply current color with particle color
  16738. */
  16739. static BLENDMODE_MULTIPLY: number;
  16740. /**
  16741. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16742. */
  16743. static BLENDMODE_MULTIPLYADD: number;
  16744. /**
  16745. * List of animations used by the particle system.
  16746. */
  16747. animations: Animation[];
  16748. /**
  16749. * The id of the Particle system.
  16750. */
  16751. id: string;
  16752. /**
  16753. * The friendly name of the Particle system.
  16754. */
  16755. name: string;
  16756. /**
  16757. * The rendering group used by the Particle system to chose when to render.
  16758. */
  16759. renderingGroupId: number;
  16760. /**
  16761. * The emitter represents the Mesh or position we are attaching the particle system to.
  16762. */
  16763. emitter: Nullable<AbstractMesh | Vector3>;
  16764. /**
  16765. * The maximum number of particles to emit per frame
  16766. */
  16767. emitRate: number;
  16768. /**
  16769. * If you want to launch only a few particles at once, that can be done, as well.
  16770. */
  16771. manualEmitCount: number;
  16772. /**
  16773. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16774. */
  16775. updateSpeed: number;
  16776. /**
  16777. * The amount of time the particle system is running (depends of the overall update speed).
  16778. */
  16779. targetStopDuration: number;
  16780. /**
  16781. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16782. */
  16783. disposeOnStop: boolean;
  16784. /**
  16785. * Minimum power of emitting particles.
  16786. */
  16787. minEmitPower: number;
  16788. /**
  16789. * Maximum power of emitting particles.
  16790. */
  16791. maxEmitPower: number;
  16792. /**
  16793. * Minimum life time of emitting particles.
  16794. */
  16795. minLifeTime: number;
  16796. /**
  16797. * Maximum life time of emitting particles.
  16798. */
  16799. maxLifeTime: number;
  16800. /**
  16801. * Minimum Size of emitting particles.
  16802. */
  16803. minSize: number;
  16804. /**
  16805. * Maximum Size of emitting particles.
  16806. */
  16807. maxSize: number;
  16808. /**
  16809. * Minimum scale of emitting particles on X axis.
  16810. */
  16811. minScaleX: number;
  16812. /**
  16813. * Maximum scale of emitting particles on X axis.
  16814. */
  16815. maxScaleX: number;
  16816. /**
  16817. * Minimum scale of emitting particles on Y axis.
  16818. */
  16819. minScaleY: number;
  16820. /**
  16821. * Maximum scale of emitting particles on Y axis.
  16822. */
  16823. maxScaleY: number;
  16824. /**
  16825. * Gets or sets the minimal initial rotation in radians.
  16826. */
  16827. minInitialRotation: number;
  16828. /**
  16829. * Gets or sets the maximal initial rotation in radians.
  16830. */
  16831. maxInitialRotation: number;
  16832. /**
  16833. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16834. */
  16835. minAngularSpeed: number;
  16836. /**
  16837. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16838. */
  16839. maxAngularSpeed: number;
  16840. /**
  16841. * The texture used to render each particle. (this can be a spritesheet)
  16842. */
  16843. particleTexture: Nullable<Texture>;
  16844. /**
  16845. * The layer mask we are rendering the particles through.
  16846. */
  16847. layerMask: number;
  16848. /**
  16849. * This can help using your own shader to render the particle system.
  16850. * The according effect will be created
  16851. */
  16852. customShader: any;
  16853. /**
  16854. * By default particle system starts as soon as they are created. This prevents the
  16855. * automatic start to happen and let you decide when to start emitting particles.
  16856. */
  16857. preventAutoStart: boolean;
  16858. private _noiseTexture;
  16859. /**
  16860. * Gets or sets a texture used to add random noise to particle positions
  16861. */
  16862. noiseTexture: Nullable<ProceduralTexture>;
  16863. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16864. noiseStrength: Vector3;
  16865. /**
  16866. * Callback triggered when the particle animation is ending.
  16867. */
  16868. onAnimationEnd: Nullable<() => void>;
  16869. /**
  16870. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16871. */
  16872. blendMode: number;
  16873. /**
  16874. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16875. * to override the particles.
  16876. */
  16877. forceDepthWrite: boolean;
  16878. /** 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 */
  16879. preWarmCycles: number;
  16880. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16881. preWarmStepOffset: number;
  16882. /**
  16883. * 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)
  16884. */
  16885. spriteCellChangeSpeed: number;
  16886. /**
  16887. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16888. */
  16889. startSpriteCellID: number;
  16890. /**
  16891. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16892. */
  16893. endSpriteCellID: number;
  16894. /**
  16895. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16896. */
  16897. spriteCellWidth: number;
  16898. /**
  16899. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16900. */
  16901. spriteCellHeight: number;
  16902. /**
  16903. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16904. */
  16905. spriteRandomStartCell: boolean;
  16906. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16907. translationPivot: Vector2;
  16908. /** @hidden */
  16909. protected _isAnimationSheetEnabled: boolean;
  16910. /**
  16911. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16912. */
  16913. beginAnimationOnStart: boolean;
  16914. /**
  16915. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16916. */
  16917. beginAnimationFrom: number;
  16918. /**
  16919. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16920. */
  16921. beginAnimationTo: number;
  16922. /**
  16923. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16924. */
  16925. beginAnimationLoop: boolean;
  16926. /**
  16927. * Gets or sets a world offset applied to all particles
  16928. */
  16929. worldOffset: Vector3;
  16930. /**
  16931. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16932. */
  16933. isAnimationSheetEnabled: boolean;
  16934. /**
  16935. * Get hosting scene
  16936. * @returns the scene
  16937. */
  16938. getScene(): Scene;
  16939. /**
  16940. * You can use gravity if you want to give an orientation to your particles.
  16941. */
  16942. gravity: Vector3;
  16943. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16944. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16945. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16946. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16947. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16948. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16949. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16950. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16951. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16952. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16953. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16954. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16955. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16956. /**
  16957. * Defines the delay in milliseconds before starting the system (0 by default)
  16958. */
  16959. startDelay: number;
  16960. /**
  16961. * Gets the current list of drag gradients.
  16962. * You must use addDragGradient and removeDragGradient to udpate this list
  16963. * @returns the list of drag gradients
  16964. */
  16965. getDragGradients(): Nullable<Array<FactorGradient>>;
  16966. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16967. limitVelocityDamping: number;
  16968. /**
  16969. * Gets the current list of limit velocity gradients.
  16970. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16971. * @returns the list of limit velocity gradients
  16972. */
  16973. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16974. /**
  16975. * Gets the current list of color gradients.
  16976. * You must use addColorGradient and removeColorGradient to udpate this list
  16977. * @returns the list of color gradients
  16978. */
  16979. getColorGradients(): Nullable<Array<ColorGradient>>;
  16980. /**
  16981. * Gets the current list of size gradients.
  16982. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16983. * @returns the list of size gradients
  16984. */
  16985. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16986. /**
  16987. * Gets the current list of color remap gradients.
  16988. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16989. * @returns the list of color remap gradients
  16990. */
  16991. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16992. /**
  16993. * Gets the current list of alpha remap gradients.
  16994. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16995. * @returns the list of alpha remap gradients
  16996. */
  16997. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16998. /**
  16999. * Gets the current list of life time gradients.
  17000. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17001. * @returns the list of life time gradients
  17002. */
  17003. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17004. /**
  17005. * Gets the current list of angular speed gradients.
  17006. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17007. * @returns the list of angular speed gradients
  17008. */
  17009. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17010. /**
  17011. * Gets the current list of velocity gradients.
  17012. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17013. * @returns the list of velocity gradients
  17014. */
  17015. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17016. /**
  17017. * Gets the current list of start size gradients.
  17018. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17019. * @returns the list of start size gradients
  17020. */
  17021. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17022. /**
  17023. * Gets the current list of emit rate gradients.
  17024. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17025. * @returns the list of emit rate gradients
  17026. */
  17027. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17028. /**
  17029. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17030. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17031. */
  17032. direction1: Vector3;
  17033. /**
  17034. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17035. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17036. */
  17037. direction2: Vector3;
  17038. /**
  17039. * 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.
  17040. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17041. */
  17042. minEmitBox: Vector3;
  17043. /**
  17044. * 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.
  17045. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17046. */
  17047. maxEmitBox: Vector3;
  17048. /**
  17049. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17050. */
  17051. color1: Color4;
  17052. /**
  17053. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17054. */
  17055. color2: Color4;
  17056. /**
  17057. * Color the particle will have at the end of its lifetime
  17058. */
  17059. colorDead: Color4;
  17060. /**
  17061. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17062. */
  17063. textureMask: Color4;
  17064. /**
  17065. * The particle emitter type defines the emitter used by the particle system.
  17066. * It can be for example box, sphere, or cone...
  17067. */
  17068. particleEmitterType: IParticleEmitterType;
  17069. /** @hidden */
  17070. _isSubEmitter: boolean;
  17071. /**
  17072. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17073. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17074. */
  17075. billboardMode: number;
  17076. protected _isBillboardBased: boolean;
  17077. /**
  17078. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17079. */
  17080. isBillboardBased: boolean;
  17081. /**
  17082. * The scene the particle system belongs to.
  17083. */
  17084. protected _scene: Scene;
  17085. /**
  17086. * Local cache of defines for image processing.
  17087. */
  17088. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17089. /**
  17090. * Default configuration related to image processing available in the standard Material.
  17091. */
  17092. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17093. /**
  17094. * Gets the image processing configuration used either in this material.
  17095. */
  17096. /**
  17097. * Sets the Default image processing configuration used either in the this material.
  17098. *
  17099. * If sets to null, the scene one is in use.
  17100. */
  17101. imageProcessingConfiguration: ImageProcessingConfiguration;
  17102. /**
  17103. * Attaches a new image processing configuration to the Standard Material.
  17104. * @param configuration
  17105. */
  17106. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17107. /** @hidden */
  17108. protected _reset(): void;
  17109. /** @hidden */
  17110. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17111. /**
  17112. * Instantiates a particle system.
  17113. * 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.
  17114. * @param name The name of the particle system
  17115. */
  17116. constructor(name: string);
  17117. /**
  17118. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17119. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17120. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17121. * @returns the emitter
  17122. */
  17123. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17124. /**
  17125. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17126. * @param radius The radius of the hemisphere to emit from
  17127. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17128. * @returns the emitter
  17129. */
  17130. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17131. /**
  17132. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17133. * @param radius The radius of the sphere to emit from
  17134. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17135. * @returns the emitter
  17136. */
  17137. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17138. /**
  17139. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17140. * @param radius The radius of the sphere to emit from
  17141. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17142. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17143. * @returns the emitter
  17144. */
  17145. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17146. /**
  17147. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17148. * @param radius The radius of the emission cylinder
  17149. * @param height The height of the emission cylinder
  17150. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17151. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17152. * @returns the emitter
  17153. */
  17154. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17155. /**
  17156. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17157. * @param radius The radius of the cylinder to emit from
  17158. * @param height The height of the emission cylinder
  17159. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17160. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17161. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17162. * @returns the emitter
  17163. */
  17164. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17165. /**
  17166. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17167. * @param radius The radius of the cone to emit from
  17168. * @param angle The base angle of the cone
  17169. * @returns the emitter
  17170. */
  17171. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17172. /**
  17173. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17174. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17175. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17176. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17177. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17178. * @returns the emitter
  17179. */
  17180. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17181. }
  17182. }
  17183. declare module "babylonjs/Particles/subEmitter" {
  17184. import { Scene } from "babylonjs/scene";
  17185. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17186. /**
  17187. * Type of sub emitter
  17188. */
  17189. export enum SubEmitterType {
  17190. /**
  17191. * Attached to the particle over it's lifetime
  17192. */
  17193. ATTACHED = 0,
  17194. /**
  17195. * Created when the particle dies
  17196. */
  17197. END = 1
  17198. }
  17199. /**
  17200. * Sub emitter class used to emit particles from an existing particle
  17201. */
  17202. export class SubEmitter {
  17203. /**
  17204. * the particle system to be used by the sub emitter
  17205. */
  17206. particleSystem: ParticleSystem;
  17207. /**
  17208. * Type of the submitter (Default: END)
  17209. */
  17210. type: SubEmitterType;
  17211. /**
  17212. * 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)
  17213. * Note: This only is supported when using an emitter of type Mesh
  17214. */
  17215. inheritDirection: boolean;
  17216. /**
  17217. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17218. */
  17219. inheritedVelocityAmount: number;
  17220. /**
  17221. * Creates a sub emitter
  17222. * @param particleSystem the particle system to be used by the sub emitter
  17223. */
  17224. constructor(
  17225. /**
  17226. * the particle system to be used by the sub emitter
  17227. */
  17228. particleSystem: ParticleSystem);
  17229. /**
  17230. * Clones the sub emitter
  17231. * @returns the cloned sub emitter
  17232. */
  17233. clone(): SubEmitter;
  17234. /**
  17235. * Serialize current object to a JSON object
  17236. * @returns the serialized object
  17237. */
  17238. serialize(): any;
  17239. /** @hidden */
  17240. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17241. /**
  17242. * Creates a new SubEmitter from a serialized JSON version
  17243. * @param serializationObject defines the JSON object to read from
  17244. * @param scene defines the hosting scene
  17245. * @param rootUrl defines the rootUrl for data loading
  17246. * @returns a new SubEmitter
  17247. */
  17248. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17249. /** Release associated resources */
  17250. dispose(): void;
  17251. }
  17252. }
  17253. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17254. /** @hidden */
  17255. export var clipPlaneFragmentDeclaration: {
  17256. name: string;
  17257. shader: string;
  17258. };
  17259. }
  17260. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17261. /** @hidden */
  17262. export var imageProcessingDeclaration: {
  17263. name: string;
  17264. shader: string;
  17265. };
  17266. }
  17267. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17268. /** @hidden */
  17269. export var imageProcessingFunctions: {
  17270. name: string;
  17271. shader: string;
  17272. };
  17273. }
  17274. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17275. /** @hidden */
  17276. export var clipPlaneFragment: {
  17277. name: string;
  17278. shader: string;
  17279. };
  17280. }
  17281. declare module "babylonjs/Shaders/particles.fragment" {
  17282. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17283. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17284. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17285. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17286. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17287. /** @hidden */
  17288. export var particlesPixelShader: {
  17289. name: string;
  17290. shader: string;
  17291. };
  17292. }
  17293. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17294. /** @hidden */
  17295. export var clipPlaneVertexDeclaration: {
  17296. name: string;
  17297. shader: string;
  17298. };
  17299. }
  17300. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17301. /** @hidden */
  17302. export var clipPlaneVertex: {
  17303. name: string;
  17304. shader: string;
  17305. };
  17306. }
  17307. declare module "babylonjs/Shaders/particles.vertex" {
  17308. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17309. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17310. /** @hidden */
  17311. export var particlesVertexShader: {
  17312. name: string;
  17313. shader: string;
  17314. };
  17315. }
  17316. declare module "babylonjs/Particles/particleSystem" {
  17317. import { Nullable } from "babylonjs/types";
  17318. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17319. import { Observable } from "babylonjs/Misc/observable";
  17320. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17321. import { Effect } from "babylonjs/Materials/effect";
  17322. import { Scene, IDisposable } from "babylonjs/scene";
  17323. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17324. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17325. import { Particle } from "babylonjs/Particles/particle";
  17326. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17327. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17328. import "babylonjs/Shaders/particles.fragment";
  17329. import "babylonjs/Shaders/particles.vertex";
  17330. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17331. /**
  17332. * This represents a particle system in Babylon.
  17333. * 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.
  17334. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17335. * @example https://doc.babylonjs.com/babylon101/particles
  17336. */
  17337. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17338. /**
  17339. * Billboard mode will only apply to Y axis
  17340. */
  17341. static readonly BILLBOARDMODE_Y: number;
  17342. /**
  17343. * Billboard mode will apply to all axes
  17344. */
  17345. static readonly BILLBOARDMODE_ALL: number;
  17346. /**
  17347. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17348. */
  17349. static readonly BILLBOARDMODE_STRETCHED: number;
  17350. /**
  17351. * This function can be defined to provide custom update for active particles.
  17352. * This function will be called instead of regular update (age, position, color, etc.).
  17353. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17354. */
  17355. updateFunction: (particles: Particle[]) => void;
  17356. private _emitterWorldMatrix;
  17357. /**
  17358. * This function can be defined to specify initial direction for every new particle.
  17359. * It by default use the emitterType defined function
  17360. */
  17361. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17362. /**
  17363. * This function can be defined to specify initial position for every new particle.
  17364. * It by default use the emitterType defined function
  17365. */
  17366. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17367. /**
  17368. * @hidden
  17369. */
  17370. _inheritedVelocityOffset: Vector3;
  17371. /**
  17372. * An event triggered when the system is disposed
  17373. */
  17374. onDisposeObservable: Observable<ParticleSystem>;
  17375. private _onDisposeObserver;
  17376. /**
  17377. * Sets a callback that will be triggered when the system is disposed
  17378. */
  17379. onDispose: () => void;
  17380. private _particles;
  17381. private _epsilon;
  17382. private _capacity;
  17383. private _stockParticles;
  17384. private _newPartsExcess;
  17385. private _vertexData;
  17386. private _vertexBuffer;
  17387. private _vertexBuffers;
  17388. private _spriteBuffer;
  17389. private _indexBuffer;
  17390. private _effect;
  17391. private _customEffect;
  17392. private _cachedDefines;
  17393. private _scaledColorStep;
  17394. private _colorDiff;
  17395. private _scaledDirection;
  17396. private _scaledGravity;
  17397. private _currentRenderId;
  17398. private _alive;
  17399. private _useInstancing;
  17400. private _started;
  17401. private _stopped;
  17402. private _actualFrame;
  17403. private _scaledUpdateSpeed;
  17404. private _vertexBufferSize;
  17405. /** @hidden */
  17406. _currentEmitRateGradient: Nullable<FactorGradient>;
  17407. /** @hidden */
  17408. _currentEmitRate1: number;
  17409. /** @hidden */
  17410. _currentEmitRate2: number;
  17411. /** @hidden */
  17412. _currentStartSizeGradient: Nullable<FactorGradient>;
  17413. /** @hidden */
  17414. _currentStartSize1: number;
  17415. /** @hidden */
  17416. _currentStartSize2: number;
  17417. private readonly _rawTextureWidth;
  17418. private _rampGradientsTexture;
  17419. private _useRampGradients;
  17420. /** Gets or sets a boolean indicating that ramp gradients must be used
  17421. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17422. */
  17423. useRampGradients: boolean;
  17424. /**
  17425. * 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.
  17426. * 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: [])
  17427. */
  17428. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17429. private _subEmitters;
  17430. /**
  17431. * @hidden
  17432. * If the particle systems emitter should be disposed when the particle system is disposed
  17433. */
  17434. _disposeEmitterOnDispose: boolean;
  17435. /**
  17436. * The current active Sub-systems, this property is used by the root particle system only.
  17437. */
  17438. activeSubSystems: Array<ParticleSystem>;
  17439. private _rootParticleSystem;
  17440. /**
  17441. * Gets the current list of active particles
  17442. */
  17443. readonly particles: Particle[];
  17444. /**
  17445. * Returns the string "ParticleSystem"
  17446. * @returns a string containing the class name
  17447. */
  17448. getClassName(): string;
  17449. /**
  17450. * Instantiates a particle system.
  17451. * 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.
  17452. * @param name The name of the particle system
  17453. * @param capacity The max number of particles alive at the same time
  17454. * @param scene The scene the particle system belongs to
  17455. * @param customEffect a custom effect used to change the way particles are rendered by default
  17456. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17457. * @param epsilon Offset used to render the particles
  17458. */
  17459. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17460. private _addFactorGradient;
  17461. private _removeFactorGradient;
  17462. /**
  17463. * Adds a new life time gradient
  17464. * @param gradient defines the gradient to use (between 0 and 1)
  17465. * @param factor defines the life time factor to affect to the specified gradient
  17466. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17467. * @returns the current particle system
  17468. */
  17469. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17470. /**
  17471. * Remove a specific life time gradient
  17472. * @param gradient defines the gradient to remove
  17473. * @returns the current particle system
  17474. */
  17475. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17476. /**
  17477. * Adds a new size gradient
  17478. * @param gradient defines the gradient to use (between 0 and 1)
  17479. * @param factor defines the size factor to affect to the specified gradient
  17480. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17481. * @returns the current particle system
  17482. */
  17483. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17484. /**
  17485. * Remove a specific size gradient
  17486. * @param gradient defines the gradient to remove
  17487. * @returns the current particle system
  17488. */
  17489. removeSizeGradient(gradient: number): IParticleSystem;
  17490. /**
  17491. * Adds a new color remap gradient
  17492. * @param gradient defines the gradient to use (between 0 and 1)
  17493. * @param min defines the color remap minimal range
  17494. * @param max defines the color remap maximal range
  17495. * @returns the current particle system
  17496. */
  17497. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17498. /**
  17499. * Remove a specific color remap gradient
  17500. * @param gradient defines the gradient to remove
  17501. * @returns the current particle system
  17502. */
  17503. removeColorRemapGradient(gradient: number): IParticleSystem;
  17504. /**
  17505. * Adds a new alpha remap gradient
  17506. * @param gradient defines the gradient to use (between 0 and 1)
  17507. * @param min defines the alpha remap minimal range
  17508. * @param max defines the alpha remap maximal range
  17509. * @returns the current particle system
  17510. */
  17511. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17512. /**
  17513. * Remove a specific alpha remap gradient
  17514. * @param gradient defines the gradient to remove
  17515. * @returns the current particle system
  17516. */
  17517. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17518. /**
  17519. * Adds a new angular speed gradient
  17520. * @param gradient defines the gradient to use (between 0 and 1)
  17521. * @param factor defines the angular speed to affect to the specified gradient
  17522. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17523. * @returns the current particle system
  17524. */
  17525. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17526. /**
  17527. * Remove a specific angular speed gradient
  17528. * @param gradient defines the gradient to remove
  17529. * @returns the current particle system
  17530. */
  17531. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17532. /**
  17533. * Adds a new velocity gradient
  17534. * @param gradient defines the gradient to use (between 0 and 1)
  17535. * @param factor defines the velocity to affect to the specified gradient
  17536. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17537. * @returns the current particle system
  17538. */
  17539. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17540. /**
  17541. * Remove a specific velocity gradient
  17542. * @param gradient defines the gradient to remove
  17543. * @returns the current particle system
  17544. */
  17545. removeVelocityGradient(gradient: number): IParticleSystem;
  17546. /**
  17547. * Adds a new limit velocity gradient
  17548. * @param gradient defines the gradient to use (between 0 and 1)
  17549. * @param factor defines the limit velocity value to affect to the specified gradient
  17550. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17551. * @returns the current particle system
  17552. */
  17553. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17554. /**
  17555. * Remove a specific limit velocity gradient
  17556. * @param gradient defines the gradient to remove
  17557. * @returns the current particle system
  17558. */
  17559. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17560. /**
  17561. * Adds a new drag gradient
  17562. * @param gradient defines the gradient to use (between 0 and 1)
  17563. * @param factor defines the drag value to affect to the specified gradient
  17564. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17565. * @returns the current particle system
  17566. */
  17567. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17568. /**
  17569. * Remove a specific drag gradient
  17570. * @param gradient defines the gradient to remove
  17571. * @returns the current particle system
  17572. */
  17573. removeDragGradient(gradient: number): IParticleSystem;
  17574. /**
  17575. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17576. * @param gradient defines the gradient to use (between 0 and 1)
  17577. * @param factor defines the emit rate value to affect to the specified gradient
  17578. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17579. * @returns the current particle system
  17580. */
  17581. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17582. /**
  17583. * Remove a specific emit rate gradient
  17584. * @param gradient defines the gradient to remove
  17585. * @returns the current particle system
  17586. */
  17587. removeEmitRateGradient(gradient: number): IParticleSystem;
  17588. /**
  17589. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17590. * @param gradient defines the gradient to use (between 0 and 1)
  17591. * @param factor defines the start size value to affect to the specified gradient
  17592. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17593. * @returns the current particle system
  17594. */
  17595. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17596. /**
  17597. * Remove a specific start size gradient
  17598. * @param gradient defines the gradient to remove
  17599. * @returns the current particle system
  17600. */
  17601. removeStartSizeGradient(gradient: number): IParticleSystem;
  17602. private _createRampGradientTexture;
  17603. /**
  17604. * Gets the current list of ramp gradients.
  17605. * You must use addRampGradient and removeRampGradient to udpate this list
  17606. * @returns the list of ramp gradients
  17607. */
  17608. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17609. /**
  17610. * Adds a new ramp gradient used to remap particle colors
  17611. * @param gradient defines the gradient to use (between 0 and 1)
  17612. * @param color defines the color to affect to the specified gradient
  17613. * @returns the current particle system
  17614. */
  17615. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17616. /**
  17617. * Remove a specific ramp gradient
  17618. * @param gradient defines the gradient to remove
  17619. * @returns the current particle system
  17620. */
  17621. removeRampGradient(gradient: number): ParticleSystem;
  17622. /**
  17623. * Adds a new color gradient
  17624. * @param gradient defines the gradient to use (between 0 and 1)
  17625. * @param color1 defines the color to affect to the specified gradient
  17626. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17627. * @returns this particle system
  17628. */
  17629. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17630. /**
  17631. * Remove a specific color gradient
  17632. * @param gradient defines the gradient to remove
  17633. * @returns this particle system
  17634. */
  17635. removeColorGradient(gradient: number): IParticleSystem;
  17636. private _fetchR;
  17637. protected _reset(): void;
  17638. private _resetEffect;
  17639. private _createVertexBuffers;
  17640. private _createIndexBuffer;
  17641. /**
  17642. * Gets the maximum number of particles active at the same time.
  17643. * @returns The max number of active particles.
  17644. */
  17645. getCapacity(): number;
  17646. /**
  17647. * Gets whether there are still active particles in the system.
  17648. * @returns True if it is alive, otherwise false.
  17649. */
  17650. isAlive(): boolean;
  17651. /**
  17652. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17653. * @returns True if it has been started, otherwise false.
  17654. */
  17655. isStarted(): boolean;
  17656. private _prepareSubEmitterInternalArray;
  17657. /**
  17658. * Starts the particle system and begins to emit
  17659. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17660. */
  17661. start(delay?: number): void;
  17662. /**
  17663. * Stops the particle system.
  17664. * @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.
  17665. */
  17666. stop(stopSubEmitters?: boolean): void;
  17667. /**
  17668. * Remove all active particles
  17669. */
  17670. reset(): void;
  17671. /**
  17672. * @hidden (for internal use only)
  17673. */
  17674. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17675. /**
  17676. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17677. * Its lifetime will start back at 0.
  17678. */
  17679. recycleParticle: (particle: Particle) => void;
  17680. private _stopSubEmitters;
  17681. private _createParticle;
  17682. private _removeFromRoot;
  17683. private _emitFromParticle;
  17684. private _update;
  17685. /** @hidden */
  17686. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17687. /** @hidden */
  17688. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17689. /** @hidden */
  17690. private _getEffect;
  17691. /**
  17692. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17693. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17694. */
  17695. animate(preWarmOnly?: boolean): void;
  17696. private _appendParticleVertices;
  17697. /**
  17698. * Rebuilds the particle system.
  17699. */
  17700. rebuild(): void;
  17701. /**
  17702. * Is this system ready to be used/rendered
  17703. * @return true if the system is ready
  17704. */
  17705. isReady(): boolean;
  17706. private _render;
  17707. /**
  17708. * Renders the particle system in its current state.
  17709. * @returns the current number of particles
  17710. */
  17711. render(): number;
  17712. /**
  17713. * Disposes the particle system and free the associated resources
  17714. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17715. */
  17716. dispose(disposeTexture?: boolean): void;
  17717. /**
  17718. * Clones the particle system.
  17719. * @param name The name of the cloned object
  17720. * @param newEmitter The new emitter to use
  17721. * @returns the cloned particle system
  17722. */
  17723. clone(name: string, newEmitter: any): ParticleSystem;
  17724. /**
  17725. * Serializes the particle system to a JSON object.
  17726. * @returns the JSON object
  17727. */
  17728. serialize(): any;
  17729. /** @hidden */
  17730. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17731. /** @hidden */
  17732. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17733. /**
  17734. * Parses a JSON object to create a particle system.
  17735. * @param parsedParticleSystem The JSON object to parse
  17736. * @param scene The scene to create the particle system in
  17737. * @param rootUrl The root url to use to load external dependencies like texture
  17738. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17739. * @returns the Parsed particle system
  17740. */
  17741. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17742. }
  17743. }
  17744. declare module "babylonjs/Particles/particle" {
  17745. import { Nullable } from "babylonjs/types";
  17746. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17747. import { Color4 } from "babylonjs/Maths/math.color";
  17748. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17749. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17750. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17751. /**
  17752. * A particle represents one of the element emitted by a particle system.
  17753. * This is mainly define by its coordinates, direction, velocity and age.
  17754. */
  17755. export class Particle {
  17756. /**
  17757. * The particle system the particle belongs to.
  17758. */
  17759. particleSystem: ParticleSystem;
  17760. private static _Count;
  17761. /**
  17762. * Unique ID of the particle
  17763. */
  17764. id: number;
  17765. /**
  17766. * The world position of the particle in the scene.
  17767. */
  17768. position: Vector3;
  17769. /**
  17770. * The world direction of the particle in the scene.
  17771. */
  17772. direction: Vector3;
  17773. /**
  17774. * The color of the particle.
  17775. */
  17776. color: Color4;
  17777. /**
  17778. * The color change of the particle per step.
  17779. */
  17780. colorStep: Color4;
  17781. /**
  17782. * Defines how long will the life of the particle be.
  17783. */
  17784. lifeTime: number;
  17785. /**
  17786. * The current age of the particle.
  17787. */
  17788. age: number;
  17789. /**
  17790. * The current size of the particle.
  17791. */
  17792. size: number;
  17793. /**
  17794. * The current scale of the particle.
  17795. */
  17796. scale: Vector2;
  17797. /**
  17798. * The current angle of the particle.
  17799. */
  17800. angle: number;
  17801. /**
  17802. * Defines how fast is the angle changing.
  17803. */
  17804. angularSpeed: number;
  17805. /**
  17806. * Defines the cell index used by the particle to be rendered from a sprite.
  17807. */
  17808. cellIndex: number;
  17809. /**
  17810. * The information required to support color remapping
  17811. */
  17812. remapData: Vector4;
  17813. /** @hidden */
  17814. _randomCellOffset?: number;
  17815. /** @hidden */
  17816. _initialDirection: Nullable<Vector3>;
  17817. /** @hidden */
  17818. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17819. /** @hidden */
  17820. _initialStartSpriteCellID: number;
  17821. /** @hidden */
  17822. _initialEndSpriteCellID: number;
  17823. /** @hidden */
  17824. _currentColorGradient: Nullable<ColorGradient>;
  17825. /** @hidden */
  17826. _currentColor1: Color4;
  17827. /** @hidden */
  17828. _currentColor2: Color4;
  17829. /** @hidden */
  17830. _currentSizeGradient: Nullable<FactorGradient>;
  17831. /** @hidden */
  17832. _currentSize1: number;
  17833. /** @hidden */
  17834. _currentSize2: number;
  17835. /** @hidden */
  17836. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17837. /** @hidden */
  17838. _currentAngularSpeed1: number;
  17839. /** @hidden */
  17840. _currentAngularSpeed2: number;
  17841. /** @hidden */
  17842. _currentVelocityGradient: Nullable<FactorGradient>;
  17843. /** @hidden */
  17844. _currentVelocity1: number;
  17845. /** @hidden */
  17846. _currentVelocity2: number;
  17847. /** @hidden */
  17848. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17849. /** @hidden */
  17850. _currentLimitVelocity1: number;
  17851. /** @hidden */
  17852. _currentLimitVelocity2: number;
  17853. /** @hidden */
  17854. _currentDragGradient: Nullable<FactorGradient>;
  17855. /** @hidden */
  17856. _currentDrag1: number;
  17857. /** @hidden */
  17858. _currentDrag2: number;
  17859. /** @hidden */
  17860. _randomNoiseCoordinates1: Vector3;
  17861. /** @hidden */
  17862. _randomNoiseCoordinates2: Vector3;
  17863. /**
  17864. * Creates a new instance Particle
  17865. * @param particleSystem the particle system the particle belongs to
  17866. */
  17867. constructor(
  17868. /**
  17869. * The particle system the particle belongs to.
  17870. */
  17871. particleSystem: ParticleSystem);
  17872. private updateCellInfoFromSystem;
  17873. /**
  17874. * Defines how the sprite cell index is updated for the particle
  17875. */
  17876. updateCellIndex(): void;
  17877. /** @hidden */
  17878. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17879. /** @hidden */
  17880. _inheritParticleInfoToSubEmitters(): void;
  17881. /** @hidden */
  17882. _reset(): void;
  17883. /**
  17884. * Copy the properties of particle to another one.
  17885. * @param other the particle to copy the information to.
  17886. */
  17887. copyTo(other: Particle): void;
  17888. }
  17889. }
  17890. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  17891. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17892. import { Effect } from "babylonjs/Materials/effect";
  17893. import { Particle } from "babylonjs/Particles/particle";
  17894. /**
  17895. * Particle emitter represents a volume emitting particles.
  17896. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17897. */
  17898. export interface IParticleEmitterType {
  17899. /**
  17900. * Called by the particle System when the direction is computed for the created particle.
  17901. * @param worldMatrix is the world matrix of the particle system
  17902. * @param directionToUpdate is the direction vector to update with the result
  17903. * @param particle is the particle we are computed the direction for
  17904. */
  17905. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17906. /**
  17907. * Called by the particle System when the position is computed for the created particle.
  17908. * @param worldMatrix is the world matrix of the particle system
  17909. * @param positionToUpdate is the position vector to update with the result
  17910. * @param particle is the particle we are computed the position for
  17911. */
  17912. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17913. /**
  17914. * Clones the current emitter and returns a copy of it
  17915. * @returns the new emitter
  17916. */
  17917. clone(): IParticleEmitterType;
  17918. /**
  17919. * Called by the GPUParticleSystem to setup the update shader
  17920. * @param effect defines the update shader
  17921. */
  17922. applyToShader(effect: Effect): void;
  17923. /**
  17924. * Returns a string to use to update the GPU particles update shader
  17925. * @returns the effect defines string
  17926. */
  17927. getEffectDefines(): string;
  17928. /**
  17929. * Returns a string representing the class name
  17930. * @returns a string containing the class name
  17931. */
  17932. getClassName(): string;
  17933. /**
  17934. * Serializes the particle system to a JSON object.
  17935. * @returns the JSON object
  17936. */
  17937. serialize(): any;
  17938. /**
  17939. * Parse properties from a JSON object
  17940. * @param serializationObject defines the JSON object
  17941. */
  17942. parse(serializationObject: any): void;
  17943. }
  17944. }
  17945. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  17946. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17947. import { Effect } from "babylonjs/Materials/effect";
  17948. import { Particle } from "babylonjs/Particles/particle";
  17949. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17950. /**
  17951. * Particle emitter emitting particles from the inside of a box.
  17952. * It emits the particles randomly between 2 given directions.
  17953. */
  17954. export class BoxParticleEmitter implements IParticleEmitterType {
  17955. /**
  17956. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17957. */
  17958. direction1: Vector3;
  17959. /**
  17960. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17961. */
  17962. direction2: Vector3;
  17963. /**
  17964. * 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.
  17965. */
  17966. minEmitBox: Vector3;
  17967. /**
  17968. * 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.
  17969. */
  17970. maxEmitBox: Vector3;
  17971. /**
  17972. * Creates a new instance BoxParticleEmitter
  17973. */
  17974. constructor();
  17975. /**
  17976. * Called by the particle System when the direction is computed for the created particle.
  17977. * @param worldMatrix is the world matrix of the particle system
  17978. * @param directionToUpdate is the direction vector to update with the result
  17979. * @param particle is the particle we are computed the direction for
  17980. */
  17981. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17982. /**
  17983. * Called by the particle System when the position is computed for the created particle.
  17984. * @param worldMatrix is the world matrix of the particle system
  17985. * @param positionToUpdate is the position vector to update with the result
  17986. * @param particle is the particle we are computed the position for
  17987. */
  17988. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17989. /**
  17990. * Clones the current emitter and returns a copy of it
  17991. * @returns the new emitter
  17992. */
  17993. clone(): BoxParticleEmitter;
  17994. /**
  17995. * Called by the GPUParticleSystem to setup the update shader
  17996. * @param effect defines the update shader
  17997. */
  17998. applyToShader(effect: Effect): void;
  17999. /**
  18000. * Returns a string to use to update the GPU particles update shader
  18001. * @returns a string containng the defines string
  18002. */
  18003. getEffectDefines(): string;
  18004. /**
  18005. * Returns the string "BoxParticleEmitter"
  18006. * @returns a string containing the class name
  18007. */
  18008. getClassName(): string;
  18009. /**
  18010. * Serializes the particle system to a JSON object.
  18011. * @returns the JSON object
  18012. */
  18013. serialize(): any;
  18014. /**
  18015. * Parse properties from a JSON object
  18016. * @param serializationObject defines the JSON object
  18017. */
  18018. parse(serializationObject: any): void;
  18019. }
  18020. }
  18021. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18022. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18023. import { Effect } from "babylonjs/Materials/effect";
  18024. import { Particle } from "babylonjs/Particles/particle";
  18025. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18026. /**
  18027. * Particle emitter emitting particles from the inside of a cone.
  18028. * It emits the particles alongside the cone volume from the base to the particle.
  18029. * The emission direction might be randomized.
  18030. */
  18031. export class ConeParticleEmitter implements IParticleEmitterType {
  18032. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18033. directionRandomizer: number;
  18034. private _radius;
  18035. private _angle;
  18036. private _height;
  18037. /**
  18038. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18039. */
  18040. radiusRange: number;
  18041. /**
  18042. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18043. */
  18044. heightRange: number;
  18045. /**
  18046. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18047. */
  18048. emitFromSpawnPointOnly: boolean;
  18049. /**
  18050. * Gets or sets the radius of the emission cone
  18051. */
  18052. radius: number;
  18053. /**
  18054. * Gets or sets the angle of the emission cone
  18055. */
  18056. angle: number;
  18057. private _buildHeight;
  18058. /**
  18059. * Creates a new instance ConeParticleEmitter
  18060. * @param radius the radius of the emission cone (1 by default)
  18061. * @param angle the cone base angle (PI by default)
  18062. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18063. */
  18064. constructor(radius?: number, angle?: number,
  18065. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18066. directionRandomizer?: number);
  18067. /**
  18068. * Called by the particle System when the direction is computed for the created particle.
  18069. * @param worldMatrix is the world matrix of the particle system
  18070. * @param directionToUpdate is the direction vector to update with the result
  18071. * @param particle is the particle we are computed the direction for
  18072. */
  18073. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18074. /**
  18075. * Called by the particle System when the position is computed for the created particle.
  18076. * @param worldMatrix is the world matrix of the particle system
  18077. * @param positionToUpdate is the position vector to update with the result
  18078. * @param particle is the particle we are computed the position for
  18079. */
  18080. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18081. /**
  18082. * Clones the current emitter and returns a copy of it
  18083. * @returns the new emitter
  18084. */
  18085. clone(): ConeParticleEmitter;
  18086. /**
  18087. * Called by the GPUParticleSystem to setup the update shader
  18088. * @param effect defines the update shader
  18089. */
  18090. applyToShader(effect: Effect): void;
  18091. /**
  18092. * Returns a string to use to update the GPU particles update shader
  18093. * @returns a string containng the defines string
  18094. */
  18095. getEffectDefines(): string;
  18096. /**
  18097. * Returns the string "ConeParticleEmitter"
  18098. * @returns a string containing the class name
  18099. */
  18100. getClassName(): string;
  18101. /**
  18102. * Serializes the particle system to a JSON object.
  18103. * @returns the JSON object
  18104. */
  18105. serialize(): any;
  18106. /**
  18107. * Parse properties from a JSON object
  18108. * @param serializationObject defines the JSON object
  18109. */
  18110. parse(serializationObject: any): void;
  18111. }
  18112. }
  18113. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18114. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18115. import { Effect } from "babylonjs/Materials/effect";
  18116. import { Particle } from "babylonjs/Particles/particle";
  18117. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18118. /**
  18119. * Particle emitter emitting particles from the inside of a cylinder.
  18120. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18121. */
  18122. export class CylinderParticleEmitter implements IParticleEmitterType {
  18123. /**
  18124. * The radius of the emission cylinder.
  18125. */
  18126. radius: number;
  18127. /**
  18128. * The height of the emission cylinder.
  18129. */
  18130. height: number;
  18131. /**
  18132. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18133. */
  18134. radiusRange: number;
  18135. /**
  18136. * How much to randomize the particle direction [0-1].
  18137. */
  18138. directionRandomizer: number;
  18139. /**
  18140. * Creates a new instance CylinderParticleEmitter
  18141. * @param radius the radius of the emission cylinder (1 by default)
  18142. * @param height the height of the emission cylinder (1 by default)
  18143. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18144. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18145. */
  18146. constructor(
  18147. /**
  18148. * The radius of the emission cylinder.
  18149. */
  18150. radius?: number,
  18151. /**
  18152. * The height of the emission cylinder.
  18153. */
  18154. height?: number,
  18155. /**
  18156. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18157. */
  18158. radiusRange?: number,
  18159. /**
  18160. * How much to randomize the particle direction [0-1].
  18161. */
  18162. directionRandomizer?: number);
  18163. /**
  18164. * Called by the particle System when the direction is computed for the created particle.
  18165. * @param worldMatrix is the world matrix of the particle system
  18166. * @param directionToUpdate is the direction vector to update with the result
  18167. * @param particle is the particle we are computed the direction for
  18168. */
  18169. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18170. /**
  18171. * Called by the particle System when the position is computed for the created particle.
  18172. * @param worldMatrix is the world matrix of the particle system
  18173. * @param positionToUpdate is the position vector to update with the result
  18174. * @param particle is the particle we are computed the position for
  18175. */
  18176. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18177. /**
  18178. * Clones the current emitter and returns a copy of it
  18179. * @returns the new emitter
  18180. */
  18181. clone(): CylinderParticleEmitter;
  18182. /**
  18183. * Called by the GPUParticleSystem to setup the update shader
  18184. * @param effect defines the update shader
  18185. */
  18186. applyToShader(effect: Effect): void;
  18187. /**
  18188. * Returns a string to use to update the GPU particles update shader
  18189. * @returns a string containng the defines string
  18190. */
  18191. getEffectDefines(): string;
  18192. /**
  18193. * Returns the string "CylinderParticleEmitter"
  18194. * @returns a string containing the class name
  18195. */
  18196. getClassName(): string;
  18197. /**
  18198. * Serializes the particle system to a JSON object.
  18199. * @returns the JSON object
  18200. */
  18201. serialize(): any;
  18202. /**
  18203. * Parse properties from a JSON object
  18204. * @param serializationObject defines the JSON object
  18205. */
  18206. parse(serializationObject: any): void;
  18207. }
  18208. /**
  18209. * Particle emitter emitting particles from the inside of a cylinder.
  18210. * It emits the particles randomly between two vectors.
  18211. */
  18212. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18213. /**
  18214. * The min limit of the emission direction.
  18215. */
  18216. direction1: Vector3;
  18217. /**
  18218. * The max limit of the emission direction.
  18219. */
  18220. direction2: Vector3;
  18221. /**
  18222. * Creates a new instance CylinderDirectedParticleEmitter
  18223. * @param radius the radius of the emission cylinder (1 by default)
  18224. * @param height the height of the emission cylinder (1 by default)
  18225. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18226. * @param direction1 the min limit of the emission direction (up vector by default)
  18227. * @param direction2 the max limit of the emission direction (up vector by default)
  18228. */
  18229. constructor(radius?: number, height?: number, radiusRange?: number,
  18230. /**
  18231. * The min limit of the emission direction.
  18232. */
  18233. direction1?: Vector3,
  18234. /**
  18235. * The max limit of the emission direction.
  18236. */
  18237. direction2?: Vector3);
  18238. /**
  18239. * Called by the particle System when the direction is computed for the created particle.
  18240. * @param worldMatrix is the world matrix of the particle system
  18241. * @param directionToUpdate is the direction vector to update with the result
  18242. * @param particle is the particle we are computed the direction for
  18243. */
  18244. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18245. /**
  18246. * Clones the current emitter and returns a copy of it
  18247. * @returns the new emitter
  18248. */
  18249. clone(): CylinderDirectedParticleEmitter;
  18250. /**
  18251. * Called by the GPUParticleSystem to setup the update shader
  18252. * @param effect defines the update shader
  18253. */
  18254. applyToShader(effect: Effect): void;
  18255. /**
  18256. * Returns a string to use to update the GPU particles update shader
  18257. * @returns a string containng the defines string
  18258. */
  18259. getEffectDefines(): string;
  18260. /**
  18261. * Returns the string "CylinderDirectedParticleEmitter"
  18262. * @returns a string containing the class name
  18263. */
  18264. getClassName(): string;
  18265. /**
  18266. * Serializes the particle system to a JSON object.
  18267. * @returns the JSON object
  18268. */
  18269. serialize(): any;
  18270. /**
  18271. * Parse properties from a JSON object
  18272. * @param serializationObject defines the JSON object
  18273. */
  18274. parse(serializationObject: any): void;
  18275. }
  18276. }
  18277. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18278. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18279. import { Effect } from "babylonjs/Materials/effect";
  18280. import { Particle } from "babylonjs/Particles/particle";
  18281. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18282. /**
  18283. * Particle emitter emitting particles from the inside of a hemisphere.
  18284. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18285. */
  18286. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18287. /**
  18288. * The radius of the emission hemisphere.
  18289. */
  18290. radius: number;
  18291. /**
  18292. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18293. */
  18294. radiusRange: number;
  18295. /**
  18296. * How much to randomize the particle direction [0-1].
  18297. */
  18298. directionRandomizer: number;
  18299. /**
  18300. * Creates a new instance HemisphericParticleEmitter
  18301. * @param radius the radius of the emission hemisphere (1 by default)
  18302. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18303. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18304. */
  18305. constructor(
  18306. /**
  18307. * The radius of the emission hemisphere.
  18308. */
  18309. radius?: number,
  18310. /**
  18311. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18312. */
  18313. radiusRange?: number,
  18314. /**
  18315. * How much to randomize the particle direction [0-1].
  18316. */
  18317. directionRandomizer?: number);
  18318. /**
  18319. * Called by the particle System when the direction is computed for the created particle.
  18320. * @param worldMatrix is the world matrix of the particle system
  18321. * @param directionToUpdate is the direction vector to update with the result
  18322. * @param particle is the particle we are computed the direction for
  18323. */
  18324. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18325. /**
  18326. * Called by the particle System when the position is computed for the created particle.
  18327. * @param worldMatrix is the world matrix of the particle system
  18328. * @param positionToUpdate is the position vector to update with the result
  18329. * @param particle is the particle we are computed the position for
  18330. */
  18331. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18332. /**
  18333. * Clones the current emitter and returns a copy of it
  18334. * @returns the new emitter
  18335. */
  18336. clone(): HemisphericParticleEmitter;
  18337. /**
  18338. * Called by the GPUParticleSystem to setup the update shader
  18339. * @param effect defines the update shader
  18340. */
  18341. applyToShader(effect: Effect): void;
  18342. /**
  18343. * Returns a string to use to update the GPU particles update shader
  18344. * @returns a string containng the defines string
  18345. */
  18346. getEffectDefines(): string;
  18347. /**
  18348. * Returns the string "HemisphericParticleEmitter"
  18349. * @returns a string containing the class name
  18350. */
  18351. getClassName(): string;
  18352. /**
  18353. * Serializes the particle system to a JSON object.
  18354. * @returns the JSON object
  18355. */
  18356. serialize(): any;
  18357. /**
  18358. * Parse properties from a JSON object
  18359. * @param serializationObject defines the JSON object
  18360. */
  18361. parse(serializationObject: any): void;
  18362. }
  18363. }
  18364. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18365. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18366. import { Effect } from "babylonjs/Materials/effect";
  18367. import { Particle } from "babylonjs/Particles/particle";
  18368. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18369. /**
  18370. * Particle emitter emitting particles from a point.
  18371. * It emits the particles randomly between 2 given directions.
  18372. */
  18373. export class PointParticleEmitter implements IParticleEmitterType {
  18374. /**
  18375. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18376. */
  18377. direction1: Vector3;
  18378. /**
  18379. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18380. */
  18381. direction2: Vector3;
  18382. /**
  18383. * Creates a new instance PointParticleEmitter
  18384. */
  18385. constructor();
  18386. /**
  18387. * Called by the particle System when the direction is computed for the created particle.
  18388. * @param worldMatrix is the world matrix of the particle system
  18389. * @param directionToUpdate is the direction vector to update with the result
  18390. * @param particle is the particle we are computed the direction for
  18391. */
  18392. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18393. /**
  18394. * Called by the particle System when the position is computed for the created particle.
  18395. * @param worldMatrix is the world matrix of the particle system
  18396. * @param positionToUpdate is the position vector to update with the result
  18397. * @param particle is the particle we are computed the position for
  18398. */
  18399. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18400. /**
  18401. * Clones the current emitter and returns a copy of it
  18402. * @returns the new emitter
  18403. */
  18404. clone(): PointParticleEmitter;
  18405. /**
  18406. * Called by the GPUParticleSystem to setup the update shader
  18407. * @param effect defines the update shader
  18408. */
  18409. applyToShader(effect: Effect): void;
  18410. /**
  18411. * Returns a string to use to update the GPU particles update shader
  18412. * @returns a string containng the defines string
  18413. */
  18414. getEffectDefines(): string;
  18415. /**
  18416. * Returns the string "PointParticleEmitter"
  18417. * @returns a string containing the class name
  18418. */
  18419. getClassName(): string;
  18420. /**
  18421. * Serializes the particle system to a JSON object.
  18422. * @returns the JSON object
  18423. */
  18424. serialize(): any;
  18425. /**
  18426. * Parse properties from a JSON object
  18427. * @param serializationObject defines the JSON object
  18428. */
  18429. parse(serializationObject: any): void;
  18430. }
  18431. }
  18432. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18433. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18434. import { Effect } from "babylonjs/Materials/effect";
  18435. import { Particle } from "babylonjs/Particles/particle";
  18436. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18437. /**
  18438. * Particle emitter emitting particles from the inside of a sphere.
  18439. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18440. */
  18441. export class SphereParticleEmitter implements IParticleEmitterType {
  18442. /**
  18443. * The radius of the emission sphere.
  18444. */
  18445. radius: number;
  18446. /**
  18447. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18448. */
  18449. radiusRange: number;
  18450. /**
  18451. * How much to randomize the particle direction [0-1].
  18452. */
  18453. directionRandomizer: number;
  18454. /**
  18455. * Creates a new instance SphereParticleEmitter
  18456. * @param radius the radius of the emission sphere (1 by default)
  18457. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18458. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18459. */
  18460. constructor(
  18461. /**
  18462. * The radius of the emission sphere.
  18463. */
  18464. radius?: number,
  18465. /**
  18466. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18467. */
  18468. radiusRange?: number,
  18469. /**
  18470. * How much to randomize the particle direction [0-1].
  18471. */
  18472. directionRandomizer?: number);
  18473. /**
  18474. * Called by the particle System when the direction is computed for the created particle.
  18475. * @param worldMatrix is the world matrix of the particle system
  18476. * @param directionToUpdate is the direction vector to update with the result
  18477. * @param particle is the particle we are computed the direction for
  18478. */
  18479. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18480. /**
  18481. * Called by the particle System when the position is computed for the created particle.
  18482. * @param worldMatrix is the world matrix of the particle system
  18483. * @param positionToUpdate is the position vector to update with the result
  18484. * @param particle is the particle we are computed the position for
  18485. */
  18486. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18487. /**
  18488. * Clones the current emitter and returns a copy of it
  18489. * @returns the new emitter
  18490. */
  18491. clone(): SphereParticleEmitter;
  18492. /**
  18493. * Called by the GPUParticleSystem to setup the update shader
  18494. * @param effect defines the update shader
  18495. */
  18496. applyToShader(effect: Effect): void;
  18497. /**
  18498. * Returns a string to use to update the GPU particles update shader
  18499. * @returns a string containng the defines string
  18500. */
  18501. getEffectDefines(): string;
  18502. /**
  18503. * Returns the string "SphereParticleEmitter"
  18504. * @returns a string containing the class name
  18505. */
  18506. getClassName(): string;
  18507. /**
  18508. * Serializes the particle system to a JSON object.
  18509. * @returns the JSON object
  18510. */
  18511. serialize(): any;
  18512. /**
  18513. * Parse properties from a JSON object
  18514. * @param serializationObject defines the JSON object
  18515. */
  18516. parse(serializationObject: any): void;
  18517. }
  18518. /**
  18519. * Particle emitter emitting particles from the inside of a sphere.
  18520. * It emits the particles randomly between two vectors.
  18521. */
  18522. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18523. /**
  18524. * The min limit of the emission direction.
  18525. */
  18526. direction1: Vector3;
  18527. /**
  18528. * The max limit of the emission direction.
  18529. */
  18530. direction2: Vector3;
  18531. /**
  18532. * Creates a new instance SphereDirectedParticleEmitter
  18533. * @param radius the radius of the emission sphere (1 by default)
  18534. * @param direction1 the min limit of the emission direction (up vector by default)
  18535. * @param direction2 the max limit of the emission direction (up vector by default)
  18536. */
  18537. constructor(radius?: number,
  18538. /**
  18539. * The min limit of the emission direction.
  18540. */
  18541. direction1?: Vector3,
  18542. /**
  18543. * The max limit of the emission direction.
  18544. */
  18545. direction2?: Vector3);
  18546. /**
  18547. * Called by the particle System when the direction is computed for the created particle.
  18548. * @param worldMatrix is the world matrix of the particle system
  18549. * @param directionToUpdate is the direction vector to update with the result
  18550. * @param particle is the particle we are computed the direction for
  18551. */
  18552. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18553. /**
  18554. * Clones the current emitter and returns a copy of it
  18555. * @returns the new emitter
  18556. */
  18557. clone(): SphereDirectedParticleEmitter;
  18558. /**
  18559. * Called by the GPUParticleSystem to setup the update shader
  18560. * @param effect defines the update shader
  18561. */
  18562. applyToShader(effect: Effect): void;
  18563. /**
  18564. * Returns a string to use to update the GPU particles update shader
  18565. * @returns a string containng the defines string
  18566. */
  18567. getEffectDefines(): string;
  18568. /**
  18569. * Returns the string "SphereDirectedParticleEmitter"
  18570. * @returns a string containing the class name
  18571. */
  18572. getClassName(): string;
  18573. /**
  18574. * Serializes the particle system to a JSON object.
  18575. * @returns the JSON object
  18576. */
  18577. serialize(): any;
  18578. /**
  18579. * Parse properties from a JSON object
  18580. * @param serializationObject defines the JSON object
  18581. */
  18582. parse(serializationObject: any): void;
  18583. }
  18584. }
  18585. declare module "babylonjs/Particles/EmitterTypes/index" {
  18586. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18587. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18588. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18589. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18590. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18591. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18592. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18593. }
  18594. declare module "babylonjs/Particles/IParticleSystem" {
  18595. import { Nullable } from "babylonjs/types";
  18596. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18597. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18598. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18599. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18600. import { Texture } from "babylonjs/Materials/Textures/texture";
  18601. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18602. import { Scene } from "babylonjs/scene";
  18603. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18604. import { Animation } from "babylonjs/Animations/animation";
  18605. /**
  18606. * Interface representing a particle system in Babylon.js.
  18607. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18608. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18609. */
  18610. export interface IParticleSystem {
  18611. /**
  18612. * List of animations used by the particle system.
  18613. */
  18614. animations: Animation[];
  18615. /**
  18616. * The id of the Particle system.
  18617. */
  18618. id: string;
  18619. /**
  18620. * The name of the Particle system.
  18621. */
  18622. name: string;
  18623. /**
  18624. * The emitter represents the Mesh or position we are attaching the particle system to.
  18625. */
  18626. emitter: Nullable<AbstractMesh | Vector3>;
  18627. /**
  18628. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18629. */
  18630. isBillboardBased: boolean;
  18631. /**
  18632. * The rendering group used by the Particle system to chose when to render.
  18633. */
  18634. renderingGroupId: number;
  18635. /**
  18636. * The layer mask we are rendering the particles through.
  18637. */
  18638. layerMask: number;
  18639. /**
  18640. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18641. */
  18642. updateSpeed: number;
  18643. /**
  18644. * The amount of time the particle system is running (depends of the overall update speed).
  18645. */
  18646. targetStopDuration: number;
  18647. /**
  18648. * The texture used to render each particle. (this can be a spritesheet)
  18649. */
  18650. particleTexture: Nullable<Texture>;
  18651. /**
  18652. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18653. */
  18654. blendMode: number;
  18655. /**
  18656. * Minimum life time of emitting particles.
  18657. */
  18658. minLifeTime: number;
  18659. /**
  18660. * Maximum life time of emitting particles.
  18661. */
  18662. maxLifeTime: number;
  18663. /**
  18664. * Minimum Size of emitting particles.
  18665. */
  18666. minSize: number;
  18667. /**
  18668. * Maximum Size of emitting particles.
  18669. */
  18670. maxSize: number;
  18671. /**
  18672. * Minimum scale of emitting particles on X axis.
  18673. */
  18674. minScaleX: number;
  18675. /**
  18676. * Maximum scale of emitting particles on X axis.
  18677. */
  18678. maxScaleX: number;
  18679. /**
  18680. * Minimum scale of emitting particles on Y axis.
  18681. */
  18682. minScaleY: number;
  18683. /**
  18684. * Maximum scale of emitting particles on Y axis.
  18685. */
  18686. maxScaleY: number;
  18687. /**
  18688. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18689. */
  18690. color1: Color4;
  18691. /**
  18692. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18693. */
  18694. color2: Color4;
  18695. /**
  18696. * Color the particle will have at the end of its lifetime.
  18697. */
  18698. colorDead: Color4;
  18699. /**
  18700. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18701. */
  18702. emitRate: number;
  18703. /**
  18704. * You can use gravity if you want to give an orientation to your particles.
  18705. */
  18706. gravity: Vector3;
  18707. /**
  18708. * Minimum power of emitting particles.
  18709. */
  18710. minEmitPower: number;
  18711. /**
  18712. * Maximum power of emitting particles.
  18713. */
  18714. maxEmitPower: number;
  18715. /**
  18716. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18717. */
  18718. minAngularSpeed: number;
  18719. /**
  18720. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18721. */
  18722. maxAngularSpeed: number;
  18723. /**
  18724. * Gets or sets the minimal initial rotation in radians.
  18725. */
  18726. minInitialRotation: number;
  18727. /**
  18728. * Gets or sets the maximal initial rotation in radians.
  18729. */
  18730. maxInitialRotation: number;
  18731. /**
  18732. * The particle emitter type defines the emitter used by the particle system.
  18733. * It can be for example box, sphere, or cone...
  18734. */
  18735. particleEmitterType: Nullable<IParticleEmitterType>;
  18736. /**
  18737. * Defines the delay in milliseconds before starting the system (0 by default)
  18738. */
  18739. startDelay: number;
  18740. /**
  18741. * 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
  18742. */
  18743. preWarmCycles: number;
  18744. /**
  18745. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18746. */
  18747. preWarmStepOffset: number;
  18748. /**
  18749. * 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)
  18750. */
  18751. spriteCellChangeSpeed: number;
  18752. /**
  18753. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18754. */
  18755. startSpriteCellID: number;
  18756. /**
  18757. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18758. */
  18759. endSpriteCellID: number;
  18760. /**
  18761. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18762. */
  18763. spriteCellWidth: number;
  18764. /**
  18765. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18766. */
  18767. spriteCellHeight: number;
  18768. /**
  18769. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18770. */
  18771. spriteRandomStartCell: boolean;
  18772. /**
  18773. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18774. */
  18775. isAnimationSheetEnabled: boolean;
  18776. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18777. translationPivot: Vector2;
  18778. /**
  18779. * Gets or sets a texture used to add random noise to particle positions
  18780. */
  18781. noiseTexture: Nullable<BaseTexture>;
  18782. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18783. noiseStrength: Vector3;
  18784. /**
  18785. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18786. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18787. */
  18788. billboardMode: number;
  18789. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18790. limitVelocityDamping: number;
  18791. /**
  18792. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18793. */
  18794. beginAnimationOnStart: boolean;
  18795. /**
  18796. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18797. */
  18798. beginAnimationFrom: number;
  18799. /**
  18800. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18801. */
  18802. beginAnimationTo: number;
  18803. /**
  18804. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18805. */
  18806. beginAnimationLoop: boolean;
  18807. /**
  18808. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18809. */
  18810. disposeOnStop: boolean;
  18811. /**
  18812. * Gets the maximum number of particles active at the same time.
  18813. * @returns The max number of active particles.
  18814. */
  18815. getCapacity(): number;
  18816. /**
  18817. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18818. * @returns True if it has been started, otherwise false.
  18819. */
  18820. isStarted(): boolean;
  18821. /**
  18822. * Animates the particle system for this frame.
  18823. */
  18824. animate(): void;
  18825. /**
  18826. * Renders the particle system in its current state.
  18827. * @returns the current number of particles
  18828. */
  18829. render(): number;
  18830. /**
  18831. * Dispose the particle system and frees its associated resources.
  18832. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18833. */
  18834. dispose(disposeTexture?: boolean): void;
  18835. /**
  18836. * Clones the particle system.
  18837. * @param name The name of the cloned object
  18838. * @param newEmitter The new emitter to use
  18839. * @returns the cloned particle system
  18840. */
  18841. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18842. /**
  18843. * Serializes the particle system to a JSON object.
  18844. * @returns the JSON object
  18845. */
  18846. serialize(): any;
  18847. /**
  18848. * Rebuild the particle system
  18849. */
  18850. rebuild(): void;
  18851. /**
  18852. * Starts the particle system and begins to emit
  18853. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18854. */
  18855. start(delay?: number): void;
  18856. /**
  18857. * Stops the particle system.
  18858. */
  18859. stop(): void;
  18860. /**
  18861. * Remove all active particles
  18862. */
  18863. reset(): void;
  18864. /**
  18865. * Is this system ready to be used/rendered
  18866. * @return true if the system is ready
  18867. */
  18868. isReady(): boolean;
  18869. /**
  18870. * Adds a new color gradient
  18871. * @param gradient defines the gradient to use (between 0 and 1)
  18872. * @param color1 defines the color to affect to the specified gradient
  18873. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18874. * @returns the current particle system
  18875. */
  18876. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18877. /**
  18878. * Remove a specific color gradient
  18879. * @param gradient defines the gradient to remove
  18880. * @returns the current particle system
  18881. */
  18882. removeColorGradient(gradient: number): IParticleSystem;
  18883. /**
  18884. * Adds a new size gradient
  18885. * @param gradient defines the gradient to use (between 0 and 1)
  18886. * @param factor defines the size factor to affect to the specified gradient
  18887. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18888. * @returns the current particle system
  18889. */
  18890. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18891. /**
  18892. * Remove a specific size gradient
  18893. * @param gradient defines the gradient to remove
  18894. * @returns the current particle system
  18895. */
  18896. removeSizeGradient(gradient: number): IParticleSystem;
  18897. /**
  18898. * Gets the current list of color gradients.
  18899. * You must use addColorGradient and removeColorGradient to udpate this list
  18900. * @returns the list of color gradients
  18901. */
  18902. getColorGradients(): Nullable<Array<ColorGradient>>;
  18903. /**
  18904. * Gets the current list of size gradients.
  18905. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18906. * @returns the list of size gradients
  18907. */
  18908. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18909. /**
  18910. * Gets the current list of angular speed gradients.
  18911. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18912. * @returns the list of angular speed gradients
  18913. */
  18914. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18915. /**
  18916. * Adds a new angular speed gradient
  18917. * @param gradient defines the gradient to use (between 0 and 1)
  18918. * @param factor defines the angular speed to affect to the specified gradient
  18919. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18920. * @returns the current particle system
  18921. */
  18922. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18923. /**
  18924. * Remove a specific angular speed gradient
  18925. * @param gradient defines the gradient to remove
  18926. * @returns the current particle system
  18927. */
  18928. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18929. /**
  18930. * Gets the current list of velocity gradients.
  18931. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18932. * @returns the list of velocity gradients
  18933. */
  18934. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18935. /**
  18936. * Adds a new velocity gradient
  18937. * @param gradient defines the gradient to use (between 0 and 1)
  18938. * @param factor defines the velocity to affect to the specified gradient
  18939. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18940. * @returns the current particle system
  18941. */
  18942. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18943. /**
  18944. * Remove a specific velocity gradient
  18945. * @param gradient defines the gradient to remove
  18946. * @returns the current particle system
  18947. */
  18948. removeVelocityGradient(gradient: number): IParticleSystem;
  18949. /**
  18950. * Gets the current list of limit velocity gradients.
  18951. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18952. * @returns the list of limit velocity gradients
  18953. */
  18954. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18955. /**
  18956. * Adds a new limit velocity gradient
  18957. * @param gradient defines the gradient to use (between 0 and 1)
  18958. * @param factor defines the limit velocity to affect to the specified gradient
  18959. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18960. * @returns the current particle system
  18961. */
  18962. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18963. /**
  18964. * Remove a specific limit velocity gradient
  18965. * @param gradient defines the gradient to remove
  18966. * @returns the current particle system
  18967. */
  18968. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18969. /**
  18970. * Adds a new drag gradient
  18971. * @param gradient defines the gradient to use (between 0 and 1)
  18972. * @param factor defines the drag to affect to the specified gradient
  18973. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18974. * @returns the current particle system
  18975. */
  18976. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18977. /**
  18978. * Remove a specific drag gradient
  18979. * @param gradient defines the gradient to remove
  18980. * @returns the current particle system
  18981. */
  18982. removeDragGradient(gradient: number): IParticleSystem;
  18983. /**
  18984. * Gets the current list of drag gradients.
  18985. * You must use addDragGradient and removeDragGradient to udpate this list
  18986. * @returns the list of drag gradients
  18987. */
  18988. getDragGradients(): Nullable<Array<FactorGradient>>;
  18989. /**
  18990. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18991. * @param gradient defines the gradient to use (between 0 and 1)
  18992. * @param factor defines the emit rate to affect to the specified gradient
  18993. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18994. * @returns the current particle system
  18995. */
  18996. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18997. /**
  18998. * Remove a specific emit rate gradient
  18999. * @param gradient defines the gradient to remove
  19000. * @returns the current particle system
  19001. */
  19002. removeEmitRateGradient(gradient: number): IParticleSystem;
  19003. /**
  19004. * Gets the current list of emit rate gradients.
  19005. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19006. * @returns the list of emit rate gradients
  19007. */
  19008. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19009. /**
  19010. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19011. * @param gradient defines the gradient to use (between 0 and 1)
  19012. * @param factor defines the start size to affect to the specified gradient
  19013. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19014. * @returns the current particle system
  19015. */
  19016. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19017. /**
  19018. * Remove a specific start size gradient
  19019. * @param gradient defines the gradient to remove
  19020. * @returns the current particle system
  19021. */
  19022. removeStartSizeGradient(gradient: number): IParticleSystem;
  19023. /**
  19024. * Gets the current list of start size gradients.
  19025. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19026. * @returns the list of start size gradients
  19027. */
  19028. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19029. /**
  19030. * Adds a new life time gradient
  19031. * @param gradient defines the gradient to use (between 0 and 1)
  19032. * @param factor defines the life time factor to affect to the specified gradient
  19033. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19034. * @returns the current particle system
  19035. */
  19036. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19037. /**
  19038. * Remove a specific life time gradient
  19039. * @param gradient defines the gradient to remove
  19040. * @returns the current particle system
  19041. */
  19042. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19043. /**
  19044. * Gets the current list of life time gradients.
  19045. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19046. * @returns the list of life time gradients
  19047. */
  19048. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19049. /**
  19050. * Gets the current list of color gradients.
  19051. * You must use addColorGradient and removeColorGradient to udpate this list
  19052. * @returns the list of color gradients
  19053. */
  19054. getColorGradients(): Nullable<Array<ColorGradient>>;
  19055. /**
  19056. * Adds a new ramp gradient used to remap particle colors
  19057. * @param gradient defines the gradient to use (between 0 and 1)
  19058. * @param color defines the color to affect to the specified gradient
  19059. * @returns the current particle system
  19060. */
  19061. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19062. /**
  19063. * Gets the current list of ramp gradients.
  19064. * You must use addRampGradient and removeRampGradient to udpate this list
  19065. * @returns the list of ramp gradients
  19066. */
  19067. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19068. /** Gets or sets a boolean indicating that ramp gradients must be used
  19069. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19070. */
  19071. useRampGradients: boolean;
  19072. /**
  19073. * Adds a new color remap gradient
  19074. * @param gradient defines the gradient to use (between 0 and 1)
  19075. * @param min defines the color remap minimal range
  19076. * @param max defines the color remap maximal range
  19077. * @returns the current particle system
  19078. */
  19079. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19080. /**
  19081. * Gets the current list of color remap gradients.
  19082. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19083. * @returns the list of color remap gradients
  19084. */
  19085. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19086. /**
  19087. * Adds a new alpha remap gradient
  19088. * @param gradient defines the gradient to use (between 0 and 1)
  19089. * @param min defines the alpha remap minimal range
  19090. * @param max defines the alpha remap maximal range
  19091. * @returns the current particle system
  19092. */
  19093. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19094. /**
  19095. * Gets the current list of alpha remap gradients.
  19096. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19097. * @returns the list of alpha remap gradients
  19098. */
  19099. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19100. /**
  19101. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19102. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19103. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19104. * @returns the emitter
  19105. */
  19106. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19107. /**
  19108. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19109. * @param radius The radius of the hemisphere to emit from
  19110. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19111. * @returns the emitter
  19112. */
  19113. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19114. /**
  19115. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19116. * @param radius The radius of the sphere to emit from
  19117. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19118. * @returns the emitter
  19119. */
  19120. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19121. /**
  19122. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19123. * @param radius The radius of the sphere to emit from
  19124. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19125. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19126. * @returns the emitter
  19127. */
  19128. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19129. /**
  19130. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19131. * @param radius The radius of the emission cylinder
  19132. * @param height The height of the emission cylinder
  19133. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19134. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19135. * @returns the emitter
  19136. */
  19137. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19138. /**
  19139. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19140. * @param radius The radius of the cylinder to emit from
  19141. * @param height The height of the emission cylinder
  19142. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19143. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19144. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19145. * @returns the emitter
  19146. */
  19147. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19148. /**
  19149. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19150. * @param radius The radius of the cone to emit from
  19151. * @param angle The base angle of the cone
  19152. * @returns the emitter
  19153. */
  19154. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19155. /**
  19156. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19157. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19158. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19159. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19160. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19161. * @returns the emitter
  19162. */
  19163. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19164. /**
  19165. * Get hosting scene
  19166. * @returns the scene
  19167. */
  19168. getScene(): Scene;
  19169. }
  19170. }
  19171. declare module "babylonjs/Meshes/instancedMesh" {
  19172. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19173. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19174. import { Camera } from "babylonjs/Cameras/camera";
  19175. import { Node } from "babylonjs/node";
  19176. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19177. import { Mesh } from "babylonjs/Meshes/mesh";
  19178. import { Material } from "babylonjs/Materials/material";
  19179. import { Skeleton } from "babylonjs/Bones/skeleton";
  19180. import { Light } from "babylonjs/Lights/light";
  19181. /**
  19182. * Creates an instance based on a source mesh.
  19183. */
  19184. export class InstancedMesh extends AbstractMesh {
  19185. private _sourceMesh;
  19186. private _currentLOD;
  19187. /** @hidden */
  19188. _indexInSourceMeshInstanceArray: number;
  19189. constructor(name: string, source: Mesh);
  19190. /**
  19191. * Returns the string "InstancedMesh".
  19192. */
  19193. getClassName(): string;
  19194. /** Gets the list of lights affecting that mesh */
  19195. readonly lightSources: Light[];
  19196. _resyncLightSources(): void;
  19197. _resyncLighSource(light: Light): void;
  19198. _removeLightSource(light: Light, dispose: boolean): void;
  19199. /**
  19200. * If the source mesh receives shadows
  19201. */
  19202. readonly receiveShadows: boolean;
  19203. /**
  19204. * The material of the source mesh
  19205. */
  19206. readonly material: Nullable<Material>;
  19207. /**
  19208. * Visibility of the source mesh
  19209. */
  19210. readonly visibility: number;
  19211. /**
  19212. * Skeleton of the source mesh
  19213. */
  19214. readonly skeleton: Nullable<Skeleton>;
  19215. /**
  19216. * Rendering ground id of the source mesh
  19217. */
  19218. renderingGroupId: number;
  19219. /**
  19220. * Returns the total number of vertices (integer).
  19221. */
  19222. getTotalVertices(): number;
  19223. /**
  19224. * Returns a positive integer : the total number of indices in this mesh geometry.
  19225. * @returns the numner of indices or zero if the mesh has no geometry.
  19226. */
  19227. getTotalIndices(): number;
  19228. /**
  19229. * The source mesh of the instance
  19230. */
  19231. readonly sourceMesh: Mesh;
  19232. /**
  19233. * Is this node ready to be used/rendered
  19234. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19235. * @return {boolean} is it ready
  19236. */
  19237. isReady(completeCheck?: boolean): boolean;
  19238. /**
  19239. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19240. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19241. * @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.
  19242. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19243. */
  19244. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19245. /**
  19246. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19247. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19248. * The `data` are either a numeric array either a Float32Array.
  19249. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19250. * 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).
  19251. * Note that a new underlying VertexBuffer object is created each call.
  19252. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19253. *
  19254. * Possible `kind` values :
  19255. * - VertexBuffer.PositionKind
  19256. * - VertexBuffer.UVKind
  19257. * - VertexBuffer.UV2Kind
  19258. * - VertexBuffer.UV3Kind
  19259. * - VertexBuffer.UV4Kind
  19260. * - VertexBuffer.UV5Kind
  19261. * - VertexBuffer.UV6Kind
  19262. * - VertexBuffer.ColorKind
  19263. * - VertexBuffer.MatricesIndicesKind
  19264. * - VertexBuffer.MatricesIndicesExtraKind
  19265. * - VertexBuffer.MatricesWeightsKind
  19266. * - VertexBuffer.MatricesWeightsExtraKind
  19267. *
  19268. * Returns the Mesh.
  19269. */
  19270. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19271. /**
  19272. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19273. * If the mesh has no geometry, it is simply returned as it is.
  19274. * The `data` are either a numeric array either a Float32Array.
  19275. * No new underlying VertexBuffer object is created.
  19276. * 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.
  19277. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19278. *
  19279. * Possible `kind` values :
  19280. * - VertexBuffer.PositionKind
  19281. * - VertexBuffer.UVKind
  19282. * - VertexBuffer.UV2Kind
  19283. * - VertexBuffer.UV3Kind
  19284. * - VertexBuffer.UV4Kind
  19285. * - VertexBuffer.UV5Kind
  19286. * - VertexBuffer.UV6Kind
  19287. * - VertexBuffer.ColorKind
  19288. * - VertexBuffer.MatricesIndicesKind
  19289. * - VertexBuffer.MatricesIndicesExtraKind
  19290. * - VertexBuffer.MatricesWeightsKind
  19291. * - VertexBuffer.MatricesWeightsExtraKind
  19292. *
  19293. * Returns the Mesh.
  19294. */
  19295. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19296. /**
  19297. * Sets the mesh indices.
  19298. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19299. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19300. * This method creates a new index buffer each call.
  19301. * Returns the Mesh.
  19302. */
  19303. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19304. /**
  19305. * Boolean : True if the mesh owns the requested kind of data.
  19306. */
  19307. isVerticesDataPresent(kind: string): boolean;
  19308. /**
  19309. * Returns an array of indices (IndicesArray).
  19310. */
  19311. getIndices(): Nullable<IndicesArray>;
  19312. readonly _positions: Nullable<Vector3[]>;
  19313. /**
  19314. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19315. * This means the mesh underlying bounding box and sphere are recomputed.
  19316. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19317. * @returns the current mesh
  19318. */
  19319. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19320. /** @hidden */
  19321. _preActivate(): InstancedMesh;
  19322. /** @hidden */
  19323. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19324. /** @hidden */
  19325. _postActivate(): void;
  19326. getWorldMatrix(): Matrix;
  19327. readonly isAnInstance: boolean;
  19328. /**
  19329. * Returns the current associated LOD AbstractMesh.
  19330. */
  19331. getLOD(camera: Camera): AbstractMesh;
  19332. /** @hidden */
  19333. _syncSubMeshes(): InstancedMesh;
  19334. /** @hidden */
  19335. _generatePointsArray(): boolean;
  19336. /**
  19337. * Creates a new InstancedMesh from the current mesh.
  19338. * - name (string) : the cloned mesh name
  19339. * - newParent (optional Node) : the optional Node to parent the clone to.
  19340. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19341. *
  19342. * Returns the clone.
  19343. */
  19344. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19345. /**
  19346. * Disposes the InstancedMesh.
  19347. * Returns nothing.
  19348. */
  19349. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19350. }
  19351. }
  19352. declare module "babylonjs/Materials/shaderMaterial" {
  19353. import { Scene } from "babylonjs/scene";
  19354. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19355. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19356. import { Mesh } from "babylonjs/Meshes/mesh";
  19357. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19358. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19359. import { Texture } from "babylonjs/Materials/Textures/texture";
  19360. import { Material } from "babylonjs/Materials/material";
  19361. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19362. /**
  19363. * Defines the options associated with the creation of a shader material.
  19364. */
  19365. export interface IShaderMaterialOptions {
  19366. /**
  19367. * Does the material work in alpha blend mode
  19368. */
  19369. needAlphaBlending: boolean;
  19370. /**
  19371. * Does the material work in alpha test mode
  19372. */
  19373. needAlphaTesting: boolean;
  19374. /**
  19375. * The list of attribute names used in the shader
  19376. */
  19377. attributes: string[];
  19378. /**
  19379. * The list of unifrom names used in the shader
  19380. */
  19381. uniforms: string[];
  19382. /**
  19383. * The list of UBO names used in the shader
  19384. */
  19385. uniformBuffers: string[];
  19386. /**
  19387. * The list of sampler names used in the shader
  19388. */
  19389. samplers: string[];
  19390. /**
  19391. * The list of defines used in the shader
  19392. */
  19393. defines: string[];
  19394. }
  19395. /**
  19396. * 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.
  19397. *
  19398. * This returned material effects how the mesh will look based on the code in the shaders.
  19399. *
  19400. * @see http://doc.babylonjs.com/how_to/shader_material
  19401. */
  19402. export class ShaderMaterial extends Material {
  19403. private _shaderPath;
  19404. private _options;
  19405. private _textures;
  19406. private _textureArrays;
  19407. private _floats;
  19408. private _ints;
  19409. private _floatsArrays;
  19410. private _colors3;
  19411. private _colors3Arrays;
  19412. private _colors4;
  19413. private _colors4Arrays;
  19414. private _vectors2;
  19415. private _vectors3;
  19416. private _vectors4;
  19417. private _matrices;
  19418. private _matrices3x3;
  19419. private _matrices2x2;
  19420. private _vectors2Arrays;
  19421. private _vectors3Arrays;
  19422. private _vectors4Arrays;
  19423. private _cachedWorldViewMatrix;
  19424. private _cachedWorldViewProjectionMatrix;
  19425. private _renderId;
  19426. /**
  19427. * Instantiate a new shader material.
  19428. * 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.
  19429. * This returned material effects how the mesh will look based on the code in the shaders.
  19430. * @see http://doc.babylonjs.com/how_to/shader_material
  19431. * @param name Define the name of the material in the scene
  19432. * @param scene Define the scene the material belongs to
  19433. * @param shaderPath Defines the route to the shader code in one of three ways:
  19434. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19435. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19436. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19437. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19438. * @param options Define the options used to create the shader
  19439. */
  19440. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19441. /**
  19442. * Gets the options used to compile the shader.
  19443. * They can be modified to trigger a new compilation
  19444. */
  19445. readonly options: IShaderMaterialOptions;
  19446. /**
  19447. * Gets the current class name of the material e.g. "ShaderMaterial"
  19448. * Mainly use in serialization.
  19449. * @returns the class name
  19450. */
  19451. getClassName(): string;
  19452. /**
  19453. * Specifies if the material will require alpha blending
  19454. * @returns a boolean specifying if alpha blending is needed
  19455. */
  19456. needAlphaBlending(): boolean;
  19457. /**
  19458. * Specifies if this material should be rendered in alpha test mode
  19459. * @returns a boolean specifying if an alpha test is needed.
  19460. */
  19461. needAlphaTesting(): boolean;
  19462. private _checkUniform;
  19463. /**
  19464. * Set a texture in the shader.
  19465. * @param name Define the name of the uniform samplers as defined in the shader
  19466. * @param texture Define the texture to bind to this sampler
  19467. * @return the material itself allowing "fluent" like uniform updates
  19468. */
  19469. setTexture(name: string, texture: Texture): ShaderMaterial;
  19470. /**
  19471. * Set a texture array in the shader.
  19472. * @param name Define the name of the uniform sampler array as defined in the shader
  19473. * @param textures Define the list of textures to bind to this sampler
  19474. * @return the material itself allowing "fluent" like uniform updates
  19475. */
  19476. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19477. /**
  19478. * Set a float in the shader.
  19479. * @param name Define the name of the uniform as defined in the shader
  19480. * @param value Define the value to give to the uniform
  19481. * @return the material itself allowing "fluent" like uniform updates
  19482. */
  19483. setFloat(name: string, value: number): ShaderMaterial;
  19484. /**
  19485. * Set a int in the shader.
  19486. * @param name Define the name of the uniform as defined in the shader
  19487. * @param value Define the value to give to the uniform
  19488. * @return the material itself allowing "fluent" like uniform updates
  19489. */
  19490. setInt(name: string, value: number): ShaderMaterial;
  19491. /**
  19492. * Set an array of floats in the shader.
  19493. * @param name Define the name of the uniform as defined in the shader
  19494. * @param value Define the value to give to the uniform
  19495. * @return the material itself allowing "fluent" like uniform updates
  19496. */
  19497. setFloats(name: string, value: number[]): ShaderMaterial;
  19498. /**
  19499. * Set a vec3 in the shader from a Color3.
  19500. * @param name Define the name of the uniform as defined in the shader
  19501. * @param value Define the value to give to the uniform
  19502. * @return the material itself allowing "fluent" like uniform updates
  19503. */
  19504. setColor3(name: string, value: Color3): ShaderMaterial;
  19505. /**
  19506. * Set a vec3 array in the shader from a Color3 array.
  19507. * @param name Define the name of the uniform as defined in the shader
  19508. * @param value Define the value to give to the uniform
  19509. * @return the material itself allowing "fluent" like uniform updates
  19510. */
  19511. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19512. /**
  19513. * Set a vec4 in the shader from a Color4.
  19514. * @param name Define the name of the uniform as defined in the shader
  19515. * @param value Define the value to give to the uniform
  19516. * @return the material itself allowing "fluent" like uniform updates
  19517. */
  19518. setColor4(name: string, value: Color4): ShaderMaterial;
  19519. /**
  19520. * Set a vec4 array in the shader from a Color4 array.
  19521. * @param name Define the name of the uniform as defined in the shader
  19522. * @param value Define the value to give to the uniform
  19523. * @return the material itself allowing "fluent" like uniform updates
  19524. */
  19525. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19526. /**
  19527. * Set a vec2 in the shader from a Vector2.
  19528. * @param name Define the name of the uniform as defined in the shader
  19529. * @param value Define the value to give to the uniform
  19530. * @return the material itself allowing "fluent" like uniform updates
  19531. */
  19532. setVector2(name: string, value: Vector2): ShaderMaterial;
  19533. /**
  19534. * Set a vec3 in the shader from a Vector3.
  19535. * @param name Define the name of the uniform as defined in the shader
  19536. * @param value Define the value to give to the uniform
  19537. * @return the material itself allowing "fluent" like uniform updates
  19538. */
  19539. setVector3(name: string, value: Vector3): ShaderMaterial;
  19540. /**
  19541. * Set a vec4 in the shader from a Vector4.
  19542. * @param name Define the name of the uniform as defined in the shader
  19543. * @param value Define the value to give to the uniform
  19544. * @return the material itself allowing "fluent" like uniform updates
  19545. */
  19546. setVector4(name: string, value: Vector4): ShaderMaterial;
  19547. /**
  19548. * Set a mat4 in the shader from a Matrix.
  19549. * @param name Define the name of the uniform as defined in the shader
  19550. * @param value Define the value to give to the uniform
  19551. * @return the material itself allowing "fluent" like uniform updates
  19552. */
  19553. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19554. /**
  19555. * Set a mat3 in the shader from a Float32Array.
  19556. * @param name Define the name of the uniform as defined in the shader
  19557. * @param value Define the value to give to the uniform
  19558. * @return the material itself allowing "fluent" like uniform updates
  19559. */
  19560. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19561. /**
  19562. * Set a mat2 in the shader from a Float32Array.
  19563. * @param name Define the name of the uniform as defined in the shader
  19564. * @param value Define the value to give to the uniform
  19565. * @return the material itself allowing "fluent" like uniform updates
  19566. */
  19567. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19568. /**
  19569. * Set a vec2 array in the shader from a number array.
  19570. * @param name Define the name of the uniform as defined in the shader
  19571. * @param value Define the value to give to the uniform
  19572. * @return the material itself allowing "fluent" like uniform updates
  19573. */
  19574. setArray2(name: string, value: number[]): ShaderMaterial;
  19575. /**
  19576. * Set a vec3 array in the shader from a number array.
  19577. * @param name Define the name of the uniform as defined in the shader
  19578. * @param value Define the value to give to the uniform
  19579. * @return the material itself allowing "fluent" like uniform updates
  19580. */
  19581. setArray3(name: string, value: number[]): ShaderMaterial;
  19582. /**
  19583. * Set a vec4 array in the shader from a number array.
  19584. * @param name Define the name of the uniform as defined in the shader
  19585. * @param value Define the value to give to the uniform
  19586. * @return the material itself allowing "fluent" like uniform updates
  19587. */
  19588. setArray4(name: string, value: number[]): ShaderMaterial;
  19589. private _checkCache;
  19590. /**
  19591. * Specifies that the submesh is ready to be used
  19592. * @param mesh defines the mesh to check
  19593. * @param subMesh defines which submesh to check
  19594. * @param useInstances specifies that instances should be used
  19595. * @returns a boolean indicating that the submesh is ready or not
  19596. */
  19597. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19598. /**
  19599. * Checks if the material is ready to render the requested mesh
  19600. * @param mesh Define the mesh to render
  19601. * @param useInstances Define whether or not the material is used with instances
  19602. * @returns true if ready, otherwise false
  19603. */
  19604. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19605. /**
  19606. * Binds the world matrix to the material
  19607. * @param world defines the world transformation matrix
  19608. */
  19609. bindOnlyWorldMatrix(world: Matrix): void;
  19610. /**
  19611. * Binds the material to the mesh
  19612. * @param world defines the world transformation matrix
  19613. * @param mesh defines the mesh to bind the material to
  19614. */
  19615. bind(world: Matrix, mesh?: Mesh): void;
  19616. /**
  19617. * Gets the active textures from the material
  19618. * @returns an array of textures
  19619. */
  19620. getActiveTextures(): BaseTexture[];
  19621. /**
  19622. * Specifies if the material uses a texture
  19623. * @param texture defines the texture to check against the material
  19624. * @returns a boolean specifying if the material uses the texture
  19625. */
  19626. hasTexture(texture: BaseTexture): boolean;
  19627. /**
  19628. * Makes a duplicate of the material, and gives it a new name
  19629. * @param name defines the new name for the duplicated material
  19630. * @returns the cloned material
  19631. */
  19632. clone(name: string): ShaderMaterial;
  19633. /**
  19634. * Disposes the material
  19635. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19636. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19637. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19638. */
  19639. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19640. /**
  19641. * Serializes this material in a JSON representation
  19642. * @returns the serialized material object
  19643. */
  19644. serialize(): any;
  19645. /**
  19646. * Creates a shader material from parsed shader material data
  19647. * @param source defines the JSON represnetation of the material
  19648. * @param scene defines the hosting scene
  19649. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19650. * @returns a new material
  19651. */
  19652. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19653. }
  19654. }
  19655. declare module "babylonjs/Shaders/color.fragment" {
  19656. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19657. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19658. /** @hidden */
  19659. export var colorPixelShader: {
  19660. name: string;
  19661. shader: string;
  19662. };
  19663. }
  19664. declare module "babylonjs/Shaders/color.vertex" {
  19665. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19666. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19667. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19668. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19669. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19670. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19671. /** @hidden */
  19672. export var colorVertexShader: {
  19673. name: string;
  19674. shader: string;
  19675. };
  19676. }
  19677. declare module "babylonjs/Meshes/linesMesh" {
  19678. import { Nullable } from "babylonjs/types";
  19679. import { Scene } from "babylonjs/scene";
  19680. import { Color3 } from "babylonjs/Maths/math.color";
  19681. import { Node } from "babylonjs/node";
  19682. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19683. import { Mesh } from "babylonjs/Meshes/mesh";
  19684. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19685. import { Effect } from "babylonjs/Materials/effect";
  19686. import { Material } from "babylonjs/Materials/material";
  19687. import "babylonjs/Shaders/color.fragment";
  19688. import "babylonjs/Shaders/color.vertex";
  19689. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19690. /**
  19691. * Line mesh
  19692. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19693. */
  19694. export class LinesMesh extends Mesh {
  19695. /**
  19696. * If vertex color should be applied to the mesh
  19697. */
  19698. readonly useVertexColor?: boolean | undefined;
  19699. /**
  19700. * If vertex alpha should be applied to the mesh
  19701. */
  19702. readonly useVertexAlpha?: boolean | undefined;
  19703. /**
  19704. * Color of the line (Default: White)
  19705. */
  19706. color: Color3;
  19707. /**
  19708. * Alpha of the line (Default: 1)
  19709. */
  19710. alpha: number;
  19711. /**
  19712. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19713. * This margin is expressed in world space coordinates, so its value may vary.
  19714. * Default value is 0.1
  19715. */
  19716. intersectionThreshold: number;
  19717. private _colorShader;
  19718. private color4;
  19719. /**
  19720. * Creates a new LinesMesh
  19721. * @param name defines the name
  19722. * @param scene defines the hosting scene
  19723. * @param parent defines the parent mesh if any
  19724. * @param source defines the optional source LinesMesh used to clone data from
  19725. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19726. * When false, achieved by calling a clone(), also passing False.
  19727. * This will make creation of children, recursive.
  19728. * @param useVertexColor defines if this LinesMesh supports vertex color
  19729. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19730. */
  19731. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19732. /**
  19733. * If vertex color should be applied to the mesh
  19734. */
  19735. useVertexColor?: boolean | undefined,
  19736. /**
  19737. * If vertex alpha should be applied to the mesh
  19738. */
  19739. useVertexAlpha?: boolean | undefined);
  19740. private _addClipPlaneDefine;
  19741. private _removeClipPlaneDefine;
  19742. isReady(): boolean;
  19743. /**
  19744. * Returns the string "LineMesh"
  19745. */
  19746. getClassName(): string;
  19747. /**
  19748. * @hidden
  19749. */
  19750. /**
  19751. * @hidden
  19752. */
  19753. material: Material;
  19754. /**
  19755. * @hidden
  19756. */
  19757. readonly checkCollisions: boolean;
  19758. /** @hidden */
  19759. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19760. /** @hidden */
  19761. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19762. /**
  19763. * Disposes of the line mesh
  19764. * @param doNotRecurse If children should be disposed
  19765. */
  19766. dispose(doNotRecurse?: boolean): void;
  19767. /**
  19768. * Returns a new LineMesh object cloned from the current one.
  19769. */
  19770. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19771. /**
  19772. * Creates a new InstancedLinesMesh object from the mesh model.
  19773. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19774. * @param name defines the name of the new instance
  19775. * @returns a new InstancedLinesMesh
  19776. */
  19777. createInstance(name: string): InstancedLinesMesh;
  19778. }
  19779. /**
  19780. * Creates an instance based on a source LinesMesh
  19781. */
  19782. export class InstancedLinesMesh extends InstancedMesh {
  19783. /**
  19784. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19785. * This margin is expressed in world space coordinates, so its value may vary.
  19786. * Initilized with the intersectionThreshold value of the source LinesMesh
  19787. */
  19788. intersectionThreshold: number;
  19789. constructor(name: string, source: LinesMesh);
  19790. /**
  19791. * Returns the string "InstancedLinesMesh".
  19792. */
  19793. getClassName(): string;
  19794. }
  19795. }
  19796. declare module "babylonjs/Shaders/line.fragment" {
  19797. /** @hidden */
  19798. export var linePixelShader: {
  19799. name: string;
  19800. shader: string;
  19801. };
  19802. }
  19803. declare module "babylonjs/Shaders/line.vertex" {
  19804. /** @hidden */
  19805. export var lineVertexShader: {
  19806. name: string;
  19807. shader: string;
  19808. };
  19809. }
  19810. declare module "babylonjs/Rendering/edgesRenderer" {
  19811. import { Nullable } from "babylonjs/types";
  19812. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19813. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19814. import { Vector3 } from "babylonjs/Maths/math.vector";
  19815. import { IDisposable } from "babylonjs/scene";
  19816. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  19817. import "babylonjs/Shaders/line.fragment";
  19818. import "babylonjs/Shaders/line.vertex";
  19819. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  19820. module "babylonjs/Meshes/abstractMesh" {
  19821. interface AbstractMesh {
  19822. /**
  19823. * Gets the edgesRenderer associated with the mesh
  19824. */
  19825. edgesRenderer: Nullable<EdgesRenderer>;
  19826. }
  19827. }
  19828. module "babylonjs/Meshes/linesMesh" {
  19829. interface LinesMesh {
  19830. /**
  19831. * Enables the edge rendering mode on the mesh.
  19832. * This mode makes the mesh edges visible
  19833. * @param epsilon defines the maximal distance between two angles to detect a face
  19834. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19835. * @returns the currentAbstractMesh
  19836. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19837. */
  19838. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19839. }
  19840. }
  19841. module "babylonjs/Meshes/linesMesh" {
  19842. interface InstancedLinesMesh {
  19843. /**
  19844. * Enables the edge rendering mode on the mesh.
  19845. * This mode makes the mesh edges visible
  19846. * @param epsilon defines the maximal distance between two angles to detect a face
  19847. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19848. * @returns the current InstancedLinesMesh
  19849. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19850. */
  19851. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19852. }
  19853. }
  19854. /**
  19855. * Defines the minimum contract an Edges renderer should follow.
  19856. */
  19857. export interface IEdgesRenderer extends IDisposable {
  19858. /**
  19859. * Gets or sets a boolean indicating if the edgesRenderer is active
  19860. */
  19861. isEnabled: boolean;
  19862. /**
  19863. * Renders the edges of the attached mesh,
  19864. */
  19865. render(): void;
  19866. /**
  19867. * Checks wether or not the edges renderer is ready to render.
  19868. * @return true if ready, otherwise false.
  19869. */
  19870. isReady(): boolean;
  19871. }
  19872. /**
  19873. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19874. */
  19875. export class EdgesRenderer implements IEdgesRenderer {
  19876. /**
  19877. * Define the size of the edges with an orthographic camera
  19878. */
  19879. edgesWidthScalerForOrthographic: number;
  19880. /**
  19881. * Define the size of the edges with a perspective camera
  19882. */
  19883. edgesWidthScalerForPerspective: number;
  19884. protected _source: AbstractMesh;
  19885. protected _linesPositions: number[];
  19886. protected _linesNormals: number[];
  19887. protected _linesIndices: number[];
  19888. protected _epsilon: number;
  19889. protected _indicesCount: number;
  19890. protected _lineShader: ShaderMaterial;
  19891. protected _ib: DataBuffer;
  19892. protected _buffers: {
  19893. [key: string]: Nullable<VertexBuffer>;
  19894. };
  19895. protected _checkVerticesInsteadOfIndices: boolean;
  19896. private _meshRebuildObserver;
  19897. private _meshDisposeObserver;
  19898. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19899. isEnabled: boolean;
  19900. /**
  19901. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19902. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19903. * @param source Mesh used to create edges
  19904. * @param epsilon sum of angles in adjacency to check for edge
  19905. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19906. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19907. */
  19908. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19909. protected _prepareRessources(): void;
  19910. /** @hidden */
  19911. _rebuild(): void;
  19912. /**
  19913. * Releases the required resources for the edges renderer
  19914. */
  19915. dispose(): void;
  19916. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19917. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19918. /**
  19919. * Checks if the pair of p0 and p1 is en edge
  19920. * @param faceIndex
  19921. * @param edge
  19922. * @param faceNormals
  19923. * @param p0
  19924. * @param p1
  19925. * @private
  19926. */
  19927. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19928. /**
  19929. * push line into the position, normal and index buffer
  19930. * @protected
  19931. */
  19932. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19933. /**
  19934. * Generates lines edges from adjacencjes
  19935. * @private
  19936. */
  19937. _generateEdgesLines(): void;
  19938. /**
  19939. * Checks wether or not the edges renderer is ready to render.
  19940. * @return true if ready, otherwise false.
  19941. */
  19942. isReady(): boolean;
  19943. /**
  19944. * Renders the edges of the attached mesh,
  19945. */
  19946. render(): void;
  19947. }
  19948. /**
  19949. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19950. */
  19951. export class LineEdgesRenderer extends EdgesRenderer {
  19952. /**
  19953. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19954. * @param source LineMesh used to generate edges
  19955. * @param epsilon not important (specified angle for edge detection)
  19956. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19957. */
  19958. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19959. /**
  19960. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19961. */
  19962. _generateEdgesLines(): void;
  19963. }
  19964. }
  19965. declare module "babylonjs/Rendering/renderingGroup" {
  19966. import { SmartArray } from "babylonjs/Misc/smartArray";
  19967. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19968. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19969. import { Nullable } from "babylonjs/types";
  19970. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  19971. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  19972. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  19973. import { Material } from "babylonjs/Materials/material";
  19974. import { Scene } from "babylonjs/scene";
  19975. /**
  19976. * This represents the object necessary to create a rendering group.
  19977. * This is exclusively used and created by the rendering manager.
  19978. * To modify the behavior, you use the available helpers in your scene or meshes.
  19979. * @hidden
  19980. */
  19981. export class RenderingGroup {
  19982. index: number;
  19983. private static _zeroVector;
  19984. private _scene;
  19985. private _opaqueSubMeshes;
  19986. private _transparentSubMeshes;
  19987. private _alphaTestSubMeshes;
  19988. private _depthOnlySubMeshes;
  19989. private _particleSystems;
  19990. private _spriteManagers;
  19991. private _opaqueSortCompareFn;
  19992. private _alphaTestSortCompareFn;
  19993. private _transparentSortCompareFn;
  19994. private _renderOpaque;
  19995. private _renderAlphaTest;
  19996. private _renderTransparent;
  19997. /** @hidden */
  19998. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19999. onBeforeTransparentRendering: () => void;
  20000. /**
  20001. * Set the opaque sort comparison function.
  20002. * If null the sub meshes will be render in the order they were created
  20003. */
  20004. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20005. /**
  20006. * Set the alpha test sort comparison function.
  20007. * If null the sub meshes will be render in the order they were created
  20008. */
  20009. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20010. /**
  20011. * Set the transparent sort comparison function.
  20012. * If null the sub meshes will be render in the order they were created
  20013. */
  20014. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20015. /**
  20016. * Creates a new rendering group.
  20017. * @param index The rendering group index
  20018. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20019. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20020. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20021. */
  20022. 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>);
  20023. /**
  20024. * Render all the sub meshes contained in the group.
  20025. * @param customRenderFunction Used to override the default render behaviour of the group.
  20026. * @returns true if rendered some submeshes.
  20027. */
  20028. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20029. /**
  20030. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20031. * @param subMeshes The submeshes to render
  20032. */
  20033. private renderOpaqueSorted;
  20034. /**
  20035. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20036. * @param subMeshes The submeshes to render
  20037. */
  20038. private renderAlphaTestSorted;
  20039. /**
  20040. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20041. * @param subMeshes The submeshes to render
  20042. */
  20043. private renderTransparentSorted;
  20044. /**
  20045. * Renders the submeshes in a specified order.
  20046. * @param subMeshes The submeshes to sort before render
  20047. * @param sortCompareFn The comparison function use to sort
  20048. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20049. * @param transparent Specifies to activate blending if true
  20050. */
  20051. private static renderSorted;
  20052. /**
  20053. * Renders the submeshes in the order they were dispatched (no sort applied).
  20054. * @param subMeshes The submeshes to render
  20055. */
  20056. private static renderUnsorted;
  20057. /**
  20058. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20059. * are rendered back to front if in the same alpha index.
  20060. *
  20061. * @param a The first submesh
  20062. * @param b The second submesh
  20063. * @returns The result of the comparison
  20064. */
  20065. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20066. /**
  20067. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20068. * are rendered back to front.
  20069. *
  20070. * @param a The first submesh
  20071. * @param b The second submesh
  20072. * @returns The result of the comparison
  20073. */
  20074. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20075. /**
  20076. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20077. * are rendered front to back (prevent overdraw).
  20078. *
  20079. * @param a The first submesh
  20080. * @param b The second submesh
  20081. * @returns The result of the comparison
  20082. */
  20083. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20084. /**
  20085. * Resets the different lists of submeshes to prepare a new frame.
  20086. */
  20087. prepare(): void;
  20088. dispose(): void;
  20089. /**
  20090. * Inserts the submesh in its correct queue depending on its material.
  20091. * @param subMesh The submesh to dispatch
  20092. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20093. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20094. */
  20095. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20096. dispatchSprites(spriteManager: ISpriteManager): void;
  20097. dispatchParticles(particleSystem: IParticleSystem): void;
  20098. private _renderParticles;
  20099. private _renderSprites;
  20100. }
  20101. }
  20102. declare module "babylonjs/Rendering/renderingManager" {
  20103. import { Nullable } from "babylonjs/types";
  20104. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20105. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20106. import { SmartArray } from "babylonjs/Misc/smartArray";
  20107. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20108. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20109. import { Material } from "babylonjs/Materials/material";
  20110. import { Scene } from "babylonjs/scene";
  20111. import { Camera } from "babylonjs/Cameras/camera";
  20112. /**
  20113. * Interface describing the different options available in the rendering manager
  20114. * regarding Auto Clear between groups.
  20115. */
  20116. export interface IRenderingManagerAutoClearSetup {
  20117. /**
  20118. * Defines whether or not autoclear is enable.
  20119. */
  20120. autoClear: boolean;
  20121. /**
  20122. * Defines whether or not to autoclear the depth buffer.
  20123. */
  20124. depth: boolean;
  20125. /**
  20126. * Defines whether or not to autoclear the stencil buffer.
  20127. */
  20128. stencil: boolean;
  20129. }
  20130. /**
  20131. * This class is used by the onRenderingGroupObservable
  20132. */
  20133. export class RenderingGroupInfo {
  20134. /**
  20135. * The Scene that being rendered
  20136. */
  20137. scene: Scene;
  20138. /**
  20139. * The camera currently used for the rendering pass
  20140. */
  20141. camera: Nullable<Camera>;
  20142. /**
  20143. * The ID of the renderingGroup being processed
  20144. */
  20145. renderingGroupId: number;
  20146. }
  20147. /**
  20148. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20149. * It is enable to manage the different groups as well as the different necessary sort functions.
  20150. * This should not be used directly aside of the few static configurations
  20151. */
  20152. export class RenderingManager {
  20153. /**
  20154. * The max id used for rendering groups (not included)
  20155. */
  20156. static MAX_RENDERINGGROUPS: number;
  20157. /**
  20158. * The min id used for rendering groups (included)
  20159. */
  20160. static MIN_RENDERINGGROUPS: number;
  20161. /**
  20162. * Used to globally prevent autoclearing scenes.
  20163. */
  20164. static AUTOCLEAR: boolean;
  20165. /**
  20166. * @hidden
  20167. */
  20168. _useSceneAutoClearSetup: boolean;
  20169. private _scene;
  20170. private _renderingGroups;
  20171. private _depthStencilBufferAlreadyCleaned;
  20172. private _autoClearDepthStencil;
  20173. private _customOpaqueSortCompareFn;
  20174. private _customAlphaTestSortCompareFn;
  20175. private _customTransparentSortCompareFn;
  20176. private _renderingGroupInfo;
  20177. /**
  20178. * Instantiates a new rendering group for a particular scene
  20179. * @param scene Defines the scene the groups belongs to
  20180. */
  20181. constructor(scene: Scene);
  20182. private _clearDepthStencilBuffer;
  20183. /**
  20184. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20185. * @hidden
  20186. */
  20187. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20188. /**
  20189. * Resets the different information of the group to prepare a new frame
  20190. * @hidden
  20191. */
  20192. reset(): void;
  20193. /**
  20194. * Dispose and release the group and its associated resources.
  20195. * @hidden
  20196. */
  20197. dispose(): void;
  20198. /**
  20199. * Clear the info related to rendering groups preventing retention points during dispose.
  20200. */
  20201. freeRenderingGroups(): void;
  20202. private _prepareRenderingGroup;
  20203. /**
  20204. * Add a sprite manager to the rendering manager in order to render it this frame.
  20205. * @param spriteManager Define the sprite manager to render
  20206. */
  20207. dispatchSprites(spriteManager: ISpriteManager): void;
  20208. /**
  20209. * Add a particle system to the rendering manager in order to render it this frame.
  20210. * @param particleSystem Define the particle system to render
  20211. */
  20212. dispatchParticles(particleSystem: IParticleSystem): void;
  20213. /**
  20214. * Add a submesh to the manager in order to render it this frame
  20215. * @param subMesh The submesh to dispatch
  20216. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20217. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20218. */
  20219. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20220. /**
  20221. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20222. * This allowed control for front to back rendering or reversly depending of the special needs.
  20223. *
  20224. * @param renderingGroupId The rendering group id corresponding to its index
  20225. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20226. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20227. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20228. */
  20229. 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;
  20230. /**
  20231. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20232. *
  20233. * @param renderingGroupId The rendering group id corresponding to its index
  20234. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20235. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20236. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20237. */
  20238. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20239. /**
  20240. * Gets the current auto clear configuration for one rendering group of the rendering
  20241. * manager.
  20242. * @param index the rendering group index to get the information for
  20243. * @returns The auto clear setup for the requested rendering group
  20244. */
  20245. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20246. }
  20247. }
  20248. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20249. import { Observable } from "babylonjs/Misc/observable";
  20250. import { SmartArray } from "babylonjs/Misc/smartArray";
  20251. import { Nullable } from "babylonjs/types";
  20252. import { Camera } from "babylonjs/Cameras/camera";
  20253. import { Scene } from "babylonjs/scene";
  20254. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20255. import { Color4 } from "babylonjs/Maths/math.color";
  20256. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20257. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20258. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20259. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20260. import { Texture } from "babylonjs/Materials/Textures/texture";
  20261. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20262. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20263. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20264. import { Engine } from "babylonjs/Engines/engine";
  20265. /**
  20266. * This Helps creating a texture that will be created from a camera in your scene.
  20267. * It is basically a dynamic texture that could be used to create special effects for instance.
  20268. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20269. */
  20270. export class RenderTargetTexture extends Texture {
  20271. isCube: boolean;
  20272. /**
  20273. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20274. */
  20275. static readonly REFRESHRATE_RENDER_ONCE: number;
  20276. /**
  20277. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20278. */
  20279. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20280. /**
  20281. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20282. * the central point of your effect and can save a lot of performances.
  20283. */
  20284. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20285. /**
  20286. * Use this predicate to dynamically define the list of mesh you want to render.
  20287. * If set, the renderList property will be overwritten.
  20288. */
  20289. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20290. private _renderList;
  20291. /**
  20292. * Use this list to define the list of mesh you want to render.
  20293. */
  20294. renderList: Nullable<Array<AbstractMesh>>;
  20295. private _hookArray;
  20296. /**
  20297. * Define if particles should be rendered in your texture.
  20298. */
  20299. renderParticles: boolean;
  20300. /**
  20301. * Define if sprites should be rendered in your texture.
  20302. */
  20303. renderSprites: boolean;
  20304. /**
  20305. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20306. */
  20307. coordinatesMode: number;
  20308. /**
  20309. * Define the camera used to render the texture.
  20310. */
  20311. activeCamera: Nullable<Camera>;
  20312. /**
  20313. * Override the render function of the texture with your own one.
  20314. */
  20315. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20316. /**
  20317. * Define if camera post processes should be use while rendering the texture.
  20318. */
  20319. useCameraPostProcesses: boolean;
  20320. /**
  20321. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20322. */
  20323. ignoreCameraViewport: boolean;
  20324. private _postProcessManager;
  20325. private _postProcesses;
  20326. private _resizeObserver;
  20327. /**
  20328. * An event triggered when the texture is unbind.
  20329. */
  20330. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20331. /**
  20332. * An event triggered when the texture is unbind.
  20333. */
  20334. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20335. private _onAfterUnbindObserver;
  20336. /**
  20337. * Set a after unbind callback in the texture.
  20338. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20339. */
  20340. onAfterUnbind: () => void;
  20341. /**
  20342. * An event triggered before rendering the texture
  20343. */
  20344. onBeforeRenderObservable: Observable<number>;
  20345. private _onBeforeRenderObserver;
  20346. /**
  20347. * Set a before render callback in the texture.
  20348. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20349. */
  20350. onBeforeRender: (faceIndex: number) => void;
  20351. /**
  20352. * An event triggered after rendering the texture
  20353. */
  20354. onAfterRenderObservable: Observable<number>;
  20355. private _onAfterRenderObserver;
  20356. /**
  20357. * Set a after render callback in the texture.
  20358. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20359. */
  20360. onAfterRender: (faceIndex: number) => void;
  20361. /**
  20362. * An event triggered after the texture clear
  20363. */
  20364. onClearObservable: Observable<Engine>;
  20365. private _onClearObserver;
  20366. /**
  20367. * Set a clear callback in the texture.
  20368. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20369. */
  20370. onClear: (Engine: Engine) => void;
  20371. /**
  20372. * An event triggered when the texture is resized.
  20373. */
  20374. onResizeObservable: Observable<RenderTargetTexture>;
  20375. /**
  20376. * Define the clear color of the Render Target if it should be different from the scene.
  20377. */
  20378. clearColor: Color4;
  20379. protected _size: number | {
  20380. width: number;
  20381. height: number;
  20382. };
  20383. protected _initialSizeParameter: number | {
  20384. width: number;
  20385. height: number;
  20386. } | {
  20387. ratio: number;
  20388. };
  20389. protected _sizeRatio: Nullable<number>;
  20390. /** @hidden */
  20391. _generateMipMaps: boolean;
  20392. protected _renderingManager: RenderingManager;
  20393. /** @hidden */
  20394. _waitingRenderList: string[];
  20395. protected _doNotChangeAspectRatio: boolean;
  20396. protected _currentRefreshId: number;
  20397. protected _refreshRate: number;
  20398. protected _textureMatrix: Matrix;
  20399. protected _samples: number;
  20400. protected _renderTargetOptions: RenderTargetCreationOptions;
  20401. /**
  20402. * Gets render target creation options that were used.
  20403. */
  20404. readonly renderTargetOptions: RenderTargetCreationOptions;
  20405. protected _engine: Engine;
  20406. protected _onRatioRescale(): void;
  20407. /**
  20408. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20409. * It must define where the camera used to render the texture is set
  20410. */
  20411. boundingBoxPosition: Vector3;
  20412. private _boundingBoxSize;
  20413. /**
  20414. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20415. * When defined, the cubemap will switch to local mode
  20416. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20417. * @example https://www.babylonjs-playground.com/#RNASML
  20418. */
  20419. boundingBoxSize: Vector3;
  20420. /**
  20421. * In case the RTT has been created with a depth texture, get the associated
  20422. * depth texture.
  20423. * Otherwise, return null.
  20424. */
  20425. depthStencilTexture: Nullable<InternalTexture>;
  20426. /**
  20427. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20428. * or used a shadow, depth texture...
  20429. * @param name The friendly name of the texture
  20430. * @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)
  20431. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20432. * @param generateMipMaps True if mip maps need to be generated after render.
  20433. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20434. * @param type The type of the buffer in the RTT (int, half float, float...)
  20435. * @param isCube True if a cube texture needs to be created
  20436. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20437. * @param generateDepthBuffer True to generate a depth buffer
  20438. * @param generateStencilBuffer True to generate a stencil buffer
  20439. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20440. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20441. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20442. */
  20443. constructor(name: string, size: number | {
  20444. width: number;
  20445. height: number;
  20446. } | {
  20447. ratio: number;
  20448. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20449. /**
  20450. * Creates a depth stencil texture.
  20451. * This is only available in WebGL 2 or with the depth texture extension available.
  20452. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20453. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20454. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20455. */
  20456. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20457. private _processSizeParameter;
  20458. /**
  20459. * Define the number of samples to use in case of MSAA.
  20460. * It defaults to one meaning no MSAA has been enabled.
  20461. */
  20462. samples: number;
  20463. /**
  20464. * Resets the refresh counter of the texture and start bak from scratch.
  20465. * Could be useful to regenerate the texture if it is setup to render only once.
  20466. */
  20467. resetRefreshCounter(): void;
  20468. /**
  20469. * Define the refresh rate of the texture or the rendering frequency.
  20470. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20471. */
  20472. refreshRate: number;
  20473. /**
  20474. * Adds a post process to the render target rendering passes.
  20475. * @param postProcess define the post process to add
  20476. */
  20477. addPostProcess(postProcess: PostProcess): void;
  20478. /**
  20479. * Clear all the post processes attached to the render target
  20480. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20481. */
  20482. clearPostProcesses(dispose?: boolean): void;
  20483. /**
  20484. * Remove one of the post process from the list of attached post processes to the texture
  20485. * @param postProcess define the post process to remove from the list
  20486. */
  20487. removePostProcess(postProcess: PostProcess): void;
  20488. /** @hidden */
  20489. _shouldRender(): boolean;
  20490. /**
  20491. * Gets the actual render size of the texture.
  20492. * @returns the width of the render size
  20493. */
  20494. getRenderSize(): number;
  20495. /**
  20496. * Gets the actual render width of the texture.
  20497. * @returns the width of the render size
  20498. */
  20499. getRenderWidth(): number;
  20500. /**
  20501. * Gets the actual render height of the texture.
  20502. * @returns the height of the render size
  20503. */
  20504. getRenderHeight(): number;
  20505. /**
  20506. * Get if the texture can be rescaled or not.
  20507. */
  20508. readonly canRescale: boolean;
  20509. /**
  20510. * Resize the texture using a ratio.
  20511. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20512. */
  20513. scale(ratio: number): void;
  20514. /**
  20515. * Get the texture reflection matrix used to rotate/transform the reflection.
  20516. * @returns the reflection matrix
  20517. */
  20518. getReflectionTextureMatrix(): Matrix;
  20519. /**
  20520. * Resize the texture to a new desired size.
  20521. * Be carrefull as it will recreate all the data in the new texture.
  20522. * @param size Define the new size. It can be:
  20523. * - a number for squared texture,
  20524. * - an object containing { width: number, height: number }
  20525. * - or an object containing a ratio { ratio: number }
  20526. */
  20527. resize(size: number | {
  20528. width: number;
  20529. height: number;
  20530. } | {
  20531. ratio: number;
  20532. }): void;
  20533. /**
  20534. * Renders all the objects from the render list into the texture.
  20535. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20536. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20537. */
  20538. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20539. private _bestReflectionRenderTargetDimension;
  20540. /**
  20541. * @hidden
  20542. * @param faceIndex face index to bind to if this is a cubetexture
  20543. */
  20544. _bindFrameBuffer(faceIndex?: number): void;
  20545. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20546. private renderToTarget;
  20547. /**
  20548. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20549. * This allowed control for front to back rendering or reversly depending of the special needs.
  20550. *
  20551. * @param renderingGroupId The rendering group id corresponding to its index
  20552. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20553. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20554. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20555. */
  20556. 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;
  20557. /**
  20558. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20559. *
  20560. * @param renderingGroupId The rendering group id corresponding to its index
  20561. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20562. */
  20563. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20564. /**
  20565. * Clones the texture.
  20566. * @returns the cloned texture
  20567. */
  20568. clone(): RenderTargetTexture;
  20569. /**
  20570. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20571. * @returns The JSON representation of the texture
  20572. */
  20573. serialize(): any;
  20574. /**
  20575. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20576. */
  20577. disposeFramebufferObjects(): void;
  20578. /**
  20579. * Dispose the texture and release its associated resources.
  20580. */
  20581. dispose(): void;
  20582. /** @hidden */
  20583. _rebuild(): void;
  20584. /**
  20585. * Clear the info related to rendering groups preventing retention point in material dispose.
  20586. */
  20587. freeRenderingGroups(): void;
  20588. /**
  20589. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20590. * @returns the view count
  20591. */
  20592. getViewCount(): number;
  20593. }
  20594. }
  20595. declare module "babylonjs/Materials/material" {
  20596. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20597. import { SmartArray } from "babylonjs/Misc/smartArray";
  20598. import { Observable } from "babylonjs/Misc/observable";
  20599. import { Nullable } from "babylonjs/types";
  20600. import { Scene } from "babylonjs/scene";
  20601. import { Matrix } from "babylonjs/Maths/math.vector";
  20602. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20603. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20604. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20605. import { Effect } from "babylonjs/Materials/effect";
  20606. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20607. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20608. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20609. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20610. import { Mesh } from "babylonjs/Meshes/mesh";
  20611. import { Animation } from "babylonjs/Animations/animation";
  20612. /**
  20613. * Base class for the main features of a material in Babylon.js
  20614. */
  20615. export class Material implements IAnimatable {
  20616. /**
  20617. * Returns the triangle fill mode
  20618. */
  20619. static readonly TriangleFillMode: number;
  20620. /**
  20621. * Returns the wireframe mode
  20622. */
  20623. static readonly WireFrameFillMode: number;
  20624. /**
  20625. * Returns the point fill mode
  20626. */
  20627. static readonly PointFillMode: number;
  20628. /**
  20629. * Returns the point list draw mode
  20630. */
  20631. static readonly PointListDrawMode: number;
  20632. /**
  20633. * Returns the line list draw mode
  20634. */
  20635. static readonly LineListDrawMode: number;
  20636. /**
  20637. * Returns the line loop draw mode
  20638. */
  20639. static readonly LineLoopDrawMode: number;
  20640. /**
  20641. * Returns the line strip draw mode
  20642. */
  20643. static readonly LineStripDrawMode: number;
  20644. /**
  20645. * Returns the triangle strip draw mode
  20646. */
  20647. static readonly TriangleStripDrawMode: number;
  20648. /**
  20649. * Returns the triangle fan draw mode
  20650. */
  20651. static readonly TriangleFanDrawMode: number;
  20652. /**
  20653. * Stores the clock-wise side orientation
  20654. */
  20655. static readonly ClockWiseSideOrientation: number;
  20656. /**
  20657. * Stores the counter clock-wise side orientation
  20658. */
  20659. static readonly CounterClockWiseSideOrientation: number;
  20660. /**
  20661. * The dirty texture flag value
  20662. */
  20663. static readonly TextureDirtyFlag: number;
  20664. /**
  20665. * The dirty light flag value
  20666. */
  20667. static readonly LightDirtyFlag: number;
  20668. /**
  20669. * The dirty fresnel flag value
  20670. */
  20671. static readonly FresnelDirtyFlag: number;
  20672. /**
  20673. * The dirty attribute flag value
  20674. */
  20675. static readonly AttributesDirtyFlag: number;
  20676. /**
  20677. * The dirty misc flag value
  20678. */
  20679. static readonly MiscDirtyFlag: number;
  20680. /**
  20681. * The all dirty flag value
  20682. */
  20683. static readonly AllDirtyFlag: number;
  20684. /**
  20685. * The ID of the material
  20686. */
  20687. id: string;
  20688. /**
  20689. * Gets or sets the unique id of the material
  20690. */
  20691. uniqueId: number;
  20692. /**
  20693. * The name of the material
  20694. */
  20695. name: string;
  20696. /**
  20697. * Gets or sets user defined metadata
  20698. */
  20699. metadata: any;
  20700. /**
  20701. * For internal use only. Please do not use.
  20702. */
  20703. reservedDataStore: any;
  20704. /**
  20705. * Specifies if the ready state should be checked on each call
  20706. */
  20707. checkReadyOnEveryCall: boolean;
  20708. /**
  20709. * Specifies if the ready state should be checked once
  20710. */
  20711. checkReadyOnlyOnce: boolean;
  20712. /**
  20713. * The state of the material
  20714. */
  20715. state: string;
  20716. /**
  20717. * The alpha value of the material
  20718. */
  20719. protected _alpha: number;
  20720. /**
  20721. * List of inspectable custom properties (used by the Inspector)
  20722. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20723. */
  20724. inspectableCustomProperties: IInspectable[];
  20725. /**
  20726. * Sets the alpha value of the material
  20727. */
  20728. /**
  20729. * Gets the alpha value of the material
  20730. */
  20731. alpha: number;
  20732. /**
  20733. * Specifies if back face culling is enabled
  20734. */
  20735. protected _backFaceCulling: boolean;
  20736. /**
  20737. * Sets the back-face culling state
  20738. */
  20739. /**
  20740. * Gets the back-face culling state
  20741. */
  20742. backFaceCulling: boolean;
  20743. /**
  20744. * Stores the value for side orientation
  20745. */
  20746. sideOrientation: number;
  20747. /**
  20748. * Callback triggered when the material is compiled
  20749. */
  20750. onCompiled: Nullable<(effect: Effect) => void>;
  20751. /**
  20752. * Callback triggered when an error occurs
  20753. */
  20754. onError: Nullable<(effect: Effect, errors: string) => void>;
  20755. /**
  20756. * Callback triggered to get the render target textures
  20757. */
  20758. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20759. /**
  20760. * Gets a boolean indicating that current material needs to register RTT
  20761. */
  20762. readonly hasRenderTargetTextures: boolean;
  20763. /**
  20764. * Specifies if the material should be serialized
  20765. */
  20766. doNotSerialize: boolean;
  20767. /**
  20768. * @hidden
  20769. */
  20770. _storeEffectOnSubMeshes: boolean;
  20771. /**
  20772. * Stores the animations for the material
  20773. */
  20774. animations: Nullable<Array<Animation>>;
  20775. /**
  20776. * An event triggered when the material is disposed
  20777. */
  20778. onDisposeObservable: Observable<Material>;
  20779. /**
  20780. * An observer which watches for dispose events
  20781. */
  20782. private _onDisposeObserver;
  20783. private _onUnBindObservable;
  20784. /**
  20785. * Called during a dispose event
  20786. */
  20787. onDispose: () => void;
  20788. private _onBindObservable;
  20789. /**
  20790. * An event triggered when the material is bound
  20791. */
  20792. readonly onBindObservable: Observable<AbstractMesh>;
  20793. /**
  20794. * An observer which watches for bind events
  20795. */
  20796. private _onBindObserver;
  20797. /**
  20798. * Called during a bind event
  20799. */
  20800. onBind: (Mesh: AbstractMesh) => void;
  20801. /**
  20802. * An event triggered when the material is unbound
  20803. */
  20804. readonly onUnBindObservable: Observable<Material>;
  20805. /**
  20806. * Stores the value of the alpha mode
  20807. */
  20808. private _alphaMode;
  20809. /**
  20810. * Sets the value of the alpha mode.
  20811. *
  20812. * | Value | Type | Description |
  20813. * | --- | --- | --- |
  20814. * | 0 | ALPHA_DISABLE | |
  20815. * | 1 | ALPHA_ADD | |
  20816. * | 2 | ALPHA_COMBINE | |
  20817. * | 3 | ALPHA_SUBTRACT | |
  20818. * | 4 | ALPHA_MULTIPLY | |
  20819. * | 5 | ALPHA_MAXIMIZED | |
  20820. * | 6 | ALPHA_ONEONE | |
  20821. * | 7 | ALPHA_PREMULTIPLIED | |
  20822. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20823. * | 9 | ALPHA_INTERPOLATE | |
  20824. * | 10 | ALPHA_SCREENMODE | |
  20825. *
  20826. */
  20827. /**
  20828. * Gets the value of the alpha mode
  20829. */
  20830. alphaMode: number;
  20831. /**
  20832. * Stores the state of the need depth pre-pass value
  20833. */
  20834. private _needDepthPrePass;
  20835. /**
  20836. * Sets the need depth pre-pass value
  20837. */
  20838. /**
  20839. * Gets the depth pre-pass value
  20840. */
  20841. needDepthPrePass: boolean;
  20842. /**
  20843. * Specifies if depth writing should be disabled
  20844. */
  20845. disableDepthWrite: boolean;
  20846. /**
  20847. * Specifies if depth writing should be forced
  20848. */
  20849. forceDepthWrite: boolean;
  20850. /**
  20851. * Specifies if there should be a separate pass for culling
  20852. */
  20853. separateCullingPass: boolean;
  20854. /**
  20855. * Stores the state specifing if fog should be enabled
  20856. */
  20857. private _fogEnabled;
  20858. /**
  20859. * Sets the state for enabling fog
  20860. */
  20861. /**
  20862. * Gets the value of the fog enabled state
  20863. */
  20864. fogEnabled: boolean;
  20865. /**
  20866. * Stores the size of points
  20867. */
  20868. pointSize: number;
  20869. /**
  20870. * Stores the z offset value
  20871. */
  20872. zOffset: number;
  20873. /**
  20874. * Gets a value specifying if wireframe mode is enabled
  20875. */
  20876. /**
  20877. * Sets the state of wireframe mode
  20878. */
  20879. wireframe: boolean;
  20880. /**
  20881. * Gets the value specifying if point clouds are enabled
  20882. */
  20883. /**
  20884. * Sets the state of point cloud mode
  20885. */
  20886. pointsCloud: boolean;
  20887. /**
  20888. * Gets the material fill mode
  20889. */
  20890. /**
  20891. * Sets the material fill mode
  20892. */
  20893. fillMode: number;
  20894. /**
  20895. * @hidden
  20896. * Stores the effects for the material
  20897. */
  20898. _effect: Nullable<Effect>;
  20899. /**
  20900. * @hidden
  20901. * Specifies if the material was previously ready
  20902. */
  20903. _wasPreviouslyReady: boolean;
  20904. /**
  20905. * Specifies if uniform buffers should be used
  20906. */
  20907. private _useUBO;
  20908. /**
  20909. * Stores a reference to the scene
  20910. */
  20911. private _scene;
  20912. /**
  20913. * Stores the fill mode state
  20914. */
  20915. private _fillMode;
  20916. /**
  20917. * Specifies if the depth write state should be cached
  20918. */
  20919. private _cachedDepthWriteState;
  20920. /**
  20921. * Stores the uniform buffer
  20922. */
  20923. protected _uniformBuffer: UniformBuffer;
  20924. /** @hidden */
  20925. _indexInSceneMaterialArray: number;
  20926. /** @hidden */
  20927. meshMap: Nullable<{
  20928. [id: string]: AbstractMesh | undefined;
  20929. }>;
  20930. /**
  20931. * Creates a material instance
  20932. * @param name defines the name of the material
  20933. * @param scene defines the scene to reference
  20934. * @param doNotAdd specifies if the material should be added to the scene
  20935. */
  20936. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20937. /**
  20938. * Returns a string representation of the current material
  20939. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20940. * @returns a string with material information
  20941. */
  20942. toString(fullDetails?: boolean): string;
  20943. /**
  20944. * Gets the class name of the material
  20945. * @returns a string with the class name of the material
  20946. */
  20947. getClassName(): string;
  20948. /**
  20949. * Specifies if updates for the material been locked
  20950. */
  20951. readonly isFrozen: boolean;
  20952. /**
  20953. * Locks updates for the material
  20954. */
  20955. freeze(): void;
  20956. /**
  20957. * Unlocks updates for the material
  20958. */
  20959. unfreeze(): void;
  20960. /**
  20961. * Specifies if the material is ready to be used
  20962. * @param mesh defines the mesh to check
  20963. * @param useInstances specifies if instances should be used
  20964. * @returns a boolean indicating if the material is ready to be used
  20965. */
  20966. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20967. /**
  20968. * Specifies that the submesh is ready to be used
  20969. * @param mesh defines the mesh to check
  20970. * @param subMesh defines which submesh to check
  20971. * @param useInstances specifies that instances should be used
  20972. * @returns a boolean indicating that the submesh is ready or not
  20973. */
  20974. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20975. /**
  20976. * Returns the material effect
  20977. * @returns the effect associated with the material
  20978. */
  20979. getEffect(): Nullable<Effect>;
  20980. /**
  20981. * Returns the current scene
  20982. * @returns a Scene
  20983. */
  20984. getScene(): Scene;
  20985. /**
  20986. * Specifies if the material will require alpha blending
  20987. * @returns a boolean specifying if alpha blending is needed
  20988. */
  20989. needAlphaBlending(): boolean;
  20990. /**
  20991. * Specifies if the mesh will require alpha blending
  20992. * @param mesh defines the mesh to check
  20993. * @returns a boolean specifying if alpha blending is needed for the mesh
  20994. */
  20995. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20996. /**
  20997. * Specifies if this material should be rendered in alpha test mode
  20998. * @returns a boolean specifying if an alpha test is needed.
  20999. */
  21000. needAlphaTesting(): boolean;
  21001. /**
  21002. * Gets the texture used for the alpha test
  21003. * @returns the texture to use for alpha testing
  21004. */
  21005. getAlphaTestTexture(): Nullable<BaseTexture>;
  21006. /**
  21007. * Marks the material to indicate that it needs to be re-calculated
  21008. */
  21009. markDirty(): void;
  21010. /** @hidden */
  21011. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21012. /**
  21013. * Binds the material to the mesh
  21014. * @param world defines the world transformation matrix
  21015. * @param mesh defines the mesh to bind the material to
  21016. */
  21017. bind(world: Matrix, mesh?: Mesh): void;
  21018. /**
  21019. * Binds the submesh to the material
  21020. * @param world defines the world transformation matrix
  21021. * @param mesh defines the mesh containing the submesh
  21022. * @param subMesh defines the submesh to bind the material to
  21023. */
  21024. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21025. /**
  21026. * Binds the world matrix to the material
  21027. * @param world defines the world transformation matrix
  21028. */
  21029. bindOnlyWorldMatrix(world: Matrix): void;
  21030. /**
  21031. * Binds the scene's uniform buffer to the effect.
  21032. * @param effect defines the effect to bind to the scene uniform buffer
  21033. * @param sceneUbo defines the uniform buffer storing scene data
  21034. */
  21035. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21036. /**
  21037. * Binds the view matrix to the effect
  21038. * @param effect defines the effect to bind the view matrix to
  21039. */
  21040. bindView(effect: Effect): void;
  21041. /**
  21042. * Binds the view projection matrix to the effect
  21043. * @param effect defines the effect to bind the view projection matrix to
  21044. */
  21045. bindViewProjection(effect: Effect): void;
  21046. /**
  21047. * Specifies if material alpha testing should be turned on for the mesh
  21048. * @param mesh defines the mesh to check
  21049. */
  21050. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21051. /**
  21052. * Processes to execute after binding the material to a mesh
  21053. * @param mesh defines the rendered mesh
  21054. */
  21055. protected _afterBind(mesh?: Mesh): void;
  21056. /**
  21057. * Unbinds the material from the mesh
  21058. */
  21059. unbind(): void;
  21060. /**
  21061. * Gets the active textures from the material
  21062. * @returns an array of textures
  21063. */
  21064. getActiveTextures(): BaseTexture[];
  21065. /**
  21066. * Specifies if the material uses a texture
  21067. * @param texture defines the texture to check against the material
  21068. * @returns a boolean specifying if the material uses the texture
  21069. */
  21070. hasTexture(texture: BaseTexture): boolean;
  21071. /**
  21072. * Makes a duplicate of the material, and gives it a new name
  21073. * @param name defines the new name for the duplicated material
  21074. * @returns the cloned material
  21075. */
  21076. clone(name: string): Nullable<Material>;
  21077. /**
  21078. * Gets the meshes bound to the material
  21079. * @returns an array of meshes bound to the material
  21080. */
  21081. getBindedMeshes(): AbstractMesh[];
  21082. /**
  21083. * Force shader compilation
  21084. * @param mesh defines the mesh associated with this material
  21085. * @param onCompiled defines a function to execute once the material is compiled
  21086. * @param options defines the options to configure the compilation
  21087. */
  21088. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21089. clipPlane: boolean;
  21090. }>): void;
  21091. /**
  21092. * Force shader compilation
  21093. * @param mesh defines the mesh that will use this material
  21094. * @param options defines additional options for compiling the shaders
  21095. * @returns a promise that resolves when the compilation completes
  21096. */
  21097. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21098. clipPlane: boolean;
  21099. }>): Promise<void>;
  21100. private static readonly _AllDirtyCallBack;
  21101. private static readonly _ImageProcessingDirtyCallBack;
  21102. private static readonly _TextureDirtyCallBack;
  21103. private static readonly _FresnelDirtyCallBack;
  21104. private static readonly _MiscDirtyCallBack;
  21105. private static readonly _LightsDirtyCallBack;
  21106. private static readonly _AttributeDirtyCallBack;
  21107. private static _FresnelAndMiscDirtyCallBack;
  21108. private static _TextureAndMiscDirtyCallBack;
  21109. private static readonly _DirtyCallbackArray;
  21110. private static readonly _RunDirtyCallBacks;
  21111. /**
  21112. * Marks a define in the material to indicate that it needs to be re-computed
  21113. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21114. */
  21115. markAsDirty(flag: number): void;
  21116. /**
  21117. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21118. * @param func defines a function which checks material defines against the submeshes
  21119. */
  21120. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21121. /**
  21122. * Indicates that we need to re-calculated for all submeshes
  21123. */
  21124. protected _markAllSubMeshesAsAllDirty(): void;
  21125. /**
  21126. * Indicates that image processing needs to be re-calculated for all submeshes
  21127. */
  21128. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21129. /**
  21130. * Indicates that textures need to be re-calculated for all submeshes
  21131. */
  21132. protected _markAllSubMeshesAsTexturesDirty(): void;
  21133. /**
  21134. * Indicates that fresnel needs to be re-calculated for all submeshes
  21135. */
  21136. protected _markAllSubMeshesAsFresnelDirty(): void;
  21137. /**
  21138. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21139. */
  21140. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21141. /**
  21142. * Indicates that lights need to be re-calculated for all submeshes
  21143. */
  21144. protected _markAllSubMeshesAsLightsDirty(): void;
  21145. /**
  21146. * Indicates that attributes need to be re-calculated for all submeshes
  21147. */
  21148. protected _markAllSubMeshesAsAttributesDirty(): void;
  21149. /**
  21150. * Indicates that misc needs to be re-calculated for all submeshes
  21151. */
  21152. protected _markAllSubMeshesAsMiscDirty(): void;
  21153. /**
  21154. * Indicates that textures and misc need to be re-calculated for all submeshes
  21155. */
  21156. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21157. /**
  21158. * Disposes the material
  21159. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21160. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21161. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21162. */
  21163. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21164. /** @hidden */
  21165. private releaseVertexArrayObject;
  21166. /**
  21167. * Serializes this material
  21168. * @returns the serialized material object
  21169. */
  21170. serialize(): any;
  21171. /**
  21172. * Creates a material from parsed material data
  21173. * @param parsedMaterial defines parsed material data
  21174. * @param scene defines the hosting scene
  21175. * @param rootUrl defines the root URL to use to load textures
  21176. * @returns a new material
  21177. */
  21178. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21179. }
  21180. }
  21181. declare module "babylonjs/Materials/multiMaterial" {
  21182. import { Nullable } from "babylonjs/types";
  21183. import { Scene } from "babylonjs/scene";
  21184. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21185. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21186. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21187. import { Material } from "babylonjs/Materials/material";
  21188. /**
  21189. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21190. * separate meshes. This can be use to improve performances.
  21191. * @see http://doc.babylonjs.com/how_to/multi_materials
  21192. */
  21193. export class MultiMaterial extends Material {
  21194. private _subMaterials;
  21195. /**
  21196. * Gets or Sets the list of Materials used within the multi material.
  21197. * They need to be ordered according to the submeshes order in the associated mesh
  21198. */
  21199. subMaterials: Nullable<Material>[];
  21200. /**
  21201. * Function used to align with Node.getChildren()
  21202. * @returns the list of Materials used within the multi material
  21203. */
  21204. getChildren(): Nullable<Material>[];
  21205. /**
  21206. * Instantiates a new Multi Material
  21207. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21208. * separate meshes. This can be use to improve performances.
  21209. * @see http://doc.babylonjs.com/how_to/multi_materials
  21210. * @param name Define the name in the scene
  21211. * @param scene Define the scene the material belongs to
  21212. */
  21213. constructor(name: string, scene: Scene);
  21214. private _hookArray;
  21215. /**
  21216. * Get one of the submaterial by its index in the submaterials array
  21217. * @param index The index to look the sub material at
  21218. * @returns The Material if the index has been defined
  21219. */
  21220. getSubMaterial(index: number): Nullable<Material>;
  21221. /**
  21222. * Get the list of active textures for the whole sub materials list.
  21223. * @returns All the textures that will be used during the rendering
  21224. */
  21225. getActiveTextures(): BaseTexture[];
  21226. /**
  21227. * Gets the current class name of the material e.g. "MultiMaterial"
  21228. * Mainly use in serialization.
  21229. * @returns the class name
  21230. */
  21231. getClassName(): string;
  21232. /**
  21233. * Checks if the material is ready to render the requested sub mesh
  21234. * @param mesh Define the mesh the submesh belongs to
  21235. * @param subMesh Define the sub mesh to look readyness for
  21236. * @param useInstances Define whether or not the material is used with instances
  21237. * @returns true if ready, otherwise false
  21238. */
  21239. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21240. /**
  21241. * Clones the current material and its related sub materials
  21242. * @param name Define the name of the newly cloned material
  21243. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21244. * @returns the cloned material
  21245. */
  21246. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21247. /**
  21248. * Serializes the materials into a JSON representation.
  21249. * @returns the JSON representation
  21250. */
  21251. serialize(): any;
  21252. /**
  21253. * Dispose the material and release its associated resources
  21254. * @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)
  21255. * @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)
  21256. * @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)
  21257. */
  21258. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21259. /**
  21260. * Creates a MultiMaterial from parsed MultiMaterial data.
  21261. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21262. * @param scene defines the hosting scene
  21263. * @returns a new MultiMaterial
  21264. */
  21265. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21266. }
  21267. }
  21268. declare module "babylonjs/Meshes/subMesh" {
  21269. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21270. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21271. import { Engine } from "babylonjs/Engines/engine";
  21272. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21273. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21274. import { Effect } from "babylonjs/Materials/effect";
  21275. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21276. import { Plane } from "babylonjs/Maths/math.plane";
  21277. import { Collider } from "babylonjs/Collisions/collider";
  21278. import { Material } from "babylonjs/Materials/material";
  21279. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21280. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21281. import { Mesh } from "babylonjs/Meshes/mesh";
  21282. import { Ray } from "babylonjs/Culling/ray";
  21283. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21284. /**
  21285. * Base class for submeshes
  21286. */
  21287. export class BaseSubMesh {
  21288. /** @hidden */
  21289. _materialDefines: Nullable<MaterialDefines>;
  21290. /** @hidden */
  21291. _materialEffect: Nullable<Effect>;
  21292. /**
  21293. * Gets associated effect
  21294. */
  21295. readonly effect: Nullable<Effect>;
  21296. /**
  21297. * Sets associated effect (effect used to render this submesh)
  21298. * @param effect defines the effect to associate with
  21299. * @param defines defines the set of defines used to compile this effect
  21300. */
  21301. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21302. }
  21303. /**
  21304. * Defines a subdivision inside a mesh
  21305. */
  21306. export class SubMesh extends BaseSubMesh implements ICullable {
  21307. /** the material index to use */
  21308. materialIndex: number;
  21309. /** vertex index start */
  21310. verticesStart: number;
  21311. /** vertices count */
  21312. verticesCount: number;
  21313. /** index start */
  21314. indexStart: number;
  21315. /** indices count */
  21316. indexCount: number;
  21317. /** @hidden */
  21318. _linesIndexCount: number;
  21319. private _mesh;
  21320. private _renderingMesh;
  21321. private _boundingInfo;
  21322. private _linesIndexBuffer;
  21323. /** @hidden */
  21324. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21325. /** @hidden */
  21326. _trianglePlanes: Plane[];
  21327. /** @hidden */
  21328. _lastColliderTransformMatrix: Nullable<Matrix>;
  21329. /** @hidden */
  21330. _renderId: number;
  21331. /** @hidden */
  21332. _alphaIndex: number;
  21333. /** @hidden */
  21334. _distanceToCamera: number;
  21335. /** @hidden */
  21336. _id: number;
  21337. private _currentMaterial;
  21338. /**
  21339. * Add a new submesh to a mesh
  21340. * @param materialIndex defines the material index to use
  21341. * @param verticesStart defines vertex index start
  21342. * @param verticesCount defines vertices count
  21343. * @param indexStart defines index start
  21344. * @param indexCount defines indices count
  21345. * @param mesh defines the parent mesh
  21346. * @param renderingMesh defines an optional rendering mesh
  21347. * @param createBoundingBox defines if bounding box should be created for this submesh
  21348. * @returns the new submesh
  21349. */
  21350. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21351. /**
  21352. * Creates a new submesh
  21353. * @param materialIndex defines the material index to use
  21354. * @param verticesStart defines vertex index start
  21355. * @param verticesCount defines vertices count
  21356. * @param indexStart defines index start
  21357. * @param indexCount defines indices count
  21358. * @param mesh defines the parent mesh
  21359. * @param renderingMesh defines an optional rendering mesh
  21360. * @param createBoundingBox defines if bounding box should be created for this submesh
  21361. */
  21362. constructor(
  21363. /** the material index to use */
  21364. materialIndex: number,
  21365. /** vertex index start */
  21366. verticesStart: number,
  21367. /** vertices count */
  21368. verticesCount: number,
  21369. /** index start */
  21370. indexStart: number,
  21371. /** indices count */
  21372. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21373. /**
  21374. * Returns true if this submesh covers the entire parent mesh
  21375. * @ignorenaming
  21376. */
  21377. readonly IsGlobal: boolean;
  21378. /**
  21379. * Returns the submesh BoudingInfo object
  21380. * @returns current bounding info (or mesh's one if the submesh is global)
  21381. */
  21382. getBoundingInfo(): BoundingInfo;
  21383. /**
  21384. * Sets the submesh BoundingInfo
  21385. * @param boundingInfo defines the new bounding info to use
  21386. * @returns the SubMesh
  21387. */
  21388. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21389. /**
  21390. * Returns the mesh of the current submesh
  21391. * @return the parent mesh
  21392. */
  21393. getMesh(): AbstractMesh;
  21394. /**
  21395. * Returns the rendering mesh of the submesh
  21396. * @returns the rendering mesh (could be different from parent mesh)
  21397. */
  21398. getRenderingMesh(): Mesh;
  21399. /**
  21400. * Returns the submesh material
  21401. * @returns null or the current material
  21402. */
  21403. getMaterial(): Nullable<Material>;
  21404. /**
  21405. * Sets a new updated BoundingInfo object to the submesh
  21406. * @param data defines an optional position array to use to determine the bounding info
  21407. * @returns the SubMesh
  21408. */
  21409. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21410. /** @hidden */
  21411. _checkCollision(collider: Collider): boolean;
  21412. /**
  21413. * Updates the submesh BoundingInfo
  21414. * @param world defines the world matrix to use to update the bounding info
  21415. * @returns the submesh
  21416. */
  21417. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21418. /**
  21419. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21420. * @param frustumPlanes defines the frustum planes
  21421. * @returns true if the submesh is intersecting with the frustum
  21422. */
  21423. isInFrustum(frustumPlanes: Plane[]): boolean;
  21424. /**
  21425. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21426. * @param frustumPlanes defines the frustum planes
  21427. * @returns true if the submesh is inside the frustum
  21428. */
  21429. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21430. /**
  21431. * Renders the submesh
  21432. * @param enableAlphaMode defines if alpha needs to be used
  21433. * @returns the submesh
  21434. */
  21435. render(enableAlphaMode: boolean): SubMesh;
  21436. /**
  21437. * @hidden
  21438. */
  21439. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21440. /**
  21441. * Checks if the submesh intersects with a ray
  21442. * @param ray defines the ray to test
  21443. * @returns true is the passed ray intersects the submesh bounding box
  21444. */
  21445. canIntersects(ray: Ray): boolean;
  21446. /**
  21447. * Intersects current submesh with a ray
  21448. * @param ray defines the ray to test
  21449. * @param positions defines mesh's positions array
  21450. * @param indices defines mesh's indices array
  21451. * @param fastCheck defines if only bounding info should be used
  21452. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21453. * @returns intersection info or null if no intersection
  21454. */
  21455. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21456. /** @hidden */
  21457. private _intersectLines;
  21458. /** @hidden */
  21459. private _intersectUnIndexedLines;
  21460. /** @hidden */
  21461. private _intersectTriangles;
  21462. /** @hidden */
  21463. private _intersectUnIndexedTriangles;
  21464. /** @hidden */
  21465. _rebuild(): void;
  21466. /**
  21467. * Creates a new submesh from the passed mesh
  21468. * @param newMesh defines the new hosting mesh
  21469. * @param newRenderingMesh defines an optional rendering mesh
  21470. * @returns the new submesh
  21471. */
  21472. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21473. /**
  21474. * Release associated resources
  21475. */
  21476. dispose(): void;
  21477. /**
  21478. * Gets the class name
  21479. * @returns the string "SubMesh".
  21480. */
  21481. getClassName(): string;
  21482. /**
  21483. * Creates a new submesh from indices data
  21484. * @param materialIndex the index of the main mesh material
  21485. * @param startIndex the index where to start the copy in the mesh indices array
  21486. * @param indexCount the number of indices to copy then from the startIndex
  21487. * @param mesh the main mesh to create the submesh from
  21488. * @param renderingMesh the optional rendering mesh
  21489. * @returns a new submesh
  21490. */
  21491. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21492. }
  21493. }
  21494. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21495. /**
  21496. * Class used to represent data loading progression
  21497. */
  21498. export class SceneLoaderFlags {
  21499. private static _ForceFullSceneLoadingForIncremental;
  21500. private static _ShowLoadingScreen;
  21501. private static _CleanBoneMatrixWeights;
  21502. private static _loggingLevel;
  21503. /**
  21504. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21505. */
  21506. static ForceFullSceneLoadingForIncremental: boolean;
  21507. /**
  21508. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21509. */
  21510. static ShowLoadingScreen: boolean;
  21511. /**
  21512. * Defines the current logging level (while loading the scene)
  21513. * @ignorenaming
  21514. */
  21515. static loggingLevel: number;
  21516. /**
  21517. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21518. */
  21519. static CleanBoneMatrixWeights: boolean;
  21520. }
  21521. }
  21522. declare module "babylonjs/Meshes/geometry" {
  21523. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21524. import { Scene } from "babylonjs/scene";
  21525. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21526. import { Engine } from "babylonjs/Engines/engine";
  21527. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21528. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21529. import { Effect } from "babylonjs/Materials/effect";
  21530. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21531. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21532. import { Mesh } from "babylonjs/Meshes/mesh";
  21533. /**
  21534. * Class used to store geometry data (vertex buffers + index buffer)
  21535. */
  21536. export class Geometry implements IGetSetVerticesData {
  21537. /**
  21538. * Gets or sets the ID of the geometry
  21539. */
  21540. id: string;
  21541. /**
  21542. * Gets or sets the unique ID of the geometry
  21543. */
  21544. uniqueId: number;
  21545. /**
  21546. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21547. */
  21548. delayLoadState: number;
  21549. /**
  21550. * Gets the file containing the data to load when running in delay load state
  21551. */
  21552. delayLoadingFile: Nullable<string>;
  21553. /**
  21554. * Callback called when the geometry is updated
  21555. */
  21556. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21557. private _scene;
  21558. private _engine;
  21559. private _meshes;
  21560. private _totalVertices;
  21561. /** @hidden */
  21562. _indices: IndicesArray;
  21563. /** @hidden */
  21564. _vertexBuffers: {
  21565. [key: string]: VertexBuffer;
  21566. };
  21567. private _isDisposed;
  21568. private _extend;
  21569. private _boundingBias;
  21570. /** @hidden */
  21571. _delayInfo: Array<string>;
  21572. private _indexBuffer;
  21573. private _indexBufferIsUpdatable;
  21574. /** @hidden */
  21575. _boundingInfo: Nullable<BoundingInfo>;
  21576. /** @hidden */
  21577. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21578. /** @hidden */
  21579. _softwareSkinningFrameId: number;
  21580. private _vertexArrayObjects;
  21581. private _updatable;
  21582. /** @hidden */
  21583. _positions: Nullable<Vector3[]>;
  21584. /**
  21585. * 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
  21586. */
  21587. /**
  21588. * 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
  21589. */
  21590. boundingBias: Vector2;
  21591. /**
  21592. * Static function used to attach a new empty geometry to a mesh
  21593. * @param mesh defines the mesh to attach the geometry to
  21594. * @returns the new Geometry
  21595. */
  21596. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21597. /**
  21598. * Creates a new geometry
  21599. * @param id defines the unique ID
  21600. * @param scene defines the hosting scene
  21601. * @param vertexData defines the VertexData used to get geometry data
  21602. * @param updatable defines if geometry must be updatable (false by default)
  21603. * @param mesh defines the mesh that will be associated with the geometry
  21604. */
  21605. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21606. /**
  21607. * Gets the current extend of the geometry
  21608. */
  21609. readonly extend: {
  21610. minimum: Vector3;
  21611. maximum: Vector3;
  21612. };
  21613. /**
  21614. * Gets the hosting scene
  21615. * @returns the hosting Scene
  21616. */
  21617. getScene(): Scene;
  21618. /**
  21619. * Gets the hosting engine
  21620. * @returns the hosting Engine
  21621. */
  21622. getEngine(): Engine;
  21623. /**
  21624. * Defines if the geometry is ready to use
  21625. * @returns true if the geometry is ready to be used
  21626. */
  21627. isReady(): boolean;
  21628. /**
  21629. * Gets a value indicating that the geometry should not be serialized
  21630. */
  21631. readonly doNotSerialize: boolean;
  21632. /** @hidden */
  21633. _rebuild(): void;
  21634. /**
  21635. * Affects all geometry data in one call
  21636. * @param vertexData defines the geometry data
  21637. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21638. */
  21639. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21640. /**
  21641. * Set specific vertex data
  21642. * @param kind defines the data kind (Position, normal, etc...)
  21643. * @param data defines the vertex data to use
  21644. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21645. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21646. */
  21647. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21648. /**
  21649. * Removes a specific vertex data
  21650. * @param kind defines the data kind (Position, normal, etc...)
  21651. */
  21652. removeVerticesData(kind: string): void;
  21653. /**
  21654. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21655. * @param buffer defines the vertex buffer to use
  21656. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21657. */
  21658. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21659. /**
  21660. * Update a specific vertex buffer
  21661. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21662. * It will do nothing if the buffer is not updatable
  21663. * @param kind defines the data kind (Position, normal, etc...)
  21664. * @param data defines the data to use
  21665. * @param offset defines the offset in the target buffer where to store the data
  21666. * @param useBytes set to true if the offset is in bytes
  21667. */
  21668. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21669. /**
  21670. * Update a specific vertex buffer
  21671. * This function will create a new buffer if the current one is not updatable
  21672. * @param kind defines the data kind (Position, normal, etc...)
  21673. * @param data defines the data to use
  21674. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21675. */
  21676. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21677. private _updateBoundingInfo;
  21678. /** @hidden */
  21679. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21680. /**
  21681. * Gets total number of vertices
  21682. * @returns the total number of vertices
  21683. */
  21684. getTotalVertices(): number;
  21685. /**
  21686. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21687. * @param kind defines the data kind (Position, normal, etc...)
  21688. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21689. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21690. * @returns a float array containing vertex data
  21691. */
  21692. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21693. /**
  21694. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21695. * @param kind defines the data kind (Position, normal, etc...)
  21696. * @returns true if the vertex buffer with the specified kind is updatable
  21697. */
  21698. isVertexBufferUpdatable(kind: string): boolean;
  21699. /**
  21700. * Gets a specific vertex buffer
  21701. * @param kind defines the data kind (Position, normal, etc...)
  21702. * @returns a VertexBuffer
  21703. */
  21704. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21705. /**
  21706. * Returns all vertex buffers
  21707. * @return an object holding all vertex buffers indexed by kind
  21708. */
  21709. getVertexBuffers(): Nullable<{
  21710. [key: string]: VertexBuffer;
  21711. }>;
  21712. /**
  21713. * Gets a boolean indicating if specific vertex buffer is present
  21714. * @param kind defines the data kind (Position, normal, etc...)
  21715. * @returns true if data is present
  21716. */
  21717. isVerticesDataPresent(kind: string): boolean;
  21718. /**
  21719. * Gets a list of all attached data kinds (Position, normal, etc...)
  21720. * @returns a list of string containing all kinds
  21721. */
  21722. getVerticesDataKinds(): string[];
  21723. /**
  21724. * Update index buffer
  21725. * @param indices defines the indices to store in the index buffer
  21726. * @param offset defines the offset in the target buffer where to store the data
  21727. * @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)
  21728. */
  21729. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21730. /**
  21731. * Creates a new index buffer
  21732. * @param indices defines the indices to store in the index buffer
  21733. * @param totalVertices defines the total number of vertices (could be null)
  21734. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21735. */
  21736. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21737. /**
  21738. * Return the total number of indices
  21739. * @returns the total number of indices
  21740. */
  21741. getTotalIndices(): number;
  21742. /**
  21743. * Gets the index buffer array
  21744. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21745. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21746. * @returns the index buffer array
  21747. */
  21748. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21749. /**
  21750. * Gets the index buffer
  21751. * @return the index buffer
  21752. */
  21753. getIndexBuffer(): Nullable<DataBuffer>;
  21754. /** @hidden */
  21755. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21756. /**
  21757. * Release the associated resources for a specific mesh
  21758. * @param mesh defines the source mesh
  21759. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21760. */
  21761. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21762. /**
  21763. * Apply current geometry to a given mesh
  21764. * @param mesh defines the mesh to apply geometry to
  21765. */
  21766. applyToMesh(mesh: Mesh): void;
  21767. private _updateExtend;
  21768. private _applyToMesh;
  21769. private notifyUpdate;
  21770. /**
  21771. * Load the geometry if it was flagged as delay loaded
  21772. * @param scene defines the hosting scene
  21773. * @param onLoaded defines a callback called when the geometry is loaded
  21774. */
  21775. load(scene: Scene, onLoaded?: () => void): void;
  21776. private _queueLoad;
  21777. /**
  21778. * Invert the geometry to move from a right handed system to a left handed one.
  21779. */
  21780. toLeftHanded(): void;
  21781. /** @hidden */
  21782. _resetPointsArrayCache(): void;
  21783. /** @hidden */
  21784. _generatePointsArray(): boolean;
  21785. /**
  21786. * Gets a value indicating if the geometry is disposed
  21787. * @returns true if the geometry was disposed
  21788. */
  21789. isDisposed(): boolean;
  21790. private _disposeVertexArrayObjects;
  21791. /**
  21792. * Free all associated resources
  21793. */
  21794. dispose(): void;
  21795. /**
  21796. * Clone the current geometry into a new geometry
  21797. * @param id defines the unique ID of the new geometry
  21798. * @returns a new geometry object
  21799. */
  21800. copy(id: string): Geometry;
  21801. /**
  21802. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21803. * @return a JSON representation of the current geometry data (without the vertices data)
  21804. */
  21805. serialize(): any;
  21806. private toNumberArray;
  21807. /**
  21808. * Serialize all vertices data into a JSON oject
  21809. * @returns a JSON representation of the current geometry data
  21810. */
  21811. serializeVerticeData(): any;
  21812. /**
  21813. * Extracts a clone of a mesh geometry
  21814. * @param mesh defines the source mesh
  21815. * @param id defines the unique ID of the new geometry object
  21816. * @returns the new geometry object
  21817. */
  21818. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21819. /**
  21820. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21821. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21822. * Be aware Math.random() could cause collisions, but:
  21823. * "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"
  21824. * @returns a string containing a new GUID
  21825. */
  21826. static RandomId(): string;
  21827. /** @hidden */
  21828. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21829. private static _CleanMatricesWeights;
  21830. /**
  21831. * Create a new geometry from persisted data (Using .babylon file format)
  21832. * @param parsedVertexData defines the persisted data
  21833. * @param scene defines the hosting scene
  21834. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21835. * @returns the new geometry object
  21836. */
  21837. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21838. }
  21839. }
  21840. declare module "babylonjs/Meshes/mesh.vertexData" {
  21841. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21842. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  21843. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  21844. import { Geometry } from "babylonjs/Meshes/geometry";
  21845. import { Mesh } from "babylonjs/Meshes/mesh";
  21846. /**
  21847. * Define an interface for all classes that will get and set the data on vertices
  21848. */
  21849. export interface IGetSetVerticesData {
  21850. /**
  21851. * Gets a boolean indicating if specific vertex data is present
  21852. * @param kind defines the vertex data kind to use
  21853. * @returns true is data kind is present
  21854. */
  21855. isVerticesDataPresent(kind: string): boolean;
  21856. /**
  21857. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21858. * @param kind defines the data kind (Position, normal, etc...)
  21859. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21860. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21861. * @returns a float array containing vertex data
  21862. */
  21863. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21864. /**
  21865. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21866. * @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.
  21867. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21868. * @returns the indices array or an empty array if the mesh has no geometry
  21869. */
  21870. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21871. /**
  21872. * Set specific vertex data
  21873. * @param kind defines the data kind (Position, normal, etc...)
  21874. * @param data defines the vertex data to use
  21875. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21876. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21877. */
  21878. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21879. /**
  21880. * Update a specific associated vertex buffer
  21881. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21882. * - VertexBuffer.PositionKind
  21883. * - VertexBuffer.UVKind
  21884. * - VertexBuffer.UV2Kind
  21885. * - VertexBuffer.UV3Kind
  21886. * - VertexBuffer.UV4Kind
  21887. * - VertexBuffer.UV5Kind
  21888. * - VertexBuffer.UV6Kind
  21889. * - VertexBuffer.ColorKind
  21890. * - VertexBuffer.MatricesIndicesKind
  21891. * - VertexBuffer.MatricesIndicesExtraKind
  21892. * - VertexBuffer.MatricesWeightsKind
  21893. * - VertexBuffer.MatricesWeightsExtraKind
  21894. * @param data defines the data source
  21895. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21896. * @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)
  21897. */
  21898. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21899. /**
  21900. * Creates a new index buffer
  21901. * @param indices defines the indices to store in the index buffer
  21902. * @param totalVertices defines the total number of vertices (could be null)
  21903. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21904. */
  21905. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21906. }
  21907. /**
  21908. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21909. */
  21910. export class VertexData {
  21911. /**
  21912. * Mesh side orientation : usually the external or front surface
  21913. */
  21914. static readonly FRONTSIDE: number;
  21915. /**
  21916. * Mesh side orientation : usually the internal or back surface
  21917. */
  21918. static readonly BACKSIDE: number;
  21919. /**
  21920. * Mesh side orientation : both internal and external or front and back surfaces
  21921. */
  21922. static readonly DOUBLESIDE: number;
  21923. /**
  21924. * Mesh side orientation : by default, `FRONTSIDE`
  21925. */
  21926. static readonly DEFAULTSIDE: number;
  21927. /**
  21928. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21929. */
  21930. positions: Nullable<FloatArray>;
  21931. /**
  21932. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21933. */
  21934. normals: Nullable<FloatArray>;
  21935. /**
  21936. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21937. */
  21938. tangents: Nullable<FloatArray>;
  21939. /**
  21940. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21941. */
  21942. uvs: Nullable<FloatArray>;
  21943. /**
  21944. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21945. */
  21946. uvs2: Nullable<FloatArray>;
  21947. /**
  21948. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21949. */
  21950. uvs3: Nullable<FloatArray>;
  21951. /**
  21952. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21953. */
  21954. uvs4: Nullable<FloatArray>;
  21955. /**
  21956. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21957. */
  21958. uvs5: Nullable<FloatArray>;
  21959. /**
  21960. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21961. */
  21962. uvs6: Nullable<FloatArray>;
  21963. /**
  21964. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21965. */
  21966. colors: Nullable<FloatArray>;
  21967. /**
  21968. * 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).
  21969. */
  21970. matricesIndices: Nullable<FloatArray>;
  21971. /**
  21972. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21973. */
  21974. matricesWeights: Nullable<FloatArray>;
  21975. /**
  21976. * An array extending the number of possible indices
  21977. */
  21978. matricesIndicesExtra: Nullable<FloatArray>;
  21979. /**
  21980. * An array extending the number of possible weights when the number of indices is extended
  21981. */
  21982. matricesWeightsExtra: Nullable<FloatArray>;
  21983. /**
  21984. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21985. */
  21986. indices: Nullable<IndicesArray>;
  21987. /**
  21988. * Uses the passed data array to set the set the values for the specified kind of data
  21989. * @param data a linear array of floating numbers
  21990. * @param kind the type of data that is being set, eg positions, colors etc
  21991. */
  21992. set(data: FloatArray, kind: string): void;
  21993. /**
  21994. * Associates the vertexData to the passed Mesh.
  21995. * Sets it as updatable or not (default `false`)
  21996. * @param mesh the mesh the vertexData is applied to
  21997. * @param updatable when used and having the value true allows new data to update the vertexData
  21998. * @returns the VertexData
  21999. */
  22000. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22001. /**
  22002. * Associates the vertexData to the passed Geometry.
  22003. * Sets it as updatable or not (default `false`)
  22004. * @param geometry the geometry the vertexData is applied to
  22005. * @param updatable when used and having the value true allows new data to update the vertexData
  22006. * @returns VertexData
  22007. */
  22008. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22009. /**
  22010. * Updates the associated mesh
  22011. * @param mesh the mesh to be updated
  22012. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22013. * @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
  22014. * @returns VertexData
  22015. */
  22016. updateMesh(mesh: Mesh): VertexData;
  22017. /**
  22018. * Updates the associated geometry
  22019. * @param geometry the geometry to be updated
  22020. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22021. * @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
  22022. * @returns VertexData.
  22023. */
  22024. updateGeometry(geometry: Geometry): VertexData;
  22025. private _applyTo;
  22026. private _update;
  22027. /**
  22028. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22029. * @param matrix the transforming matrix
  22030. * @returns the VertexData
  22031. */
  22032. transform(matrix: Matrix): VertexData;
  22033. /**
  22034. * Merges the passed VertexData into the current one
  22035. * @param other the VertexData to be merged into the current one
  22036. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22037. * @returns the modified VertexData
  22038. */
  22039. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22040. private _mergeElement;
  22041. private _validate;
  22042. /**
  22043. * Serializes the VertexData
  22044. * @returns a serialized object
  22045. */
  22046. serialize(): any;
  22047. /**
  22048. * Extracts the vertexData from a mesh
  22049. * @param mesh the mesh from which to extract the VertexData
  22050. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22051. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22052. * @returns the object VertexData associated to the passed mesh
  22053. */
  22054. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22055. /**
  22056. * Extracts the vertexData from the geometry
  22057. * @param geometry the geometry from which to extract the VertexData
  22058. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22059. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22060. * @returns the object VertexData associated to the passed mesh
  22061. */
  22062. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22063. private static _ExtractFrom;
  22064. /**
  22065. * Creates the VertexData for a Ribbon
  22066. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22067. * * pathArray array of paths, each of which an array of successive Vector3
  22068. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22069. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22070. * * 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
  22071. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22072. * * 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)
  22073. * * 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)
  22074. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22075. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22076. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22077. * @returns the VertexData of the ribbon
  22078. */
  22079. static CreateRibbon(options: {
  22080. pathArray: Vector3[][];
  22081. closeArray?: boolean;
  22082. closePath?: boolean;
  22083. offset?: number;
  22084. sideOrientation?: number;
  22085. frontUVs?: Vector4;
  22086. backUVs?: Vector4;
  22087. invertUV?: boolean;
  22088. uvs?: Vector2[];
  22089. colors?: Color4[];
  22090. }): VertexData;
  22091. /**
  22092. * Creates the VertexData for a box
  22093. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22094. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22095. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22096. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22097. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22098. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22099. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22100. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22101. * * 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)
  22102. * * 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)
  22103. * @returns the VertexData of the box
  22104. */
  22105. static CreateBox(options: {
  22106. size?: number;
  22107. width?: number;
  22108. height?: number;
  22109. depth?: number;
  22110. faceUV?: Vector4[];
  22111. faceColors?: Color4[];
  22112. sideOrientation?: number;
  22113. frontUVs?: Vector4;
  22114. backUVs?: Vector4;
  22115. }): VertexData;
  22116. /**
  22117. * Creates the VertexData for a tiled box
  22118. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22119. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22120. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22121. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22122. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22123. * @returns the VertexData of the box
  22124. */
  22125. static CreateTiledBox(options: {
  22126. pattern?: number;
  22127. width?: number;
  22128. height?: number;
  22129. depth?: number;
  22130. tileSize?: number;
  22131. tileWidth?: number;
  22132. tileHeight?: number;
  22133. alignHorizontal?: number;
  22134. alignVertical?: number;
  22135. faceUV?: Vector4[];
  22136. faceColors?: Color4[];
  22137. sideOrientation?: number;
  22138. }): VertexData;
  22139. /**
  22140. * Creates the VertexData for a tiled plane
  22141. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22142. * * pattern a limited pattern arrangement depending on the number
  22143. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22144. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22145. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22146. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22147. * * 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)
  22148. * * 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)
  22149. * @returns the VertexData of the tiled plane
  22150. */
  22151. static CreateTiledPlane(options: {
  22152. pattern?: number;
  22153. tileSize?: number;
  22154. tileWidth?: number;
  22155. tileHeight?: number;
  22156. size?: number;
  22157. width?: number;
  22158. height?: number;
  22159. alignHorizontal?: number;
  22160. alignVertical?: number;
  22161. sideOrientation?: number;
  22162. frontUVs?: Vector4;
  22163. backUVs?: Vector4;
  22164. }): VertexData;
  22165. /**
  22166. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22167. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22168. * * segments sets the number of horizontal strips optional, default 32
  22169. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22170. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22171. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22172. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22173. * * 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
  22174. * * 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
  22175. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22176. * * 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)
  22177. * * 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)
  22178. * @returns the VertexData of the ellipsoid
  22179. */
  22180. static CreateSphere(options: {
  22181. segments?: number;
  22182. diameter?: number;
  22183. diameterX?: number;
  22184. diameterY?: number;
  22185. diameterZ?: number;
  22186. arc?: number;
  22187. slice?: number;
  22188. sideOrientation?: number;
  22189. frontUVs?: Vector4;
  22190. backUVs?: Vector4;
  22191. }): VertexData;
  22192. /**
  22193. * Creates the VertexData for a cylinder, cone or prism
  22194. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22195. * * height sets the height (y direction) of the cylinder, optional, default 2
  22196. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22197. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22198. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22199. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22200. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22201. * * 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
  22202. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22203. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22204. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22205. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22206. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22207. * * 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)
  22208. * * 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)
  22209. * @returns the VertexData of the cylinder, cone or prism
  22210. */
  22211. static CreateCylinder(options: {
  22212. height?: number;
  22213. diameterTop?: number;
  22214. diameterBottom?: number;
  22215. diameter?: number;
  22216. tessellation?: number;
  22217. subdivisions?: number;
  22218. arc?: number;
  22219. faceColors?: Color4[];
  22220. faceUV?: Vector4[];
  22221. hasRings?: boolean;
  22222. enclose?: boolean;
  22223. sideOrientation?: number;
  22224. frontUVs?: Vector4;
  22225. backUVs?: Vector4;
  22226. }): VertexData;
  22227. /**
  22228. * Creates the VertexData for a torus
  22229. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22230. * * diameter the diameter of the torus, optional default 1
  22231. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22232. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22233. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22234. * * 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)
  22235. * * 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)
  22236. * @returns the VertexData of the torus
  22237. */
  22238. static CreateTorus(options: {
  22239. diameter?: number;
  22240. thickness?: number;
  22241. tessellation?: number;
  22242. sideOrientation?: number;
  22243. frontUVs?: Vector4;
  22244. backUVs?: Vector4;
  22245. }): VertexData;
  22246. /**
  22247. * Creates the VertexData of the LineSystem
  22248. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22249. * - lines an array of lines, each line being an array of successive Vector3
  22250. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22251. * @returns the VertexData of the LineSystem
  22252. */
  22253. static CreateLineSystem(options: {
  22254. lines: Vector3[][];
  22255. colors?: Nullable<Color4[][]>;
  22256. }): VertexData;
  22257. /**
  22258. * Create the VertexData for a DashedLines
  22259. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22260. * - points an array successive Vector3
  22261. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22262. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22263. * - dashNb the intended total number of dashes, optional, default 200
  22264. * @returns the VertexData for the DashedLines
  22265. */
  22266. static CreateDashedLines(options: {
  22267. points: Vector3[];
  22268. dashSize?: number;
  22269. gapSize?: number;
  22270. dashNb?: number;
  22271. }): VertexData;
  22272. /**
  22273. * Creates the VertexData for a Ground
  22274. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22275. * - width the width (x direction) of the ground, optional, default 1
  22276. * - height the height (z direction) of the ground, optional, default 1
  22277. * - subdivisions the number of subdivisions per side, optional, default 1
  22278. * @returns the VertexData of the Ground
  22279. */
  22280. static CreateGround(options: {
  22281. width?: number;
  22282. height?: number;
  22283. subdivisions?: number;
  22284. subdivisionsX?: number;
  22285. subdivisionsY?: number;
  22286. }): VertexData;
  22287. /**
  22288. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22289. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22290. * * xmin the ground minimum X coordinate, optional, default -1
  22291. * * zmin the ground minimum Z coordinate, optional, default -1
  22292. * * xmax the ground maximum X coordinate, optional, default 1
  22293. * * zmax the ground maximum Z coordinate, optional, default 1
  22294. * * 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}
  22295. * * 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}
  22296. * @returns the VertexData of the TiledGround
  22297. */
  22298. static CreateTiledGround(options: {
  22299. xmin: number;
  22300. zmin: number;
  22301. xmax: number;
  22302. zmax: number;
  22303. subdivisions?: {
  22304. w: number;
  22305. h: number;
  22306. };
  22307. precision?: {
  22308. w: number;
  22309. h: number;
  22310. };
  22311. }): VertexData;
  22312. /**
  22313. * Creates the VertexData of the Ground designed from a heightmap
  22314. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22315. * * width the width (x direction) of the ground
  22316. * * height the height (z direction) of the ground
  22317. * * subdivisions the number of subdivisions per side
  22318. * * minHeight the minimum altitude on the ground, optional, default 0
  22319. * * maxHeight the maximum altitude on the ground, optional default 1
  22320. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22321. * * buffer the array holding the image color data
  22322. * * bufferWidth the width of image
  22323. * * bufferHeight the height of image
  22324. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22325. * @returns the VertexData of the Ground designed from a heightmap
  22326. */
  22327. static CreateGroundFromHeightMap(options: {
  22328. width: number;
  22329. height: number;
  22330. subdivisions: number;
  22331. minHeight: number;
  22332. maxHeight: number;
  22333. colorFilter: Color3;
  22334. buffer: Uint8Array;
  22335. bufferWidth: number;
  22336. bufferHeight: number;
  22337. alphaFilter: number;
  22338. }): VertexData;
  22339. /**
  22340. * Creates the VertexData for a Plane
  22341. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22342. * * size sets the width and height of the plane to the value of size, optional default 1
  22343. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22344. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22345. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22346. * * 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)
  22347. * * 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)
  22348. * @returns the VertexData of the box
  22349. */
  22350. static CreatePlane(options: {
  22351. size?: number;
  22352. width?: number;
  22353. height?: number;
  22354. sideOrientation?: number;
  22355. frontUVs?: Vector4;
  22356. backUVs?: Vector4;
  22357. }): VertexData;
  22358. /**
  22359. * Creates the VertexData of the Disc or regular Polygon
  22360. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22361. * * radius the radius of the disc, optional default 0.5
  22362. * * tessellation the number of polygon sides, optional, default 64
  22363. * * 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
  22364. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22365. * * 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)
  22366. * * 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)
  22367. * @returns the VertexData of the box
  22368. */
  22369. static CreateDisc(options: {
  22370. radius?: number;
  22371. tessellation?: number;
  22372. arc?: number;
  22373. sideOrientation?: number;
  22374. frontUVs?: Vector4;
  22375. backUVs?: Vector4;
  22376. }): VertexData;
  22377. /**
  22378. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22379. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22380. * @param polygon a mesh built from polygonTriangulation.build()
  22381. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22382. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22383. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22384. * @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)
  22385. * @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)
  22386. * @returns the VertexData of the Polygon
  22387. */
  22388. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22389. /**
  22390. * Creates the VertexData of the IcoSphere
  22391. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22392. * * radius the radius of the IcoSphere, optional default 1
  22393. * * radiusX allows stretching in the x direction, optional, default radius
  22394. * * radiusY allows stretching in the y direction, optional, default radius
  22395. * * radiusZ allows stretching in the z direction, optional, default radius
  22396. * * flat when true creates a flat shaded mesh, optional, default true
  22397. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22398. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22399. * * 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)
  22400. * * 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)
  22401. * @returns the VertexData of the IcoSphere
  22402. */
  22403. static CreateIcoSphere(options: {
  22404. radius?: number;
  22405. radiusX?: number;
  22406. radiusY?: number;
  22407. radiusZ?: number;
  22408. flat?: boolean;
  22409. subdivisions?: number;
  22410. sideOrientation?: number;
  22411. frontUVs?: Vector4;
  22412. backUVs?: Vector4;
  22413. }): VertexData;
  22414. /**
  22415. * Creates the VertexData for a Polyhedron
  22416. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22417. * * type provided types are:
  22418. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22419. * * 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)
  22420. * * size the size of the IcoSphere, optional default 1
  22421. * * sizeX allows stretching in the x direction, optional, default size
  22422. * * sizeY allows stretching in the y direction, optional, default size
  22423. * * sizeZ allows stretching in the z direction, optional, default size
  22424. * * 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
  22425. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22426. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22427. * * flat when true creates a flat shaded mesh, optional, default true
  22428. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22429. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22430. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22431. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22432. * @returns the VertexData of the Polyhedron
  22433. */
  22434. static CreatePolyhedron(options: {
  22435. type?: number;
  22436. size?: number;
  22437. sizeX?: number;
  22438. sizeY?: number;
  22439. sizeZ?: number;
  22440. custom?: any;
  22441. faceUV?: Vector4[];
  22442. faceColors?: Color4[];
  22443. flat?: boolean;
  22444. sideOrientation?: number;
  22445. frontUVs?: Vector4;
  22446. backUVs?: Vector4;
  22447. }): VertexData;
  22448. /**
  22449. * Creates the VertexData for a TorusKnot
  22450. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22451. * * radius the radius of the torus knot, optional, default 2
  22452. * * tube the thickness of the tube, optional, default 0.5
  22453. * * radialSegments the number of sides on each tube segments, optional, default 32
  22454. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22455. * * p the number of windings around the z axis, optional, default 2
  22456. * * q the number of windings around the x axis, optional, default 3
  22457. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22458. * * 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)
  22459. * * 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)
  22460. * @returns the VertexData of the Torus Knot
  22461. */
  22462. static CreateTorusKnot(options: {
  22463. radius?: number;
  22464. tube?: number;
  22465. radialSegments?: number;
  22466. tubularSegments?: number;
  22467. p?: number;
  22468. q?: number;
  22469. sideOrientation?: number;
  22470. frontUVs?: Vector4;
  22471. backUVs?: Vector4;
  22472. }): VertexData;
  22473. /**
  22474. * Compute normals for given positions and indices
  22475. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22476. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22477. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22478. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22479. * * facetNormals : optional array of facet normals (vector3)
  22480. * * facetPositions : optional array of facet positions (vector3)
  22481. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22482. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22483. * * bInfo : optional bounding info, required for facetPartitioning computation
  22484. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22485. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22486. * * useRightHandedSystem: optional boolean to for right handed system computation
  22487. * * depthSort : optional boolean to enable the facet depth sort computation
  22488. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22489. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22490. */
  22491. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22492. facetNormals?: any;
  22493. facetPositions?: any;
  22494. facetPartitioning?: any;
  22495. ratio?: number;
  22496. bInfo?: any;
  22497. bbSize?: Vector3;
  22498. subDiv?: any;
  22499. useRightHandedSystem?: boolean;
  22500. depthSort?: boolean;
  22501. distanceTo?: Vector3;
  22502. depthSortedFacets?: any;
  22503. }): void;
  22504. /** @hidden */
  22505. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22506. /**
  22507. * Applies VertexData created from the imported parameters to the geometry
  22508. * @param parsedVertexData the parsed data from an imported file
  22509. * @param geometry the geometry to apply the VertexData to
  22510. */
  22511. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22512. }
  22513. }
  22514. declare module "babylonjs/Morph/morphTarget" {
  22515. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22516. import { Observable } from "babylonjs/Misc/observable";
  22517. import { Nullable, FloatArray } from "babylonjs/types";
  22518. import { Scene } from "babylonjs/scene";
  22519. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22520. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22521. /**
  22522. * Defines a target to use with MorphTargetManager
  22523. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22524. */
  22525. export class MorphTarget implements IAnimatable {
  22526. /** defines the name of the target */
  22527. name: string;
  22528. /**
  22529. * Gets or sets the list of animations
  22530. */
  22531. animations: import("babylonjs/Animations/animation").Animation[];
  22532. private _scene;
  22533. private _positions;
  22534. private _normals;
  22535. private _tangents;
  22536. private _uvs;
  22537. private _influence;
  22538. /**
  22539. * Observable raised when the influence changes
  22540. */
  22541. onInfluenceChanged: Observable<boolean>;
  22542. /** @hidden */
  22543. _onDataLayoutChanged: Observable<void>;
  22544. /**
  22545. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22546. */
  22547. influence: number;
  22548. /**
  22549. * Gets or sets the id of the morph Target
  22550. */
  22551. id: string;
  22552. private _animationPropertiesOverride;
  22553. /**
  22554. * Gets or sets the animation properties override
  22555. */
  22556. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22557. /**
  22558. * Creates a new MorphTarget
  22559. * @param name defines the name of the target
  22560. * @param influence defines the influence to use
  22561. * @param scene defines the scene the morphtarget belongs to
  22562. */
  22563. constructor(
  22564. /** defines the name of the target */
  22565. name: string, influence?: number, scene?: Nullable<Scene>);
  22566. /**
  22567. * Gets a boolean defining if the target contains position data
  22568. */
  22569. readonly hasPositions: boolean;
  22570. /**
  22571. * Gets a boolean defining if the target contains normal data
  22572. */
  22573. readonly hasNormals: boolean;
  22574. /**
  22575. * Gets a boolean defining if the target contains tangent data
  22576. */
  22577. readonly hasTangents: boolean;
  22578. /**
  22579. * Gets a boolean defining if the target contains texture coordinates data
  22580. */
  22581. readonly hasUVs: boolean;
  22582. /**
  22583. * Affects position data to this target
  22584. * @param data defines the position data to use
  22585. */
  22586. setPositions(data: Nullable<FloatArray>): void;
  22587. /**
  22588. * Gets the position data stored in this target
  22589. * @returns a FloatArray containing the position data (or null if not present)
  22590. */
  22591. getPositions(): Nullable<FloatArray>;
  22592. /**
  22593. * Affects normal data to this target
  22594. * @param data defines the normal data to use
  22595. */
  22596. setNormals(data: Nullable<FloatArray>): void;
  22597. /**
  22598. * Gets the normal data stored in this target
  22599. * @returns a FloatArray containing the normal data (or null if not present)
  22600. */
  22601. getNormals(): Nullable<FloatArray>;
  22602. /**
  22603. * Affects tangent data to this target
  22604. * @param data defines the tangent data to use
  22605. */
  22606. setTangents(data: Nullable<FloatArray>): void;
  22607. /**
  22608. * Gets the tangent data stored in this target
  22609. * @returns a FloatArray containing the tangent data (or null if not present)
  22610. */
  22611. getTangents(): Nullable<FloatArray>;
  22612. /**
  22613. * Affects texture coordinates data to this target
  22614. * @param data defines the texture coordinates data to use
  22615. */
  22616. setUVs(data: Nullable<FloatArray>): void;
  22617. /**
  22618. * Gets the texture coordinates data stored in this target
  22619. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22620. */
  22621. getUVs(): Nullable<FloatArray>;
  22622. /**
  22623. * Serializes the current target into a Serialization object
  22624. * @returns the serialized object
  22625. */
  22626. serialize(): any;
  22627. /**
  22628. * Returns the string "MorphTarget"
  22629. * @returns "MorphTarget"
  22630. */
  22631. getClassName(): string;
  22632. /**
  22633. * Creates a new target from serialized data
  22634. * @param serializationObject defines the serialized data to use
  22635. * @returns a new MorphTarget
  22636. */
  22637. static Parse(serializationObject: any): MorphTarget;
  22638. /**
  22639. * Creates a MorphTarget from mesh data
  22640. * @param mesh defines the source mesh
  22641. * @param name defines the name to use for the new target
  22642. * @param influence defines the influence to attach to the target
  22643. * @returns a new MorphTarget
  22644. */
  22645. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22646. }
  22647. }
  22648. declare module "babylonjs/Morph/morphTargetManager" {
  22649. import { Nullable } from "babylonjs/types";
  22650. import { Scene } from "babylonjs/scene";
  22651. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22652. /**
  22653. * This class is used to deform meshes using morphing between different targets
  22654. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22655. */
  22656. export class MorphTargetManager {
  22657. private _targets;
  22658. private _targetInfluenceChangedObservers;
  22659. private _targetDataLayoutChangedObservers;
  22660. private _activeTargets;
  22661. private _scene;
  22662. private _influences;
  22663. private _supportsNormals;
  22664. private _supportsTangents;
  22665. private _supportsUVs;
  22666. private _vertexCount;
  22667. private _uniqueId;
  22668. private _tempInfluences;
  22669. /**
  22670. * Gets or sets a boolean indicating if normals must be morphed
  22671. */
  22672. enableNormalMorphing: boolean;
  22673. /**
  22674. * Gets or sets a boolean indicating if tangents must be morphed
  22675. */
  22676. enableTangentMorphing: boolean;
  22677. /**
  22678. * Gets or sets a boolean indicating if UV must be morphed
  22679. */
  22680. enableUVMorphing: boolean;
  22681. /**
  22682. * Creates a new MorphTargetManager
  22683. * @param scene defines the current scene
  22684. */
  22685. constructor(scene?: Nullable<Scene>);
  22686. /**
  22687. * Gets the unique ID of this manager
  22688. */
  22689. readonly uniqueId: number;
  22690. /**
  22691. * Gets the number of vertices handled by this manager
  22692. */
  22693. readonly vertexCount: number;
  22694. /**
  22695. * Gets a boolean indicating if this manager supports morphing of normals
  22696. */
  22697. readonly supportsNormals: boolean;
  22698. /**
  22699. * Gets a boolean indicating if this manager supports morphing of tangents
  22700. */
  22701. readonly supportsTangents: boolean;
  22702. /**
  22703. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22704. */
  22705. readonly supportsUVs: boolean;
  22706. /**
  22707. * Gets the number of targets stored in this manager
  22708. */
  22709. readonly numTargets: number;
  22710. /**
  22711. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22712. */
  22713. readonly numInfluencers: number;
  22714. /**
  22715. * Gets the list of influences (one per target)
  22716. */
  22717. readonly influences: Float32Array;
  22718. /**
  22719. * Gets the active target at specified index. An active target is a target with an influence > 0
  22720. * @param index defines the index to check
  22721. * @returns the requested target
  22722. */
  22723. getActiveTarget(index: number): MorphTarget;
  22724. /**
  22725. * Gets the target at specified index
  22726. * @param index defines the index to check
  22727. * @returns the requested target
  22728. */
  22729. getTarget(index: number): MorphTarget;
  22730. /**
  22731. * Add a new target to this manager
  22732. * @param target defines the target to add
  22733. */
  22734. addTarget(target: MorphTarget): void;
  22735. /**
  22736. * Removes a target from the manager
  22737. * @param target defines the target to remove
  22738. */
  22739. removeTarget(target: MorphTarget): void;
  22740. /**
  22741. * Serializes the current manager into a Serialization object
  22742. * @returns the serialized object
  22743. */
  22744. serialize(): any;
  22745. private _syncActiveTargets;
  22746. /**
  22747. * Syncrhonize the targets with all the meshes using this morph target manager
  22748. */
  22749. synchronize(): void;
  22750. /**
  22751. * Creates a new MorphTargetManager from serialized data
  22752. * @param serializationObject defines the serialized data
  22753. * @param scene defines the hosting scene
  22754. * @returns the new MorphTargetManager
  22755. */
  22756. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22757. }
  22758. }
  22759. declare module "babylonjs/Meshes/meshLODLevel" {
  22760. import { Mesh } from "babylonjs/Meshes/mesh";
  22761. import { Nullable } from "babylonjs/types";
  22762. /**
  22763. * Class used to represent a specific level of detail of a mesh
  22764. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22765. */
  22766. export class MeshLODLevel {
  22767. /** Defines the distance where this level should start being displayed */
  22768. distance: number;
  22769. /** Defines the mesh to use to render this level */
  22770. mesh: Nullable<Mesh>;
  22771. /**
  22772. * Creates a new LOD level
  22773. * @param distance defines the distance where this level should star being displayed
  22774. * @param mesh defines the mesh to use to render this level
  22775. */
  22776. constructor(
  22777. /** Defines the distance where this level should start being displayed */
  22778. distance: number,
  22779. /** Defines the mesh to use to render this level */
  22780. mesh: Nullable<Mesh>);
  22781. }
  22782. }
  22783. declare module "babylonjs/Meshes/groundMesh" {
  22784. import { Scene } from "babylonjs/scene";
  22785. import { Vector3 } from "babylonjs/Maths/math.vector";
  22786. import { Mesh } from "babylonjs/Meshes/mesh";
  22787. /**
  22788. * Mesh representing the gorund
  22789. */
  22790. export class GroundMesh extends Mesh {
  22791. /** If octree should be generated */
  22792. generateOctree: boolean;
  22793. private _heightQuads;
  22794. /** @hidden */
  22795. _subdivisionsX: number;
  22796. /** @hidden */
  22797. _subdivisionsY: number;
  22798. /** @hidden */
  22799. _width: number;
  22800. /** @hidden */
  22801. _height: number;
  22802. /** @hidden */
  22803. _minX: number;
  22804. /** @hidden */
  22805. _maxX: number;
  22806. /** @hidden */
  22807. _minZ: number;
  22808. /** @hidden */
  22809. _maxZ: number;
  22810. constructor(name: string, scene: Scene);
  22811. /**
  22812. * "GroundMesh"
  22813. * @returns "GroundMesh"
  22814. */
  22815. getClassName(): string;
  22816. /**
  22817. * The minimum of x and y subdivisions
  22818. */
  22819. readonly subdivisions: number;
  22820. /**
  22821. * X subdivisions
  22822. */
  22823. readonly subdivisionsX: number;
  22824. /**
  22825. * Y subdivisions
  22826. */
  22827. readonly subdivisionsY: number;
  22828. /**
  22829. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22830. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22831. * @param chunksCount the number of subdivisions for x and y
  22832. * @param octreeBlocksSize (Default: 32)
  22833. */
  22834. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22835. /**
  22836. * Returns a height (y) value in the Worl system :
  22837. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22838. * @param x x coordinate
  22839. * @param z z coordinate
  22840. * @returns the ground y position if (x, z) are outside the ground surface.
  22841. */
  22842. getHeightAtCoordinates(x: number, z: number): number;
  22843. /**
  22844. * Returns a normalized vector (Vector3) orthogonal to the ground
  22845. * at the ground coordinates (x, z) expressed in the World system.
  22846. * @param x x coordinate
  22847. * @param z z coordinate
  22848. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22849. */
  22850. getNormalAtCoordinates(x: number, z: number): Vector3;
  22851. /**
  22852. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22853. * at the ground coordinates (x, z) expressed in the World system.
  22854. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22855. * @param x x coordinate
  22856. * @param z z coordinate
  22857. * @param ref vector to store the result
  22858. * @returns the GroundMesh.
  22859. */
  22860. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22861. /**
  22862. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22863. * if the ground has been updated.
  22864. * This can be used in the render loop.
  22865. * @returns the GroundMesh.
  22866. */
  22867. updateCoordinateHeights(): GroundMesh;
  22868. private _getFacetAt;
  22869. private _initHeightQuads;
  22870. private _computeHeightQuads;
  22871. /**
  22872. * Serializes this ground mesh
  22873. * @param serializationObject object to write serialization to
  22874. */
  22875. serialize(serializationObject: any): void;
  22876. /**
  22877. * Parses a serialized ground mesh
  22878. * @param parsedMesh the serialized mesh
  22879. * @param scene the scene to create the ground mesh in
  22880. * @returns the created ground mesh
  22881. */
  22882. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22883. }
  22884. }
  22885. declare module "babylonjs/Physics/physicsJoint" {
  22886. import { Vector3 } from "babylonjs/Maths/math.vector";
  22887. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  22888. /**
  22889. * Interface for Physics-Joint data
  22890. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22891. */
  22892. export interface PhysicsJointData {
  22893. /**
  22894. * The main pivot of the joint
  22895. */
  22896. mainPivot?: Vector3;
  22897. /**
  22898. * The connected pivot of the joint
  22899. */
  22900. connectedPivot?: Vector3;
  22901. /**
  22902. * The main axis of the joint
  22903. */
  22904. mainAxis?: Vector3;
  22905. /**
  22906. * The connected axis of the joint
  22907. */
  22908. connectedAxis?: Vector3;
  22909. /**
  22910. * The collision of the joint
  22911. */
  22912. collision?: boolean;
  22913. /**
  22914. * Native Oimo/Cannon/Energy data
  22915. */
  22916. nativeParams?: any;
  22917. }
  22918. /**
  22919. * This is a holder class for the physics joint created by the physics plugin
  22920. * It holds a set of functions to control the underlying joint
  22921. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22922. */
  22923. export class PhysicsJoint {
  22924. /**
  22925. * The type of the physics joint
  22926. */
  22927. type: number;
  22928. /**
  22929. * The data for the physics joint
  22930. */
  22931. jointData: PhysicsJointData;
  22932. private _physicsJoint;
  22933. protected _physicsPlugin: IPhysicsEnginePlugin;
  22934. /**
  22935. * Initializes the physics joint
  22936. * @param type The type of the physics joint
  22937. * @param jointData The data for the physics joint
  22938. */
  22939. constructor(
  22940. /**
  22941. * The type of the physics joint
  22942. */
  22943. type: number,
  22944. /**
  22945. * The data for the physics joint
  22946. */
  22947. jointData: PhysicsJointData);
  22948. /**
  22949. * Gets the physics joint
  22950. */
  22951. /**
  22952. * Sets the physics joint
  22953. */
  22954. physicsJoint: any;
  22955. /**
  22956. * Sets the physics plugin
  22957. */
  22958. physicsPlugin: IPhysicsEnginePlugin;
  22959. /**
  22960. * Execute a function that is physics-plugin specific.
  22961. * @param {Function} func the function that will be executed.
  22962. * It accepts two parameters: the physics world and the physics joint
  22963. */
  22964. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22965. /**
  22966. * Distance-Joint type
  22967. */
  22968. static DistanceJoint: number;
  22969. /**
  22970. * Hinge-Joint type
  22971. */
  22972. static HingeJoint: number;
  22973. /**
  22974. * Ball-and-Socket joint type
  22975. */
  22976. static BallAndSocketJoint: number;
  22977. /**
  22978. * Wheel-Joint type
  22979. */
  22980. static WheelJoint: number;
  22981. /**
  22982. * Slider-Joint type
  22983. */
  22984. static SliderJoint: number;
  22985. /**
  22986. * Prismatic-Joint type
  22987. */
  22988. static PrismaticJoint: number;
  22989. /**
  22990. * Universal-Joint type
  22991. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22992. */
  22993. static UniversalJoint: number;
  22994. /**
  22995. * Hinge-Joint 2 type
  22996. */
  22997. static Hinge2Joint: number;
  22998. /**
  22999. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23000. */
  23001. static PointToPointJoint: number;
  23002. /**
  23003. * Spring-Joint type
  23004. */
  23005. static SpringJoint: number;
  23006. /**
  23007. * Lock-Joint type
  23008. */
  23009. static LockJoint: number;
  23010. }
  23011. /**
  23012. * A class representing a physics distance joint
  23013. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23014. */
  23015. export class DistanceJoint extends PhysicsJoint {
  23016. /**
  23017. *
  23018. * @param jointData The data for the Distance-Joint
  23019. */
  23020. constructor(jointData: DistanceJointData);
  23021. /**
  23022. * Update the predefined distance.
  23023. * @param maxDistance The maximum preferred distance
  23024. * @param minDistance The minimum preferred distance
  23025. */
  23026. updateDistance(maxDistance: number, minDistance?: number): void;
  23027. }
  23028. /**
  23029. * Represents a Motor-Enabled Joint
  23030. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23031. */
  23032. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23033. /**
  23034. * Initializes the Motor-Enabled Joint
  23035. * @param type The type of the joint
  23036. * @param jointData The physica joint data for the joint
  23037. */
  23038. constructor(type: number, jointData: PhysicsJointData);
  23039. /**
  23040. * Set the motor values.
  23041. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23042. * @param force the force to apply
  23043. * @param maxForce max force for this motor.
  23044. */
  23045. setMotor(force?: number, maxForce?: number): void;
  23046. /**
  23047. * Set the motor's limits.
  23048. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23049. * @param upperLimit The upper limit of the motor
  23050. * @param lowerLimit The lower limit of the motor
  23051. */
  23052. setLimit(upperLimit: number, lowerLimit?: number): void;
  23053. }
  23054. /**
  23055. * This class represents a single physics Hinge-Joint
  23056. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23057. */
  23058. export class HingeJoint extends MotorEnabledJoint {
  23059. /**
  23060. * Initializes the Hinge-Joint
  23061. * @param jointData The joint data for the Hinge-Joint
  23062. */
  23063. constructor(jointData: PhysicsJointData);
  23064. /**
  23065. * Set the motor values.
  23066. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23067. * @param {number} force the force to apply
  23068. * @param {number} maxForce max force for this motor.
  23069. */
  23070. setMotor(force?: number, maxForce?: number): void;
  23071. /**
  23072. * Set the motor's limits.
  23073. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23074. * @param upperLimit The upper limit of the motor
  23075. * @param lowerLimit The lower limit of the motor
  23076. */
  23077. setLimit(upperLimit: number, lowerLimit?: number): void;
  23078. }
  23079. /**
  23080. * This class represents a dual hinge physics joint (same as wheel joint)
  23081. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23082. */
  23083. export class Hinge2Joint extends MotorEnabledJoint {
  23084. /**
  23085. * Initializes the Hinge2-Joint
  23086. * @param jointData The joint data for the Hinge2-Joint
  23087. */
  23088. constructor(jointData: PhysicsJointData);
  23089. /**
  23090. * Set the motor values.
  23091. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23092. * @param {number} targetSpeed the speed the motor is to reach
  23093. * @param {number} maxForce max force for this motor.
  23094. * @param {motorIndex} the motor's index, 0 or 1.
  23095. */
  23096. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23097. /**
  23098. * Set the motor limits.
  23099. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23100. * @param {number} upperLimit the upper limit
  23101. * @param {number} lowerLimit lower limit
  23102. * @param {motorIndex} the motor's index, 0 or 1.
  23103. */
  23104. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23105. }
  23106. /**
  23107. * Interface for a motor enabled joint
  23108. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23109. */
  23110. export interface IMotorEnabledJoint {
  23111. /**
  23112. * Physics joint
  23113. */
  23114. physicsJoint: any;
  23115. /**
  23116. * Sets the motor of the motor-enabled joint
  23117. * @param force The force of the motor
  23118. * @param maxForce The maximum force of the motor
  23119. * @param motorIndex The index of the motor
  23120. */
  23121. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23122. /**
  23123. * Sets the limit of the motor
  23124. * @param upperLimit The upper limit of the motor
  23125. * @param lowerLimit The lower limit of the motor
  23126. * @param motorIndex The index of the motor
  23127. */
  23128. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23129. }
  23130. /**
  23131. * Joint data for a Distance-Joint
  23132. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23133. */
  23134. export interface DistanceJointData extends PhysicsJointData {
  23135. /**
  23136. * Max distance the 2 joint objects can be apart
  23137. */
  23138. maxDistance: number;
  23139. }
  23140. /**
  23141. * Joint data from a spring joint
  23142. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23143. */
  23144. export interface SpringJointData extends PhysicsJointData {
  23145. /**
  23146. * Length of the spring
  23147. */
  23148. length: number;
  23149. /**
  23150. * Stiffness of the spring
  23151. */
  23152. stiffness: number;
  23153. /**
  23154. * Damping of the spring
  23155. */
  23156. damping: number;
  23157. /** this callback will be called when applying the force to the impostors. */
  23158. forceApplicationCallback: () => void;
  23159. }
  23160. }
  23161. declare module "babylonjs/Physics/physicsRaycastResult" {
  23162. import { Vector3 } from "babylonjs/Maths/math.vector";
  23163. /**
  23164. * Holds the data for the raycast result
  23165. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23166. */
  23167. export class PhysicsRaycastResult {
  23168. private _hasHit;
  23169. private _hitDistance;
  23170. private _hitNormalWorld;
  23171. private _hitPointWorld;
  23172. private _rayFromWorld;
  23173. private _rayToWorld;
  23174. /**
  23175. * Gets if there was a hit
  23176. */
  23177. readonly hasHit: boolean;
  23178. /**
  23179. * Gets the distance from the hit
  23180. */
  23181. readonly hitDistance: number;
  23182. /**
  23183. * Gets the hit normal/direction in the world
  23184. */
  23185. readonly hitNormalWorld: Vector3;
  23186. /**
  23187. * Gets the hit point in the world
  23188. */
  23189. readonly hitPointWorld: Vector3;
  23190. /**
  23191. * Gets the ray "start point" of the ray in the world
  23192. */
  23193. readonly rayFromWorld: Vector3;
  23194. /**
  23195. * Gets the ray "end point" of the ray in the world
  23196. */
  23197. readonly rayToWorld: Vector3;
  23198. /**
  23199. * Sets the hit data (normal & point in world space)
  23200. * @param hitNormalWorld defines the normal in world space
  23201. * @param hitPointWorld defines the point in world space
  23202. */
  23203. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23204. /**
  23205. * Sets the distance from the start point to the hit point
  23206. * @param distance
  23207. */
  23208. setHitDistance(distance: number): void;
  23209. /**
  23210. * Calculates the distance manually
  23211. */
  23212. calculateHitDistance(): void;
  23213. /**
  23214. * Resets all the values to default
  23215. * @param from The from point on world space
  23216. * @param to The to point on world space
  23217. */
  23218. reset(from?: Vector3, to?: Vector3): void;
  23219. }
  23220. /**
  23221. * Interface for the size containing width and height
  23222. */
  23223. interface IXYZ {
  23224. /**
  23225. * X
  23226. */
  23227. x: number;
  23228. /**
  23229. * Y
  23230. */
  23231. y: number;
  23232. /**
  23233. * Z
  23234. */
  23235. z: number;
  23236. }
  23237. }
  23238. declare module "babylonjs/Physics/IPhysicsEngine" {
  23239. import { Nullable } from "babylonjs/types";
  23240. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23241. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23242. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23243. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23244. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23245. /**
  23246. * Interface used to describe a physics joint
  23247. */
  23248. export interface PhysicsImpostorJoint {
  23249. /** Defines the main impostor to which the joint is linked */
  23250. mainImpostor: PhysicsImpostor;
  23251. /** Defines the impostor that is connected to the main impostor using this joint */
  23252. connectedImpostor: PhysicsImpostor;
  23253. /** Defines the joint itself */
  23254. joint: PhysicsJoint;
  23255. }
  23256. /** @hidden */
  23257. export interface IPhysicsEnginePlugin {
  23258. world: any;
  23259. name: string;
  23260. setGravity(gravity: Vector3): void;
  23261. setTimeStep(timeStep: number): void;
  23262. getTimeStep(): number;
  23263. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23264. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23265. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23266. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23267. removePhysicsBody(impostor: PhysicsImpostor): void;
  23268. generateJoint(joint: PhysicsImpostorJoint): void;
  23269. removeJoint(joint: PhysicsImpostorJoint): void;
  23270. isSupported(): boolean;
  23271. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23272. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23273. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23274. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23275. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23276. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23277. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23278. getBodyMass(impostor: PhysicsImpostor): number;
  23279. getBodyFriction(impostor: PhysicsImpostor): number;
  23280. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23281. getBodyRestitution(impostor: PhysicsImpostor): number;
  23282. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23283. getBodyPressure?(impostor: PhysicsImpostor): number;
  23284. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23285. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23286. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23287. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23288. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23289. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23290. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23291. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23292. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23293. sleepBody(impostor: PhysicsImpostor): void;
  23294. wakeUpBody(impostor: PhysicsImpostor): void;
  23295. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23296. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23297. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23298. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23299. getRadius(impostor: PhysicsImpostor): number;
  23300. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23301. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23302. dispose(): void;
  23303. }
  23304. /**
  23305. * Interface used to define a physics engine
  23306. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23307. */
  23308. export interface IPhysicsEngine {
  23309. /**
  23310. * Gets the gravity vector used by the simulation
  23311. */
  23312. gravity: Vector3;
  23313. /**
  23314. * Sets the gravity vector used by the simulation
  23315. * @param gravity defines the gravity vector to use
  23316. */
  23317. setGravity(gravity: Vector3): void;
  23318. /**
  23319. * Set the time step of the physics engine.
  23320. * Default is 1/60.
  23321. * To slow it down, enter 1/600 for example.
  23322. * To speed it up, 1/30
  23323. * @param newTimeStep the new timestep to apply to this world.
  23324. */
  23325. setTimeStep(newTimeStep: number): void;
  23326. /**
  23327. * Get the time step of the physics engine.
  23328. * @returns the current time step
  23329. */
  23330. getTimeStep(): number;
  23331. /**
  23332. * Release all resources
  23333. */
  23334. dispose(): void;
  23335. /**
  23336. * Gets the name of the current physics plugin
  23337. * @returns the name of the plugin
  23338. */
  23339. getPhysicsPluginName(): string;
  23340. /**
  23341. * Adding a new impostor for the impostor tracking.
  23342. * This will be done by the impostor itself.
  23343. * @param impostor the impostor to add
  23344. */
  23345. addImpostor(impostor: PhysicsImpostor): void;
  23346. /**
  23347. * Remove an impostor from the engine.
  23348. * This impostor and its mesh will not longer be updated by the physics engine.
  23349. * @param impostor the impostor to remove
  23350. */
  23351. removeImpostor(impostor: PhysicsImpostor): void;
  23352. /**
  23353. * Add a joint to the physics engine
  23354. * @param mainImpostor defines the main impostor to which the joint is added.
  23355. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23356. * @param joint defines the joint that will connect both impostors.
  23357. */
  23358. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23359. /**
  23360. * Removes a joint from the simulation
  23361. * @param mainImpostor defines the impostor used with the joint
  23362. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23363. * @param joint defines the joint to remove
  23364. */
  23365. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23366. /**
  23367. * Gets the current plugin used to run the simulation
  23368. * @returns current plugin
  23369. */
  23370. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23371. /**
  23372. * Gets the list of physic impostors
  23373. * @returns an array of PhysicsImpostor
  23374. */
  23375. getImpostors(): Array<PhysicsImpostor>;
  23376. /**
  23377. * Gets the impostor for a physics enabled object
  23378. * @param object defines the object impersonated by the impostor
  23379. * @returns the PhysicsImpostor or null if not found
  23380. */
  23381. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23382. /**
  23383. * Gets the impostor for a physics body object
  23384. * @param body defines physics body used by the impostor
  23385. * @returns the PhysicsImpostor or null if not found
  23386. */
  23387. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23388. /**
  23389. * Does a raycast in the physics world
  23390. * @param from when should the ray start?
  23391. * @param to when should the ray end?
  23392. * @returns PhysicsRaycastResult
  23393. */
  23394. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23395. /**
  23396. * Called by the scene. No need to call it.
  23397. * @param delta defines the timespam between frames
  23398. */
  23399. _step(delta: number): void;
  23400. }
  23401. }
  23402. declare module "babylonjs/Physics/physicsImpostor" {
  23403. import { Nullable, IndicesArray } from "babylonjs/types";
  23404. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23405. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23406. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23407. import { Scene } from "babylonjs/scene";
  23408. import { Bone } from "babylonjs/Bones/bone";
  23409. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23410. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23411. import { Space } from "babylonjs/Maths/math.axis";
  23412. /**
  23413. * The interface for the physics imposter parameters
  23414. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23415. */
  23416. export interface PhysicsImpostorParameters {
  23417. /**
  23418. * The mass of the physics imposter
  23419. */
  23420. mass: number;
  23421. /**
  23422. * The friction of the physics imposter
  23423. */
  23424. friction?: number;
  23425. /**
  23426. * The coefficient of restitution of the physics imposter
  23427. */
  23428. restitution?: number;
  23429. /**
  23430. * The native options of the physics imposter
  23431. */
  23432. nativeOptions?: any;
  23433. /**
  23434. * Specifies if the parent should be ignored
  23435. */
  23436. ignoreParent?: boolean;
  23437. /**
  23438. * Specifies if bi-directional transformations should be disabled
  23439. */
  23440. disableBidirectionalTransformation?: boolean;
  23441. /**
  23442. * The pressure inside the physics imposter, soft object only
  23443. */
  23444. pressure?: number;
  23445. /**
  23446. * The stiffness the physics imposter, soft object only
  23447. */
  23448. stiffness?: number;
  23449. /**
  23450. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23451. */
  23452. velocityIterations?: number;
  23453. /**
  23454. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23455. */
  23456. positionIterations?: number;
  23457. /**
  23458. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23459. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23460. * Add to fix multiple points
  23461. */
  23462. fixedPoints?: number;
  23463. /**
  23464. * The collision margin around a soft object
  23465. */
  23466. margin?: number;
  23467. /**
  23468. * The collision margin around a soft object
  23469. */
  23470. damping?: number;
  23471. /**
  23472. * The path for a rope based on an extrusion
  23473. */
  23474. path?: any;
  23475. /**
  23476. * The shape of an extrusion used for a rope based on an extrusion
  23477. */
  23478. shape?: any;
  23479. }
  23480. /**
  23481. * Interface for a physics-enabled object
  23482. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23483. */
  23484. export interface IPhysicsEnabledObject {
  23485. /**
  23486. * The position of the physics-enabled object
  23487. */
  23488. position: Vector3;
  23489. /**
  23490. * The rotation of the physics-enabled object
  23491. */
  23492. rotationQuaternion: Nullable<Quaternion>;
  23493. /**
  23494. * The scale of the physics-enabled object
  23495. */
  23496. scaling: Vector3;
  23497. /**
  23498. * The rotation of the physics-enabled object
  23499. */
  23500. rotation?: Vector3;
  23501. /**
  23502. * The parent of the physics-enabled object
  23503. */
  23504. parent?: any;
  23505. /**
  23506. * The bounding info of the physics-enabled object
  23507. * @returns The bounding info of the physics-enabled object
  23508. */
  23509. getBoundingInfo(): BoundingInfo;
  23510. /**
  23511. * Computes the world matrix
  23512. * @param force Specifies if the world matrix should be computed by force
  23513. * @returns A world matrix
  23514. */
  23515. computeWorldMatrix(force: boolean): Matrix;
  23516. /**
  23517. * Gets the world matrix
  23518. * @returns A world matrix
  23519. */
  23520. getWorldMatrix?(): Matrix;
  23521. /**
  23522. * Gets the child meshes
  23523. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23524. * @returns An array of abstract meshes
  23525. */
  23526. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23527. /**
  23528. * Gets the vertex data
  23529. * @param kind The type of vertex data
  23530. * @returns A nullable array of numbers, or a float32 array
  23531. */
  23532. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23533. /**
  23534. * Gets the indices from the mesh
  23535. * @returns A nullable array of index arrays
  23536. */
  23537. getIndices?(): Nullable<IndicesArray>;
  23538. /**
  23539. * Gets the scene from the mesh
  23540. * @returns the indices array or null
  23541. */
  23542. getScene?(): Scene;
  23543. /**
  23544. * Gets the absolute position from the mesh
  23545. * @returns the absolute position
  23546. */
  23547. getAbsolutePosition(): Vector3;
  23548. /**
  23549. * Gets the absolute pivot point from the mesh
  23550. * @returns the absolute pivot point
  23551. */
  23552. getAbsolutePivotPoint(): Vector3;
  23553. /**
  23554. * Rotates the mesh
  23555. * @param axis The axis of rotation
  23556. * @param amount The amount of rotation
  23557. * @param space The space of the rotation
  23558. * @returns The rotation transform node
  23559. */
  23560. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23561. /**
  23562. * Translates the mesh
  23563. * @param axis The axis of translation
  23564. * @param distance The distance of translation
  23565. * @param space The space of the translation
  23566. * @returns The transform node
  23567. */
  23568. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23569. /**
  23570. * Sets the absolute position of the mesh
  23571. * @param absolutePosition The absolute position of the mesh
  23572. * @returns The transform node
  23573. */
  23574. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23575. /**
  23576. * Gets the class name of the mesh
  23577. * @returns The class name
  23578. */
  23579. getClassName(): string;
  23580. }
  23581. /**
  23582. * Represents a physics imposter
  23583. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23584. */
  23585. export class PhysicsImpostor {
  23586. /**
  23587. * The physics-enabled object used as the physics imposter
  23588. */
  23589. object: IPhysicsEnabledObject;
  23590. /**
  23591. * The type of the physics imposter
  23592. */
  23593. type: number;
  23594. private _options;
  23595. private _scene?;
  23596. /**
  23597. * The default object size of the imposter
  23598. */
  23599. static DEFAULT_OBJECT_SIZE: Vector3;
  23600. /**
  23601. * The identity quaternion of the imposter
  23602. */
  23603. static IDENTITY_QUATERNION: Quaternion;
  23604. /** @hidden */
  23605. _pluginData: any;
  23606. private _physicsEngine;
  23607. private _physicsBody;
  23608. private _bodyUpdateRequired;
  23609. private _onBeforePhysicsStepCallbacks;
  23610. private _onAfterPhysicsStepCallbacks;
  23611. /** @hidden */
  23612. _onPhysicsCollideCallbacks: Array<{
  23613. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23614. otherImpostors: Array<PhysicsImpostor>;
  23615. }>;
  23616. private _deltaPosition;
  23617. private _deltaRotation;
  23618. private _deltaRotationConjugated;
  23619. /** @hidden */
  23620. _isFromLine: boolean;
  23621. private _parent;
  23622. private _isDisposed;
  23623. private static _tmpVecs;
  23624. private static _tmpQuat;
  23625. /**
  23626. * Specifies if the physics imposter is disposed
  23627. */
  23628. readonly isDisposed: boolean;
  23629. /**
  23630. * Gets the mass of the physics imposter
  23631. */
  23632. mass: number;
  23633. /**
  23634. * Gets the coefficient of friction
  23635. */
  23636. /**
  23637. * Sets the coefficient of friction
  23638. */
  23639. friction: number;
  23640. /**
  23641. * Gets the coefficient of restitution
  23642. */
  23643. /**
  23644. * Sets the coefficient of restitution
  23645. */
  23646. restitution: number;
  23647. /**
  23648. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23649. */
  23650. /**
  23651. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23652. */
  23653. pressure: number;
  23654. /**
  23655. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23656. */
  23657. /**
  23658. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23659. */
  23660. stiffness: number;
  23661. /**
  23662. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23663. */
  23664. /**
  23665. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23666. */
  23667. velocityIterations: number;
  23668. /**
  23669. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23670. */
  23671. /**
  23672. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23673. */
  23674. positionIterations: number;
  23675. /**
  23676. * The unique id of the physics imposter
  23677. * set by the physics engine when adding this impostor to the array
  23678. */
  23679. uniqueId: number;
  23680. /**
  23681. * @hidden
  23682. */
  23683. soft: boolean;
  23684. /**
  23685. * @hidden
  23686. */
  23687. segments: number;
  23688. private _joints;
  23689. /**
  23690. * Initializes the physics imposter
  23691. * @param object The physics-enabled object used as the physics imposter
  23692. * @param type The type of the physics imposter
  23693. * @param _options The options for the physics imposter
  23694. * @param _scene The Babylon scene
  23695. */
  23696. constructor(
  23697. /**
  23698. * The physics-enabled object used as the physics imposter
  23699. */
  23700. object: IPhysicsEnabledObject,
  23701. /**
  23702. * The type of the physics imposter
  23703. */
  23704. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23705. /**
  23706. * This function will completly initialize this impostor.
  23707. * It will create a new body - but only if this mesh has no parent.
  23708. * If it has, this impostor will not be used other than to define the impostor
  23709. * of the child mesh.
  23710. * @hidden
  23711. */
  23712. _init(): void;
  23713. private _getPhysicsParent;
  23714. /**
  23715. * Should a new body be generated.
  23716. * @returns boolean specifying if body initialization is required
  23717. */
  23718. isBodyInitRequired(): boolean;
  23719. /**
  23720. * Sets the updated scaling
  23721. * @param updated Specifies if the scaling is updated
  23722. */
  23723. setScalingUpdated(): void;
  23724. /**
  23725. * Force a regeneration of this or the parent's impostor's body.
  23726. * Use under cautious - This will remove all joints already implemented.
  23727. */
  23728. forceUpdate(): void;
  23729. /**
  23730. * Gets the body that holds this impostor. Either its own, or its parent.
  23731. */
  23732. /**
  23733. * Set the physics body. Used mainly by the physics engine/plugin
  23734. */
  23735. physicsBody: any;
  23736. /**
  23737. * Get the parent of the physics imposter
  23738. * @returns Physics imposter or null
  23739. */
  23740. /**
  23741. * Sets the parent of the physics imposter
  23742. */
  23743. parent: Nullable<PhysicsImpostor>;
  23744. /**
  23745. * Resets the update flags
  23746. */
  23747. resetUpdateFlags(): void;
  23748. /**
  23749. * Gets the object extend size
  23750. * @returns the object extend size
  23751. */
  23752. getObjectExtendSize(): Vector3;
  23753. /**
  23754. * Gets the object center
  23755. * @returns The object center
  23756. */
  23757. getObjectCenter(): Vector3;
  23758. /**
  23759. * Get a specific parametes from the options parameter
  23760. * @param paramName The object parameter name
  23761. * @returns The object parameter
  23762. */
  23763. getParam(paramName: string): any;
  23764. /**
  23765. * Sets a specific parameter in the options given to the physics plugin
  23766. * @param paramName The parameter name
  23767. * @param value The value of the parameter
  23768. */
  23769. setParam(paramName: string, value: number): void;
  23770. /**
  23771. * Specifically change the body's mass option. Won't recreate the physics body object
  23772. * @param mass The mass of the physics imposter
  23773. */
  23774. setMass(mass: number): void;
  23775. /**
  23776. * Gets the linear velocity
  23777. * @returns linear velocity or null
  23778. */
  23779. getLinearVelocity(): Nullable<Vector3>;
  23780. /**
  23781. * Sets the linear velocity
  23782. * @param velocity linear velocity or null
  23783. */
  23784. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23785. /**
  23786. * Gets the angular velocity
  23787. * @returns angular velocity or null
  23788. */
  23789. getAngularVelocity(): Nullable<Vector3>;
  23790. /**
  23791. * Sets the angular velocity
  23792. * @param velocity The velocity or null
  23793. */
  23794. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23795. /**
  23796. * Execute a function with the physics plugin native code
  23797. * Provide a function the will have two variables - the world object and the physics body object
  23798. * @param func The function to execute with the physics plugin native code
  23799. */
  23800. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23801. /**
  23802. * Register a function that will be executed before the physics world is stepping forward
  23803. * @param func The function to execute before the physics world is stepped forward
  23804. */
  23805. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23806. /**
  23807. * Unregister a function that will be executed before the physics world is stepping forward
  23808. * @param func The function to execute before the physics world is stepped forward
  23809. */
  23810. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23811. /**
  23812. * Register a function that will be executed after the physics step
  23813. * @param func The function to execute after physics step
  23814. */
  23815. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23816. /**
  23817. * Unregisters a function that will be executed after the physics step
  23818. * @param func The function to execute after physics step
  23819. */
  23820. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23821. /**
  23822. * register a function that will be executed when this impostor collides against a different body
  23823. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23824. * @param func Callback that is executed on collision
  23825. */
  23826. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23827. /**
  23828. * Unregisters the physics imposter on contact
  23829. * @param collideAgainst The physics object to collide against
  23830. * @param func Callback to execute on collision
  23831. */
  23832. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23833. private _tmpQuat;
  23834. private _tmpQuat2;
  23835. /**
  23836. * Get the parent rotation
  23837. * @returns The parent rotation
  23838. */
  23839. getParentsRotation(): Quaternion;
  23840. /**
  23841. * this function is executed by the physics engine.
  23842. */
  23843. beforeStep: () => void;
  23844. /**
  23845. * this function is executed by the physics engine
  23846. */
  23847. afterStep: () => void;
  23848. /**
  23849. * Legacy collision detection event support
  23850. */
  23851. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23852. /**
  23853. * event and body object due to cannon's event-based architecture.
  23854. */
  23855. onCollide: (e: {
  23856. body: any;
  23857. }) => void;
  23858. /**
  23859. * Apply a force
  23860. * @param force The force to apply
  23861. * @param contactPoint The contact point for the force
  23862. * @returns The physics imposter
  23863. */
  23864. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23865. /**
  23866. * Apply an impulse
  23867. * @param force The impulse force
  23868. * @param contactPoint The contact point for the impulse force
  23869. * @returns The physics imposter
  23870. */
  23871. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23872. /**
  23873. * A help function to create a joint
  23874. * @param otherImpostor A physics imposter used to create a joint
  23875. * @param jointType The type of joint
  23876. * @param jointData The data for the joint
  23877. * @returns The physics imposter
  23878. */
  23879. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23880. /**
  23881. * Add a joint to this impostor with a different impostor
  23882. * @param otherImpostor A physics imposter used to add a joint
  23883. * @param joint The joint to add
  23884. * @returns The physics imposter
  23885. */
  23886. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23887. /**
  23888. * Add an anchor to a cloth impostor
  23889. * @param otherImpostor rigid impostor to anchor to
  23890. * @param width ratio across width from 0 to 1
  23891. * @param height ratio up height from 0 to 1
  23892. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23893. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23894. * @returns impostor the soft imposter
  23895. */
  23896. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23897. /**
  23898. * Add a hook to a rope impostor
  23899. * @param otherImpostor rigid impostor to anchor to
  23900. * @param length ratio across rope from 0 to 1
  23901. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23902. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23903. * @returns impostor the rope imposter
  23904. */
  23905. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23906. /**
  23907. * Will keep this body still, in a sleep mode.
  23908. * @returns the physics imposter
  23909. */
  23910. sleep(): PhysicsImpostor;
  23911. /**
  23912. * Wake the body up.
  23913. * @returns The physics imposter
  23914. */
  23915. wakeUp(): PhysicsImpostor;
  23916. /**
  23917. * Clones the physics imposter
  23918. * @param newObject The physics imposter clones to this physics-enabled object
  23919. * @returns A nullable physics imposter
  23920. */
  23921. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23922. /**
  23923. * Disposes the physics imposter
  23924. */
  23925. dispose(): void;
  23926. /**
  23927. * Sets the delta position
  23928. * @param position The delta position amount
  23929. */
  23930. setDeltaPosition(position: Vector3): void;
  23931. /**
  23932. * Sets the delta rotation
  23933. * @param rotation The delta rotation amount
  23934. */
  23935. setDeltaRotation(rotation: Quaternion): void;
  23936. /**
  23937. * Gets the box size of the physics imposter and stores the result in the input parameter
  23938. * @param result Stores the box size
  23939. * @returns The physics imposter
  23940. */
  23941. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23942. /**
  23943. * Gets the radius of the physics imposter
  23944. * @returns Radius of the physics imposter
  23945. */
  23946. getRadius(): number;
  23947. /**
  23948. * Sync a bone with this impostor
  23949. * @param bone The bone to sync to the impostor.
  23950. * @param boneMesh The mesh that the bone is influencing.
  23951. * @param jointPivot The pivot of the joint / bone in local space.
  23952. * @param distToJoint Optional distance from the impostor to the joint.
  23953. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23954. */
  23955. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23956. /**
  23957. * Sync impostor to a bone
  23958. * @param bone The bone that the impostor will be synced to.
  23959. * @param boneMesh The mesh that the bone is influencing.
  23960. * @param jointPivot The pivot of the joint / bone in local space.
  23961. * @param distToJoint Optional distance from the impostor to the joint.
  23962. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23963. * @param boneAxis Optional vector3 axis the bone is aligned with
  23964. */
  23965. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23966. /**
  23967. * No-Imposter type
  23968. */
  23969. static NoImpostor: number;
  23970. /**
  23971. * Sphere-Imposter type
  23972. */
  23973. static SphereImpostor: number;
  23974. /**
  23975. * Box-Imposter type
  23976. */
  23977. static BoxImpostor: number;
  23978. /**
  23979. * Plane-Imposter type
  23980. */
  23981. static PlaneImpostor: number;
  23982. /**
  23983. * Mesh-imposter type
  23984. */
  23985. static MeshImpostor: number;
  23986. /**
  23987. * Capsule-Impostor type (Ammo.js plugin only)
  23988. */
  23989. static CapsuleImpostor: number;
  23990. /**
  23991. * Cylinder-Imposter type
  23992. */
  23993. static CylinderImpostor: number;
  23994. /**
  23995. * Particle-Imposter type
  23996. */
  23997. static ParticleImpostor: number;
  23998. /**
  23999. * Heightmap-Imposter type
  24000. */
  24001. static HeightmapImpostor: number;
  24002. /**
  24003. * ConvexHull-Impostor type (Ammo.js plugin only)
  24004. */
  24005. static ConvexHullImpostor: number;
  24006. /**
  24007. * Rope-Imposter type
  24008. */
  24009. static RopeImpostor: number;
  24010. /**
  24011. * Cloth-Imposter type
  24012. */
  24013. static ClothImpostor: number;
  24014. /**
  24015. * Softbody-Imposter type
  24016. */
  24017. static SoftbodyImpostor: number;
  24018. }
  24019. }
  24020. declare module "babylonjs/Meshes/mesh" {
  24021. import { Observable } from "babylonjs/Misc/observable";
  24022. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24023. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24024. import { Camera } from "babylonjs/Cameras/camera";
  24025. import { Scene } from "babylonjs/scene";
  24026. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24027. import { Color4 } from "babylonjs/Maths/math.color";
  24028. import { Engine } from "babylonjs/Engines/engine";
  24029. import { Node } from "babylonjs/node";
  24030. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24031. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24032. import { Buffer } from "babylonjs/Meshes/buffer";
  24033. import { Geometry } from "babylonjs/Meshes/geometry";
  24034. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24035. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24036. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24037. import { Effect } from "babylonjs/Materials/effect";
  24038. import { Material } from "babylonjs/Materials/material";
  24039. import { Skeleton } from "babylonjs/Bones/skeleton";
  24040. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24041. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24042. import { Path3D } from "babylonjs/Maths/math.path";
  24043. import { Plane } from "babylonjs/Maths/math.plane";
  24044. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24045. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24046. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24047. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24048. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24049. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24050. /**
  24051. * @hidden
  24052. **/
  24053. export class _CreationDataStorage {
  24054. closePath?: boolean;
  24055. closeArray?: boolean;
  24056. idx: number[];
  24057. dashSize: number;
  24058. gapSize: number;
  24059. path3D: Path3D;
  24060. pathArray: Vector3[][];
  24061. arc: number;
  24062. radius: number;
  24063. cap: number;
  24064. tessellation: number;
  24065. }
  24066. /**
  24067. * @hidden
  24068. **/
  24069. class _InstanceDataStorage {
  24070. visibleInstances: any;
  24071. batchCache: _InstancesBatch;
  24072. instancesBufferSize: number;
  24073. instancesBuffer: Nullable<Buffer>;
  24074. instancesData: Float32Array;
  24075. overridenInstanceCount: number;
  24076. isFrozen: boolean;
  24077. previousBatch: Nullable<_InstancesBatch>;
  24078. hardwareInstancedRendering: boolean;
  24079. sideOrientation: number;
  24080. }
  24081. /**
  24082. * @hidden
  24083. **/
  24084. export class _InstancesBatch {
  24085. mustReturn: boolean;
  24086. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24087. renderSelf: boolean[];
  24088. hardwareInstancedRendering: boolean[];
  24089. }
  24090. /**
  24091. * Class used to represent renderable models
  24092. */
  24093. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24094. /**
  24095. * Mesh side orientation : usually the external or front surface
  24096. */
  24097. static readonly FRONTSIDE: number;
  24098. /**
  24099. * Mesh side orientation : usually the internal or back surface
  24100. */
  24101. static readonly BACKSIDE: number;
  24102. /**
  24103. * Mesh side orientation : both internal and external or front and back surfaces
  24104. */
  24105. static readonly DOUBLESIDE: number;
  24106. /**
  24107. * Mesh side orientation : by default, `FRONTSIDE`
  24108. */
  24109. static readonly DEFAULTSIDE: number;
  24110. /**
  24111. * Mesh cap setting : no cap
  24112. */
  24113. static readonly NO_CAP: number;
  24114. /**
  24115. * Mesh cap setting : one cap at the beginning of the mesh
  24116. */
  24117. static readonly CAP_START: number;
  24118. /**
  24119. * Mesh cap setting : one cap at the end of the mesh
  24120. */
  24121. static readonly CAP_END: number;
  24122. /**
  24123. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24124. */
  24125. static readonly CAP_ALL: number;
  24126. /**
  24127. * Mesh pattern setting : no flip or rotate
  24128. */
  24129. static readonly NO_FLIP: number;
  24130. /**
  24131. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24132. */
  24133. static readonly FLIP_TILE: number;
  24134. /**
  24135. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24136. */
  24137. static readonly ROTATE_TILE: number;
  24138. /**
  24139. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24140. */
  24141. static readonly FLIP_ROW: number;
  24142. /**
  24143. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24144. */
  24145. static readonly ROTATE_ROW: number;
  24146. /**
  24147. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24148. */
  24149. static readonly FLIP_N_ROTATE_TILE: number;
  24150. /**
  24151. * Mesh pattern setting : rotate pattern and rotate
  24152. */
  24153. static readonly FLIP_N_ROTATE_ROW: number;
  24154. /**
  24155. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24156. */
  24157. static readonly CENTER: number;
  24158. /**
  24159. * Mesh tile positioning : part tiles on left
  24160. */
  24161. static readonly LEFT: number;
  24162. /**
  24163. * Mesh tile positioning : part tiles on right
  24164. */
  24165. static readonly RIGHT: number;
  24166. /**
  24167. * Mesh tile positioning : part tiles on top
  24168. */
  24169. static readonly TOP: number;
  24170. /**
  24171. * Mesh tile positioning : part tiles on bottom
  24172. */
  24173. static readonly BOTTOM: number;
  24174. /**
  24175. * Gets the default side orientation.
  24176. * @param orientation the orientation to value to attempt to get
  24177. * @returns the default orientation
  24178. * @hidden
  24179. */
  24180. static _GetDefaultSideOrientation(orientation?: number): number;
  24181. private _internalMeshDataInfo;
  24182. /**
  24183. * An event triggered before rendering the mesh
  24184. */
  24185. readonly onBeforeRenderObservable: Observable<Mesh>;
  24186. /**
  24187. * An event triggered before binding the mesh
  24188. */
  24189. readonly onBeforeBindObservable: Observable<Mesh>;
  24190. /**
  24191. * An event triggered after rendering the mesh
  24192. */
  24193. readonly onAfterRenderObservable: Observable<Mesh>;
  24194. /**
  24195. * An event triggered before drawing the mesh
  24196. */
  24197. readonly onBeforeDrawObservable: Observable<Mesh>;
  24198. private _onBeforeDrawObserver;
  24199. /**
  24200. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24201. */
  24202. onBeforeDraw: () => void;
  24203. readonly hasInstances: boolean;
  24204. /**
  24205. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24206. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24207. */
  24208. delayLoadState: number;
  24209. /**
  24210. * Gets the list of instances created from this mesh
  24211. * it is not supposed to be modified manually.
  24212. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24213. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24214. */
  24215. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24216. /**
  24217. * Gets the file containing delay loading data for this mesh
  24218. */
  24219. delayLoadingFile: string;
  24220. /** @hidden */
  24221. _binaryInfo: any;
  24222. /**
  24223. * User defined function used to change how LOD level selection is done
  24224. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24225. */
  24226. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24227. /**
  24228. * Gets or sets the morph target manager
  24229. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24230. */
  24231. morphTargetManager: Nullable<MorphTargetManager>;
  24232. /** @hidden */
  24233. _creationDataStorage: Nullable<_CreationDataStorage>;
  24234. /** @hidden */
  24235. _geometry: Nullable<Geometry>;
  24236. /** @hidden */
  24237. _delayInfo: Array<string>;
  24238. /** @hidden */
  24239. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24240. /** @hidden */
  24241. _instanceDataStorage: _InstanceDataStorage;
  24242. private _effectiveMaterial;
  24243. /** @hidden */
  24244. _shouldGenerateFlatShading: boolean;
  24245. /** @hidden */
  24246. _originalBuilderSideOrientation: number;
  24247. /**
  24248. * Use this property to change the original side orientation defined at construction time
  24249. */
  24250. overrideMaterialSideOrientation: Nullable<number>;
  24251. /**
  24252. * Gets the source mesh (the one used to clone this one from)
  24253. */
  24254. readonly source: Nullable<Mesh>;
  24255. /**
  24256. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24257. */
  24258. isUnIndexed: boolean;
  24259. /**
  24260. * @constructor
  24261. * @param name The value used by scene.getMeshByName() to do a lookup.
  24262. * @param scene The scene to add this mesh to.
  24263. * @param parent The parent of this mesh, if it has one
  24264. * @param source An optional Mesh from which geometry is shared, cloned.
  24265. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24266. * When false, achieved by calling a clone(), also passing False.
  24267. * This will make creation of children, recursive.
  24268. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24269. */
  24270. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24271. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  24272. /**
  24273. * Gets the class name
  24274. * @returns the string "Mesh".
  24275. */
  24276. getClassName(): string;
  24277. /** @hidden */
  24278. readonly _isMesh: boolean;
  24279. /**
  24280. * Returns a description of this mesh
  24281. * @param fullDetails define if full details about this mesh must be used
  24282. * @returns a descriptive string representing this mesh
  24283. */
  24284. toString(fullDetails?: boolean): string;
  24285. /** @hidden */
  24286. _unBindEffect(): void;
  24287. /**
  24288. * Gets a boolean indicating if this mesh has LOD
  24289. */
  24290. readonly hasLODLevels: boolean;
  24291. /**
  24292. * Gets the list of MeshLODLevel associated with the current mesh
  24293. * @returns an array of MeshLODLevel
  24294. */
  24295. getLODLevels(): MeshLODLevel[];
  24296. private _sortLODLevels;
  24297. /**
  24298. * Add a mesh as LOD level triggered at the given distance.
  24299. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24300. * @param distance The distance from the center of the object to show this level
  24301. * @param mesh The mesh to be added as LOD level (can be null)
  24302. * @return This mesh (for chaining)
  24303. */
  24304. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24305. /**
  24306. * Returns the LOD level mesh at the passed distance or null if not found.
  24307. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24308. * @param distance The distance from the center of the object to show this level
  24309. * @returns a Mesh or `null`
  24310. */
  24311. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24312. /**
  24313. * Remove a mesh from the LOD array
  24314. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24315. * @param mesh defines the mesh to be removed
  24316. * @return This mesh (for chaining)
  24317. */
  24318. removeLODLevel(mesh: Mesh): Mesh;
  24319. /**
  24320. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24321. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24322. * @param camera defines the camera to use to compute distance
  24323. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24324. * @return This mesh (for chaining)
  24325. */
  24326. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24327. /**
  24328. * Gets the mesh internal Geometry object
  24329. */
  24330. readonly geometry: Nullable<Geometry>;
  24331. /**
  24332. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24333. * @returns the total number of vertices
  24334. */
  24335. getTotalVertices(): number;
  24336. /**
  24337. * Returns the content of an associated vertex buffer
  24338. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24339. * - VertexBuffer.PositionKind
  24340. * - VertexBuffer.UVKind
  24341. * - VertexBuffer.UV2Kind
  24342. * - VertexBuffer.UV3Kind
  24343. * - VertexBuffer.UV4Kind
  24344. * - VertexBuffer.UV5Kind
  24345. * - VertexBuffer.UV6Kind
  24346. * - VertexBuffer.ColorKind
  24347. * - VertexBuffer.MatricesIndicesKind
  24348. * - VertexBuffer.MatricesIndicesExtraKind
  24349. * - VertexBuffer.MatricesWeightsKind
  24350. * - VertexBuffer.MatricesWeightsExtraKind
  24351. * @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
  24352. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24353. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24354. */
  24355. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24356. /**
  24357. * Returns the mesh VertexBuffer object from the requested `kind`
  24358. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24359. * - VertexBuffer.PositionKind
  24360. * - VertexBuffer.NormalKind
  24361. * - VertexBuffer.UVKind
  24362. * - VertexBuffer.UV2Kind
  24363. * - VertexBuffer.UV3Kind
  24364. * - VertexBuffer.UV4Kind
  24365. * - VertexBuffer.UV5Kind
  24366. * - VertexBuffer.UV6Kind
  24367. * - VertexBuffer.ColorKind
  24368. * - VertexBuffer.MatricesIndicesKind
  24369. * - VertexBuffer.MatricesIndicesExtraKind
  24370. * - VertexBuffer.MatricesWeightsKind
  24371. * - VertexBuffer.MatricesWeightsExtraKind
  24372. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24373. */
  24374. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24375. /**
  24376. * Tests if a specific vertex buffer is associated with this mesh
  24377. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24378. * - VertexBuffer.PositionKind
  24379. * - VertexBuffer.NormalKind
  24380. * - VertexBuffer.UVKind
  24381. * - VertexBuffer.UV2Kind
  24382. * - VertexBuffer.UV3Kind
  24383. * - VertexBuffer.UV4Kind
  24384. * - VertexBuffer.UV5Kind
  24385. * - VertexBuffer.UV6Kind
  24386. * - VertexBuffer.ColorKind
  24387. * - VertexBuffer.MatricesIndicesKind
  24388. * - VertexBuffer.MatricesIndicesExtraKind
  24389. * - VertexBuffer.MatricesWeightsKind
  24390. * - VertexBuffer.MatricesWeightsExtraKind
  24391. * @returns a boolean
  24392. */
  24393. isVerticesDataPresent(kind: string): boolean;
  24394. /**
  24395. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24396. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24397. * - VertexBuffer.PositionKind
  24398. * - VertexBuffer.UVKind
  24399. * - VertexBuffer.UV2Kind
  24400. * - VertexBuffer.UV3Kind
  24401. * - VertexBuffer.UV4Kind
  24402. * - VertexBuffer.UV5Kind
  24403. * - VertexBuffer.UV6Kind
  24404. * - VertexBuffer.ColorKind
  24405. * - VertexBuffer.MatricesIndicesKind
  24406. * - VertexBuffer.MatricesIndicesExtraKind
  24407. * - VertexBuffer.MatricesWeightsKind
  24408. * - VertexBuffer.MatricesWeightsExtraKind
  24409. * @returns a boolean
  24410. */
  24411. isVertexBufferUpdatable(kind: string): boolean;
  24412. /**
  24413. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24414. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24415. * - VertexBuffer.PositionKind
  24416. * - VertexBuffer.NormalKind
  24417. * - VertexBuffer.UVKind
  24418. * - VertexBuffer.UV2Kind
  24419. * - VertexBuffer.UV3Kind
  24420. * - VertexBuffer.UV4Kind
  24421. * - VertexBuffer.UV5Kind
  24422. * - VertexBuffer.UV6Kind
  24423. * - VertexBuffer.ColorKind
  24424. * - VertexBuffer.MatricesIndicesKind
  24425. * - VertexBuffer.MatricesIndicesExtraKind
  24426. * - VertexBuffer.MatricesWeightsKind
  24427. * - VertexBuffer.MatricesWeightsExtraKind
  24428. * @returns an array of strings
  24429. */
  24430. getVerticesDataKinds(): string[];
  24431. /**
  24432. * Returns a positive integer : the total number of indices in this mesh geometry.
  24433. * @returns the numner of indices or zero if the mesh has no geometry.
  24434. */
  24435. getTotalIndices(): number;
  24436. /**
  24437. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24438. * @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.
  24439. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24440. * @returns the indices array or an empty array if the mesh has no geometry
  24441. */
  24442. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24443. readonly isBlocked: boolean;
  24444. /**
  24445. * Determine if the current mesh is ready to be rendered
  24446. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24447. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24448. * @returns true if all associated assets are ready (material, textures, shaders)
  24449. */
  24450. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24451. /**
  24452. * 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.
  24453. */
  24454. readonly areNormalsFrozen: boolean;
  24455. /**
  24456. * 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.
  24457. * @returns the current mesh
  24458. */
  24459. freezeNormals(): Mesh;
  24460. /**
  24461. * 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
  24462. * @returns the current mesh
  24463. */
  24464. unfreezeNormals(): Mesh;
  24465. /**
  24466. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24467. */
  24468. overridenInstanceCount: number;
  24469. /** @hidden */
  24470. _preActivate(): Mesh;
  24471. /** @hidden */
  24472. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24473. /** @hidden */
  24474. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24475. /**
  24476. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24477. * This means the mesh underlying bounding box and sphere are recomputed.
  24478. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24479. * @returns the current mesh
  24480. */
  24481. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24482. /** @hidden */
  24483. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24484. /**
  24485. * This function will subdivide the mesh into multiple submeshes
  24486. * @param count defines the expected number of submeshes
  24487. */
  24488. subdivide(count: number): void;
  24489. /**
  24490. * Copy a FloatArray into a specific associated vertex buffer
  24491. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24492. * - VertexBuffer.PositionKind
  24493. * - VertexBuffer.UVKind
  24494. * - VertexBuffer.UV2Kind
  24495. * - VertexBuffer.UV3Kind
  24496. * - VertexBuffer.UV4Kind
  24497. * - VertexBuffer.UV5Kind
  24498. * - VertexBuffer.UV6Kind
  24499. * - VertexBuffer.ColorKind
  24500. * - VertexBuffer.MatricesIndicesKind
  24501. * - VertexBuffer.MatricesIndicesExtraKind
  24502. * - VertexBuffer.MatricesWeightsKind
  24503. * - VertexBuffer.MatricesWeightsExtraKind
  24504. * @param data defines the data source
  24505. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24506. * @param stride defines the data stride size (can be null)
  24507. * @returns the current mesh
  24508. */
  24509. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24510. /**
  24511. * Flags an associated vertex buffer as updatable
  24512. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24513. * - VertexBuffer.PositionKind
  24514. * - VertexBuffer.UVKind
  24515. * - VertexBuffer.UV2Kind
  24516. * - VertexBuffer.UV3Kind
  24517. * - VertexBuffer.UV4Kind
  24518. * - VertexBuffer.UV5Kind
  24519. * - VertexBuffer.UV6Kind
  24520. * - VertexBuffer.ColorKind
  24521. * - VertexBuffer.MatricesIndicesKind
  24522. * - VertexBuffer.MatricesIndicesExtraKind
  24523. * - VertexBuffer.MatricesWeightsKind
  24524. * - VertexBuffer.MatricesWeightsExtraKind
  24525. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24526. */
  24527. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24528. /**
  24529. * Sets the mesh global Vertex Buffer
  24530. * @param buffer defines the buffer to use
  24531. * @returns the current mesh
  24532. */
  24533. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24534. /**
  24535. * Update a specific associated vertex buffer
  24536. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24537. * - VertexBuffer.PositionKind
  24538. * - VertexBuffer.UVKind
  24539. * - VertexBuffer.UV2Kind
  24540. * - VertexBuffer.UV3Kind
  24541. * - VertexBuffer.UV4Kind
  24542. * - VertexBuffer.UV5Kind
  24543. * - VertexBuffer.UV6Kind
  24544. * - VertexBuffer.ColorKind
  24545. * - VertexBuffer.MatricesIndicesKind
  24546. * - VertexBuffer.MatricesIndicesExtraKind
  24547. * - VertexBuffer.MatricesWeightsKind
  24548. * - VertexBuffer.MatricesWeightsExtraKind
  24549. * @param data defines the data source
  24550. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24551. * @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)
  24552. * @returns the current mesh
  24553. */
  24554. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24555. /**
  24556. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24557. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24558. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24559. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24560. * @returns the current mesh
  24561. */
  24562. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24563. /**
  24564. * Creates a un-shared specific occurence of the geometry for the mesh.
  24565. * @returns the current mesh
  24566. */
  24567. makeGeometryUnique(): Mesh;
  24568. /**
  24569. * Set the index buffer of this mesh
  24570. * @param indices defines the source data
  24571. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24572. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24573. * @returns the current mesh
  24574. */
  24575. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24576. /**
  24577. * Update the current index buffer
  24578. * @param indices defines the source data
  24579. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24580. * @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)
  24581. * @returns the current mesh
  24582. */
  24583. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24584. /**
  24585. * Invert the geometry to move from a right handed system to a left handed one.
  24586. * @returns the current mesh
  24587. */
  24588. toLeftHanded(): Mesh;
  24589. /** @hidden */
  24590. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24591. /** @hidden */
  24592. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24593. /**
  24594. * Registers for this mesh a javascript function called just before the rendering process
  24595. * @param func defines the function to call before rendering this mesh
  24596. * @returns the current mesh
  24597. */
  24598. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24599. /**
  24600. * Disposes a previously registered javascript function called before the rendering
  24601. * @param func defines the function to remove
  24602. * @returns the current mesh
  24603. */
  24604. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24605. /**
  24606. * Registers for this mesh a javascript function called just after the rendering is complete
  24607. * @param func defines the function to call after rendering this mesh
  24608. * @returns the current mesh
  24609. */
  24610. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24611. /**
  24612. * Disposes a previously registered javascript function called after the rendering.
  24613. * @param func defines the function to remove
  24614. * @returns the current mesh
  24615. */
  24616. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24617. /** @hidden */
  24618. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24619. /** @hidden */
  24620. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24621. /** @hidden */
  24622. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24623. /** @hidden */
  24624. _rebuild(): void;
  24625. /** @hidden */
  24626. _freeze(): void;
  24627. /** @hidden */
  24628. _unFreeze(): void;
  24629. /**
  24630. * 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
  24631. * @param subMesh defines the subMesh to render
  24632. * @param enableAlphaMode defines if alpha mode can be changed
  24633. * @returns the current mesh
  24634. */
  24635. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  24636. private _onBeforeDraw;
  24637. /**
  24638. * Renormalize the mesh and patch it up if there are no weights
  24639. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24640. * However in the case of zero weights then we set just a single influence to 1.
  24641. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24642. */
  24643. cleanMatrixWeights(): void;
  24644. private normalizeSkinFourWeights;
  24645. private normalizeSkinWeightsAndExtra;
  24646. /**
  24647. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24648. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24649. * the user know there was an issue with importing the mesh
  24650. * @returns a validation object with skinned, valid and report string
  24651. */
  24652. validateSkinning(): {
  24653. skinned: boolean;
  24654. valid: boolean;
  24655. report: string;
  24656. };
  24657. /** @hidden */
  24658. _checkDelayState(): Mesh;
  24659. private _queueLoad;
  24660. /**
  24661. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24662. * A mesh is in the frustum if its bounding box intersects the frustum
  24663. * @param frustumPlanes defines the frustum to test
  24664. * @returns true if the mesh is in the frustum planes
  24665. */
  24666. isInFrustum(frustumPlanes: Plane[]): boolean;
  24667. /**
  24668. * Sets the mesh material by the material or multiMaterial `id` property
  24669. * @param id is a string identifying the material or the multiMaterial
  24670. * @returns the current mesh
  24671. */
  24672. setMaterialByID(id: string): Mesh;
  24673. /**
  24674. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24675. * @returns an array of IAnimatable
  24676. */
  24677. getAnimatables(): IAnimatable[];
  24678. /**
  24679. * Modifies the mesh geometry according to the passed transformation matrix.
  24680. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24681. * The mesh normals are modified using the same transformation.
  24682. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24683. * @param transform defines the transform matrix to use
  24684. * @see http://doc.babylonjs.com/resources/baking_transformations
  24685. * @returns the current mesh
  24686. */
  24687. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24688. /**
  24689. * Modifies the mesh geometry according to its own current World Matrix.
  24690. * The mesh World Matrix is then reset.
  24691. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24692. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24693. * @see http://doc.babylonjs.com/resources/baking_transformations
  24694. * @returns the current mesh
  24695. */
  24696. bakeCurrentTransformIntoVertices(): Mesh;
  24697. /** @hidden */
  24698. readonly _positions: Nullable<Vector3[]>;
  24699. /** @hidden */
  24700. _resetPointsArrayCache(): Mesh;
  24701. /** @hidden */
  24702. _generatePointsArray(): boolean;
  24703. /**
  24704. * Returns a new Mesh object generated from the current mesh properties.
  24705. * This method must not get confused with createInstance()
  24706. * @param name is a string, the name given to the new mesh
  24707. * @param newParent can be any Node object (default `null`)
  24708. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24709. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24710. * @returns a new mesh
  24711. */
  24712. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24713. /**
  24714. * Releases resources associated with this mesh.
  24715. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24716. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24717. */
  24718. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24719. /**
  24720. * Modifies the mesh geometry according to a displacement map.
  24721. * 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.
  24722. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24723. * @param url is a string, the URL from the image file is to be downloaded.
  24724. * @param minHeight is the lower limit of the displacement.
  24725. * @param maxHeight is the upper limit of the displacement.
  24726. * @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.
  24727. * @param uvOffset is an optional vector2 used to offset UV.
  24728. * @param uvScale is an optional vector2 used to scale UV.
  24729. * @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.
  24730. * @returns the Mesh.
  24731. */
  24732. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24733. /**
  24734. * Modifies the mesh geometry according to a displacementMap buffer.
  24735. * 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.
  24736. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24737. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24738. * @param heightMapWidth is the width of the buffer image.
  24739. * @param heightMapHeight is the height of the buffer image.
  24740. * @param minHeight is the lower limit of the displacement.
  24741. * @param maxHeight is the upper limit of the displacement.
  24742. * @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.
  24743. * @param uvOffset is an optional vector2 used to offset UV.
  24744. * @param uvScale is an optional vector2 used to scale UV.
  24745. * @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.
  24746. * @returns the Mesh.
  24747. */
  24748. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24749. /**
  24750. * Modify the mesh to get a flat shading rendering.
  24751. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24752. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24753. * @returns current mesh
  24754. */
  24755. convertToFlatShadedMesh(): Mesh;
  24756. /**
  24757. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24758. * In other words, more vertices, no more indices and a single bigger VBO.
  24759. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24760. * @returns current mesh
  24761. */
  24762. convertToUnIndexedMesh(): Mesh;
  24763. /**
  24764. * Inverses facet orientations.
  24765. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24766. * @param flipNormals will also inverts the normals
  24767. * @returns current mesh
  24768. */
  24769. flipFaces(flipNormals?: boolean): Mesh;
  24770. /**
  24771. * Increase the number of facets and hence vertices in a mesh
  24772. * Vertex normals are interpolated from existing vertex normals
  24773. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24774. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24775. */
  24776. increaseVertices(numberPerEdge: number): void;
  24777. /**
  24778. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24779. * This will undo any application of covertToFlatShadedMesh
  24780. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24781. */
  24782. forceSharedVertices(): void;
  24783. /** @hidden */
  24784. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24785. /** @hidden */
  24786. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24787. /**
  24788. * Creates a new InstancedMesh object from the mesh model.
  24789. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24790. * @param name defines the name of the new instance
  24791. * @returns a new InstancedMesh
  24792. */
  24793. createInstance(name: string): InstancedMesh;
  24794. /**
  24795. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24796. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24797. * @returns the current mesh
  24798. */
  24799. synchronizeInstances(): Mesh;
  24800. /**
  24801. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24802. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24803. * This should be used together with the simplification to avoid disappearing triangles.
  24804. * @param successCallback an optional success callback to be called after the optimization finished.
  24805. * @returns the current mesh
  24806. */
  24807. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24808. /**
  24809. * Serialize current mesh
  24810. * @param serializationObject defines the object which will receive the serialization data
  24811. */
  24812. serialize(serializationObject: any): void;
  24813. /** @hidden */
  24814. _syncGeometryWithMorphTargetManager(): void;
  24815. /** @hidden */
  24816. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24817. /**
  24818. * Returns a new Mesh object parsed from the source provided.
  24819. * @param parsedMesh is the source
  24820. * @param scene defines the hosting scene
  24821. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24822. * @returns a new Mesh
  24823. */
  24824. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24825. /**
  24826. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24827. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24828. * @param name defines the name of the mesh to create
  24829. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24830. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24831. * @param closePath creates a seam between the first and the last points of each path of the path array
  24832. * @param offset is taken in account only if the `pathArray` is containing a single path
  24833. * @param scene defines the hosting scene
  24834. * @param updatable defines if the mesh must be flagged as updatable
  24835. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24836. * @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)
  24837. * @returns a new Mesh
  24838. */
  24839. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24840. /**
  24841. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24842. * @param name defines the name of the mesh to create
  24843. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24844. * @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
  24845. * @param scene defines the hosting scene
  24846. * @param updatable defines if the mesh must be flagged as updatable
  24847. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24848. * @returns a new Mesh
  24849. */
  24850. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24851. /**
  24852. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24853. * @param name defines the name of the mesh to create
  24854. * @param size sets the size (float) of each box side (default 1)
  24855. * @param scene defines the hosting scene
  24856. * @param updatable defines if the mesh must be flagged as updatable
  24857. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24858. * @returns a new Mesh
  24859. */
  24860. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24861. /**
  24862. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24863. * @param name defines the name of the mesh to create
  24864. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24865. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24866. * @param scene defines the hosting scene
  24867. * @param updatable defines if the mesh must be flagged as updatable
  24868. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24869. * @returns a new Mesh
  24870. */
  24871. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24872. /**
  24873. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24874. * @param name defines the name of the mesh to create
  24875. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24876. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24877. * @param scene defines the hosting scene
  24878. * @returns a new Mesh
  24879. */
  24880. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24881. /**
  24882. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24883. * @param name defines the name of the mesh to create
  24884. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24885. * @param diameterTop set the top cap diameter (floats, default 1)
  24886. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24887. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24888. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24889. * @param scene defines the hosting scene
  24890. * @param updatable defines if the mesh must be flagged as updatable
  24891. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24892. * @returns a new Mesh
  24893. */
  24894. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24895. /**
  24896. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24897. * @param name defines the name of the mesh to create
  24898. * @param diameter sets the diameter size (float) of the torus (default 1)
  24899. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24900. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24901. * @param scene defines the hosting scene
  24902. * @param updatable defines if the mesh must be flagged as updatable
  24903. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24904. * @returns a new Mesh
  24905. */
  24906. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24907. /**
  24908. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24909. * @param name defines the name of the mesh to create
  24910. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24911. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24912. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24913. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24914. * @param p the number of windings on X axis (positive integers, default 2)
  24915. * @param q the number of windings on Y axis (positive integers, default 3)
  24916. * @param scene defines the hosting scene
  24917. * @param updatable defines if the mesh must be flagged as updatable
  24918. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24919. * @returns a new Mesh
  24920. */
  24921. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24922. /**
  24923. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24924. * @param name defines the name of the mesh to create
  24925. * @param points is an array successive Vector3
  24926. * @param scene defines the hosting scene
  24927. * @param updatable defines if the mesh must be flagged as updatable
  24928. * @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).
  24929. * @returns a new Mesh
  24930. */
  24931. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24932. /**
  24933. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24934. * @param name defines the name of the mesh to create
  24935. * @param points is an array successive Vector3
  24936. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24937. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24938. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24939. * @param scene defines the hosting scene
  24940. * @param updatable defines if the mesh must be flagged as updatable
  24941. * @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)
  24942. * @returns a new Mesh
  24943. */
  24944. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24945. /**
  24946. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24947. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24948. * 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.
  24949. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24950. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24951. * Remember you can only change the shape positions, not their number when updating a polygon.
  24952. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24953. * @param name defines the name of the mesh to create
  24954. * @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
  24955. * @param scene defines the hosting scene
  24956. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24957. * @param updatable defines if the mesh must be flagged as updatable
  24958. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24959. * @param earcutInjection can be used to inject your own earcut reference
  24960. * @returns a new Mesh
  24961. */
  24962. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24963. /**
  24964. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24965. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24966. * @param name defines the name of the mesh to create
  24967. * @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
  24968. * @param depth defines the height of extrusion
  24969. * @param scene defines the hosting scene
  24970. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24971. * @param updatable defines if the mesh must be flagged as updatable
  24972. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24973. * @param earcutInjection can be used to inject your own earcut reference
  24974. * @returns a new Mesh
  24975. */
  24976. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24977. /**
  24978. * Creates an extruded shape mesh.
  24979. * 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
  24980. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24981. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24982. * @param name defines the name of the mesh to create
  24983. * @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
  24984. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24985. * @param scale is the value to scale the shape
  24986. * @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
  24987. * @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
  24988. * @param scene defines the hosting scene
  24989. * @param updatable defines if the mesh must be flagged as updatable
  24990. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24991. * @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)
  24992. * @returns a new Mesh
  24993. */
  24994. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24995. /**
  24996. * Creates an custom extruded shape mesh.
  24997. * The custom extrusion is a parametric shape.
  24998. * It has no predefined shape. Its final shape will depend on the input parameters.
  24999. * Please consider using the same method from the MeshBuilder class instead
  25000. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25001. * @param name defines the name of the mesh to create
  25002. * @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
  25003. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25004. * @param scaleFunction is a custom Javascript function called on each path point
  25005. * @param rotationFunction is a custom Javascript function called on each path point
  25006. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25007. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25008. * @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
  25009. * @param scene defines the hosting scene
  25010. * @param updatable defines if the mesh must be flagged as updatable
  25011. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25012. * @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)
  25013. * @returns a new Mesh
  25014. */
  25015. 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;
  25016. /**
  25017. * Creates lathe mesh.
  25018. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25019. * Please consider using the same method from the MeshBuilder class instead
  25020. * @param name defines the name of the mesh to create
  25021. * @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
  25022. * @param radius is the radius value of the lathe
  25023. * @param tessellation is the side number of the lathe.
  25024. * @param scene defines the hosting scene
  25025. * @param updatable defines if the mesh must be flagged as updatable
  25026. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25027. * @returns a new Mesh
  25028. */
  25029. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25030. /**
  25031. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25032. * @param name defines the name of the mesh to create
  25033. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25034. * @param scene defines the hosting scene
  25035. * @param updatable defines if the mesh must be flagged as updatable
  25036. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25037. * @returns a new Mesh
  25038. */
  25039. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25040. /**
  25041. * Creates a ground mesh.
  25042. * Please consider using the same method from the MeshBuilder class instead
  25043. * @param name defines the name of the mesh to create
  25044. * @param width set the width of the ground
  25045. * @param height set the height of the ground
  25046. * @param subdivisions sets the number of subdivisions per side
  25047. * @param scene defines the hosting scene
  25048. * @param updatable defines if the mesh must be flagged as updatable
  25049. * @returns a new Mesh
  25050. */
  25051. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25052. /**
  25053. * Creates a tiled ground mesh.
  25054. * Please consider using the same method from the MeshBuilder class instead
  25055. * @param name defines the name of the mesh to create
  25056. * @param xmin set the ground minimum X coordinate
  25057. * @param zmin set the ground minimum Y coordinate
  25058. * @param xmax set the ground maximum X coordinate
  25059. * @param zmax set the ground maximum Z coordinate
  25060. * @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
  25061. * @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
  25062. * @param scene defines the hosting scene
  25063. * @param updatable defines if the mesh must be flagged as updatable
  25064. * @returns a new Mesh
  25065. */
  25066. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25067. w: number;
  25068. h: number;
  25069. }, precision: {
  25070. w: number;
  25071. h: number;
  25072. }, scene: Scene, updatable?: boolean): Mesh;
  25073. /**
  25074. * Creates a ground mesh from a height map.
  25075. * Please consider using the same method from the MeshBuilder class instead
  25076. * @see http://doc.babylonjs.com/babylon101/height_map
  25077. * @param name defines the name of the mesh to create
  25078. * @param url sets the URL of the height map image resource
  25079. * @param width set the ground width size
  25080. * @param height set the ground height size
  25081. * @param subdivisions sets the number of subdivision per side
  25082. * @param minHeight is the minimum altitude on the ground
  25083. * @param maxHeight is the maximum altitude on the ground
  25084. * @param scene defines the hosting scene
  25085. * @param updatable defines if the mesh must be flagged as updatable
  25086. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25087. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25088. * @returns a new Mesh
  25089. */
  25090. 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;
  25091. /**
  25092. * Creates a tube mesh.
  25093. * The tube is a parametric shape.
  25094. * It has no predefined shape. Its final shape will depend on the input parameters.
  25095. * Please consider using the same method from the MeshBuilder class instead
  25096. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25097. * @param name defines the name of the mesh to create
  25098. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25099. * @param radius sets the tube radius size
  25100. * @param tessellation is the number of sides on the tubular surface
  25101. * @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
  25102. * @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
  25103. * @param scene defines the hosting scene
  25104. * @param updatable defines if the mesh must be flagged as updatable
  25105. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25106. * @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)
  25107. * @returns a new Mesh
  25108. */
  25109. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25110. (i: number, distance: number): number;
  25111. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25112. /**
  25113. * Creates a polyhedron mesh.
  25114. * Please consider using the same method from the MeshBuilder class instead.
  25115. * * 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
  25116. * * The parameter `size` (positive float, default 1) sets the polygon size
  25117. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25118. * * 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`
  25119. * * 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
  25120. * * 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)`)
  25121. * * 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
  25122. * * 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
  25123. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25124. * * If you create a double-sided mesh, you can choose what parts of 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
  25125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25126. * @param name defines the name of the mesh to create
  25127. * @param options defines the options used to create the mesh
  25128. * @param scene defines the hosting scene
  25129. * @returns a new Mesh
  25130. */
  25131. static CreatePolyhedron(name: string, options: {
  25132. type?: number;
  25133. size?: number;
  25134. sizeX?: number;
  25135. sizeY?: number;
  25136. sizeZ?: number;
  25137. custom?: any;
  25138. faceUV?: Vector4[];
  25139. faceColors?: Color4[];
  25140. updatable?: boolean;
  25141. sideOrientation?: number;
  25142. }, scene: Scene): Mesh;
  25143. /**
  25144. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25145. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25146. * * 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`)
  25147. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25148. * * 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
  25149. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25150. * * If you create a double-sided mesh, you can choose what parts of 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
  25151. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25152. * @param name defines the name of the mesh
  25153. * @param options defines the options used to create the mesh
  25154. * @param scene defines the hosting scene
  25155. * @returns a new Mesh
  25156. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25157. */
  25158. static CreateIcoSphere(name: string, options: {
  25159. radius?: number;
  25160. flat?: boolean;
  25161. subdivisions?: number;
  25162. sideOrientation?: number;
  25163. updatable?: boolean;
  25164. }, scene: Scene): Mesh;
  25165. /**
  25166. * Creates a decal mesh.
  25167. * Please consider using the same method from the MeshBuilder class instead.
  25168. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25169. * @param name defines the name of the mesh
  25170. * @param sourceMesh defines the mesh receiving the decal
  25171. * @param position sets the position of the decal in world coordinates
  25172. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25173. * @param size sets the decal scaling
  25174. * @param angle sets the angle to rotate the decal
  25175. * @returns a new Mesh
  25176. */
  25177. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25178. /**
  25179. * Prepare internal position array for software CPU skinning
  25180. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25181. */
  25182. setPositionsForCPUSkinning(): Float32Array;
  25183. /**
  25184. * Prepare internal normal array for software CPU skinning
  25185. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25186. */
  25187. setNormalsForCPUSkinning(): Float32Array;
  25188. /**
  25189. * Updates the vertex buffer by applying transformation from the bones
  25190. * @param skeleton defines the skeleton to apply to current mesh
  25191. * @returns the current mesh
  25192. */
  25193. applySkeleton(skeleton: Skeleton): Mesh;
  25194. /**
  25195. * 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
  25196. * @param meshes defines the list of meshes to scan
  25197. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25198. */
  25199. static MinMax(meshes: AbstractMesh[]): {
  25200. min: Vector3;
  25201. max: Vector3;
  25202. };
  25203. /**
  25204. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25205. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25206. * @returns a vector3
  25207. */
  25208. static Center(meshesOrMinMaxVector: {
  25209. min: Vector3;
  25210. max: Vector3;
  25211. } | AbstractMesh[]): Vector3;
  25212. /**
  25213. * Merge the array of meshes into a single mesh for performance reasons.
  25214. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25215. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25216. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25217. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25218. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25219. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25220. * @returns a new mesh
  25221. */
  25222. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25223. /** @hidden */
  25224. addInstance(instance: InstancedMesh): void;
  25225. /** @hidden */
  25226. removeInstance(instance: InstancedMesh): void;
  25227. }
  25228. }
  25229. declare module "babylonjs/Cameras/camera" {
  25230. import { SmartArray } from "babylonjs/Misc/smartArray";
  25231. import { Observable } from "babylonjs/Misc/observable";
  25232. import { Nullable } from "babylonjs/types";
  25233. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25234. import { Scene } from "babylonjs/scene";
  25235. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25236. import { Node } from "babylonjs/node";
  25237. import { Mesh } from "babylonjs/Meshes/mesh";
  25238. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25239. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25240. import { Viewport } from "babylonjs/Maths/math.viewport";
  25241. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25242. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25243. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25244. import { Ray } from "babylonjs/Culling/ray";
  25245. /**
  25246. * This is the base class of all the camera used in the application.
  25247. * @see http://doc.babylonjs.com/features/cameras
  25248. */
  25249. export class Camera extends Node {
  25250. /** @hidden */
  25251. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25252. /**
  25253. * This is the default projection mode used by the cameras.
  25254. * It helps recreating a feeling of perspective and better appreciate depth.
  25255. * This is the best way to simulate real life cameras.
  25256. */
  25257. static readonly PERSPECTIVE_CAMERA: number;
  25258. /**
  25259. * This helps creating camera with an orthographic mode.
  25260. * 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.
  25261. */
  25262. static readonly ORTHOGRAPHIC_CAMERA: number;
  25263. /**
  25264. * This is the default FOV mode for perspective cameras.
  25265. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25266. */
  25267. static readonly FOVMODE_VERTICAL_FIXED: number;
  25268. /**
  25269. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25270. */
  25271. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25272. /**
  25273. * This specifies ther is no need for a camera rig.
  25274. * Basically only one eye is rendered corresponding to the camera.
  25275. */
  25276. static readonly RIG_MODE_NONE: number;
  25277. /**
  25278. * Simulates a camera Rig with one blue eye and one red eye.
  25279. * This can be use with 3d blue and red glasses.
  25280. */
  25281. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25282. /**
  25283. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25284. */
  25285. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25286. /**
  25287. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25288. */
  25289. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25290. /**
  25291. * Defines that both eyes of the camera will be rendered over under each other.
  25292. */
  25293. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25294. /**
  25295. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25296. */
  25297. static readonly RIG_MODE_VR: number;
  25298. /**
  25299. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25300. */
  25301. static readonly RIG_MODE_WEBVR: number;
  25302. /**
  25303. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25304. */
  25305. static readonly RIG_MODE_CUSTOM: number;
  25306. /**
  25307. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25308. */
  25309. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25310. /**
  25311. * Define the input manager associated with the camera.
  25312. */
  25313. inputs: CameraInputsManager<Camera>;
  25314. /** @hidden */
  25315. _position: Vector3;
  25316. /**
  25317. * Define the current local position of the camera in the scene
  25318. */
  25319. position: Vector3;
  25320. /**
  25321. * The vector the camera should consider as up.
  25322. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25323. */
  25324. upVector: Vector3;
  25325. /**
  25326. * Define the current limit on the left side for an orthographic camera
  25327. * In scene unit
  25328. */
  25329. orthoLeft: Nullable<number>;
  25330. /**
  25331. * Define the current limit on the right side for an orthographic camera
  25332. * In scene unit
  25333. */
  25334. orthoRight: Nullable<number>;
  25335. /**
  25336. * Define the current limit on the bottom side for an orthographic camera
  25337. * In scene unit
  25338. */
  25339. orthoBottom: Nullable<number>;
  25340. /**
  25341. * Define the current limit on the top side for an orthographic camera
  25342. * In scene unit
  25343. */
  25344. orthoTop: Nullable<number>;
  25345. /**
  25346. * Field Of View is set in Radians. (default is 0.8)
  25347. */
  25348. fov: number;
  25349. /**
  25350. * Define the minimum distance the camera can see from.
  25351. * This is important to note that the depth buffer are not infinite and the closer it starts
  25352. * the more your scene might encounter depth fighting issue.
  25353. */
  25354. minZ: number;
  25355. /**
  25356. * Define the maximum distance the camera can see to.
  25357. * This is important to note that the depth buffer are not infinite and the further it end
  25358. * the more your scene might encounter depth fighting issue.
  25359. */
  25360. maxZ: number;
  25361. /**
  25362. * Define the default inertia of the camera.
  25363. * This helps giving a smooth feeling to the camera movement.
  25364. */
  25365. inertia: number;
  25366. /**
  25367. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25368. */
  25369. mode: number;
  25370. /**
  25371. * Define wether the camera is intermediate.
  25372. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25373. */
  25374. isIntermediate: boolean;
  25375. /**
  25376. * Define the viewport of the camera.
  25377. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25378. */
  25379. viewport: Viewport;
  25380. /**
  25381. * Restricts the camera to viewing objects with the same layerMask.
  25382. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25383. */
  25384. layerMask: number;
  25385. /**
  25386. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25387. */
  25388. fovMode: number;
  25389. /**
  25390. * Rig mode of the camera.
  25391. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25392. * This is normally controlled byt the camera themselves as internal use.
  25393. */
  25394. cameraRigMode: number;
  25395. /**
  25396. * Defines the distance between both "eyes" in case of a RIG
  25397. */
  25398. interaxialDistance: number;
  25399. /**
  25400. * Defines if stereoscopic rendering is done side by side or over under.
  25401. */
  25402. isStereoscopicSideBySide: boolean;
  25403. /**
  25404. * 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
  25405. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25406. * else in the scene. (Eg. security camera)
  25407. *
  25408. * 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)
  25409. */
  25410. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25411. /**
  25412. * When set, the camera will render to this render target instead of the default canvas
  25413. *
  25414. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25415. */
  25416. outputRenderTarget: Nullable<RenderTargetTexture>;
  25417. /**
  25418. * Observable triggered when the camera view matrix has changed.
  25419. */
  25420. onViewMatrixChangedObservable: Observable<Camera>;
  25421. /**
  25422. * Observable triggered when the camera Projection matrix has changed.
  25423. */
  25424. onProjectionMatrixChangedObservable: Observable<Camera>;
  25425. /**
  25426. * Observable triggered when the inputs have been processed.
  25427. */
  25428. onAfterCheckInputsObservable: Observable<Camera>;
  25429. /**
  25430. * Observable triggered when reset has been called and applied to the camera.
  25431. */
  25432. onRestoreStateObservable: Observable<Camera>;
  25433. /** @hidden */
  25434. _cameraRigParams: any;
  25435. /** @hidden */
  25436. _rigCameras: Camera[];
  25437. /** @hidden */
  25438. _rigPostProcess: Nullable<PostProcess>;
  25439. protected _webvrViewMatrix: Matrix;
  25440. /** @hidden */
  25441. _skipRendering: boolean;
  25442. /** @hidden */
  25443. _projectionMatrix: Matrix;
  25444. /** @hidden */
  25445. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25446. /** @hidden */
  25447. _activeMeshes: SmartArray<AbstractMesh>;
  25448. protected _globalPosition: Vector3;
  25449. /** @hidden */
  25450. _computedViewMatrix: Matrix;
  25451. private _doNotComputeProjectionMatrix;
  25452. private _transformMatrix;
  25453. private _frustumPlanes;
  25454. private _refreshFrustumPlanes;
  25455. private _storedFov;
  25456. private _stateStored;
  25457. /**
  25458. * Instantiates a new camera object.
  25459. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25460. * @see http://doc.babylonjs.com/features/cameras
  25461. * @param name Defines the name of the camera in the scene
  25462. * @param position Defines the position of the camera
  25463. * @param scene Defines the scene the camera belongs too
  25464. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25465. */
  25466. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25467. /**
  25468. * Store current camera state (fov, position, etc..)
  25469. * @returns the camera
  25470. */
  25471. storeState(): Camera;
  25472. /**
  25473. * Restores the camera state values if it has been stored. You must call storeState() first
  25474. */
  25475. protected _restoreStateValues(): boolean;
  25476. /**
  25477. * Restored camera state. You must call storeState() first.
  25478. * @returns true if restored and false otherwise
  25479. */
  25480. restoreState(): boolean;
  25481. /**
  25482. * Gets the class name of the camera.
  25483. * @returns the class name
  25484. */
  25485. getClassName(): string;
  25486. /** @hidden */
  25487. readonly _isCamera: boolean;
  25488. /**
  25489. * Gets a string representation of the camera useful for debug purpose.
  25490. * @param fullDetails Defines that a more verboe level of logging is required
  25491. * @returns the string representation
  25492. */
  25493. toString(fullDetails?: boolean): string;
  25494. /**
  25495. * Gets the current world space position of the camera.
  25496. */
  25497. readonly globalPosition: Vector3;
  25498. /**
  25499. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25500. * @returns the active meshe list
  25501. */
  25502. getActiveMeshes(): SmartArray<AbstractMesh>;
  25503. /**
  25504. * Check wether a mesh is part of the current active mesh list of the camera
  25505. * @param mesh Defines the mesh to check
  25506. * @returns true if active, false otherwise
  25507. */
  25508. isActiveMesh(mesh: Mesh): boolean;
  25509. /**
  25510. * Is this camera ready to be used/rendered
  25511. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25512. * @return true if the camera is ready
  25513. */
  25514. isReady(completeCheck?: boolean): boolean;
  25515. /** @hidden */
  25516. _initCache(): void;
  25517. /** @hidden */
  25518. _updateCache(ignoreParentClass?: boolean): void;
  25519. /** @hidden */
  25520. _isSynchronized(): boolean;
  25521. /** @hidden */
  25522. _isSynchronizedViewMatrix(): boolean;
  25523. /** @hidden */
  25524. _isSynchronizedProjectionMatrix(): boolean;
  25525. /**
  25526. * Attach the input controls to a specific dom element to get the input from.
  25527. * @param element Defines the element the controls should be listened from
  25528. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25529. */
  25530. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25531. /**
  25532. * Detach the current controls from the specified dom element.
  25533. * @param element Defines the element to stop listening the inputs from
  25534. */
  25535. detachControl(element: HTMLElement): void;
  25536. /**
  25537. * Update the camera state according to the different inputs gathered during the frame.
  25538. */
  25539. update(): void;
  25540. /** @hidden */
  25541. _checkInputs(): void;
  25542. /** @hidden */
  25543. readonly rigCameras: Camera[];
  25544. /**
  25545. * Gets the post process used by the rig cameras
  25546. */
  25547. readonly rigPostProcess: Nullable<PostProcess>;
  25548. /**
  25549. * Internal, gets the first post proces.
  25550. * @returns the first post process to be run on this camera.
  25551. */
  25552. _getFirstPostProcess(): Nullable<PostProcess>;
  25553. private _cascadePostProcessesToRigCams;
  25554. /**
  25555. * Attach a post process to the camera.
  25556. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25557. * @param postProcess The post process to attach to the camera
  25558. * @param insertAt The position of the post process in case several of them are in use in the scene
  25559. * @returns the position the post process has been inserted at
  25560. */
  25561. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25562. /**
  25563. * Detach a post process to the camera.
  25564. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25565. * @param postProcess The post process to detach from the camera
  25566. */
  25567. detachPostProcess(postProcess: PostProcess): void;
  25568. /**
  25569. * Gets the current world matrix of the camera
  25570. */
  25571. getWorldMatrix(): Matrix;
  25572. /** @hidden */
  25573. _getViewMatrix(): Matrix;
  25574. /**
  25575. * Gets the current view matrix of the camera.
  25576. * @param force forces the camera to recompute the matrix without looking at the cached state
  25577. * @returns the view matrix
  25578. */
  25579. getViewMatrix(force?: boolean): Matrix;
  25580. /**
  25581. * Freeze the projection matrix.
  25582. * It will prevent the cache check of the camera projection compute and can speed up perf
  25583. * if no parameter of the camera are meant to change
  25584. * @param projection Defines manually a projection if necessary
  25585. */
  25586. freezeProjectionMatrix(projection?: Matrix): void;
  25587. /**
  25588. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25589. */
  25590. unfreezeProjectionMatrix(): void;
  25591. /**
  25592. * Gets the current projection matrix of the camera.
  25593. * @param force forces the camera to recompute the matrix without looking at the cached state
  25594. * @returns the projection matrix
  25595. */
  25596. getProjectionMatrix(force?: boolean): Matrix;
  25597. /**
  25598. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25599. * @returns a Matrix
  25600. */
  25601. getTransformationMatrix(): Matrix;
  25602. private _updateFrustumPlanes;
  25603. /**
  25604. * Checks if a cullable object (mesh...) is in the camera frustum
  25605. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25606. * @param target The object to check
  25607. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25608. * @returns true if the object is in frustum otherwise false
  25609. */
  25610. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25611. /**
  25612. * Checks if a cullable object (mesh...) is in the camera frustum
  25613. * Unlike isInFrustum this cheks the full bounding box
  25614. * @param target The object to check
  25615. * @returns true if the object is in frustum otherwise false
  25616. */
  25617. isCompletelyInFrustum(target: ICullable): boolean;
  25618. /**
  25619. * Gets a ray in the forward direction from the camera.
  25620. * @param length Defines the length of the ray to create
  25621. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25622. * @param origin Defines the start point of the ray which defaults to the camera position
  25623. * @returns the forward ray
  25624. */
  25625. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25626. /**
  25627. * Releases resources associated with this node.
  25628. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25629. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25630. */
  25631. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25632. /** @hidden */
  25633. _isLeftCamera: boolean;
  25634. /**
  25635. * Gets the left camera of a rig setup in case of Rigged Camera
  25636. */
  25637. readonly isLeftCamera: boolean;
  25638. /** @hidden */
  25639. _isRightCamera: boolean;
  25640. /**
  25641. * Gets the right camera of a rig setup in case of Rigged Camera
  25642. */
  25643. readonly isRightCamera: boolean;
  25644. /**
  25645. * Gets the left camera of a rig setup in case of Rigged Camera
  25646. */
  25647. readonly leftCamera: Nullable<FreeCamera>;
  25648. /**
  25649. * Gets the right camera of a rig setup in case of Rigged Camera
  25650. */
  25651. readonly rightCamera: Nullable<FreeCamera>;
  25652. /**
  25653. * Gets the left camera target of a rig setup in case of Rigged Camera
  25654. * @returns the target position
  25655. */
  25656. getLeftTarget(): Nullable<Vector3>;
  25657. /**
  25658. * Gets the right camera target of a rig setup in case of Rigged Camera
  25659. * @returns the target position
  25660. */
  25661. getRightTarget(): Nullable<Vector3>;
  25662. /**
  25663. * @hidden
  25664. */
  25665. setCameraRigMode(mode: number, rigParams: any): void;
  25666. /** @hidden */
  25667. static _setStereoscopicRigMode(camera: Camera): void;
  25668. /** @hidden */
  25669. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25670. /** @hidden */
  25671. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25672. /** @hidden */
  25673. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25674. /** @hidden */
  25675. _getVRProjectionMatrix(): Matrix;
  25676. protected _updateCameraRotationMatrix(): void;
  25677. protected _updateWebVRCameraRotationMatrix(): void;
  25678. /**
  25679. * This function MUST be overwritten by the different WebVR cameras available.
  25680. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25681. * @hidden
  25682. */
  25683. _getWebVRProjectionMatrix(): Matrix;
  25684. /**
  25685. * This function MUST be overwritten by the different WebVR cameras available.
  25686. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25687. * @hidden
  25688. */
  25689. _getWebVRViewMatrix(): Matrix;
  25690. /** @hidden */
  25691. setCameraRigParameter(name: string, value: any): void;
  25692. /**
  25693. * needs to be overridden by children so sub has required properties to be copied
  25694. * @hidden
  25695. */
  25696. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25697. /**
  25698. * May need to be overridden by children
  25699. * @hidden
  25700. */
  25701. _updateRigCameras(): void;
  25702. /** @hidden */
  25703. _setupInputs(): void;
  25704. /**
  25705. * Serialiaze the camera setup to a json represention
  25706. * @returns the JSON representation
  25707. */
  25708. serialize(): any;
  25709. /**
  25710. * Clones the current camera.
  25711. * @param name The cloned camera name
  25712. * @returns the cloned camera
  25713. */
  25714. clone(name: string): Camera;
  25715. /**
  25716. * Gets the direction of the camera relative to a given local axis.
  25717. * @param localAxis Defines the reference axis to provide a relative direction.
  25718. * @return the direction
  25719. */
  25720. getDirection(localAxis: Vector3): Vector3;
  25721. /**
  25722. * Returns the current camera absolute rotation
  25723. */
  25724. readonly absoluteRotation: Quaternion;
  25725. /**
  25726. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25727. * @param localAxis Defines the reference axis to provide a relative direction.
  25728. * @param result Defines the vector to store the result in
  25729. */
  25730. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25731. /**
  25732. * Gets a camera constructor for a given camera type
  25733. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25734. * @param name The name of the camera the result will be able to instantiate
  25735. * @param scene The scene the result will construct the camera in
  25736. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25737. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25738. * @returns a factory method to construc the camera
  25739. */
  25740. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25741. /**
  25742. * Compute the world matrix of the camera.
  25743. * @returns the camera workd matrix
  25744. */
  25745. computeWorldMatrix(): Matrix;
  25746. /**
  25747. * Parse a JSON and creates the camera from the parsed information
  25748. * @param parsedCamera The JSON to parse
  25749. * @param scene The scene to instantiate the camera in
  25750. * @returns the newly constructed camera
  25751. */
  25752. static Parse(parsedCamera: any, scene: Scene): Camera;
  25753. }
  25754. }
  25755. declare module "babylonjs/Meshes/Builders/discBuilder" {
  25756. import { Nullable } from "babylonjs/types";
  25757. import { Scene } from "babylonjs/scene";
  25758. import { Vector4 } from "babylonjs/Maths/math.vector";
  25759. import { Mesh } from "babylonjs/Meshes/mesh";
  25760. /**
  25761. * Class containing static functions to help procedurally build meshes
  25762. */
  25763. export class DiscBuilder {
  25764. /**
  25765. * Creates a plane polygonal mesh. By default, this is a disc
  25766. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25767. * * 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
  25768. * * 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
  25769. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25770. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25771. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25772. * @param name defines the name of the mesh
  25773. * @param options defines the options used to create the mesh
  25774. * @param scene defines the hosting scene
  25775. * @returns the plane polygonal mesh
  25776. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25777. */
  25778. static CreateDisc(name: string, options: {
  25779. radius?: number;
  25780. tessellation?: number;
  25781. arc?: number;
  25782. updatable?: boolean;
  25783. sideOrientation?: number;
  25784. frontUVs?: Vector4;
  25785. backUVs?: Vector4;
  25786. }, scene?: Nullable<Scene>): Mesh;
  25787. }
  25788. }
  25789. declare module "babylonjs/Particles/solidParticleSystem" {
  25790. import { Vector3 } from "babylonjs/Maths/math.vector";
  25791. import { Mesh } from "babylonjs/Meshes/mesh";
  25792. import { Scene, IDisposable } from "babylonjs/scene";
  25793. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  25794. /**
  25795. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25796. *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.
  25797. * The SPS is also a particle system. It provides some methods to manage the particles.
  25798. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25799. *
  25800. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25801. */
  25802. export class SolidParticleSystem implements IDisposable {
  25803. /**
  25804. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25805. * Example : var p = SPS.particles[i];
  25806. */
  25807. particles: SolidParticle[];
  25808. /**
  25809. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25810. */
  25811. nbParticles: number;
  25812. /**
  25813. * If the particles must ever face the camera (default false). Useful for planar particles.
  25814. */
  25815. billboard: boolean;
  25816. /**
  25817. * Recompute normals when adding a shape
  25818. */
  25819. recomputeNormals: boolean;
  25820. /**
  25821. * This a counter ofr your own usage. It's not set by any SPS functions.
  25822. */
  25823. counter: number;
  25824. /**
  25825. * The SPS name. This name is also given to the underlying mesh.
  25826. */
  25827. name: string;
  25828. /**
  25829. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25830. */
  25831. mesh: Mesh;
  25832. /**
  25833. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25834. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25835. */
  25836. vars: any;
  25837. /**
  25838. * This array is populated when the SPS is set as 'pickable'.
  25839. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25840. * Each element of this array is an object `{idx: int, faceId: int}`.
  25841. * `idx` is the picked particle index in the `SPS.particles` array
  25842. * `faceId` is the picked face index counted within this particle.
  25843. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25844. */
  25845. pickedParticles: {
  25846. idx: number;
  25847. faceId: number;
  25848. }[];
  25849. /**
  25850. * This array is populated when `enableDepthSort` is set to true.
  25851. * Each element of this array is an instance of the class DepthSortedParticle.
  25852. */
  25853. depthSortedParticles: DepthSortedParticle[];
  25854. /**
  25855. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25856. * @hidden
  25857. */
  25858. _bSphereOnly: boolean;
  25859. /**
  25860. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25861. * @hidden
  25862. */
  25863. _bSphereRadiusFactor: number;
  25864. private _scene;
  25865. private _positions;
  25866. private _indices;
  25867. private _normals;
  25868. private _colors;
  25869. private _uvs;
  25870. private _indices32;
  25871. private _positions32;
  25872. private _normals32;
  25873. private _fixedNormal32;
  25874. private _colors32;
  25875. private _uvs32;
  25876. private _index;
  25877. private _updatable;
  25878. private _pickable;
  25879. private _isVisibilityBoxLocked;
  25880. private _alwaysVisible;
  25881. private _depthSort;
  25882. private _shapeCounter;
  25883. private _copy;
  25884. private _color;
  25885. private _computeParticleColor;
  25886. private _computeParticleTexture;
  25887. private _computeParticleRotation;
  25888. private _computeParticleVertex;
  25889. private _computeBoundingBox;
  25890. private _depthSortParticles;
  25891. private _camera;
  25892. private _mustUnrotateFixedNormals;
  25893. private _particlesIntersect;
  25894. private _needs32Bits;
  25895. /**
  25896. * Creates a SPS (Solid Particle System) object.
  25897. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25898. * @param scene (Scene) is the scene in which the SPS is added.
  25899. * @param options defines the options of the sps e.g.
  25900. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25901. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25902. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25903. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25904. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25905. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25906. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25907. */
  25908. constructor(name: string, scene: Scene, options?: {
  25909. updatable?: boolean;
  25910. isPickable?: boolean;
  25911. enableDepthSort?: boolean;
  25912. particleIntersection?: boolean;
  25913. boundingSphereOnly?: boolean;
  25914. bSphereRadiusFactor?: number;
  25915. });
  25916. /**
  25917. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25918. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25919. * @returns the created mesh
  25920. */
  25921. buildMesh(): Mesh;
  25922. /**
  25923. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25924. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25925. * Thus the particles generated from `digest()` have their property `position` set yet.
  25926. * @param mesh ( Mesh ) is the mesh to be digested
  25927. * @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
  25928. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25929. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25930. * @returns the current SPS
  25931. */
  25932. digest(mesh: Mesh, options?: {
  25933. facetNb?: number;
  25934. number?: number;
  25935. delta?: number;
  25936. }): SolidParticleSystem;
  25937. private _unrotateFixedNormals;
  25938. private _resetCopy;
  25939. private _meshBuilder;
  25940. private _posToShape;
  25941. private _uvsToShapeUV;
  25942. private _addParticle;
  25943. /**
  25944. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25945. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25946. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25947. * @param nb (positive integer) the number of particles to be created from this model
  25948. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25949. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25950. * @returns the number of shapes in the system
  25951. */
  25952. addShape(mesh: Mesh, nb: number, options?: {
  25953. positionFunction?: any;
  25954. vertexFunction?: any;
  25955. }): number;
  25956. private _rebuildParticle;
  25957. /**
  25958. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25959. * @returns the SPS.
  25960. */
  25961. rebuildMesh(): SolidParticleSystem;
  25962. /**
  25963. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25964. * This method calls `updateParticle()` for each particle of the SPS.
  25965. * For an animated SPS, it is usually called within the render loop.
  25966. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25967. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25968. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25969. * @returns the SPS.
  25970. */
  25971. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25972. /**
  25973. * Disposes the SPS.
  25974. */
  25975. dispose(): void;
  25976. /**
  25977. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25978. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25979. * @returns the SPS.
  25980. */
  25981. refreshVisibleSize(): SolidParticleSystem;
  25982. /**
  25983. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25984. * @param size the size (float) of the visibility box
  25985. * note : this doesn't lock the SPS mesh bounding box.
  25986. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25987. */
  25988. setVisibilityBox(size: number): void;
  25989. /**
  25990. * Gets whether the SPS as always visible or not
  25991. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25992. */
  25993. /**
  25994. * Sets the SPS as always visible or not
  25995. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25996. */
  25997. isAlwaysVisible: boolean;
  25998. /**
  25999. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26000. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26001. */
  26002. /**
  26003. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26004. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26005. */
  26006. isVisibilityBoxLocked: boolean;
  26007. /**
  26008. * Tells to `setParticles()` to compute the particle rotations or not.
  26009. * Default value : true. The SPS is faster when it's set to false.
  26010. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26011. */
  26012. /**
  26013. * Gets if `setParticles()` computes the particle rotations or not.
  26014. * Default value : true. The SPS is faster when it's set to false.
  26015. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26016. */
  26017. computeParticleRotation: boolean;
  26018. /**
  26019. * Tells to `setParticles()` to compute the particle colors or not.
  26020. * Default value : true. The SPS is faster when it's set to false.
  26021. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26022. */
  26023. /**
  26024. * Gets if `setParticles()` computes the particle colors or not.
  26025. * Default value : true. The SPS is faster when it's set to false.
  26026. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26027. */
  26028. computeParticleColor: boolean;
  26029. /**
  26030. * Gets if `setParticles()` computes the particle textures or not.
  26031. * Default value : true. The SPS is faster when it's set to false.
  26032. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26033. */
  26034. computeParticleTexture: boolean;
  26035. /**
  26036. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26037. * Default value : false. The SPS is faster when it's set to false.
  26038. * Note : the particle custom vertex positions aren't stored values.
  26039. */
  26040. /**
  26041. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26042. * Default value : false. The SPS is faster when it's set to false.
  26043. * Note : the particle custom vertex positions aren't stored values.
  26044. */
  26045. computeParticleVertex: boolean;
  26046. /**
  26047. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26048. */
  26049. /**
  26050. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26051. */
  26052. computeBoundingBox: boolean;
  26053. /**
  26054. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26055. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26056. * Default : `true`
  26057. */
  26058. /**
  26059. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26060. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26061. * Default : `true`
  26062. */
  26063. depthSortParticles: boolean;
  26064. /**
  26065. * This function does nothing. It may be overwritten to set all the particle first values.
  26066. * The SPS doesn't call this function, you may have to call it by your own.
  26067. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26068. */
  26069. initParticles(): void;
  26070. /**
  26071. * This function does nothing. It may be overwritten to recycle a particle.
  26072. * The SPS doesn't call this function, you may have to call it by your own.
  26073. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26074. * @param particle The particle to recycle
  26075. * @returns the recycled particle
  26076. */
  26077. recycleParticle(particle: SolidParticle): SolidParticle;
  26078. /**
  26079. * Updates a particle : this function should be overwritten by the user.
  26080. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26081. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26082. * @example : just set a particle position or velocity and recycle conditions
  26083. * @param particle The particle to update
  26084. * @returns the updated particle
  26085. */
  26086. updateParticle(particle: SolidParticle): SolidParticle;
  26087. /**
  26088. * Updates a vertex of a particle : it can be overwritten by the user.
  26089. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26090. * @param particle the current particle
  26091. * @param vertex the current index of the current particle
  26092. * @param pt the index of the current vertex in the particle shape
  26093. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  26094. * @example : just set a vertex particle position
  26095. * @returns the updated vertex
  26096. */
  26097. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26098. /**
  26099. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26100. * This does nothing and may be overwritten by the user.
  26101. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26102. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26103. * @param update the boolean update value actually passed to setParticles()
  26104. */
  26105. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26106. /**
  26107. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26108. * This will be passed three parameters.
  26109. * This does nothing and may be overwritten by the user.
  26110. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26111. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26112. * @param update the boolean update value actually passed to setParticles()
  26113. */
  26114. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26115. }
  26116. }
  26117. declare module "babylonjs/Particles/solidParticle" {
  26118. import { Nullable } from "babylonjs/types";
  26119. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26120. import { Color4 } from "babylonjs/Maths/math.color";
  26121. import { Mesh } from "babylonjs/Meshes/mesh";
  26122. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26123. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26124. import { Plane } from "babylonjs/Maths/math.plane";
  26125. /**
  26126. * Represents one particle of a solid particle system.
  26127. */
  26128. export class SolidParticle {
  26129. /**
  26130. * particle global index
  26131. */
  26132. idx: number;
  26133. /**
  26134. * The color of the particle
  26135. */
  26136. color: Nullable<Color4>;
  26137. /**
  26138. * The world space position of the particle.
  26139. */
  26140. position: Vector3;
  26141. /**
  26142. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26143. */
  26144. rotation: Vector3;
  26145. /**
  26146. * The world space rotation quaternion of the particle.
  26147. */
  26148. rotationQuaternion: Nullable<Quaternion>;
  26149. /**
  26150. * The scaling of the particle.
  26151. */
  26152. scaling: Vector3;
  26153. /**
  26154. * The uvs of the particle.
  26155. */
  26156. uvs: Vector4;
  26157. /**
  26158. * The current speed of the particle.
  26159. */
  26160. velocity: Vector3;
  26161. /**
  26162. * The pivot point in the particle local space.
  26163. */
  26164. pivot: Vector3;
  26165. /**
  26166. * Must the particle be translated from its pivot point in its local space ?
  26167. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26168. * Default : false
  26169. */
  26170. translateFromPivot: boolean;
  26171. /**
  26172. * Is the particle active or not ?
  26173. */
  26174. alive: boolean;
  26175. /**
  26176. * Is the particle visible or not ?
  26177. */
  26178. isVisible: boolean;
  26179. /**
  26180. * Index of this particle in the global "positions" array (Internal use)
  26181. * @hidden
  26182. */
  26183. _pos: number;
  26184. /**
  26185. * @hidden Index of this particle in the global "indices" array (Internal use)
  26186. */
  26187. _ind: number;
  26188. /**
  26189. * @hidden ModelShape of this particle (Internal use)
  26190. */
  26191. _model: ModelShape;
  26192. /**
  26193. * ModelShape id of this particle
  26194. */
  26195. shapeId: number;
  26196. /**
  26197. * Index of the particle in its shape id
  26198. */
  26199. idxInShape: number;
  26200. /**
  26201. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26202. */
  26203. _modelBoundingInfo: BoundingInfo;
  26204. /**
  26205. * @hidden Particle BoundingInfo object (Internal use)
  26206. */
  26207. _boundingInfo: BoundingInfo;
  26208. /**
  26209. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26210. */
  26211. _sps: SolidParticleSystem;
  26212. /**
  26213. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26214. */
  26215. _stillInvisible: boolean;
  26216. /**
  26217. * @hidden Last computed particle rotation matrix
  26218. */
  26219. _rotationMatrix: number[];
  26220. /**
  26221. * Parent particle Id, if any.
  26222. * Default null.
  26223. */
  26224. parentId: Nullable<number>;
  26225. /**
  26226. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26227. * The possible values are :
  26228. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26229. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26230. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26231. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26232. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26233. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26234. * */
  26235. cullingStrategy: number;
  26236. /**
  26237. * @hidden Internal global position in the SPS.
  26238. */
  26239. _globalPosition: Vector3;
  26240. /**
  26241. * Creates a Solid Particle object.
  26242. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26243. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26244. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26245. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26246. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26247. * @param shapeId (integer) is the model shape identifier in the SPS.
  26248. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26249. * @param sps defines the sps it is associated to
  26250. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26251. */
  26252. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26253. /**
  26254. * Legacy support, changed scale to scaling
  26255. */
  26256. /**
  26257. * Legacy support, changed scale to scaling
  26258. */
  26259. scale: Vector3;
  26260. /**
  26261. * Legacy support, changed quaternion to rotationQuaternion
  26262. */
  26263. /**
  26264. * Legacy support, changed quaternion to rotationQuaternion
  26265. */
  26266. quaternion: Nullable<Quaternion>;
  26267. /**
  26268. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26269. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26270. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26271. * @returns true if it intersects
  26272. */
  26273. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26274. /**
  26275. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26276. * A particle is in the frustum if its bounding box intersects the frustum
  26277. * @param frustumPlanes defines the frustum to test
  26278. * @returns true if the particle is in the frustum planes
  26279. */
  26280. isInFrustum(frustumPlanes: Plane[]): boolean;
  26281. /**
  26282. * get the rotation matrix of the particle
  26283. * @hidden
  26284. */
  26285. getRotationMatrix(m: Matrix): void;
  26286. }
  26287. /**
  26288. * Represents the shape of the model used by one particle of a solid particle system.
  26289. * SPS internal tool, don't use it manually.
  26290. */
  26291. export class ModelShape {
  26292. /**
  26293. * The shape id
  26294. * @hidden
  26295. */
  26296. shapeID: number;
  26297. /**
  26298. * flat array of model positions (internal use)
  26299. * @hidden
  26300. */
  26301. _shape: Vector3[];
  26302. /**
  26303. * flat array of model UVs (internal use)
  26304. * @hidden
  26305. */
  26306. _shapeUV: number[];
  26307. /**
  26308. * length of the shape in the model indices array (internal use)
  26309. * @hidden
  26310. */
  26311. _indicesLength: number;
  26312. /**
  26313. * Custom position function (internal use)
  26314. * @hidden
  26315. */
  26316. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26317. /**
  26318. * Custom vertex function (internal use)
  26319. * @hidden
  26320. */
  26321. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26322. /**
  26323. * 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.
  26324. * SPS internal tool, don't use it manually.
  26325. * @hidden
  26326. */
  26327. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  26328. }
  26329. /**
  26330. * Represents a Depth Sorted Particle in the solid particle system.
  26331. */
  26332. export class DepthSortedParticle {
  26333. /**
  26334. * Index of the particle in the "indices" array
  26335. */
  26336. ind: number;
  26337. /**
  26338. * Length of the particle shape in the "indices" array
  26339. */
  26340. indicesLength: number;
  26341. /**
  26342. * Squared distance from the particle to the camera
  26343. */
  26344. sqDistance: number;
  26345. }
  26346. }
  26347. declare module "babylonjs/Collisions/meshCollisionData" {
  26348. import { Collider } from "babylonjs/Collisions/collider";
  26349. import { Vector3 } from "babylonjs/Maths/math.vector";
  26350. import { Nullable } from "babylonjs/types";
  26351. import { Observer } from "babylonjs/Misc/observable";
  26352. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26353. /**
  26354. * @hidden
  26355. */
  26356. export class _MeshCollisionData {
  26357. _checkCollisions: boolean;
  26358. _collisionMask: number;
  26359. _collisionGroup: number;
  26360. _collider: Nullable<Collider>;
  26361. _oldPositionForCollisions: Vector3;
  26362. _diffPositionForCollisions: Vector3;
  26363. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26364. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26365. }
  26366. }
  26367. declare module "babylonjs/Meshes/abstractMesh" {
  26368. import { Observable } from "babylonjs/Misc/observable";
  26369. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26370. import { Camera } from "babylonjs/Cameras/camera";
  26371. import { Scene, IDisposable } from "babylonjs/scene";
  26372. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26373. import { Node } from "babylonjs/node";
  26374. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26375. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26376. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26377. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26378. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26379. import { Material } from "babylonjs/Materials/material";
  26380. import { Light } from "babylonjs/Lights/light";
  26381. import { Skeleton } from "babylonjs/Bones/skeleton";
  26382. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26383. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26384. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26385. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26386. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26387. import { Plane } from "babylonjs/Maths/math.plane";
  26388. import { Ray } from "babylonjs/Culling/ray";
  26389. import { Collider } from "babylonjs/Collisions/collider";
  26390. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26391. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26392. /** @hidden */
  26393. class _FacetDataStorage {
  26394. facetPositions: Vector3[];
  26395. facetNormals: Vector3[];
  26396. facetPartitioning: number[][];
  26397. facetNb: number;
  26398. partitioningSubdivisions: number;
  26399. partitioningBBoxRatio: number;
  26400. facetDataEnabled: boolean;
  26401. facetParameters: any;
  26402. bbSize: Vector3;
  26403. subDiv: {
  26404. max: number;
  26405. X: number;
  26406. Y: number;
  26407. Z: number;
  26408. };
  26409. facetDepthSort: boolean;
  26410. facetDepthSortEnabled: boolean;
  26411. depthSortedIndices: IndicesArray;
  26412. depthSortedFacets: {
  26413. ind: number;
  26414. sqDistance: number;
  26415. }[];
  26416. facetDepthSortFunction: (f1: {
  26417. ind: number;
  26418. sqDistance: number;
  26419. }, f2: {
  26420. ind: number;
  26421. sqDistance: number;
  26422. }) => number;
  26423. facetDepthSortFrom: Vector3;
  26424. facetDepthSortOrigin: Vector3;
  26425. invertedMatrix: Matrix;
  26426. }
  26427. /**
  26428. * @hidden
  26429. **/
  26430. class _InternalAbstractMeshDataInfo {
  26431. _hasVertexAlpha: boolean;
  26432. _useVertexColors: boolean;
  26433. _numBoneInfluencers: number;
  26434. _applyFog: boolean;
  26435. _receiveShadows: boolean;
  26436. _facetData: _FacetDataStorage;
  26437. _visibility: number;
  26438. _skeleton: Nullable<Skeleton>;
  26439. _layerMask: number;
  26440. _computeBonesUsingShaders: boolean;
  26441. _isActive: boolean;
  26442. _onlyForInstances: boolean;
  26443. _isActiveIntermediate: boolean;
  26444. _onlyForInstancesIntermediate: boolean;
  26445. }
  26446. /**
  26447. * Class used to store all common mesh properties
  26448. */
  26449. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26450. /** No occlusion */
  26451. static OCCLUSION_TYPE_NONE: number;
  26452. /** Occlusion set to optimisitic */
  26453. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26454. /** Occlusion set to strict */
  26455. static OCCLUSION_TYPE_STRICT: number;
  26456. /** Use an accurante occlusion algorithm */
  26457. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26458. /** Use a conservative occlusion algorithm */
  26459. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26460. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26461. * Test order :
  26462. * Is the bounding sphere outside the frustum ?
  26463. * If not, are the bounding box vertices outside the frustum ?
  26464. * It not, then the cullable object is in the frustum.
  26465. */
  26466. static readonly CULLINGSTRATEGY_STANDARD: number;
  26467. /** Culling strategy : Bounding Sphere Only.
  26468. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26469. * It's also less accurate than the standard because some not visible objects can still be selected.
  26470. * Test : is the bounding sphere outside the frustum ?
  26471. * If not, then the cullable object is in the frustum.
  26472. */
  26473. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26474. /** Culling strategy : Optimistic Inclusion.
  26475. * This in an inclusion test first, then the standard exclusion test.
  26476. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26477. * 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.
  26478. * Anyway, it's as accurate as the standard strategy.
  26479. * Test :
  26480. * Is the cullable object bounding sphere center in the frustum ?
  26481. * If not, apply the default culling strategy.
  26482. */
  26483. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26484. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26485. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26486. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26487. * 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.
  26488. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26489. * Test :
  26490. * Is the cullable object bounding sphere center in the frustum ?
  26491. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26492. */
  26493. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26494. /**
  26495. * No billboard
  26496. */
  26497. static readonly BILLBOARDMODE_NONE: number;
  26498. /** Billboard on X axis */
  26499. static readonly BILLBOARDMODE_X: number;
  26500. /** Billboard on Y axis */
  26501. static readonly BILLBOARDMODE_Y: number;
  26502. /** Billboard on Z axis */
  26503. static readonly BILLBOARDMODE_Z: number;
  26504. /** Billboard on all axes */
  26505. static readonly BILLBOARDMODE_ALL: number;
  26506. /** Billboard on using position instead of orientation */
  26507. static readonly BILLBOARDMODE_USE_POSITION: number;
  26508. /** @hidden */
  26509. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26510. /**
  26511. * The culling strategy to use to check whether the mesh must be rendered or not.
  26512. * This value can be changed at any time and will be used on the next render mesh selection.
  26513. * The possible values are :
  26514. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26515. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26516. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26517. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26518. * Please read each static variable documentation to get details about the culling process.
  26519. * */
  26520. cullingStrategy: number;
  26521. /**
  26522. * Gets the number of facets in the mesh
  26523. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26524. */
  26525. readonly facetNb: number;
  26526. /**
  26527. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26528. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26529. */
  26530. partitioningSubdivisions: number;
  26531. /**
  26532. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26533. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26534. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26535. */
  26536. partitioningBBoxRatio: number;
  26537. /**
  26538. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26539. * Works only for updatable meshes.
  26540. * Doesn't work with multi-materials
  26541. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26542. */
  26543. mustDepthSortFacets: boolean;
  26544. /**
  26545. * The location (Vector3) where the facet depth sort must be computed from.
  26546. * By default, the active camera position.
  26547. * Used only when facet depth sort is enabled
  26548. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26549. */
  26550. facetDepthSortFrom: Vector3;
  26551. /**
  26552. * gets a boolean indicating if facetData is enabled
  26553. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26554. */
  26555. readonly isFacetDataEnabled: boolean;
  26556. /** @hidden */
  26557. _updateNonUniformScalingState(value: boolean): boolean;
  26558. /**
  26559. * An event triggered when this mesh collides with another one
  26560. */
  26561. onCollideObservable: Observable<AbstractMesh>;
  26562. /** Set a function to call when this mesh collides with another one */
  26563. onCollide: () => void;
  26564. /**
  26565. * An event triggered when the collision's position changes
  26566. */
  26567. onCollisionPositionChangeObservable: Observable<Vector3>;
  26568. /** Set a function to call when the collision's position changes */
  26569. onCollisionPositionChange: () => void;
  26570. /**
  26571. * An event triggered when material is changed
  26572. */
  26573. onMaterialChangedObservable: Observable<AbstractMesh>;
  26574. /**
  26575. * Gets or sets the orientation for POV movement & rotation
  26576. */
  26577. definedFacingForward: boolean;
  26578. /** @hidden */
  26579. _occlusionQuery: Nullable<WebGLQuery>;
  26580. /** @hidden */
  26581. _renderingGroup: Nullable<RenderingGroup>;
  26582. /**
  26583. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26584. */
  26585. /**
  26586. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26587. */
  26588. visibility: number;
  26589. /** Gets or sets the alpha index used to sort transparent meshes
  26590. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26591. */
  26592. alphaIndex: number;
  26593. /**
  26594. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26595. */
  26596. isVisible: boolean;
  26597. /**
  26598. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26599. */
  26600. isPickable: boolean;
  26601. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26602. showSubMeshesBoundingBox: boolean;
  26603. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26604. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26605. */
  26606. isBlocker: boolean;
  26607. /**
  26608. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26609. */
  26610. enablePointerMoveEvents: boolean;
  26611. /**
  26612. * Specifies the rendering group id for this mesh (0 by default)
  26613. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26614. */
  26615. renderingGroupId: number;
  26616. private _material;
  26617. /** Gets or sets current material */
  26618. material: Nullable<Material>;
  26619. /**
  26620. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26621. * @see http://doc.babylonjs.com/babylon101/shadows
  26622. */
  26623. receiveShadows: boolean;
  26624. /** Defines color to use when rendering outline */
  26625. outlineColor: Color3;
  26626. /** Define width to use when rendering outline */
  26627. outlineWidth: number;
  26628. /** Defines color to use when rendering overlay */
  26629. overlayColor: Color3;
  26630. /** Defines alpha to use when rendering overlay */
  26631. overlayAlpha: number;
  26632. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26633. hasVertexAlpha: boolean;
  26634. /** 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) */
  26635. useVertexColors: boolean;
  26636. /**
  26637. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26638. */
  26639. computeBonesUsingShaders: boolean;
  26640. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26641. numBoneInfluencers: number;
  26642. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26643. applyFog: boolean;
  26644. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26645. useOctreeForRenderingSelection: boolean;
  26646. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26647. useOctreeForPicking: boolean;
  26648. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26649. useOctreeForCollisions: boolean;
  26650. /**
  26651. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26652. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26653. */
  26654. layerMask: number;
  26655. /**
  26656. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26657. */
  26658. alwaysSelectAsActiveMesh: boolean;
  26659. /**
  26660. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26661. */
  26662. doNotSyncBoundingInfo: boolean;
  26663. /**
  26664. * Gets or sets the current action manager
  26665. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26666. */
  26667. actionManager: Nullable<AbstractActionManager>;
  26668. private _meshCollisionData;
  26669. /**
  26670. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26671. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26672. */
  26673. ellipsoid: Vector3;
  26674. /**
  26675. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26676. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26677. */
  26678. ellipsoidOffset: Vector3;
  26679. /**
  26680. * Gets or sets a collision mask used to mask collisions (default is -1).
  26681. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26682. */
  26683. collisionMask: number;
  26684. /**
  26685. * Gets or sets the current collision group mask (-1 by default).
  26686. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26687. */
  26688. collisionGroup: number;
  26689. /**
  26690. * Defines edge width used when edgesRenderer is enabled
  26691. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26692. */
  26693. edgesWidth: number;
  26694. /**
  26695. * Defines edge color used when edgesRenderer is enabled
  26696. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26697. */
  26698. edgesColor: Color4;
  26699. /** @hidden */
  26700. _edgesRenderer: Nullable<IEdgesRenderer>;
  26701. /** @hidden */
  26702. _masterMesh: Nullable<AbstractMesh>;
  26703. /** @hidden */
  26704. _boundingInfo: Nullable<BoundingInfo>;
  26705. /** @hidden */
  26706. _renderId: number;
  26707. /**
  26708. * Gets or sets the list of subMeshes
  26709. * @see http://doc.babylonjs.com/how_to/multi_materials
  26710. */
  26711. subMeshes: SubMesh[];
  26712. /** @hidden */
  26713. _intersectionsInProgress: AbstractMesh[];
  26714. /** @hidden */
  26715. _unIndexed: boolean;
  26716. /** @hidden */
  26717. _lightSources: Light[];
  26718. /** Gets the list of lights affecting that mesh */
  26719. readonly lightSources: Light[];
  26720. /** @hidden */
  26721. readonly _positions: Nullable<Vector3[]>;
  26722. /** @hidden */
  26723. _waitingData: {
  26724. lods: Nullable<any>;
  26725. actions: Nullable<any>;
  26726. freezeWorldMatrix: Nullable<boolean>;
  26727. };
  26728. /** @hidden */
  26729. _bonesTransformMatrices: Nullable<Float32Array>;
  26730. /** @hidden */
  26731. _transformMatrixTexture: Nullable<RawTexture>;
  26732. /**
  26733. * Gets or sets a skeleton to apply skining transformations
  26734. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26735. */
  26736. skeleton: Nullable<Skeleton>;
  26737. /**
  26738. * An event triggered when the mesh is rebuilt.
  26739. */
  26740. onRebuildObservable: Observable<AbstractMesh>;
  26741. /**
  26742. * Creates a new AbstractMesh
  26743. * @param name defines the name of the mesh
  26744. * @param scene defines the hosting scene
  26745. */
  26746. constructor(name: string, scene?: Nullable<Scene>);
  26747. /**
  26748. * Returns the string "AbstractMesh"
  26749. * @returns "AbstractMesh"
  26750. */
  26751. getClassName(): string;
  26752. /**
  26753. * Gets a string representation of the current mesh
  26754. * @param fullDetails defines a boolean indicating if full details must be included
  26755. * @returns a string representation of the current mesh
  26756. */
  26757. toString(fullDetails?: boolean): string;
  26758. /**
  26759. * @hidden
  26760. */
  26761. protected _getEffectiveParent(): Nullable<Node>;
  26762. /** @hidden */
  26763. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26764. /** @hidden */
  26765. _rebuild(): void;
  26766. /** @hidden */
  26767. _resyncLightSources(): void;
  26768. /** @hidden */
  26769. _resyncLighSource(light: Light): void;
  26770. /** @hidden */
  26771. _unBindEffect(): void;
  26772. /** @hidden */
  26773. _removeLightSource(light: Light, dispose: boolean): void;
  26774. private _markSubMeshesAsDirty;
  26775. /** @hidden */
  26776. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26777. /** @hidden */
  26778. _markSubMeshesAsAttributesDirty(): void;
  26779. /** @hidden */
  26780. _markSubMeshesAsMiscDirty(): void;
  26781. /**
  26782. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26783. */
  26784. scaling: Vector3;
  26785. /**
  26786. * Returns true if the mesh is blocked. Implemented by child classes
  26787. */
  26788. readonly isBlocked: boolean;
  26789. /**
  26790. * Returns the mesh itself by default. Implemented by child classes
  26791. * @param camera defines the camera to use to pick the right LOD level
  26792. * @returns the currentAbstractMesh
  26793. */
  26794. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26795. /**
  26796. * Returns 0 by default. Implemented by child classes
  26797. * @returns an integer
  26798. */
  26799. getTotalVertices(): number;
  26800. /**
  26801. * Returns a positive integer : the total number of indices in this mesh geometry.
  26802. * @returns the numner of indices or zero if the mesh has no geometry.
  26803. */
  26804. getTotalIndices(): number;
  26805. /**
  26806. * Returns null by default. Implemented by child classes
  26807. * @returns null
  26808. */
  26809. getIndices(): Nullable<IndicesArray>;
  26810. /**
  26811. * Returns the array of the requested vertex data kind. Implemented by child classes
  26812. * @param kind defines the vertex data kind to use
  26813. * @returns null
  26814. */
  26815. getVerticesData(kind: string): Nullable<FloatArray>;
  26816. /**
  26817. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26818. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26819. * Note that a new underlying VertexBuffer object is created each call.
  26820. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26821. * @param kind defines vertex data kind:
  26822. * * VertexBuffer.PositionKind
  26823. * * VertexBuffer.UVKind
  26824. * * VertexBuffer.UV2Kind
  26825. * * VertexBuffer.UV3Kind
  26826. * * VertexBuffer.UV4Kind
  26827. * * VertexBuffer.UV5Kind
  26828. * * VertexBuffer.UV6Kind
  26829. * * VertexBuffer.ColorKind
  26830. * * VertexBuffer.MatricesIndicesKind
  26831. * * VertexBuffer.MatricesIndicesExtraKind
  26832. * * VertexBuffer.MatricesWeightsKind
  26833. * * VertexBuffer.MatricesWeightsExtraKind
  26834. * @param data defines the data source
  26835. * @param updatable defines if the data must be flagged as updatable (or static)
  26836. * @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
  26837. * @returns the current mesh
  26838. */
  26839. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26840. /**
  26841. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26842. * If the mesh has no geometry, it is simply returned as it is.
  26843. * @param kind defines vertex data kind:
  26844. * * VertexBuffer.PositionKind
  26845. * * VertexBuffer.UVKind
  26846. * * VertexBuffer.UV2Kind
  26847. * * VertexBuffer.UV3Kind
  26848. * * VertexBuffer.UV4Kind
  26849. * * VertexBuffer.UV5Kind
  26850. * * VertexBuffer.UV6Kind
  26851. * * VertexBuffer.ColorKind
  26852. * * VertexBuffer.MatricesIndicesKind
  26853. * * VertexBuffer.MatricesIndicesExtraKind
  26854. * * VertexBuffer.MatricesWeightsKind
  26855. * * VertexBuffer.MatricesWeightsExtraKind
  26856. * @param data defines the data source
  26857. * @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
  26858. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26859. * @returns the current mesh
  26860. */
  26861. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26862. /**
  26863. * Sets the mesh indices,
  26864. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26865. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26866. * @param totalVertices Defines the total number of vertices
  26867. * @returns the current mesh
  26868. */
  26869. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26870. /**
  26871. * Gets a boolean indicating if specific vertex data is present
  26872. * @param kind defines the vertex data kind to use
  26873. * @returns true is data kind is present
  26874. */
  26875. isVerticesDataPresent(kind: string): boolean;
  26876. /**
  26877. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26878. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26879. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26880. * @returns a BoundingInfo
  26881. */
  26882. getBoundingInfo(): BoundingInfo;
  26883. /**
  26884. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26885. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26886. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26887. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26888. * @returns the current mesh
  26889. */
  26890. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26891. /**
  26892. * Overwrite the current bounding info
  26893. * @param boundingInfo defines the new bounding info
  26894. * @returns the current mesh
  26895. */
  26896. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26897. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26898. readonly useBones: boolean;
  26899. /** @hidden */
  26900. _preActivate(): void;
  26901. /** @hidden */
  26902. _preActivateForIntermediateRendering(renderId: number): void;
  26903. /** @hidden */
  26904. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26905. /** @hidden */
  26906. _postActivate(): void;
  26907. /** @hidden */
  26908. _freeze(): void;
  26909. /** @hidden */
  26910. _unFreeze(): void;
  26911. /**
  26912. * Gets the current world matrix
  26913. * @returns a Matrix
  26914. */
  26915. getWorldMatrix(): Matrix;
  26916. /** @hidden */
  26917. _getWorldMatrixDeterminant(): number;
  26918. /**
  26919. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26920. */
  26921. readonly isAnInstance: boolean;
  26922. /**
  26923. * Gets a boolean indicating if this mesh has instances
  26924. */
  26925. readonly hasInstances: boolean;
  26926. /**
  26927. * Perform relative position change from the point of view of behind the front of the mesh.
  26928. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26929. * Supports definition of mesh facing forward or backward
  26930. * @param amountRight defines the distance on the right axis
  26931. * @param amountUp defines the distance on the up axis
  26932. * @param amountForward defines the distance on the forward axis
  26933. * @returns the current mesh
  26934. */
  26935. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26936. /**
  26937. * Calculate relative position change from the point of view of behind the front of the mesh.
  26938. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26939. * Supports definition of mesh facing forward or backward
  26940. * @param amountRight defines the distance on the right axis
  26941. * @param amountUp defines the distance on the up axis
  26942. * @param amountForward defines the distance on the forward axis
  26943. * @returns the new displacement vector
  26944. */
  26945. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26946. /**
  26947. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26948. * Supports definition of mesh facing forward or backward
  26949. * @param flipBack defines the flip
  26950. * @param twirlClockwise defines the twirl
  26951. * @param tiltRight defines the tilt
  26952. * @returns the current mesh
  26953. */
  26954. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26955. /**
  26956. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26957. * Supports definition of mesh facing forward or backward.
  26958. * @param flipBack defines the flip
  26959. * @param twirlClockwise defines the twirl
  26960. * @param tiltRight defines the tilt
  26961. * @returns the new rotation vector
  26962. */
  26963. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26964. /**
  26965. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26966. * This means the mesh underlying bounding box and sphere are recomputed.
  26967. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26968. * @returns the current mesh
  26969. */
  26970. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26971. /** @hidden */
  26972. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26973. /** @hidden */
  26974. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26975. /** @hidden */
  26976. _updateBoundingInfo(): AbstractMesh;
  26977. /** @hidden */
  26978. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26979. /** @hidden */
  26980. protected _afterComputeWorldMatrix(): void;
  26981. /** @hidden */
  26982. readonly _effectiveMesh: AbstractMesh;
  26983. /**
  26984. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26985. * A mesh is in the frustum if its bounding box intersects the frustum
  26986. * @param frustumPlanes defines the frustum to test
  26987. * @returns true if the mesh is in the frustum planes
  26988. */
  26989. isInFrustum(frustumPlanes: Plane[]): boolean;
  26990. /**
  26991. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26992. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26993. * @param frustumPlanes defines the frustum to test
  26994. * @returns true if the mesh is completely in the frustum planes
  26995. */
  26996. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26997. /**
  26998. * True if the mesh intersects another mesh or a SolidParticle object
  26999. * @param mesh defines a target mesh or SolidParticle to test
  27000. * @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)
  27001. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  27002. * @returns true if there is an intersection
  27003. */
  27004. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  27005. /**
  27006. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  27007. * @param point defines the point to test
  27008. * @returns true if there is an intersection
  27009. */
  27010. intersectsPoint(point: Vector3): boolean;
  27011. /**
  27012. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  27013. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27014. */
  27015. checkCollisions: boolean;
  27016. /**
  27017. * Gets Collider object used to compute collisions (not physics)
  27018. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27019. */
  27020. readonly collider: Nullable<Collider>;
  27021. /**
  27022. * Move the mesh using collision engine
  27023. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27024. * @param displacement defines the requested displacement vector
  27025. * @returns the current mesh
  27026. */
  27027. moveWithCollisions(displacement: Vector3): AbstractMesh;
  27028. private _onCollisionPositionChange;
  27029. /** @hidden */
  27030. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  27031. /** @hidden */
  27032. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  27033. /** @hidden */
  27034. _checkCollision(collider: Collider): AbstractMesh;
  27035. /** @hidden */
  27036. _generatePointsArray(): boolean;
  27037. /**
  27038. * Checks if the passed Ray intersects with the mesh
  27039. * @param ray defines the ray to use
  27040. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  27041. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  27042. * @returns the picking info
  27043. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  27044. */
  27045. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  27046. /**
  27047. * Clones the current mesh
  27048. * @param name defines the mesh name
  27049. * @param newParent defines the new mesh parent
  27050. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  27051. * @returns the new mesh
  27052. */
  27053. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  27054. /**
  27055. * Disposes all the submeshes of the current meshnp
  27056. * @returns the current mesh
  27057. */
  27058. releaseSubMeshes(): AbstractMesh;
  27059. /**
  27060. * Releases resources associated with this abstract mesh.
  27061. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27062. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27063. */
  27064. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27065. /**
  27066. * Adds the passed mesh as a child to the current mesh
  27067. * @param mesh defines the child mesh
  27068. * @returns the current mesh
  27069. */
  27070. addChild(mesh: AbstractMesh): AbstractMesh;
  27071. /**
  27072. * Removes the passed mesh from the current mesh children list
  27073. * @param mesh defines the child mesh
  27074. * @returns the current mesh
  27075. */
  27076. removeChild(mesh: AbstractMesh): AbstractMesh;
  27077. /** @hidden */
  27078. private _initFacetData;
  27079. /**
  27080. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  27081. * This method can be called within the render loop.
  27082. * 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
  27083. * @returns the current mesh
  27084. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27085. */
  27086. updateFacetData(): AbstractMesh;
  27087. /**
  27088. * Returns the facetLocalNormals array.
  27089. * The normals are expressed in the mesh local spac
  27090. * @returns an array of Vector3
  27091. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27092. */
  27093. getFacetLocalNormals(): Vector3[];
  27094. /**
  27095. * Returns the facetLocalPositions array.
  27096. * The facet positions are expressed in the mesh local space
  27097. * @returns an array of Vector3
  27098. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27099. */
  27100. getFacetLocalPositions(): Vector3[];
  27101. /**
  27102. * Returns the facetLocalPartioning array
  27103. * @returns an array of array of numbers
  27104. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27105. */
  27106. getFacetLocalPartitioning(): number[][];
  27107. /**
  27108. * Returns the i-th facet position in the world system.
  27109. * This method allocates a new Vector3 per call
  27110. * @param i defines the facet index
  27111. * @returns a new Vector3
  27112. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27113. */
  27114. getFacetPosition(i: number): Vector3;
  27115. /**
  27116. * Sets the reference Vector3 with the i-th facet position in the world system
  27117. * @param i defines the facet index
  27118. * @param ref defines the target vector
  27119. * @returns the current mesh
  27120. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27121. */
  27122. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27123. /**
  27124. * Returns the i-th facet normal in the world system.
  27125. * This method allocates a new Vector3 per call
  27126. * @param i defines the facet index
  27127. * @returns a new Vector3
  27128. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27129. */
  27130. getFacetNormal(i: number): Vector3;
  27131. /**
  27132. * Sets the reference Vector3 with the i-th facet normal in the world system
  27133. * @param i defines the facet index
  27134. * @param ref defines the target vector
  27135. * @returns the current mesh
  27136. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27137. */
  27138. getFacetNormalToRef(i: number, ref: Vector3): this;
  27139. /**
  27140. * 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)
  27141. * @param x defines x coordinate
  27142. * @param y defines y coordinate
  27143. * @param z defines z coordinate
  27144. * @returns the array of facet indexes
  27145. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27146. */
  27147. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27148. /**
  27149. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27150. * @param projected sets as the (x,y,z) world projection on the facet
  27151. * @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
  27152. * @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
  27153. * @param x defines x coordinate
  27154. * @param y defines y coordinate
  27155. * @param z defines z coordinate
  27156. * @returns the face index if found (or null instead)
  27157. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27158. */
  27159. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27160. /**
  27161. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27162. * @param projected sets as the (x,y,z) local projection on the facet
  27163. * @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
  27164. * @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
  27165. * @param x defines x coordinate
  27166. * @param y defines y coordinate
  27167. * @param z defines z coordinate
  27168. * @returns the face index if found (or null instead)
  27169. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27170. */
  27171. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27172. /**
  27173. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27174. * @returns the parameters
  27175. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27176. */
  27177. getFacetDataParameters(): any;
  27178. /**
  27179. * Disables the feature FacetData and frees the related memory
  27180. * @returns the current mesh
  27181. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27182. */
  27183. disableFacetData(): AbstractMesh;
  27184. /**
  27185. * Updates the AbstractMesh indices array
  27186. * @param indices defines the data source
  27187. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27188. * @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)
  27189. * @returns the current mesh
  27190. */
  27191. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27192. /**
  27193. * Creates new normals data for the mesh
  27194. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27195. * @returns the current mesh
  27196. */
  27197. createNormals(updatable: boolean): AbstractMesh;
  27198. /**
  27199. * Align the mesh with a normal
  27200. * @param normal defines the normal to use
  27201. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27202. * @returns the current mesh
  27203. */
  27204. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27205. /** @hidden */
  27206. _checkOcclusionQuery(): boolean;
  27207. /**
  27208. * Disables the mesh edge rendering mode
  27209. * @returns the currentAbstractMesh
  27210. */
  27211. disableEdgesRendering(): AbstractMesh;
  27212. /**
  27213. * Enables the edge rendering mode on the mesh.
  27214. * This mode makes the mesh edges visible
  27215. * @param epsilon defines the maximal distance between two angles to detect a face
  27216. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27217. * @returns the currentAbstractMesh
  27218. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27219. */
  27220. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27221. }
  27222. }
  27223. declare module "babylonjs/Actions/actionEvent" {
  27224. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27225. import { Nullable } from "babylonjs/types";
  27226. import { Sprite } from "babylonjs/Sprites/sprite";
  27227. import { Scene } from "babylonjs/scene";
  27228. import { Vector2 } from "babylonjs/Maths/math.vector";
  27229. /**
  27230. * Interface used to define ActionEvent
  27231. */
  27232. export interface IActionEvent {
  27233. /** The mesh or sprite that triggered the action */
  27234. source: any;
  27235. /** The X mouse cursor position at the time of the event */
  27236. pointerX: number;
  27237. /** The Y mouse cursor position at the time of the event */
  27238. pointerY: number;
  27239. /** The mesh that is currently pointed at (can be null) */
  27240. meshUnderPointer: Nullable<AbstractMesh>;
  27241. /** the original (browser) event that triggered the ActionEvent */
  27242. sourceEvent?: any;
  27243. /** additional data for the event */
  27244. additionalData?: any;
  27245. }
  27246. /**
  27247. * ActionEvent is the event being sent when an action is triggered.
  27248. */
  27249. export class ActionEvent implements IActionEvent {
  27250. /** The mesh or sprite that triggered the action */
  27251. source: any;
  27252. /** The X mouse cursor position at the time of the event */
  27253. pointerX: number;
  27254. /** The Y mouse cursor position at the time of the event */
  27255. pointerY: number;
  27256. /** The mesh that is currently pointed at (can be null) */
  27257. meshUnderPointer: Nullable<AbstractMesh>;
  27258. /** the original (browser) event that triggered the ActionEvent */
  27259. sourceEvent?: any;
  27260. /** additional data for the event */
  27261. additionalData?: any;
  27262. /**
  27263. * Creates a new ActionEvent
  27264. * @param source The mesh or sprite that triggered the action
  27265. * @param pointerX The X mouse cursor position at the time of the event
  27266. * @param pointerY The Y mouse cursor position at the time of the event
  27267. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27268. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27269. * @param additionalData additional data for the event
  27270. */
  27271. constructor(
  27272. /** The mesh or sprite that triggered the action */
  27273. source: any,
  27274. /** The X mouse cursor position at the time of the event */
  27275. pointerX: number,
  27276. /** The Y mouse cursor position at the time of the event */
  27277. pointerY: number,
  27278. /** The mesh that is currently pointed at (can be null) */
  27279. meshUnderPointer: Nullable<AbstractMesh>,
  27280. /** the original (browser) event that triggered the ActionEvent */
  27281. sourceEvent?: any,
  27282. /** additional data for the event */
  27283. additionalData?: any);
  27284. /**
  27285. * Helper function to auto-create an ActionEvent from a source mesh.
  27286. * @param source The source mesh that triggered the event
  27287. * @param evt The original (browser) event
  27288. * @param additionalData additional data for the event
  27289. * @returns the new ActionEvent
  27290. */
  27291. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27292. /**
  27293. * Helper function to auto-create an ActionEvent from a source sprite
  27294. * @param source The source sprite that triggered the event
  27295. * @param scene Scene associated with the sprite
  27296. * @param evt The original (browser) event
  27297. * @param additionalData additional data for the event
  27298. * @returns the new ActionEvent
  27299. */
  27300. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27301. /**
  27302. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27303. * @param scene the scene where the event occurred
  27304. * @param evt The original (browser) event
  27305. * @returns the new ActionEvent
  27306. */
  27307. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27308. /**
  27309. * Helper function to auto-create an ActionEvent from a primitive
  27310. * @param prim defines the target primitive
  27311. * @param pointerPos defines the pointer position
  27312. * @param evt The original (browser) event
  27313. * @param additionalData additional data for the event
  27314. * @returns the new ActionEvent
  27315. */
  27316. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27317. }
  27318. }
  27319. declare module "babylonjs/Actions/abstractActionManager" {
  27320. import { IDisposable } from "babylonjs/scene";
  27321. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27322. import { IAction } from "babylonjs/Actions/action";
  27323. import { Nullable } from "babylonjs/types";
  27324. /**
  27325. * Abstract class used to decouple action Manager from scene and meshes.
  27326. * Do not instantiate.
  27327. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27328. */
  27329. export abstract class AbstractActionManager implements IDisposable {
  27330. /** Gets the list of active triggers */
  27331. static Triggers: {
  27332. [key: string]: number;
  27333. };
  27334. /** Gets the cursor to use when hovering items */
  27335. hoverCursor: string;
  27336. /** Gets the list of actions */
  27337. actions: IAction[];
  27338. /**
  27339. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27340. */
  27341. isRecursive: boolean;
  27342. /**
  27343. * Releases all associated resources
  27344. */
  27345. abstract dispose(): void;
  27346. /**
  27347. * Does this action manager has pointer triggers
  27348. */
  27349. abstract readonly hasPointerTriggers: boolean;
  27350. /**
  27351. * Does this action manager has pick triggers
  27352. */
  27353. abstract readonly hasPickTriggers: boolean;
  27354. /**
  27355. * Process a specific trigger
  27356. * @param trigger defines the trigger to process
  27357. * @param evt defines the event details to be processed
  27358. */
  27359. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27360. /**
  27361. * Does this action manager handles actions of any of the given triggers
  27362. * @param triggers defines the triggers to be tested
  27363. * @return a boolean indicating whether one (or more) of the triggers is handled
  27364. */
  27365. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27366. /**
  27367. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27368. * speed.
  27369. * @param triggerA defines the trigger to be tested
  27370. * @param triggerB defines the trigger to be tested
  27371. * @return a boolean indicating whether one (or more) of the triggers is handled
  27372. */
  27373. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27374. /**
  27375. * Does this action manager handles actions of a given trigger
  27376. * @param trigger defines the trigger to be tested
  27377. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27378. * @return whether the trigger is handled
  27379. */
  27380. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27381. /**
  27382. * Serialize this manager to a JSON object
  27383. * @param name defines the property name to store this manager
  27384. * @returns a JSON representation of this manager
  27385. */
  27386. abstract serialize(name: string): any;
  27387. /**
  27388. * Registers an action to this action manager
  27389. * @param action defines the action to be registered
  27390. * @return the action amended (prepared) after registration
  27391. */
  27392. abstract registerAction(action: IAction): Nullable<IAction>;
  27393. /**
  27394. * Unregisters an action to this action manager
  27395. * @param action defines the action to be unregistered
  27396. * @return a boolean indicating whether the action has been unregistered
  27397. */
  27398. abstract unregisterAction(action: IAction): Boolean;
  27399. /**
  27400. * Does exist one action manager with at least one trigger
  27401. **/
  27402. static readonly HasTriggers: boolean;
  27403. /**
  27404. * Does exist one action manager with at least one pick trigger
  27405. **/
  27406. static readonly HasPickTriggers: boolean;
  27407. /**
  27408. * Does exist one action manager that handles actions of a given trigger
  27409. * @param trigger defines the trigger to be tested
  27410. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27411. **/
  27412. static HasSpecificTrigger(trigger: number): boolean;
  27413. }
  27414. }
  27415. declare module "babylonjs/node" {
  27416. import { Scene } from "babylonjs/scene";
  27417. import { Nullable } from "babylonjs/types";
  27418. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27419. import { Engine } from "babylonjs/Engines/engine";
  27420. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27421. import { Observable } from "babylonjs/Misc/observable";
  27422. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27423. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27424. import { Animatable } from "babylonjs/Animations/animatable";
  27425. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27426. import { Animation } from "babylonjs/Animations/animation";
  27427. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27428. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27429. /**
  27430. * Defines how a node can be built from a string name.
  27431. */
  27432. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27433. /**
  27434. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27435. */
  27436. export class Node implements IBehaviorAware<Node> {
  27437. /** @hidden */
  27438. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27439. private static _NodeConstructors;
  27440. /**
  27441. * Add a new node constructor
  27442. * @param type defines the type name of the node to construct
  27443. * @param constructorFunc defines the constructor function
  27444. */
  27445. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27446. /**
  27447. * Returns a node constructor based on type name
  27448. * @param type defines the type name
  27449. * @param name defines the new node name
  27450. * @param scene defines the hosting scene
  27451. * @param options defines optional options to transmit to constructors
  27452. * @returns the new constructor or null
  27453. */
  27454. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27455. /**
  27456. * Gets or sets the name of the node
  27457. */
  27458. name: string;
  27459. /**
  27460. * Gets or sets the id of the node
  27461. */
  27462. id: string;
  27463. /**
  27464. * Gets or sets the unique id of the node
  27465. */
  27466. uniqueId: number;
  27467. /**
  27468. * Gets or sets a string used to store user defined state for the node
  27469. */
  27470. state: string;
  27471. /**
  27472. * Gets or sets an object used to store user defined information for the node
  27473. */
  27474. metadata: any;
  27475. /**
  27476. * For internal use only. Please do not use.
  27477. */
  27478. reservedDataStore: any;
  27479. /**
  27480. * List of inspectable custom properties (used by the Inspector)
  27481. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27482. */
  27483. inspectableCustomProperties: IInspectable[];
  27484. /**
  27485. * Gets or sets a boolean used to define if the node must be serialized
  27486. */
  27487. doNotSerialize: boolean;
  27488. /** @hidden */
  27489. _isDisposed: boolean;
  27490. /**
  27491. * Gets a list of Animations associated with the node
  27492. */
  27493. animations: import("babylonjs/Animations/animation").Animation[];
  27494. protected _ranges: {
  27495. [name: string]: Nullable<AnimationRange>;
  27496. };
  27497. /**
  27498. * Callback raised when the node is ready to be used
  27499. */
  27500. onReady: Nullable<(node: Node) => void>;
  27501. private _isEnabled;
  27502. private _isParentEnabled;
  27503. private _isReady;
  27504. /** @hidden */
  27505. _currentRenderId: number;
  27506. private _parentUpdateId;
  27507. /** @hidden */
  27508. _childUpdateId: number;
  27509. /** @hidden */
  27510. _waitingParentId: Nullable<string>;
  27511. /** @hidden */
  27512. _scene: Scene;
  27513. /** @hidden */
  27514. _cache: any;
  27515. private _parentNode;
  27516. private _children;
  27517. /** @hidden */
  27518. _worldMatrix: Matrix;
  27519. /** @hidden */
  27520. _worldMatrixDeterminant: number;
  27521. /** @hidden */
  27522. _worldMatrixDeterminantIsDirty: boolean;
  27523. /** @hidden */
  27524. private _sceneRootNodesIndex;
  27525. /**
  27526. * Gets a boolean indicating if the node has been disposed
  27527. * @returns true if the node was disposed
  27528. */
  27529. isDisposed(): boolean;
  27530. /**
  27531. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27532. * @see https://doc.babylonjs.com/how_to/parenting
  27533. */
  27534. parent: Nullable<Node>;
  27535. private addToSceneRootNodes;
  27536. private removeFromSceneRootNodes;
  27537. private _animationPropertiesOverride;
  27538. /**
  27539. * Gets or sets the animation properties override
  27540. */
  27541. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27542. /**
  27543. * Gets a string idenfifying the name of the class
  27544. * @returns "Node" string
  27545. */
  27546. getClassName(): string;
  27547. /** @hidden */
  27548. readonly _isNode: boolean;
  27549. /**
  27550. * An event triggered when the mesh is disposed
  27551. */
  27552. onDisposeObservable: Observable<Node>;
  27553. private _onDisposeObserver;
  27554. /**
  27555. * Sets a callback that will be raised when the node will be disposed
  27556. */
  27557. onDispose: () => void;
  27558. /**
  27559. * Creates a new Node
  27560. * @param name the name and id to be given to this node
  27561. * @param scene the scene this node will be added to
  27562. * @param addToRootNodes the node will be added to scene.rootNodes
  27563. */
  27564. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27565. /**
  27566. * Gets the scene of the node
  27567. * @returns a scene
  27568. */
  27569. getScene(): Scene;
  27570. /**
  27571. * Gets the engine of the node
  27572. * @returns a Engine
  27573. */
  27574. getEngine(): Engine;
  27575. private _behaviors;
  27576. /**
  27577. * Attach a behavior to the node
  27578. * @see http://doc.babylonjs.com/features/behaviour
  27579. * @param behavior defines the behavior to attach
  27580. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27581. * @returns the current Node
  27582. */
  27583. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27584. /**
  27585. * Remove an attached behavior
  27586. * @see http://doc.babylonjs.com/features/behaviour
  27587. * @param behavior defines the behavior to attach
  27588. * @returns the current Node
  27589. */
  27590. removeBehavior(behavior: Behavior<Node>): Node;
  27591. /**
  27592. * Gets the list of attached behaviors
  27593. * @see http://doc.babylonjs.com/features/behaviour
  27594. */
  27595. readonly behaviors: Behavior<Node>[];
  27596. /**
  27597. * Gets an attached behavior by name
  27598. * @param name defines the name of the behavior to look for
  27599. * @see http://doc.babylonjs.com/features/behaviour
  27600. * @returns null if behavior was not found else the requested behavior
  27601. */
  27602. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27603. /**
  27604. * Returns the latest update of the World matrix
  27605. * @returns a Matrix
  27606. */
  27607. getWorldMatrix(): Matrix;
  27608. /** @hidden */
  27609. _getWorldMatrixDeterminant(): number;
  27610. /**
  27611. * Returns directly the latest state of the mesh World matrix.
  27612. * A Matrix is returned.
  27613. */
  27614. readonly worldMatrixFromCache: Matrix;
  27615. /** @hidden */
  27616. _initCache(): void;
  27617. /** @hidden */
  27618. updateCache(force?: boolean): void;
  27619. /** @hidden */
  27620. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27621. /** @hidden */
  27622. _updateCache(ignoreParentClass?: boolean): void;
  27623. /** @hidden */
  27624. _isSynchronized(): boolean;
  27625. /** @hidden */
  27626. _markSyncedWithParent(): void;
  27627. /** @hidden */
  27628. isSynchronizedWithParent(): boolean;
  27629. /** @hidden */
  27630. isSynchronized(): boolean;
  27631. /**
  27632. * Is this node ready to be used/rendered
  27633. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27634. * @return true if the node is ready
  27635. */
  27636. isReady(completeCheck?: boolean): boolean;
  27637. /**
  27638. * Is this node enabled?
  27639. * 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
  27640. * @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
  27641. * @return whether this node (and its parent) is enabled
  27642. */
  27643. isEnabled(checkAncestors?: boolean): boolean;
  27644. /** @hidden */
  27645. protected _syncParentEnabledState(): void;
  27646. /**
  27647. * Set the enabled state of this node
  27648. * @param value defines the new enabled state
  27649. */
  27650. setEnabled(value: boolean): void;
  27651. /**
  27652. * Is this node a descendant of the given node?
  27653. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27654. * @param ancestor defines the parent node to inspect
  27655. * @returns a boolean indicating if this node is a descendant of the given node
  27656. */
  27657. isDescendantOf(ancestor: Node): boolean;
  27658. /** @hidden */
  27659. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27660. /**
  27661. * Will return all nodes that have this node as ascendant
  27662. * @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
  27663. * @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
  27664. * @return all children nodes of all types
  27665. */
  27666. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27667. /**
  27668. * Get all child-meshes of this node
  27669. * @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)
  27670. * @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
  27671. * @returns an array of AbstractMesh
  27672. */
  27673. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27674. /**
  27675. * Get all direct children of this node
  27676. * @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
  27677. * @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)
  27678. * @returns an array of Node
  27679. */
  27680. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27681. /** @hidden */
  27682. _setReady(state: boolean): void;
  27683. /**
  27684. * Get an animation by name
  27685. * @param name defines the name of the animation to look for
  27686. * @returns null if not found else the requested animation
  27687. */
  27688. getAnimationByName(name: string): Nullable<Animation>;
  27689. /**
  27690. * Creates an animation range for this node
  27691. * @param name defines the name of the range
  27692. * @param from defines the starting key
  27693. * @param to defines the end key
  27694. */
  27695. createAnimationRange(name: string, from: number, to: number): void;
  27696. /**
  27697. * Delete a specific animation range
  27698. * @param name defines the name of the range to delete
  27699. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27700. */
  27701. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27702. /**
  27703. * Get an animation range by name
  27704. * @param name defines the name of the animation range to look for
  27705. * @returns null if not found else the requested animation range
  27706. */
  27707. getAnimationRange(name: string): Nullable<AnimationRange>;
  27708. /**
  27709. * Gets the list of all animation ranges defined on this node
  27710. * @returns an array
  27711. */
  27712. getAnimationRanges(): Nullable<AnimationRange>[];
  27713. /**
  27714. * Will start the animation sequence
  27715. * @param name defines the range frames for animation sequence
  27716. * @param loop defines if the animation should loop (false by default)
  27717. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27718. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27719. * @returns the object created for this animation. If range does not exist, it will return null
  27720. */
  27721. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27722. /**
  27723. * Serialize animation ranges into a JSON compatible object
  27724. * @returns serialization object
  27725. */
  27726. serializeAnimationRanges(): any;
  27727. /**
  27728. * Computes the world matrix of the node
  27729. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27730. * @returns the world matrix
  27731. */
  27732. computeWorldMatrix(force?: boolean): Matrix;
  27733. /**
  27734. * Releases resources associated with this node.
  27735. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27736. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27737. */
  27738. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27739. /**
  27740. * Parse animation range data from a serialization object and store them into a given node
  27741. * @param node defines where to store the animation ranges
  27742. * @param parsedNode defines the serialization object to read data from
  27743. * @param scene defines the hosting scene
  27744. */
  27745. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27746. /**
  27747. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27748. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27749. * @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
  27750. * @returns the new bounding vectors
  27751. */
  27752. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27753. min: Vector3;
  27754. max: Vector3;
  27755. };
  27756. }
  27757. }
  27758. declare module "babylonjs/Animations/animation" {
  27759. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  27760. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  27761. import { Color3 } from "babylonjs/Maths/math.color";
  27762. import { Nullable } from "babylonjs/types";
  27763. import { Scene } from "babylonjs/scene";
  27764. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  27765. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27766. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  27767. import { Node } from "babylonjs/node";
  27768. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27769. import { Size } from "babylonjs/Maths/math.size";
  27770. import { Animatable } from "babylonjs/Animations/animatable";
  27771. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  27772. /**
  27773. * @hidden
  27774. */
  27775. export class _IAnimationState {
  27776. key: number;
  27777. repeatCount: number;
  27778. workValue?: any;
  27779. loopMode?: number;
  27780. offsetValue?: any;
  27781. highLimitValue?: any;
  27782. }
  27783. /**
  27784. * Class used to store any kind of animation
  27785. */
  27786. export class Animation {
  27787. /**Name of the animation */
  27788. name: string;
  27789. /**Property to animate */
  27790. targetProperty: string;
  27791. /**The frames per second of the animation */
  27792. framePerSecond: number;
  27793. /**The data type of the animation */
  27794. dataType: number;
  27795. /**The loop mode of the animation */
  27796. loopMode?: number | undefined;
  27797. /**Specifies if blending should be enabled */
  27798. enableBlending?: boolean | undefined;
  27799. /**
  27800. * Use matrix interpolation instead of using direct key value when animating matrices
  27801. */
  27802. static AllowMatricesInterpolation: boolean;
  27803. /**
  27804. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27805. */
  27806. static AllowMatrixDecomposeForInterpolation: boolean;
  27807. /**
  27808. * Stores the key frames of the animation
  27809. */
  27810. private _keys;
  27811. /**
  27812. * Stores the easing function of the animation
  27813. */
  27814. private _easingFunction;
  27815. /**
  27816. * @hidden Internal use only
  27817. */
  27818. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  27819. /**
  27820. * The set of event that will be linked to this animation
  27821. */
  27822. private _events;
  27823. /**
  27824. * Stores an array of target property paths
  27825. */
  27826. targetPropertyPath: string[];
  27827. /**
  27828. * Stores the blending speed of the animation
  27829. */
  27830. blendingSpeed: number;
  27831. /**
  27832. * Stores the animation ranges for the animation
  27833. */
  27834. private _ranges;
  27835. /**
  27836. * @hidden Internal use
  27837. */
  27838. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27839. /**
  27840. * Sets up an animation
  27841. * @param property The property to animate
  27842. * @param animationType The animation type to apply
  27843. * @param framePerSecond The frames per second of the animation
  27844. * @param easingFunction The easing function used in the animation
  27845. * @returns The created animation
  27846. */
  27847. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27848. /**
  27849. * Create and start an animation on a node
  27850. * @param name defines the name of the global animation that will be run on all nodes
  27851. * @param node defines the root node where the animation will take place
  27852. * @param targetProperty defines property to animate
  27853. * @param framePerSecond defines the number of frame per second yo use
  27854. * @param totalFrame defines the number of frames in total
  27855. * @param from defines the initial value
  27856. * @param to defines the final value
  27857. * @param loopMode defines which loop mode you want to use (off by default)
  27858. * @param easingFunction defines the easing function to use (linear by default)
  27859. * @param onAnimationEnd defines the callback to call when animation end
  27860. * @returns the animatable created for this animation
  27861. */
  27862. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27863. /**
  27864. * Create and start an animation on a node and its descendants
  27865. * @param name defines the name of the global animation that will be run on all nodes
  27866. * @param node defines the root node where the animation will take place
  27867. * @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
  27868. * @param targetProperty defines property to animate
  27869. * @param framePerSecond defines the number of frame per second to use
  27870. * @param totalFrame defines the number of frames in total
  27871. * @param from defines the initial value
  27872. * @param to defines the final value
  27873. * @param loopMode defines which loop mode you want to use (off by default)
  27874. * @param easingFunction defines the easing function to use (linear by default)
  27875. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27876. * @returns the list of animatables created for all nodes
  27877. * @example https://www.babylonjs-playground.com/#MH0VLI
  27878. */
  27879. 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[]>;
  27880. /**
  27881. * Creates a new animation, merges it with the existing animations and starts it
  27882. * @param name Name of the animation
  27883. * @param node Node which contains the scene that begins the animations
  27884. * @param targetProperty Specifies which property to animate
  27885. * @param framePerSecond The frames per second of the animation
  27886. * @param totalFrame The total number of frames
  27887. * @param from The frame at the beginning of the animation
  27888. * @param to The frame at the end of the animation
  27889. * @param loopMode Specifies the loop mode of the animation
  27890. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27891. * @param onAnimationEnd Callback to run once the animation is complete
  27892. * @returns Nullable animation
  27893. */
  27894. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27895. /**
  27896. * Transition property of an host to the target Value
  27897. * @param property The property to transition
  27898. * @param targetValue The target Value of the property
  27899. * @param host The object where the property to animate belongs
  27900. * @param scene Scene used to run the animation
  27901. * @param frameRate Framerate (in frame/s) to use
  27902. * @param transition The transition type we want to use
  27903. * @param duration The duration of the animation, in milliseconds
  27904. * @param onAnimationEnd Callback trigger at the end of the animation
  27905. * @returns Nullable animation
  27906. */
  27907. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27908. /**
  27909. * Return the array of runtime animations currently using this animation
  27910. */
  27911. readonly runtimeAnimations: RuntimeAnimation[];
  27912. /**
  27913. * Specifies if any of the runtime animations are currently running
  27914. */
  27915. readonly hasRunningRuntimeAnimations: boolean;
  27916. /**
  27917. * Initializes the animation
  27918. * @param name Name of the animation
  27919. * @param targetProperty Property to animate
  27920. * @param framePerSecond The frames per second of the animation
  27921. * @param dataType The data type of the animation
  27922. * @param loopMode The loop mode of the animation
  27923. * @param enableBlending Specifies if blending should be enabled
  27924. */
  27925. constructor(
  27926. /**Name of the animation */
  27927. name: string,
  27928. /**Property to animate */
  27929. targetProperty: string,
  27930. /**The frames per second of the animation */
  27931. framePerSecond: number,
  27932. /**The data type of the animation */
  27933. dataType: number,
  27934. /**The loop mode of the animation */
  27935. loopMode?: number | undefined,
  27936. /**Specifies if blending should be enabled */
  27937. enableBlending?: boolean | undefined);
  27938. /**
  27939. * Converts the animation to a string
  27940. * @param fullDetails support for multiple levels of logging within scene loading
  27941. * @returns String form of the animation
  27942. */
  27943. toString(fullDetails?: boolean): string;
  27944. /**
  27945. * Add an event to this animation
  27946. * @param event Event to add
  27947. */
  27948. addEvent(event: AnimationEvent): void;
  27949. /**
  27950. * Remove all events found at the given frame
  27951. * @param frame The frame to remove events from
  27952. */
  27953. removeEvents(frame: number): void;
  27954. /**
  27955. * Retrieves all the events from the animation
  27956. * @returns Events from the animation
  27957. */
  27958. getEvents(): AnimationEvent[];
  27959. /**
  27960. * Creates an animation range
  27961. * @param name Name of the animation range
  27962. * @param from Starting frame of the animation range
  27963. * @param to Ending frame of the animation
  27964. */
  27965. createRange(name: string, from: number, to: number): void;
  27966. /**
  27967. * Deletes an animation range by name
  27968. * @param name Name of the animation range to delete
  27969. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27970. */
  27971. deleteRange(name: string, deleteFrames?: boolean): void;
  27972. /**
  27973. * Gets the animation range by name, or null if not defined
  27974. * @param name Name of the animation range
  27975. * @returns Nullable animation range
  27976. */
  27977. getRange(name: string): Nullable<AnimationRange>;
  27978. /**
  27979. * Gets the key frames from the animation
  27980. * @returns The key frames of the animation
  27981. */
  27982. getKeys(): Array<IAnimationKey>;
  27983. /**
  27984. * Gets the highest frame rate of the animation
  27985. * @returns Highest frame rate of the animation
  27986. */
  27987. getHighestFrame(): number;
  27988. /**
  27989. * Gets the easing function of the animation
  27990. * @returns Easing function of the animation
  27991. */
  27992. getEasingFunction(): IEasingFunction;
  27993. /**
  27994. * Sets the easing function of the animation
  27995. * @param easingFunction A custom mathematical formula for animation
  27996. */
  27997. setEasingFunction(easingFunction: EasingFunction): void;
  27998. /**
  27999. * Interpolates a scalar linearly
  28000. * @param startValue Start value of the animation curve
  28001. * @param endValue End value of the animation curve
  28002. * @param gradient Scalar amount to interpolate
  28003. * @returns Interpolated scalar value
  28004. */
  28005. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  28006. /**
  28007. * Interpolates a scalar cubically
  28008. * @param startValue Start value of the animation curve
  28009. * @param outTangent End tangent of the animation
  28010. * @param endValue End value of the animation curve
  28011. * @param inTangent Start tangent of the animation curve
  28012. * @param gradient Scalar amount to interpolate
  28013. * @returns Interpolated scalar value
  28014. */
  28015. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  28016. /**
  28017. * Interpolates a quaternion using a spherical linear interpolation
  28018. * @param startValue Start value of the animation curve
  28019. * @param endValue End value of the animation curve
  28020. * @param gradient Scalar amount to interpolate
  28021. * @returns Interpolated quaternion value
  28022. */
  28023. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  28024. /**
  28025. * Interpolates a quaternion cubically
  28026. * @param startValue Start value of the animation curve
  28027. * @param outTangent End tangent of the animation curve
  28028. * @param endValue End value of the animation curve
  28029. * @param inTangent Start tangent of the animation curve
  28030. * @param gradient Scalar amount to interpolate
  28031. * @returns Interpolated quaternion value
  28032. */
  28033. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  28034. /**
  28035. * Interpolates a Vector3 linearl
  28036. * @param startValue Start value of the animation curve
  28037. * @param endValue End value of the animation curve
  28038. * @param gradient Scalar amount to interpolate
  28039. * @returns Interpolated scalar value
  28040. */
  28041. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  28042. /**
  28043. * Interpolates a Vector3 cubically
  28044. * @param startValue Start value of the animation curve
  28045. * @param outTangent End tangent of the animation
  28046. * @param endValue End value of the animation curve
  28047. * @param inTangent Start tangent of the animation curve
  28048. * @param gradient Scalar amount to interpolate
  28049. * @returns InterpolatedVector3 value
  28050. */
  28051. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  28052. /**
  28053. * Interpolates a Vector2 linearly
  28054. * @param startValue Start value of the animation curve
  28055. * @param endValue End value of the animation curve
  28056. * @param gradient Scalar amount to interpolate
  28057. * @returns Interpolated Vector2 value
  28058. */
  28059. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  28060. /**
  28061. * Interpolates a Vector2 cubically
  28062. * @param startValue Start value of the animation curve
  28063. * @param outTangent End tangent of the animation
  28064. * @param endValue End value of the animation curve
  28065. * @param inTangent Start tangent of the animation curve
  28066. * @param gradient Scalar amount to interpolate
  28067. * @returns Interpolated Vector2 value
  28068. */
  28069. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  28070. /**
  28071. * Interpolates a size linearly
  28072. * @param startValue Start value of the animation curve
  28073. * @param endValue End value of the animation curve
  28074. * @param gradient Scalar amount to interpolate
  28075. * @returns Interpolated Size value
  28076. */
  28077. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  28078. /**
  28079. * Interpolates a Color3 linearly
  28080. * @param startValue Start value of the animation curve
  28081. * @param endValue End value of the animation curve
  28082. * @param gradient Scalar amount to interpolate
  28083. * @returns Interpolated Color3 value
  28084. */
  28085. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  28086. /**
  28087. * @hidden Internal use only
  28088. */
  28089. _getKeyValue(value: any): any;
  28090. /**
  28091. * @hidden Internal use only
  28092. */
  28093. _interpolate(currentFrame: number, state: _IAnimationState): any;
  28094. /**
  28095. * Defines the function to use to interpolate matrices
  28096. * @param startValue defines the start matrix
  28097. * @param endValue defines the end matrix
  28098. * @param gradient defines the gradient between both matrices
  28099. * @param result defines an optional target matrix where to store the interpolation
  28100. * @returns the interpolated matrix
  28101. */
  28102. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28103. /**
  28104. * Makes a copy of the animation
  28105. * @returns Cloned animation
  28106. */
  28107. clone(): Animation;
  28108. /**
  28109. * Sets the key frames of the animation
  28110. * @param values The animation key frames to set
  28111. */
  28112. setKeys(values: Array<IAnimationKey>): void;
  28113. /**
  28114. * Serializes the animation to an object
  28115. * @returns Serialized object
  28116. */
  28117. serialize(): any;
  28118. /**
  28119. * Float animation type
  28120. */
  28121. private static _ANIMATIONTYPE_FLOAT;
  28122. /**
  28123. * Vector3 animation type
  28124. */
  28125. private static _ANIMATIONTYPE_VECTOR3;
  28126. /**
  28127. * Quaternion animation type
  28128. */
  28129. private static _ANIMATIONTYPE_QUATERNION;
  28130. /**
  28131. * Matrix animation type
  28132. */
  28133. private static _ANIMATIONTYPE_MATRIX;
  28134. /**
  28135. * Color3 animation type
  28136. */
  28137. private static _ANIMATIONTYPE_COLOR3;
  28138. /**
  28139. * Vector2 animation type
  28140. */
  28141. private static _ANIMATIONTYPE_VECTOR2;
  28142. /**
  28143. * Size animation type
  28144. */
  28145. private static _ANIMATIONTYPE_SIZE;
  28146. /**
  28147. * Relative Loop Mode
  28148. */
  28149. private static _ANIMATIONLOOPMODE_RELATIVE;
  28150. /**
  28151. * Cycle Loop Mode
  28152. */
  28153. private static _ANIMATIONLOOPMODE_CYCLE;
  28154. /**
  28155. * Constant Loop Mode
  28156. */
  28157. private static _ANIMATIONLOOPMODE_CONSTANT;
  28158. /**
  28159. * Get the float animation type
  28160. */
  28161. static readonly ANIMATIONTYPE_FLOAT: number;
  28162. /**
  28163. * Get the Vector3 animation type
  28164. */
  28165. static readonly ANIMATIONTYPE_VECTOR3: number;
  28166. /**
  28167. * Get the Vector2 animation type
  28168. */
  28169. static readonly ANIMATIONTYPE_VECTOR2: number;
  28170. /**
  28171. * Get the Size animation type
  28172. */
  28173. static readonly ANIMATIONTYPE_SIZE: number;
  28174. /**
  28175. * Get the Quaternion animation type
  28176. */
  28177. static readonly ANIMATIONTYPE_QUATERNION: number;
  28178. /**
  28179. * Get the Matrix animation type
  28180. */
  28181. static readonly ANIMATIONTYPE_MATRIX: number;
  28182. /**
  28183. * Get the Color3 animation type
  28184. */
  28185. static readonly ANIMATIONTYPE_COLOR3: number;
  28186. /**
  28187. * Get the Relative Loop Mode
  28188. */
  28189. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28190. /**
  28191. * Get the Cycle Loop Mode
  28192. */
  28193. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28194. /**
  28195. * Get the Constant Loop Mode
  28196. */
  28197. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28198. /** @hidden */
  28199. static _UniversalLerp(left: any, right: any, amount: number): any;
  28200. /**
  28201. * Parses an animation object and creates an animation
  28202. * @param parsedAnimation Parsed animation object
  28203. * @returns Animation object
  28204. */
  28205. static Parse(parsedAnimation: any): Animation;
  28206. /**
  28207. * Appends the serialized animations from the source animations
  28208. * @param source Source containing the animations
  28209. * @param destination Target to store the animations
  28210. */
  28211. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28212. }
  28213. }
  28214. declare module "babylonjs/Animations/animatable.interface" {
  28215. import { Nullable } from "babylonjs/types";
  28216. import { Animation } from "babylonjs/Animations/animation";
  28217. /**
  28218. * Interface containing an array of animations
  28219. */
  28220. export interface IAnimatable {
  28221. /**
  28222. * Array of animations
  28223. */
  28224. animations: Nullable<Array<Animation>>;
  28225. }
  28226. }
  28227. declare module "babylonjs/Materials/fresnelParameters" {
  28228. import { Color3 } from "babylonjs/Maths/math.color";
  28229. /**
  28230. * This represents all the required information to add a fresnel effect on a material:
  28231. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28232. */
  28233. export class FresnelParameters {
  28234. private _isEnabled;
  28235. /**
  28236. * Define if the fresnel effect is enable or not.
  28237. */
  28238. isEnabled: boolean;
  28239. /**
  28240. * Define the color used on edges (grazing angle)
  28241. */
  28242. leftColor: Color3;
  28243. /**
  28244. * Define the color used on center
  28245. */
  28246. rightColor: Color3;
  28247. /**
  28248. * Define bias applied to computed fresnel term
  28249. */
  28250. bias: number;
  28251. /**
  28252. * Defined the power exponent applied to fresnel term
  28253. */
  28254. power: number;
  28255. /**
  28256. * Clones the current fresnel and its valuues
  28257. * @returns a clone fresnel configuration
  28258. */
  28259. clone(): FresnelParameters;
  28260. /**
  28261. * Serializes the current fresnel parameters to a JSON representation.
  28262. * @return the JSON serialization
  28263. */
  28264. serialize(): any;
  28265. /**
  28266. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28267. * @param parsedFresnelParameters Define the JSON representation
  28268. * @returns the parsed parameters
  28269. */
  28270. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28271. }
  28272. }
  28273. declare module "babylonjs/Misc/decorators" {
  28274. import { Nullable } from "babylonjs/types";
  28275. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28276. import { Scene } from "babylonjs/scene";
  28277. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28278. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28279. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28280. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28281. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28282. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28283. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28284. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28285. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28286. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28287. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28288. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28289. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28290. /**
  28291. * Decorator used to define property that can be serialized as reference to a camera
  28292. * @param sourceName defines the name of the property to decorate
  28293. */
  28294. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28295. /**
  28296. * Class used to help serialization objects
  28297. */
  28298. export class SerializationHelper {
  28299. /** @hidden */
  28300. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28301. /** @hidden */
  28302. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28303. /** @hidden */
  28304. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28305. /** @hidden */
  28306. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28307. /**
  28308. * Appends the serialized animations from the source animations
  28309. * @param source Source containing the animations
  28310. * @param destination Target to store the animations
  28311. */
  28312. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28313. /**
  28314. * Static function used to serialized a specific entity
  28315. * @param entity defines the entity to serialize
  28316. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28317. * @returns a JSON compatible object representing the serialization of the entity
  28318. */
  28319. static Serialize<T>(entity: T, serializationObject?: any): any;
  28320. /**
  28321. * Creates a new entity from a serialization data object
  28322. * @param creationFunction defines a function used to instanciated the new entity
  28323. * @param source defines the source serialization data
  28324. * @param scene defines the hosting scene
  28325. * @param rootUrl defines the root url for resources
  28326. * @returns a new entity
  28327. */
  28328. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28329. /**
  28330. * Clones an object
  28331. * @param creationFunction defines the function used to instanciate the new object
  28332. * @param source defines the source object
  28333. * @returns the cloned object
  28334. */
  28335. static Clone<T>(creationFunction: () => T, source: T): T;
  28336. /**
  28337. * Instanciates a new object based on a source one (some data will be shared between both object)
  28338. * @param creationFunction defines the function used to instanciate the new object
  28339. * @param source defines the source object
  28340. * @returns the new object
  28341. */
  28342. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28343. }
  28344. }
  28345. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  28346. import { Nullable } from "babylonjs/types";
  28347. /**
  28348. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  28349. */
  28350. export interface CubeMapInfo {
  28351. /**
  28352. * The pixel array for the front face.
  28353. * This is stored in format, left to right, up to down format.
  28354. */
  28355. front: Nullable<ArrayBufferView>;
  28356. /**
  28357. * The pixel array for the back face.
  28358. * This is stored in format, left to right, up to down format.
  28359. */
  28360. back: Nullable<ArrayBufferView>;
  28361. /**
  28362. * The pixel array for the left face.
  28363. * This is stored in format, left to right, up to down format.
  28364. */
  28365. left: Nullable<ArrayBufferView>;
  28366. /**
  28367. * The pixel array for the right face.
  28368. * This is stored in format, left to right, up to down format.
  28369. */
  28370. right: Nullable<ArrayBufferView>;
  28371. /**
  28372. * The pixel array for the up face.
  28373. * This is stored in format, left to right, up to down format.
  28374. */
  28375. up: Nullable<ArrayBufferView>;
  28376. /**
  28377. * The pixel array for the down face.
  28378. * This is stored in format, left to right, up to down format.
  28379. */
  28380. down: Nullable<ArrayBufferView>;
  28381. /**
  28382. * The size of the cubemap stored.
  28383. *
  28384. * Each faces will be size * size pixels.
  28385. */
  28386. size: number;
  28387. /**
  28388. * The format of the texture.
  28389. *
  28390. * RGBA, RGB.
  28391. */
  28392. format: number;
  28393. /**
  28394. * The type of the texture data.
  28395. *
  28396. * UNSIGNED_INT, FLOAT.
  28397. */
  28398. type: number;
  28399. /**
  28400. * Specifies whether the texture is in gamma space.
  28401. */
  28402. gammaSpace: boolean;
  28403. }
  28404. /**
  28405. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  28406. */
  28407. export class PanoramaToCubeMapTools {
  28408. private static FACE_FRONT;
  28409. private static FACE_BACK;
  28410. private static FACE_RIGHT;
  28411. private static FACE_LEFT;
  28412. private static FACE_DOWN;
  28413. private static FACE_UP;
  28414. /**
  28415. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  28416. *
  28417. * @param float32Array The source data.
  28418. * @param inputWidth The width of the input panorama.
  28419. * @param inputHeight The height of the input panorama.
  28420. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  28421. * @return The cubemap data
  28422. */
  28423. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  28424. private static CreateCubemapTexture;
  28425. private static CalcProjectionSpherical;
  28426. }
  28427. }
  28428. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  28429. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28430. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28431. import { Nullable } from "babylonjs/types";
  28432. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  28433. /**
  28434. * Helper class dealing with the extraction of spherical polynomial dataArray
  28435. * from a cube map.
  28436. */
  28437. export class CubeMapToSphericalPolynomialTools {
  28438. private static FileFaces;
  28439. /**
  28440. * Converts a texture to the according Spherical Polynomial data.
  28441. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28442. *
  28443. * @param texture The texture to extract the information from.
  28444. * @return The Spherical Polynomial data.
  28445. */
  28446. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  28447. /**
  28448. * Converts a cubemap to the according Spherical Polynomial data.
  28449. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28450. *
  28451. * @param cubeInfo The Cube map to extract the information from.
  28452. * @return The Spherical Polynomial data.
  28453. */
  28454. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  28455. }
  28456. }
  28457. declare module "babylonjs/Misc/guid" {
  28458. /**
  28459. * Class used to manipulate GUIDs
  28460. */
  28461. export class GUID {
  28462. /**
  28463. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28464. * Be aware Math.random() could cause collisions, but:
  28465. * "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"
  28466. * @returns a pseudo random id
  28467. */
  28468. static RandomId(): string;
  28469. }
  28470. }
  28471. declare module "babylonjs/Materials/Textures/baseTexture" {
  28472. import { Observable } from "babylonjs/Misc/observable";
  28473. import { Nullable } from "babylonjs/types";
  28474. import { Scene } from "babylonjs/scene";
  28475. import { Matrix } from "babylonjs/Maths/math.vector";
  28476. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28477. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28478. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28479. import { ISize } from "babylonjs/Maths/math.size";
  28480. /**
  28481. * Base class of all the textures in babylon.
  28482. * It groups all the common properties the materials, post process, lights... might need
  28483. * in order to make a correct use of the texture.
  28484. */
  28485. export class BaseTexture implements IAnimatable {
  28486. /**
  28487. * Default anisotropic filtering level for the application.
  28488. * It is set to 4 as a good tradeoff between perf and quality.
  28489. */
  28490. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28491. /**
  28492. * Gets or sets the unique id of the texture
  28493. */
  28494. uniqueId: number;
  28495. /**
  28496. * Define the name of the texture.
  28497. */
  28498. name: string;
  28499. /**
  28500. * Gets or sets an object used to store user defined information.
  28501. */
  28502. metadata: any;
  28503. /**
  28504. * For internal use only. Please do not use.
  28505. */
  28506. reservedDataStore: any;
  28507. private _hasAlpha;
  28508. /**
  28509. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28510. */
  28511. hasAlpha: boolean;
  28512. /**
  28513. * Defines if the alpha value should be determined via the rgb values.
  28514. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28515. */
  28516. getAlphaFromRGB: boolean;
  28517. /**
  28518. * Intensity or strength of the texture.
  28519. * It is commonly used by materials to fine tune the intensity of the texture
  28520. */
  28521. level: number;
  28522. /**
  28523. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28524. * This is part of the texture as textures usually maps to one uv set.
  28525. */
  28526. coordinatesIndex: number;
  28527. private _coordinatesMode;
  28528. /**
  28529. * How a texture is mapped.
  28530. *
  28531. * | Value | Type | Description |
  28532. * | ----- | ----------------------------------- | ----------- |
  28533. * | 0 | EXPLICIT_MODE | |
  28534. * | 1 | SPHERICAL_MODE | |
  28535. * | 2 | PLANAR_MODE | |
  28536. * | 3 | CUBIC_MODE | |
  28537. * | 4 | PROJECTION_MODE | |
  28538. * | 5 | SKYBOX_MODE | |
  28539. * | 6 | INVCUBIC_MODE | |
  28540. * | 7 | EQUIRECTANGULAR_MODE | |
  28541. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28542. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28543. */
  28544. coordinatesMode: number;
  28545. /**
  28546. * | Value | Type | Description |
  28547. * | ----- | ------------------ | ----------- |
  28548. * | 0 | CLAMP_ADDRESSMODE | |
  28549. * | 1 | WRAP_ADDRESSMODE | |
  28550. * | 2 | MIRROR_ADDRESSMODE | |
  28551. */
  28552. wrapU: number;
  28553. /**
  28554. * | Value | Type | Description |
  28555. * | ----- | ------------------ | ----------- |
  28556. * | 0 | CLAMP_ADDRESSMODE | |
  28557. * | 1 | WRAP_ADDRESSMODE | |
  28558. * | 2 | MIRROR_ADDRESSMODE | |
  28559. */
  28560. wrapV: number;
  28561. /**
  28562. * | Value | Type | Description |
  28563. * | ----- | ------------------ | ----------- |
  28564. * | 0 | CLAMP_ADDRESSMODE | |
  28565. * | 1 | WRAP_ADDRESSMODE | |
  28566. * | 2 | MIRROR_ADDRESSMODE | |
  28567. */
  28568. wrapR: number;
  28569. /**
  28570. * With compliant hardware and browser (supporting anisotropic filtering)
  28571. * this defines the level of anisotropic filtering in the texture.
  28572. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28573. */
  28574. anisotropicFilteringLevel: number;
  28575. /**
  28576. * Define if the texture is a cube texture or if false a 2d texture.
  28577. */
  28578. isCube: boolean;
  28579. /**
  28580. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28581. */
  28582. is3D: boolean;
  28583. /**
  28584. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28585. * HDR texture are usually stored in linear space.
  28586. * This only impacts the PBR and Background materials
  28587. */
  28588. gammaSpace: boolean;
  28589. /**
  28590. * Gets or sets whether or not the texture contains RGBD data.
  28591. */
  28592. isRGBD: boolean;
  28593. /**
  28594. * Is Z inverted in the texture (useful in a cube texture).
  28595. */
  28596. invertZ: boolean;
  28597. /**
  28598. * Are mip maps generated for this texture or not.
  28599. */
  28600. readonly noMipmap: boolean;
  28601. /**
  28602. * @hidden
  28603. */
  28604. lodLevelInAlpha: boolean;
  28605. /**
  28606. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28607. */
  28608. lodGenerationOffset: number;
  28609. /**
  28610. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28611. */
  28612. lodGenerationScale: number;
  28613. /**
  28614. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28615. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28616. * average roughness values.
  28617. */
  28618. linearSpecularLOD: boolean;
  28619. /**
  28620. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28621. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28622. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28623. */
  28624. irradianceTexture: Nullable<BaseTexture>;
  28625. /**
  28626. * Define if the texture is a render target.
  28627. */
  28628. isRenderTarget: boolean;
  28629. /**
  28630. * Define the unique id of the texture in the scene.
  28631. */
  28632. readonly uid: string;
  28633. /**
  28634. * Return a string representation of the texture.
  28635. * @returns the texture as a string
  28636. */
  28637. toString(): string;
  28638. /**
  28639. * Get the class name of the texture.
  28640. * @returns "BaseTexture"
  28641. */
  28642. getClassName(): string;
  28643. /**
  28644. * Define the list of animation attached to the texture.
  28645. */
  28646. animations: import("babylonjs/Animations/animation").Animation[];
  28647. /**
  28648. * An event triggered when the texture is disposed.
  28649. */
  28650. onDisposeObservable: Observable<BaseTexture>;
  28651. private _onDisposeObserver;
  28652. /**
  28653. * Callback triggered when the texture has been disposed.
  28654. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28655. */
  28656. onDispose: () => void;
  28657. /**
  28658. * Define the current state of the loading sequence when in delayed load mode.
  28659. */
  28660. delayLoadState: number;
  28661. private _scene;
  28662. /** @hidden */
  28663. _texture: Nullable<InternalTexture>;
  28664. private _uid;
  28665. /**
  28666. * Define if the texture is preventinga material to render or not.
  28667. * If not and the texture is not ready, the engine will use a default black texture instead.
  28668. */
  28669. readonly isBlocking: boolean;
  28670. /**
  28671. * Instantiates a new BaseTexture.
  28672. * Base class of all the textures in babylon.
  28673. * It groups all the common properties the materials, post process, lights... might need
  28674. * in order to make a correct use of the texture.
  28675. * @param scene Define the scene the texture blongs to
  28676. */
  28677. constructor(scene: Nullable<Scene>);
  28678. /**
  28679. * Get the scene the texture belongs to.
  28680. * @returns the scene or null if undefined
  28681. */
  28682. getScene(): Nullable<Scene>;
  28683. /**
  28684. * Get the texture transform matrix used to offset tile the texture for istance.
  28685. * @returns the transformation matrix
  28686. */
  28687. getTextureMatrix(): Matrix;
  28688. /**
  28689. * Get the texture reflection matrix used to rotate/transform the reflection.
  28690. * @returns the reflection matrix
  28691. */
  28692. getReflectionTextureMatrix(): Matrix;
  28693. /**
  28694. * Get the underlying lower level texture from Babylon.
  28695. * @returns the insternal texture
  28696. */
  28697. getInternalTexture(): Nullable<InternalTexture>;
  28698. /**
  28699. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28700. * @returns true if ready or not blocking
  28701. */
  28702. isReadyOrNotBlocking(): boolean;
  28703. /**
  28704. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28705. * @returns true if fully ready
  28706. */
  28707. isReady(): boolean;
  28708. private _cachedSize;
  28709. /**
  28710. * Get the size of the texture.
  28711. * @returns the texture size.
  28712. */
  28713. getSize(): ISize;
  28714. /**
  28715. * Get the base size of the texture.
  28716. * It can be different from the size if the texture has been resized for POT for instance
  28717. * @returns the base size
  28718. */
  28719. getBaseSize(): ISize;
  28720. /**
  28721. * Update the sampling mode of the texture.
  28722. * Default is Trilinear mode.
  28723. *
  28724. * | Value | Type | Description |
  28725. * | ----- | ------------------ | ----------- |
  28726. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28727. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28728. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28729. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28730. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28731. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28732. * | 7 | NEAREST_LINEAR | |
  28733. * | 8 | NEAREST_NEAREST | |
  28734. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28735. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28736. * | 11 | LINEAR_LINEAR | |
  28737. * | 12 | LINEAR_NEAREST | |
  28738. *
  28739. * > _mag_: magnification filter (close to the viewer)
  28740. * > _min_: minification filter (far from the viewer)
  28741. * > _mip_: filter used between mip map levels
  28742. *@param samplingMode Define the new sampling mode of the texture
  28743. */
  28744. updateSamplingMode(samplingMode: number): void;
  28745. /**
  28746. * Scales the texture if is `canRescale()`
  28747. * @param ratio the resize factor we want to use to rescale
  28748. */
  28749. scale(ratio: number): void;
  28750. /**
  28751. * Get if the texture can rescale.
  28752. */
  28753. readonly canRescale: boolean;
  28754. /** @hidden */
  28755. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28756. /** @hidden */
  28757. _rebuild(): void;
  28758. /**
  28759. * Triggers the load sequence in delayed load mode.
  28760. */
  28761. delayLoad(): void;
  28762. /**
  28763. * Clones the texture.
  28764. * @returns the cloned texture
  28765. */
  28766. clone(): Nullable<BaseTexture>;
  28767. /**
  28768. * Get the texture underlying type (INT, FLOAT...)
  28769. */
  28770. readonly textureType: number;
  28771. /**
  28772. * Get the texture underlying format (RGB, RGBA...)
  28773. */
  28774. readonly textureFormat: number;
  28775. /**
  28776. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28777. * This will returns an RGBA array buffer containing either in values (0-255) or
  28778. * float values (0-1) depending of the underlying buffer type.
  28779. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28780. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28781. * @param buffer defines a user defined buffer to fill with data (can be null)
  28782. * @returns The Array buffer containing the pixels data.
  28783. */
  28784. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28785. /**
  28786. * Release and destroy the underlying lower level texture aka internalTexture.
  28787. */
  28788. releaseInternalTexture(): void;
  28789. /**
  28790. * Get the polynomial representation of the texture data.
  28791. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  28792. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  28793. */
  28794. sphericalPolynomial: Nullable<SphericalPolynomial>;
  28795. /** @hidden */
  28796. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28797. /** @hidden */
  28798. readonly _lodTextureMid: Nullable<BaseTexture>;
  28799. /** @hidden */
  28800. readonly _lodTextureLow: Nullable<BaseTexture>;
  28801. /**
  28802. * Dispose the texture and release its associated resources.
  28803. */
  28804. dispose(): void;
  28805. /**
  28806. * Serialize the texture into a JSON representation that can be parsed later on.
  28807. * @returns the JSON representation of the texture
  28808. */
  28809. serialize(): any;
  28810. /**
  28811. * Helper function to be called back once a list of texture contains only ready textures.
  28812. * @param textures Define the list of textures to wait for
  28813. * @param callback Define the callback triggered once the entire list will be ready
  28814. */
  28815. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28816. }
  28817. }
  28818. declare module "babylonjs/Materials/Textures/internalTexture" {
  28819. import { Observable } from "babylonjs/Misc/observable";
  28820. import { Nullable, int } from "babylonjs/types";
  28821. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28822. import { Engine } from "babylonjs/Engines/engine";
  28823. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28824. /**
  28825. * Class used to store data associated with WebGL texture data for the engine
  28826. * This class should not be used directly
  28827. */
  28828. export class InternalTexture {
  28829. /** @hidden */
  28830. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  28831. /**
  28832. * The source of the texture data is unknown
  28833. */
  28834. static DATASOURCE_UNKNOWN: number;
  28835. /**
  28836. * Texture data comes from an URL
  28837. */
  28838. static DATASOURCE_URL: number;
  28839. /**
  28840. * Texture data is only used for temporary storage
  28841. */
  28842. static DATASOURCE_TEMP: number;
  28843. /**
  28844. * Texture data comes from raw data (ArrayBuffer)
  28845. */
  28846. static DATASOURCE_RAW: number;
  28847. /**
  28848. * Texture content is dynamic (video or dynamic texture)
  28849. */
  28850. static DATASOURCE_DYNAMIC: number;
  28851. /**
  28852. * Texture content is generated by rendering to it
  28853. */
  28854. static DATASOURCE_RENDERTARGET: number;
  28855. /**
  28856. * Texture content is part of a multi render target process
  28857. */
  28858. static DATASOURCE_MULTIRENDERTARGET: number;
  28859. /**
  28860. * Texture data comes from a cube data file
  28861. */
  28862. static DATASOURCE_CUBE: number;
  28863. /**
  28864. * Texture data comes from a raw cube data
  28865. */
  28866. static DATASOURCE_CUBERAW: number;
  28867. /**
  28868. * Texture data come from a prefiltered cube data file
  28869. */
  28870. static DATASOURCE_CUBEPREFILTERED: number;
  28871. /**
  28872. * Texture content is raw 3D data
  28873. */
  28874. static DATASOURCE_RAW3D: number;
  28875. /**
  28876. * Texture content is a depth texture
  28877. */
  28878. static DATASOURCE_DEPTHTEXTURE: number;
  28879. /**
  28880. * Texture data comes from a raw cube data encoded with RGBD
  28881. */
  28882. static DATASOURCE_CUBERAW_RGBD: number;
  28883. /**
  28884. * Defines if the texture is ready
  28885. */
  28886. isReady: boolean;
  28887. /**
  28888. * Defines if the texture is a cube texture
  28889. */
  28890. isCube: boolean;
  28891. /**
  28892. * Defines if the texture contains 3D data
  28893. */
  28894. is3D: boolean;
  28895. /**
  28896. * Defines if the texture contains multiview data
  28897. */
  28898. isMultiview: boolean;
  28899. /**
  28900. * Gets the URL used to load this texture
  28901. */
  28902. url: string;
  28903. /**
  28904. * Gets the sampling mode of the texture
  28905. */
  28906. samplingMode: number;
  28907. /**
  28908. * Gets a boolean indicating if the texture needs mipmaps generation
  28909. */
  28910. generateMipMaps: boolean;
  28911. /**
  28912. * Gets the number of samples used by the texture (WebGL2+ only)
  28913. */
  28914. samples: number;
  28915. /**
  28916. * Gets the type of the texture (int, float...)
  28917. */
  28918. type: number;
  28919. /**
  28920. * Gets the format of the texture (RGB, RGBA...)
  28921. */
  28922. format: number;
  28923. /**
  28924. * Observable called when the texture is loaded
  28925. */
  28926. onLoadedObservable: Observable<InternalTexture>;
  28927. /**
  28928. * Gets the width of the texture
  28929. */
  28930. width: number;
  28931. /**
  28932. * Gets the height of the texture
  28933. */
  28934. height: number;
  28935. /**
  28936. * Gets the depth of the texture
  28937. */
  28938. depth: number;
  28939. /**
  28940. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  28941. */
  28942. baseWidth: number;
  28943. /**
  28944. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  28945. */
  28946. baseHeight: number;
  28947. /**
  28948. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  28949. */
  28950. baseDepth: number;
  28951. /**
  28952. * Gets a boolean indicating if the texture is inverted on Y axis
  28953. */
  28954. invertY: boolean;
  28955. /** @hidden */
  28956. _invertVScale: boolean;
  28957. /** @hidden */
  28958. _associatedChannel: number;
  28959. /** @hidden */
  28960. _dataSource: number;
  28961. /** @hidden */
  28962. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  28963. /** @hidden */
  28964. _bufferView: Nullable<ArrayBufferView>;
  28965. /** @hidden */
  28966. _bufferViewArray: Nullable<ArrayBufferView[]>;
  28967. /** @hidden */
  28968. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  28969. /** @hidden */
  28970. _size: number;
  28971. /** @hidden */
  28972. _extension: string;
  28973. /** @hidden */
  28974. _files: Nullable<string[]>;
  28975. /** @hidden */
  28976. _workingCanvas: Nullable<HTMLCanvasElement>;
  28977. /** @hidden */
  28978. _workingContext: Nullable<CanvasRenderingContext2D>;
  28979. /** @hidden */
  28980. _framebuffer: Nullable<WebGLFramebuffer>;
  28981. /** @hidden */
  28982. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  28983. /** @hidden */
  28984. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  28985. /** @hidden */
  28986. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  28987. /** @hidden */
  28988. _attachments: Nullable<number[]>;
  28989. /** @hidden */
  28990. _cachedCoordinatesMode: Nullable<number>;
  28991. /** @hidden */
  28992. _cachedWrapU: Nullable<number>;
  28993. /** @hidden */
  28994. _cachedWrapV: Nullable<number>;
  28995. /** @hidden */
  28996. _cachedWrapR: Nullable<number>;
  28997. /** @hidden */
  28998. _cachedAnisotropicFilteringLevel: Nullable<number>;
  28999. /** @hidden */
  29000. _isDisabled: boolean;
  29001. /** @hidden */
  29002. _compression: Nullable<string>;
  29003. /** @hidden */
  29004. _generateStencilBuffer: boolean;
  29005. /** @hidden */
  29006. _generateDepthBuffer: boolean;
  29007. /** @hidden */
  29008. _comparisonFunction: number;
  29009. /** @hidden */
  29010. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  29011. /** @hidden */
  29012. _lodGenerationScale: number;
  29013. /** @hidden */
  29014. _lodGenerationOffset: number;
  29015. /** @hidden */
  29016. _colorTextureArray: Nullable<WebGLTexture>;
  29017. /** @hidden */
  29018. _depthStencilTextureArray: Nullable<WebGLTexture>;
  29019. /** @hidden */
  29020. _lodTextureHigh: Nullable<BaseTexture>;
  29021. /** @hidden */
  29022. _lodTextureMid: Nullable<BaseTexture>;
  29023. /** @hidden */
  29024. _lodTextureLow: Nullable<BaseTexture>;
  29025. /** @hidden */
  29026. _isRGBD: boolean;
  29027. /** @hidden */
  29028. _linearSpecularLOD: boolean;
  29029. /** @hidden */
  29030. _irradianceTexture: Nullable<BaseTexture>;
  29031. /** @hidden */
  29032. _webGLTexture: Nullable<WebGLTexture>;
  29033. /** @hidden */
  29034. _references: number;
  29035. private _engine;
  29036. /**
  29037. * Gets the Engine the texture belongs to.
  29038. * @returns The babylon engine
  29039. */
  29040. getEngine(): Engine;
  29041. /**
  29042. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  29043. */
  29044. readonly dataSource: number;
  29045. /**
  29046. * Creates a new InternalTexture
  29047. * @param engine defines the engine to use
  29048. * @param dataSource defines the type of data that will be used
  29049. * @param delayAllocation if the texture allocation should be delayed (default: false)
  29050. */
  29051. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  29052. /**
  29053. * Increments the number of references (ie. the number of Texture that point to it)
  29054. */
  29055. incrementReferences(): void;
  29056. /**
  29057. * Change the size of the texture (not the size of the content)
  29058. * @param width defines the new width
  29059. * @param height defines the new height
  29060. * @param depth defines the new depth (1 by default)
  29061. */
  29062. updateSize(width: int, height: int, depth?: int): void;
  29063. /** @hidden */
  29064. _rebuild(): void;
  29065. /** @hidden */
  29066. _swapAndDie(target: InternalTexture): void;
  29067. /**
  29068. * Dispose the current allocated resources
  29069. */
  29070. dispose(): void;
  29071. }
  29072. }
  29073. declare module "babylonjs/Materials/effect" {
  29074. import { Observable } from "babylonjs/Misc/observable";
  29075. import { Nullable } from "babylonjs/types";
  29076. import { IDisposable } from "babylonjs/scene";
  29077. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29078. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29079. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  29080. import { Engine } from "babylonjs/Engines/engine";
  29081. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29082. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29083. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29084. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29085. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29086. /**
  29087. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29088. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29089. */
  29090. export class EffectFallbacks {
  29091. private _defines;
  29092. private _currentRank;
  29093. private _maxRank;
  29094. private _mesh;
  29095. /**
  29096. * Removes the fallback from the bound mesh.
  29097. */
  29098. unBindMesh(): void;
  29099. /**
  29100. * Adds a fallback on the specified property.
  29101. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29102. * @param define The name of the define in the shader
  29103. */
  29104. addFallback(rank: number, define: string): void;
  29105. /**
  29106. * Sets the mesh to use CPU skinning when needing to fallback.
  29107. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29108. * @param mesh The mesh to use the fallbacks.
  29109. */
  29110. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29111. /**
  29112. * Checks to see if more fallbacks are still availible.
  29113. */
  29114. readonly hasMoreFallbacks: boolean;
  29115. /**
  29116. * Removes the defines that should be removed when falling back.
  29117. * @param currentDefines defines the current define statements for the shader.
  29118. * @param effect defines the current effect we try to compile
  29119. * @returns The resulting defines with defines of the current rank removed.
  29120. */
  29121. reduce(currentDefines: string, effect: Effect): string;
  29122. }
  29123. /**
  29124. * Options to be used when creating an effect.
  29125. */
  29126. export class EffectCreationOptions {
  29127. /**
  29128. * Atrributes that will be used in the shader.
  29129. */
  29130. attributes: string[];
  29131. /**
  29132. * Uniform varible names that will be set in the shader.
  29133. */
  29134. uniformsNames: string[];
  29135. /**
  29136. * Uniform buffer varible names that will be set in the shader.
  29137. */
  29138. uniformBuffersNames: string[];
  29139. /**
  29140. * Sampler texture variable names that will be set in the shader.
  29141. */
  29142. samplers: string[];
  29143. /**
  29144. * Define statements that will be set in the shader.
  29145. */
  29146. defines: any;
  29147. /**
  29148. * Possible fallbacks for this effect to improve performance when needed.
  29149. */
  29150. fallbacks: Nullable<EffectFallbacks>;
  29151. /**
  29152. * Callback that will be called when the shader is compiled.
  29153. */
  29154. onCompiled: Nullable<(effect: Effect) => void>;
  29155. /**
  29156. * Callback that will be called if an error occurs during shader compilation.
  29157. */
  29158. onError: Nullable<(effect: Effect, errors: string) => void>;
  29159. /**
  29160. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29161. */
  29162. indexParameters: any;
  29163. /**
  29164. * Max number of lights that can be used in the shader.
  29165. */
  29166. maxSimultaneousLights: number;
  29167. /**
  29168. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29169. */
  29170. transformFeedbackVaryings: Nullable<string[]>;
  29171. }
  29172. /**
  29173. * Effect containing vertex and fragment shader that can be executed on an object.
  29174. */
  29175. export class Effect implements IDisposable {
  29176. /**
  29177. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29178. */
  29179. static ShadersRepository: string;
  29180. /**
  29181. * Name of the effect.
  29182. */
  29183. name: any;
  29184. /**
  29185. * String container all the define statements that should be set on the shader.
  29186. */
  29187. defines: string;
  29188. /**
  29189. * Callback that will be called when the shader is compiled.
  29190. */
  29191. onCompiled: Nullable<(effect: Effect) => void>;
  29192. /**
  29193. * Callback that will be called if an error occurs during shader compilation.
  29194. */
  29195. onError: Nullable<(effect: Effect, errors: string) => void>;
  29196. /**
  29197. * Callback that will be called when effect is bound.
  29198. */
  29199. onBind: Nullable<(effect: Effect) => void>;
  29200. /**
  29201. * Unique ID of the effect.
  29202. */
  29203. uniqueId: number;
  29204. /**
  29205. * Observable that will be called when the shader is compiled.
  29206. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29207. */
  29208. onCompileObservable: Observable<Effect>;
  29209. /**
  29210. * Observable that will be called if an error occurs during shader compilation.
  29211. */
  29212. onErrorObservable: Observable<Effect>;
  29213. /** @hidden */
  29214. _onBindObservable: Nullable<Observable<Effect>>;
  29215. /**
  29216. * Observable that will be called when effect is bound.
  29217. */
  29218. readonly onBindObservable: Observable<Effect>;
  29219. /** @hidden */
  29220. _bonesComputationForcedToCPU: boolean;
  29221. private static _uniqueIdSeed;
  29222. private _engine;
  29223. private _uniformBuffersNames;
  29224. private _uniformsNames;
  29225. private _samplerList;
  29226. private _samplers;
  29227. private _isReady;
  29228. private _compilationError;
  29229. private _attributesNames;
  29230. private _attributes;
  29231. private _uniforms;
  29232. /**
  29233. * Key for the effect.
  29234. * @hidden
  29235. */
  29236. _key: string;
  29237. private _indexParameters;
  29238. private _fallbacks;
  29239. private _vertexSourceCode;
  29240. private _fragmentSourceCode;
  29241. private _vertexSourceCodeOverride;
  29242. private _fragmentSourceCodeOverride;
  29243. private _transformFeedbackVaryings;
  29244. /**
  29245. * Compiled shader to webGL program.
  29246. * @hidden
  29247. */
  29248. _pipelineContext: Nullable<IPipelineContext>;
  29249. private _valueCache;
  29250. private static _baseCache;
  29251. /**
  29252. * Instantiates an effect.
  29253. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29254. * @param baseName Name of the effect.
  29255. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29256. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29257. * @param samplers List of sampler variables that will be passed to the shader.
  29258. * @param engine Engine to be used to render the effect
  29259. * @param defines Define statements to be added to the shader.
  29260. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29261. * @param onCompiled Callback that will be called when the shader is compiled.
  29262. * @param onError Callback that will be called if an error occurs during shader compilation.
  29263. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29264. */
  29265. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  29266. private _useFinalCode;
  29267. /**
  29268. * Unique key for this effect
  29269. */
  29270. readonly key: string;
  29271. /**
  29272. * If the effect has been compiled and prepared.
  29273. * @returns if the effect is compiled and prepared.
  29274. */
  29275. isReady(): boolean;
  29276. private _isReadyInternal;
  29277. /**
  29278. * The engine the effect was initialized with.
  29279. * @returns the engine.
  29280. */
  29281. getEngine(): Engine;
  29282. /**
  29283. * The pipeline context for this effect
  29284. * @returns the associated pipeline context
  29285. */
  29286. getPipelineContext(): Nullable<IPipelineContext>;
  29287. /**
  29288. * The set of names of attribute variables for the shader.
  29289. * @returns An array of attribute names.
  29290. */
  29291. getAttributesNames(): string[];
  29292. /**
  29293. * Returns the attribute at the given index.
  29294. * @param index The index of the attribute.
  29295. * @returns The location of the attribute.
  29296. */
  29297. getAttributeLocation(index: number): number;
  29298. /**
  29299. * Returns the attribute based on the name of the variable.
  29300. * @param name of the attribute to look up.
  29301. * @returns the attribute location.
  29302. */
  29303. getAttributeLocationByName(name: string): number;
  29304. /**
  29305. * The number of attributes.
  29306. * @returns the numnber of attributes.
  29307. */
  29308. getAttributesCount(): number;
  29309. /**
  29310. * Gets the index of a uniform variable.
  29311. * @param uniformName of the uniform to look up.
  29312. * @returns the index.
  29313. */
  29314. getUniformIndex(uniformName: string): number;
  29315. /**
  29316. * Returns the attribute based on the name of the variable.
  29317. * @param uniformName of the uniform to look up.
  29318. * @returns the location of the uniform.
  29319. */
  29320. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29321. /**
  29322. * Returns an array of sampler variable names
  29323. * @returns The array of sampler variable neames.
  29324. */
  29325. getSamplers(): string[];
  29326. /**
  29327. * The error from the last compilation.
  29328. * @returns the error string.
  29329. */
  29330. getCompilationError(): string;
  29331. /**
  29332. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29333. * @param func The callback to be used.
  29334. */
  29335. executeWhenCompiled(func: (effect: Effect) => void): void;
  29336. private _checkIsReady;
  29337. /** @hidden */
  29338. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29339. /** @hidden */
  29340. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29341. /** @hidden */
  29342. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29343. /**
  29344. * Recompiles the webGL program
  29345. * @param vertexSourceCode The source code for the vertex shader.
  29346. * @param fragmentSourceCode The source code for the fragment shader.
  29347. * @param onCompiled Callback called when completed.
  29348. * @param onError Callback called on error.
  29349. * @hidden
  29350. */
  29351. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29352. /**
  29353. * Prepares the effect
  29354. * @hidden
  29355. */
  29356. _prepareEffect(): void;
  29357. private _processCompilationErrors;
  29358. /**
  29359. * Checks if the effect is supported. (Must be called after compilation)
  29360. */
  29361. readonly isSupported: boolean;
  29362. /**
  29363. * Binds a texture to the engine to be used as output of the shader.
  29364. * @param channel Name of the output variable.
  29365. * @param texture Texture to bind.
  29366. * @hidden
  29367. */
  29368. _bindTexture(channel: string, texture: InternalTexture): void;
  29369. /**
  29370. * Sets a texture on the engine to be used in the shader.
  29371. * @param channel Name of the sampler variable.
  29372. * @param texture Texture to set.
  29373. */
  29374. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29375. /**
  29376. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29377. * @param channel Name of the sampler variable.
  29378. * @param texture Texture to set.
  29379. */
  29380. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29381. /**
  29382. * Sets an array of textures on the engine to be used in the shader.
  29383. * @param channel Name of the variable.
  29384. * @param textures Textures to set.
  29385. */
  29386. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29387. /**
  29388. * 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)
  29389. * @param channel Name of the sampler variable.
  29390. * @param postProcess Post process to get the input texture from.
  29391. */
  29392. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29393. /**
  29394. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29395. * 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)
  29396. * @param channel Name of the sampler variable.
  29397. * @param postProcess Post process to get the output texture from.
  29398. */
  29399. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29400. /** @hidden */
  29401. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29402. /** @hidden */
  29403. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29404. /** @hidden */
  29405. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29406. /** @hidden */
  29407. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29408. /**
  29409. * Binds a buffer to a uniform.
  29410. * @param buffer Buffer to bind.
  29411. * @param name Name of the uniform variable to bind to.
  29412. */
  29413. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29414. /**
  29415. * Binds block to a uniform.
  29416. * @param blockName Name of the block to bind.
  29417. * @param index Index to bind.
  29418. */
  29419. bindUniformBlock(blockName: string, index: number): void;
  29420. /**
  29421. * Sets an interger value on a uniform variable.
  29422. * @param uniformName Name of the variable.
  29423. * @param value Value to be set.
  29424. * @returns this effect.
  29425. */
  29426. setInt(uniformName: string, value: number): Effect;
  29427. /**
  29428. * Sets an int array on a uniform variable.
  29429. * @param uniformName Name of the variable.
  29430. * @param array array to be set.
  29431. * @returns this effect.
  29432. */
  29433. setIntArray(uniformName: string, array: Int32Array): Effect;
  29434. /**
  29435. * 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)
  29436. * @param uniformName Name of the variable.
  29437. * @param array array to be set.
  29438. * @returns this effect.
  29439. */
  29440. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29441. /**
  29442. * 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)
  29443. * @param uniformName Name of the variable.
  29444. * @param array array to be set.
  29445. * @returns this effect.
  29446. */
  29447. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29448. /**
  29449. * 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)
  29450. * @param uniformName Name of the variable.
  29451. * @param array array to be set.
  29452. * @returns this effect.
  29453. */
  29454. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29455. /**
  29456. * Sets an float array on a uniform variable.
  29457. * @param uniformName Name of the variable.
  29458. * @param array array to be set.
  29459. * @returns this effect.
  29460. */
  29461. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29462. /**
  29463. * 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)
  29464. * @param uniformName Name of the variable.
  29465. * @param array array to be set.
  29466. * @returns this effect.
  29467. */
  29468. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29469. /**
  29470. * 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)
  29471. * @param uniformName Name of the variable.
  29472. * @param array array to be set.
  29473. * @returns this effect.
  29474. */
  29475. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29476. /**
  29477. * 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)
  29478. * @param uniformName Name of the variable.
  29479. * @param array array to be set.
  29480. * @returns this effect.
  29481. */
  29482. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29483. /**
  29484. * Sets an array on a uniform variable.
  29485. * @param uniformName Name of the variable.
  29486. * @param array array to be set.
  29487. * @returns this effect.
  29488. */
  29489. setArray(uniformName: string, array: number[]): Effect;
  29490. /**
  29491. * 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)
  29492. * @param uniformName Name of the variable.
  29493. * @param array array to be set.
  29494. * @returns this effect.
  29495. */
  29496. setArray2(uniformName: string, array: number[]): Effect;
  29497. /**
  29498. * 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)
  29499. * @param uniformName Name of the variable.
  29500. * @param array array to be set.
  29501. * @returns this effect.
  29502. */
  29503. setArray3(uniformName: string, array: number[]): Effect;
  29504. /**
  29505. * 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)
  29506. * @param uniformName Name of the variable.
  29507. * @param array array to be set.
  29508. * @returns this effect.
  29509. */
  29510. setArray4(uniformName: string, array: number[]): Effect;
  29511. /**
  29512. * Sets matrices on a uniform variable.
  29513. * @param uniformName Name of the variable.
  29514. * @param matrices matrices to be set.
  29515. * @returns this effect.
  29516. */
  29517. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29518. /**
  29519. * Sets matrix on a uniform variable.
  29520. * @param uniformName Name of the variable.
  29521. * @param matrix matrix to be set.
  29522. * @returns this effect.
  29523. */
  29524. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29525. /**
  29526. * 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)
  29527. * @param uniformName Name of the variable.
  29528. * @param matrix matrix to be set.
  29529. * @returns this effect.
  29530. */
  29531. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29532. /**
  29533. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29534. * @param uniformName Name of the variable.
  29535. * @param matrix matrix to be set.
  29536. * @returns this effect.
  29537. */
  29538. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29539. /**
  29540. * Sets a float on a uniform variable.
  29541. * @param uniformName Name of the variable.
  29542. * @param value value to be set.
  29543. * @returns this effect.
  29544. */
  29545. setFloat(uniformName: string, value: number): Effect;
  29546. /**
  29547. * Sets a boolean on a uniform variable.
  29548. * @param uniformName Name of the variable.
  29549. * @param bool value to be set.
  29550. * @returns this effect.
  29551. */
  29552. setBool(uniformName: string, bool: boolean): Effect;
  29553. /**
  29554. * Sets a Vector2 on a uniform variable.
  29555. * @param uniformName Name of the variable.
  29556. * @param vector2 vector2 to be set.
  29557. * @returns this effect.
  29558. */
  29559. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29560. /**
  29561. * Sets a float2 on a uniform variable.
  29562. * @param uniformName Name of the variable.
  29563. * @param x First float in float2.
  29564. * @param y Second float in float2.
  29565. * @returns this effect.
  29566. */
  29567. setFloat2(uniformName: string, x: number, y: number): Effect;
  29568. /**
  29569. * Sets a Vector3 on a uniform variable.
  29570. * @param uniformName Name of the variable.
  29571. * @param vector3 Value to be set.
  29572. * @returns this effect.
  29573. */
  29574. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29575. /**
  29576. * Sets a float3 on a uniform variable.
  29577. * @param uniformName Name of the variable.
  29578. * @param x First float in float3.
  29579. * @param y Second float in float3.
  29580. * @param z Third float in float3.
  29581. * @returns this effect.
  29582. */
  29583. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29584. /**
  29585. * Sets a Vector4 on a uniform variable.
  29586. * @param uniformName Name of the variable.
  29587. * @param vector4 Value to be set.
  29588. * @returns this effect.
  29589. */
  29590. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29591. /**
  29592. * Sets a float4 on a uniform variable.
  29593. * @param uniformName Name of the variable.
  29594. * @param x First float in float4.
  29595. * @param y Second float in float4.
  29596. * @param z Third float in float4.
  29597. * @param w Fourth float in float4.
  29598. * @returns this effect.
  29599. */
  29600. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29601. /**
  29602. * Sets a Color3 on a uniform variable.
  29603. * @param uniformName Name of the variable.
  29604. * @param color3 Value to be set.
  29605. * @returns this effect.
  29606. */
  29607. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29608. /**
  29609. * Sets a Color4 on a uniform variable.
  29610. * @param uniformName Name of the variable.
  29611. * @param color3 Value to be set.
  29612. * @param alpha Alpha value to be set.
  29613. * @returns this effect.
  29614. */
  29615. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29616. /**
  29617. * Sets a Color4 on a uniform variable
  29618. * @param uniformName defines the name of the variable
  29619. * @param color4 defines the value to be set
  29620. * @returns this effect.
  29621. */
  29622. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29623. /** Release all associated resources */
  29624. dispose(): void;
  29625. /**
  29626. * This function will add a new shader to the shader store
  29627. * @param name the name of the shader
  29628. * @param pixelShader optional pixel shader content
  29629. * @param vertexShader optional vertex shader content
  29630. */
  29631. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29632. /**
  29633. * Store of each shader (The can be looked up using effect.key)
  29634. */
  29635. static ShadersStore: {
  29636. [key: string]: string;
  29637. };
  29638. /**
  29639. * Store of each included file for a shader (The can be looked up using effect.key)
  29640. */
  29641. static IncludesShadersStore: {
  29642. [key: string]: string;
  29643. };
  29644. /**
  29645. * Resets the cache of effects.
  29646. */
  29647. static ResetCache(): void;
  29648. }
  29649. }
  29650. declare module "babylonjs/Materials/uniformBuffer" {
  29651. import { Nullable, FloatArray } from "babylonjs/types";
  29652. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  29653. import { Engine } from "babylonjs/Engines/engine";
  29654. import { Effect } from "babylonjs/Materials/effect";
  29655. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29656. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29657. import { Color3 } from "babylonjs/Maths/math.color";
  29658. /**
  29659. * Uniform buffer objects.
  29660. *
  29661. * Handles blocks of uniform on the GPU.
  29662. *
  29663. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29664. *
  29665. * For more information, please refer to :
  29666. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29667. */
  29668. export class UniformBuffer {
  29669. private _engine;
  29670. private _buffer;
  29671. private _data;
  29672. private _bufferData;
  29673. private _dynamic?;
  29674. private _uniformLocations;
  29675. private _uniformSizes;
  29676. private _uniformLocationPointer;
  29677. private _needSync;
  29678. private _noUBO;
  29679. private _currentEffect;
  29680. private static _MAX_UNIFORM_SIZE;
  29681. private static _tempBuffer;
  29682. /**
  29683. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  29684. * This is dynamic to allow compat with webgl 1 and 2.
  29685. * You will need to pass the name of the uniform as well as the value.
  29686. */
  29687. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  29688. /**
  29689. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  29690. * This is dynamic to allow compat with webgl 1 and 2.
  29691. * You will need to pass the name of the uniform as well as the value.
  29692. */
  29693. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  29694. /**
  29695. * Lambda to Update a single float in a uniform buffer.
  29696. * This is dynamic to allow compat with webgl 1 and 2.
  29697. * You will need to pass the name of the uniform as well as the value.
  29698. */
  29699. updateFloat: (name: string, x: number) => void;
  29700. /**
  29701. * Lambda to Update a vec2 of float in a uniform buffer.
  29702. * This is dynamic to allow compat with webgl 1 and 2.
  29703. * You will need to pass the name of the uniform as well as the value.
  29704. */
  29705. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  29706. /**
  29707. * Lambda to Update a vec3 of float in a uniform buffer.
  29708. * This is dynamic to allow compat with webgl 1 and 2.
  29709. * You will need to pass the name of the uniform as well as the value.
  29710. */
  29711. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  29712. /**
  29713. * Lambda to Update a vec4 of float in a uniform buffer.
  29714. * This is dynamic to allow compat with webgl 1 and 2.
  29715. * You will need to pass the name of the uniform as well as the value.
  29716. */
  29717. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  29718. /**
  29719. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  29720. * This is dynamic to allow compat with webgl 1 and 2.
  29721. * You will need to pass the name of the uniform as well as the value.
  29722. */
  29723. updateMatrix: (name: string, mat: Matrix) => void;
  29724. /**
  29725. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  29726. * This is dynamic to allow compat with webgl 1 and 2.
  29727. * You will need to pass the name of the uniform as well as the value.
  29728. */
  29729. updateVector3: (name: string, vector: Vector3) => void;
  29730. /**
  29731. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  29732. * This is dynamic to allow compat with webgl 1 and 2.
  29733. * You will need to pass the name of the uniform as well as the value.
  29734. */
  29735. updateVector4: (name: string, vector: Vector4) => void;
  29736. /**
  29737. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  29738. * This is dynamic to allow compat with webgl 1 and 2.
  29739. * You will need to pass the name of the uniform as well as the value.
  29740. */
  29741. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  29742. /**
  29743. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  29744. * This is dynamic to allow compat with webgl 1 and 2.
  29745. * You will need to pass the name of the uniform as well as the value.
  29746. */
  29747. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  29748. /**
  29749. * Instantiates a new Uniform buffer objects.
  29750. *
  29751. * Handles blocks of uniform on the GPU.
  29752. *
  29753. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29754. *
  29755. * For more information, please refer to :
  29756. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29757. * @param engine Define the engine the buffer is associated with
  29758. * @param data Define the data contained in the buffer
  29759. * @param dynamic Define if the buffer is updatable
  29760. */
  29761. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  29762. /**
  29763. * Indicates if the buffer is using the WebGL2 UBO implementation,
  29764. * or just falling back on setUniformXXX calls.
  29765. */
  29766. readonly useUbo: boolean;
  29767. /**
  29768. * Indicates if the WebGL underlying uniform buffer is in sync
  29769. * with the javascript cache data.
  29770. */
  29771. readonly isSync: boolean;
  29772. /**
  29773. * Indicates if the WebGL underlying uniform buffer is dynamic.
  29774. * Also, a dynamic UniformBuffer will disable cache verification and always
  29775. * update the underlying WebGL uniform buffer to the GPU.
  29776. * @returns if Dynamic, otherwise false
  29777. */
  29778. isDynamic(): boolean;
  29779. /**
  29780. * The data cache on JS side.
  29781. * @returns the underlying data as a float array
  29782. */
  29783. getData(): Float32Array;
  29784. /**
  29785. * The underlying WebGL Uniform buffer.
  29786. * @returns the webgl buffer
  29787. */
  29788. getBuffer(): Nullable<DataBuffer>;
  29789. /**
  29790. * std140 layout specifies how to align data within an UBO structure.
  29791. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  29792. * for specs.
  29793. */
  29794. private _fillAlignment;
  29795. /**
  29796. * Adds an uniform in the buffer.
  29797. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  29798. * for the layout to be correct !
  29799. * @param name Name of the uniform, as used in the uniform block in the shader.
  29800. * @param size Data size, or data directly.
  29801. */
  29802. addUniform(name: string, size: number | number[]): void;
  29803. /**
  29804. * Adds a Matrix 4x4 to the uniform buffer.
  29805. * @param name Name of the uniform, as used in the uniform block in the shader.
  29806. * @param mat A 4x4 matrix.
  29807. */
  29808. addMatrix(name: string, mat: Matrix): void;
  29809. /**
  29810. * Adds a vec2 to the uniform buffer.
  29811. * @param name Name of the uniform, as used in the uniform block in the shader.
  29812. * @param x Define the x component value of the vec2
  29813. * @param y Define the y component value of the vec2
  29814. */
  29815. addFloat2(name: string, x: number, y: number): void;
  29816. /**
  29817. * Adds a vec3 to the uniform buffer.
  29818. * @param name Name of the uniform, as used in the uniform block in the shader.
  29819. * @param x Define the x component value of the vec3
  29820. * @param y Define the y component value of the vec3
  29821. * @param z Define the z component value of the vec3
  29822. */
  29823. addFloat3(name: string, x: number, y: number, z: number): void;
  29824. /**
  29825. * Adds a vec3 to the uniform buffer.
  29826. * @param name Name of the uniform, as used in the uniform block in the shader.
  29827. * @param color Define the vec3 from a Color
  29828. */
  29829. addColor3(name: string, color: Color3): void;
  29830. /**
  29831. * Adds a vec4 to the uniform buffer.
  29832. * @param name Name of the uniform, as used in the uniform block in the shader.
  29833. * @param color Define the rgb components from a Color
  29834. * @param alpha Define the a component of the vec4
  29835. */
  29836. addColor4(name: string, color: Color3, alpha: number): void;
  29837. /**
  29838. * Adds a vec3 to the uniform buffer.
  29839. * @param name Name of the uniform, as used in the uniform block in the shader.
  29840. * @param vector Define the vec3 components from a Vector
  29841. */
  29842. addVector3(name: string, vector: Vector3): void;
  29843. /**
  29844. * Adds a Matrix 3x3 to the uniform buffer.
  29845. * @param name Name of the uniform, as used in the uniform block in the shader.
  29846. */
  29847. addMatrix3x3(name: string): void;
  29848. /**
  29849. * Adds a Matrix 2x2 to the uniform buffer.
  29850. * @param name Name of the uniform, as used in the uniform block in the shader.
  29851. */
  29852. addMatrix2x2(name: string): void;
  29853. /**
  29854. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  29855. */
  29856. create(): void;
  29857. /** @hidden */
  29858. _rebuild(): void;
  29859. /**
  29860. * Updates the WebGL Uniform Buffer on the GPU.
  29861. * If the `dynamic` flag is set to true, no cache comparison is done.
  29862. * Otherwise, the buffer will be updated only if the cache differs.
  29863. */
  29864. update(): void;
  29865. /**
  29866. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  29867. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29868. * @param data Define the flattened data
  29869. * @param size Define the size of the data.
  29870. */
  29871. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  29872. private _valueCache;
  29873. private _cacheMatrix;
  29874. private _updateMatrix3x3ForUniform;
  29875. private _updateMatrix3x3ForEffect;
  29876. private _updateMatrix2x2ForEffect;
  29877. private _updateMatrix2x2ForUniform;
  29878. private _updateFloatForEffect;
  29879. private _updateFloatForUniform;
  29880. private _updateFloat2ForEffect;
  29881. private _updateFloat2ForUniform;
  29882. private _updateFloat3ForEffect;
  29883. private _updateFloat3ForUniform;
  29884. private _updateFloat4ForEffect;
  29885. private _updateFloat4ForUniform;
  29886. private _updateMatrixForEffect;
  29887. private _updateMatrixForUniform;
  29888. private _updateVector3ForEffect;
  29889. private _updateVector3ForUniform;
  29890. private _updateVector4ForEffect;
  29891. private _updateVector4ForUniform;
  29892. private _updateColor3ForEffect;
  29893. private _updateColor3ForUniform;
  29894. private _updateColor4ForEffect;
  29895. private _updateColor4ForUniform;
  29896. /**
  29897. * Sets a sampler uniform on the effect.
  29898. * @param name Define the name of the sampler.
  29899. * @param texture Define the texture to set in the sampler
  29900. */
  29901. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  29902. /**
  29903. * Directly updates the value of the uniform in the cache AND on the GPU.
  29904. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29905. * @param data Define the flattened data
  29906. */
  29907. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  29908. /**
  29909. * Binds this uniform buffer to an effect.
  29910. * @param effect Define the effect to bind the buffer to
  29911. * @param name Name of the uniform block in the shader.
  29912. */
  29913. bindToEffect(effect: Effect, name: string): void;
  29914. /**
  29915. * Disposes the uniform buffer.
  29916. */
  29917. dispose(): void;
  29918. }
  29919. }
  29920. declare module "babylonjs/Audio/analyser" {
  29921. import { Scene } from "babylonjs/scene";
  29922. /**
  29923. * Class used to work with sound analyzer using fast fourier transform (FFT)
  29924. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29925. */
  29926. export class Analyser {
  29927. /**
  29928. * Gets or sets the smoothing
  29929. * @ignorenaming
  29930. */
  29931. SMOOTHING: number;
  29932. /**
  29933. * Gets or sets the FFT table size
  29934. * @ignorenaming
  29935. */
  29936. FFT_SIZE: number;
  29937. /**
  29938. * Gets or sets the bar graph amplitude
  29939. * @ignorenaming
  29940. */
  29941. BARGRAPHAMPLITUDE: number;
  29942. /**
  29943. * Gets or sets the position of the debug canvas
  29944. * @ignorenaming
  29945. */
  29946. DEBUGCANVASPOS: {
  29947. x: number;
  29948. y: number;
  29949. };
  29950. /**
  29951. * Gets or sets the debug canvas size
  29952. * @ignorenaming
  29953. */
  29954. DEBUGCANVASSIZE: {
  29955. width: number;
  29956. height: number;
  29957. };
  29958. private _byteFreqs;
  29959. private _byteTime;
  29960. private _floatFreqs;
  29961. private _webAudioAnalyser;
  29962. private _debugCanvas;
  29963. private _debugCanvasContext;
  29964. private _scene;
  29965. private _registerFunc;
  29966. private _audioEngine;
  29967. /**
  29968. * Creates a new analyser
  29969. * @param scene defines hosting scene
  29970. */
  29971. constructor(scene: Scene);
  29972. /**
  29973. * Get the number of data values you will have to play with for the visualization
  29974. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  29975. * @returns a number
  29976. */
  29977. getFrequencyBinCount(): number;
  29978. /**
  29979. * Gets the current frequency data as a byte array
  29980. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29981. * @returns a Uint8Array
  29982. */
  29983. getByteFrequencyData(): Uint8Array;
  29984. /**
  29985. * Gets the current waveform as a byte array
  29986. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  29987. * @returns a Uint8Array
  29988. */
  29989. getByteTimeDomainData(): Uint8Array;
  29990. /**
  29991. * Gets the current frequency data as a float array
  29992. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29993. * @returns a Float32Array
  29994. */
  29995. getFloatFrequencyData(): Float32Array;
  29996. /**
  29997. * Renders the debug canvas
  29998. */
  29999. drawDebugCanvas(): void;
  30000. /**
  30001. * Stops rendering the debug canvas and removes it
  30002. */
  30003. stopDebugCanvas(): void;
  30004. /**
  30005. * Connects two audio nodes
  30006. * @param inputAudioNode defines first node to connect
  30007. * @param outputAudioNode defines second node to connect
  30008. */
  30009. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  30010. /**
  30011. * Releases all associated resources
  30012. */
  30013. dispose(): void;
  30014. }
  30015. }
  30016. declare module "babylonjs/Audio/audioEngine" {
  30017. import { IDisposable } from "babylonjs/scene";
  30018. import { Analyser } from "babylonjs/Audio/analyser";
  30019. import { Nullable } from "babylonjs/types";
  30020. import { Observable } from "babylonjs/Misc/observable";
  30021. /**
  30022. * This represents an audio engine and it is responsible
  30023. * to play, synchronize and analyse sounds throughout the application.
  30024. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30025. */
  30026. export interface IAudioEngine extends IDisposable {
  30027. /**
  30028. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30029. */
  30030. readonly canUseWebAudio: boolean;
  30031. /**
  30032. * Gets the current AudioContext if available.
  30033. */
  30034. readonly audioContext: Nullable<AudioContext>;
  30035. /**
  30036. * The master gain node defines the global audio volume of your audio engine.
  30037. */
  30038. readonly masterGain: GainNode;
  30039. /**
  30040. * Gets whether or not mp3 are supported by your browser.
  30041. */
  30042. readonly isMP3supported: boolean;
  30043. /**
  30044. * Gets whether or not ogg are supported by your browser.
  30045. */
  30046. readonly isOGGsupported: boolean;
  30047. /**
  30048. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30049. * @ignoreNaming
  30050. */
  30051. WarnedWebAudioUnsupported: boolean;
  30052. /**
  30053. * Defines if the audio engine relies on a custom unlocked button.
  30054. * In this case, the embedded button will not be displayed.
  30055. */
  30056. useCustomUnlockedButton: boolean;
  30057. /**
  30058. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  30059. */
  30060. readonly unlocked: boolean;
  30061. /**
  30062. * Event raised when audio has been unlocked on the browser.
  30063. */
  30064. onAudioUnlockedObservable: Observable<AudioEngine>;
  30065. /**
  30066. * Event raised when audio has been locked on the browser.
  30067. */
  30068. onAudioLockedObservable: Observable<AudioEngine>;
  30069. /**
  30070. * Flags the audio engine in Locked state.
  30071. * This happens due to new browser policies preventing audio to autoplay.
  30072. */
  30073. lock(): void;
  30074. /**
  30075. * Unlocks the audio engine once a user action has been done on the dom.
  30076. * This is helpful to resume play once browser policies have been satisfied.
  30077. */
  30078. unlock(): void;
  30079. }
  30080. /**
  30081. * This represents the default audio engine used in babylon.
  30082. * It is responsible to play, synchronize and analyse sounds throughout the application.
  30083. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30084. */
  30085. export class AudioEngine implements IAudioEngine {
  30086. private _audioContext;
  30087. private _audioContextInitialized;
  30088. private _muteButton;
  30089. private _hostElement;
  30090. /**
  30091. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30092. */
  30093. canUseWebAudio: boolean;
  30094. /**
  30095. * The master gain node defines the global audio volume of your audio engine.
  30096. */
  30097. masterGain: GainNode;
  30098. /**
  30099. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30100. * @ignoreNaming
  30101. */
  30102. WarnedWebAudioUnsupported: boolean;
  30103. /**
  30104. * Gets whether or not mp3 are supported by your browser.
  30105. */
  30106. isMP3supported: boolean;
  30107. /**
  30108. * Gets whether or not ogg are supported by your browser.
  30109. */
  30110. isOGGsupported: boolean;
  30111. /**
  30112. * Gets whether audio has been unlocked on the device.
  30113. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  30114. * a user interaction has happened.
  30115. */
  30116. unlocked: boolean;
  30117. /**
  30118. * Defines if the audio engine relies on a custom unlocked button.
  30119. * In this case, the embedded button will not be displayed.
  30120. */
  30121. useCustomUnlockedButton: boolean;
  30122. /**
  30123. * Event raised when audio has been unlocked on the browser.
  30124. */
  30125. onAudioUnlockedObservable: Observable<AudioEngine>;
  30126. /**
  30127. * Event raised when audio has been locked on the browser.
  30128. */
  30129. onAudioLockedObservable: Observable<AudioEngine>;
  30130. /**
  30131. * Gets the current AudioContext if available.
  30132. */
  30133. readonly audioContext: Nullable<AudioContext>;
  30134. private _connectedAnalyser;
  30135. /**
  30136. * Instantiates a new audio engine.
  30137. *
  30138. * There should be only one per page as some browsers restrict the number
  30139. * of audio contexts you can create.
  30140. * @param hostElement defines the host element where to display the mute icon if necessary
  30141. */
  30142. constructor(hostElement?: Nullable<HTMLElement>);
  30143. /**
  30144. * Flags the audio engine in Locked state.
  30145. * This happens due to new browser policies preventing audio to autoplay.
  30146. */
  30147. lock(): void;
  30148. /**
  30149. * Unlocks the audio engine once a user action has been done on the dom.
  30150. * This is helpful to resume play once browser policies have been satisfied.
  30151. */
  30152. unlock(): void;
  30153. private _resumeAudioContext;
  30154. private _initializeAudioContext;
  30155. private _tryToRun;
  30156. private _triggerRunningState;
  30157. private _triggerSuspendedState;
  30158. private _displayMuteButton;
  30159. private _moveButtonToTopLeft;
  30160. private _onResize;
  30161. private _hideMuteButton;
  30162. /**
  30163. * Destroy and release the resources associated with the audio ccontext.
  30164. */
  30165. dispose(): void;
  30166. /**
  30167. * Gets the global volume sets on the master gain.
  30168. * @returns the global volume if set or -1 otherwise
  30169. */
  30170. getGlobalVolume(): number;
  30171. /**
  30172. * Sets the global volume of your experience (sets on the master gain).
  30173. * @param newVolume Defines the new global volume of the application
  30174. */
  30175. setGlobalVolume(newVolume: number): void;
  30176. /**
  30177. * Connect the audio engine to an audio analyser allowing some amazing
  30178. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  30179. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  30180. * @param analyser The analyser to connect to the engine
  30181. */
  30182. connectToAnalyser(analyser: Analyser): void;
  30183. }
  30184. }
  30185. declare module "babylonjs/Loading/loadingScreen" {
  30186. /**
  30187. * Interface used to present a loading screen while loading a scene
  30188. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30189. */
  30190. export interface ILoadingScreen {
  30191. /**
  30192. * Function called to display the loading screen
  30193. */
  30194. displayLoadingUI: () => void;
  30195. /**
  30196. * Function called to hide the loading screen
  30197. */
  30198. hideLoadingUI: () => void;
  30199. /**
  30200. * Gets or sets the color to use for the background
  30201. */
  30202. loadingUIBackgroundColor: string;
  30203. /**
  30204. * Gets or sets the text to display while loading
  30205. */
  30206. loadingUIText: string;
  30207. }
  30208. /**
  30209. * Class used for the default loading screen
  30210. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30211. */
  30212. export class DefaultLoadingScreen implements ILoadingScreen {
  30213. private _renderingCanvas;
  30214. private _loadingText;
  30215. private _loadingDivBackgroundColor;
  30216. private _loadingDiv;
  30217. private _loadingTextDiv;
  30218. /** Gets or sets the logo url to use for the default loading screen */
  30219. static DefaultLogoUrl: string;
  30220. /** Gets or sets the spinner url to use for the default loading screen */
  30221. static DefaultSpinnerUrl: string;
  30222. /**
  30223. * Creates a new default loading screen
  30224. * @param _renderingCanvas defines the canvas used to render the scene
  30225. * @param _loadingText defines the default text to display
  30226. * @param _loadingDivBackgroundColor defines the default background color
  30227. */
  30228. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30229. /**
  30230. * Function called to display the loading screen
  30231. */
  30232. displayLoadingUI(): void;
  30233. /**
  30234. * Function called to hide the loading screen
  30235. */
  30236. hideLoadingUI(): void;
  30237. /**
  30238. * Gets or sets the text to display while loading
  30239. */
  30240. loadingUIText: string;
  30241. /**
  30242. * Gets or sets the color to use for the background
  30243. */
  30244. loadingUIBackgroundColor: string;
  30245. private _resizeLoadingUI;
  30246. }
  30247. }
  30248. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  30249. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30250. import { Engine } from "babylonjs/Engines/engine";
  30251. import { Nullable } from "babylonjs/types";
  30252. /** @hidden */
  30253. export class WebGLPipelineContext implements IPipelineContext {
  30254. engine: Engine;
  30255. program: Nullable<WebGLProgram>;
  30256. context?: WebGLRenderingContext;
  30257. vertexShader?: WebGLShader;
  30258. fragmentShader?: WebGLShader;
  30259. isParallelCompiled: boolean;
  30260. onCompiled?: () => void;
  30261. transformFeedback?: WebGLTransformFeedback | null;
  30262. readonly isAsync: boolean;
  30263. readonly isReady: boolean;
  30264. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  30265. }
  30266. }
  30267. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  30268. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30269. /** @hidden */
  30270. export class WebGLDataBuffer extends DataBuffer {
  30271. private _buffer;
  30272. constructor(resource: WebGLBuffer);
  30273. readonly underlyingResource: any;
  30274. }
  30275. }
  30276. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  30277. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30278. /** @hidden */
  30279. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30280. attributeProcessor(attribute: string): string;
  30281. varyingProcessor(varying: string, isFragment: boolean): string;
  30282. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30283. }
  30284. }
  30285. declare module "babylonjs/Misc/perfCounter" {
  30286. /**
  30287. * This class is used to track a performance counter which is number based.
  30288. * The user has access to many properties which give statistics of different nature.
  30289. *
  30290. * The implementer can track two kinds of Performance Counter: time and count.
  30291. * 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.
  30292. * 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.
  30293. */
  30294. export class PerfCounter {
  30295. /**
  30296. * Gets or sets a global boolean to turn on and off all the counters
  30297. */
  30298. static Enabled: boolean;
  30299. /**
  30300. * Returns the smallest value ever
  30301. */
  30302. readonly min: number;
  30303. /**
  30304. * Returns the biggest value ever
  30305. */
  30306. readonly max: number;
  30307. /**
  30308. * Returns the average value since the performance counter is running
  30309. */
  30310. readonly average: number;
  30311. /**
  30312. * Returns the average value of the last second the counter was monitored
  30313. */
  30314. readonly lastSecAverage: number;
  30315. /**
  30316. * Returns the current value
  30317. */
  30318. readonly current: number;
  30319. /**
  30320. * Gets the accumulated total
  30321. */
  30322. readonly total: number;
  30323. /**
  30324. * Gets the total value count
  30325. */
  30326. readonly count: number;
  30327. /**
  30328. * Creates a new counter
  30329. */
  30330. constructor();
  30331. /**
  30332. * Call this method to start monitoring a new frame.
  30333. * 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.
  30334. */
  30335. fetchNewFrame(): void;
  30336. /**
  30337. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30338. * @param newCount the count value to add to the monitored count
  30339. * @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.
  30340. */
  30341. addCount(newCount: number, fetchResult: boolean): void;
  30342. /**
  30343. * Start monitoring this performance counter
  30344. */
  30345. beginMonitoring(): void;
  30346. /**
  30347. * Compute the time lapsed since the previous beginMonitoring() call.
  30348. * @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
  30349. */
  30350. endMonitoring(newFrame?: boolean): void;
  30351. private _fetchResult;
  30352. private _startMonitoringTime;
  30353. private _min;
  30354. private _max;
  30355. private _average;
  30356. private _current;
  30357. private _totalValueCount;
  30358. private _totalAccumulated;
  30359. private _lastSecAverage;
  30360. private _lastSecAccumulated;
  30361. private _lastSecTime;
  30362. private _lastSecValueCount;
  30363. }
  30364. }
  30365. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  30366. /**
  30367. * Interface for any object that can request an animation frame
  30368. */
  30369. export interface ICustomAnimationFrameRequester {
  30370. /**
  30371. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30372. */
  30373. renderFunction?: Function;
  30374. /**
  30375. * Called to request the next frame to render to
  30376. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30377. */
  30378. requestAnimationFrame: Function;
  30379. /**
  30380. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30381. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30382. */
  30383. requestID?: number;
  30384. }
  30385. }
  30386. declare module "babylonjs/Materials/Textures/videoTexture" {
  30387. import { Observable } from "babylonjs/Misc/observable";
  30388. import { Nullable } from "babylonjs/types";
  30389. import { Scene } from "babylonjs/scene";
  30390. import { Texture } from "babylonjs/Materials/Textures/texture";
  30391. /**
  30392. * Settings for finer control over video usage
  30393. */
  30394. export interface VideoTextureSettings {
  30395. /**
  30396. * Applies `autoplay` to video, if specified
  30397. */
  30398. autoPlay?: boolean;
  30399. /**
  30400. * Applies `loop` to video, if specified
  30401. */
  30402. loop?: boolean;
  30403. /**
  30404. * Automatically updates internal texture from video at every frame in the render loop
  30405. */
  30406. autoUpdateTexture: boolean;
  30407. /**
  30408. * Image src displayed during the video loading or until the user interacts with the video.
  30409. */
  30410. poster?: string;
  30411. }
  30412. /**
  30413. * If you want to display a video in your scene, this is the special texture for that.
  30414. * This special texture works similar to other textures, with the exception of a few parameters.
  30415. * @see https://doc.babylonjs.com/how_to/video_texture
  30416. */
  30417. export class VideoTexture extends Texture {
  30418. /**
  30419. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30420. */
  30421. readonly autoUpdateTexture: boolean;
  30422. /**
  30423. * The video instance used by the texture internally
  30424. */
  30425. readonly video: HTMLVideoElement;
  30426. private _onUserActionRequestedObservable;
  30427. /**
  30428. * Event triggerd when a dom action is required by the user to play the video.
  30429. * This happens due to recent changes in browser policies preventing video to auto start.
  30430. */
  30431. readonly onUserActionRequestedObservable: Observable<Texture>;
  30432. private _generateMipMaps;
  30433. private _engine;
  30434. private _stillImageCaptured;
  30435. private _displayingPosterTexture;
  30436. private _settings;
  30437. private _createInternalTextureOnEvent;
  30438. private _frameId;
  30439. /**
  30440. * Creates a video texture.
  30441. * If you want to display a video in your scene, this is the special texture for that.
  30442. * This special texture works similar to other textures, with the exception of a few parameters.
  30443. * @see https://doc.babylonjs.com/how_to/video_texture
  30444. * @param name optional name, will detect from video source, if not defined
  30445. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30446. * @param scene is obviously the current scene.
  30447. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30448. * @param invertY is false by default but can be used to invert video on Y axis
  30449. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30450. * @param settings allows finer control over video usage
  30451. */
  30452. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30453. private _getName;
  30454. private _getVideo;
  30455. private _createInternalTexture;
  30456. private reset;
  30457. /**
  30458. * @hidden Internal method to initiate `update`.
  30459. */
  30460. _rebuild(): void;
  30461. /**
  30462. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30463. */
  30464. update(): void;
  30465. /**
  30466. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30467. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30468. */
  30469. updateTexture(isVisible: boolean): void;
  30470. protected _updateInternalTexture: () => void;
  30471. /**
  30472. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30473. * @param url New url.
  30474. */
  30475. updateURL(url: string): void;
  30476. /**
  30477. * Dispose the texture and release its associated resources.
  30478. */
  30479. dispose(): void;
  30480. /**
  30481. * Creates a video texture straight from a stream.
  30482. * @param scene Define the scene the texture should be created in
  30483. * @param stream Define the stream the texture should be created from
  30484. * @returns The created video texture as a promise
  30485. */
  30486. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30487. /**
  30488. * Creates a video texture straight from your WebCam video feed.
  30489. * @param scene Define the scene the texture should be created in
  30490. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30491. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30492. * @returns The created video texture as a promise
  30493. */
  30494. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30495. minWidth: number;
  30496. maxWidth: number;
  30497. minHeight: number;
  30498. maxHeight: number;
  30499. deviceId: string;
  30500. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30501. /**
  30502. * Creates a video texture straight from your WebCam video feed.
  30503. * @param scene Define the scene the texture should be created in
  30504. * @param onReady Define a callback to triggered once the texture will be ready
  30505. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30506. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30507. */
  30508. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30509. minWidth: number;
  30510. maxWidth: number;
  30511. minHeight: number;
  30512. maxHeight: number;
  30513. deviceId: string;
  30514. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30515. }
  30516. }
  30517. declare module "babylonjs/Engines/engine" {
  30518. import { Observable } from "babylonjs/Misc/observable";
  30519. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  30520. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  30521. import { Scene } from "babylonjs/scene";
  30522. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30523. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30524. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  30525. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  30526. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30527. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30528. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  30529. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30530. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  30531. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  30532. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  30533. import { WebRequest } from "babylonjs/Misc/webRequest";
  30534. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30535. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30536. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30537. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  30538. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  30539. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  30540. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  30541. import { Material } from "babylonjs/Materials/material";
  30542. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30543. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30544. /**
  30545. * Defines the interface used by objects containing a viewport (like a camera)
  30546. */
  30547. interface IViewportOwnerLike {
  30548. /**
  30549. * Gets or sets the viewport
  30550. */
  30551. viewport: IViewportLike;
  30552. }
  30553. /**
  30554. * Interface for attribute information associated with buffer instanciation
  30555. */
  30556. export class InstancingAttributeInfo {
  30557. /**
  30558. * Index/offset of the attribute in the vertex shader
  30559. */
  30560. index: number;
  30561. /**
  30562. * size of the attribute, 1, 2, 3 or 4
  30563. */
  30564. attributeSize: number;
  30565. /**
  30566. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30567. * default is FLOAT
  30568. */
  30569. attribyteType: number;
  30570. /**
  30571. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30572. */
  30573. normalized: boolean;
  30574. /**
  30575. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30576. */
  30577. offset: number;
  30578. /**
  30579. * Name of the GLSL attribute, for debugging purpose only
  30580. */
  30581. attributeName: string;
  30582. }
  30583. /**
  30584. * Define options used to create a depth texture
  30585. */
  30586. export class DepthTextureCreationOptions {
  30587. /** Specifies whether or not a stencil should be allocated in the texture */
  30588. generateStencil?: boolean;
  30589. /** Specifies whether or not bilinear filtering is enable on the texture */
  30590. bilinearFiltering?: boolean;
  30591. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  30592. comparisonFunction?: number;
  30593. /** Specifies if the created texture is a cube texture */
  30594. isCube?: boolean;
  30595. }
  30596. /**
  30597. * Class used to describe the capabilities of the engine relatively to the current browser
  30598. */
  30599. export class EngineCapabilities {
  30600. /** Maximum textures units per fragment shader */
  30601. maxTexturesImageUnits: number;
  30602. /** Maximum texture units per vertex shader */
  30603. maxVertexTextureImageUnits: number;
  30604. /** Maximum textures units in the entire pipeline */
  30605. maxCombinedTexturesImageUnits: number;
  30606. /** Maximum texture size */
  30607. maxTextureSize: number;
  30608. /** Maximum cube texture size */
  30609. maxCubemapTextureSize: number;
  30610. /** Maximum render texture size */
  30611. maxRenderTextureSize: number;
  30612. /** Maximum number of vertex attributes */
  30613. maxVertexAttribs: number;
  30614. /** Maximum number of varyings */
  30615. maxVaryingVectors: number;
  30616. /** Maximum number of uniforms per vertex shader */
  30617. maxVertexUniformVectors: number;
  30618. /** Maximum number of uniforms per fragment shader */
  30619. maxFragmentUniformVectors: number;
  30620. /** Defines if standard derivates (dx/dy) are supported */
  30621. standardDerivatives: boolean;
  30622. /** Defines if s3tc texture compression is supported */
  30623. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  30624. /** Defines if pvrtc texture compression is supported */
  30625. pvrtc: any;
  30626. /** Defines if etc1 texture compression is supported */
  30627. etc1: any;
  30628. /** Defines if etc2 texture compression is supported */
  30629. etc2: any;
  30630. /** Defines if astc texture compression is supported */
  30631. astc: any;
  30632. /** Defines if float textures are supported */
  30633. textureFloat: boolean;
  30634. /** Defines if vertex array objects are supported */
  30635. vertexArrayObject: boolean;
  30636. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30637. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  30638. /** Gets the maximum level of anisotropy supported */
  30639. maxAnisotropy: number;
  30640. /** Defines if instancing is supported */
  30641. instancedArrays: boolean;
  30642. /** Defines if 32 bits indices are supported */
  30643. uintIndices: boolean;
  30644. /** Defines if high precision shaders are supported */
  30645. highPrecisionShaderSupported: boolean;
  30646. /** Defines if depth reading in the fragment shader is supported */
  30647. fragmentDepthSupported: boolean;
  30648. /** Defines if float texture linear filtering is supported*/
  30649. textureFloatLinearFiltering: boolean;
  30650. /** Defines if rendering to float textures is supported */
  30651. textureFloatRender: boolean;
  30652. /** Defines if half float textures are supported*/
  30653. textureHalfFloat: boolean;
  30654. /** Defines if half float texture linear filtering is supported*/
  30655. textureHalfFloatLinearFiltering: boolean;
  30656. /** Defines if rendering to half float textures is supported */
  30657. textureHalfFloatRender: boolean;
  30658. /** Defines if textureLOD shader command is supported */
  30659. textureLOD: boolean;
  30660. /** Defines if draw buffers extension is supported */
  30661. drawBuffersExtension: boolean;
  30662. /** Defines if depth textures are supported */
  30663. depthTextureExtension: boolean;
  30664. /** Defines if float color buffer are supported */
  30665. colorBufferFloat: boolean;
  30666. /** Gets disjoint timer query extension (null if not supported) */
  30667. timerQuery: EXT_disjoint_timer_query;
  30668. /** Defines if timestamp can be used with timer query */
  30669. canUseTimestampForTimerQuery: boolean;
  30670. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30671. multiview: any;
  30672. /** Function used to let the system compiles shaders in background */
  30673. parallelShaderCompile: {
  30674. COMPLETION_STATUS_KHR: number;
  30675. };
  30676. /** Max number of texture samples for MSAA */
  30677. maxMSAASamples: number;
  30678. }
  30679. /** Interface defining initialization parameters for Engine class */
  30680. export interface EngineOptions extends WebGLContextAttributes {
  30681. /**
  30682. * Defines if the engine should no exceed a specified device ratio
  30683. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30684. */
  30685. limitDeviceRatio?: number;
  30686. /**
  30687. * Defines if webvr should be enabled automatically
  30688. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30689. */
  30690. autoEnableWebVR?: boolean;
  30691. /**
  30692. * Defines if webgl2 should be turned off even if supported
  30693. * @see http://doc.babylonjs.com/features/webgl2
  30694. */
  30695. disableWebGL2Support?: boolean;
  30696. /**
  30697. * Defines if webaudio should be initialized as well
  30698. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30699. */
  30700. audioEngine?: boolean;
  30701. /**
  30702. * Defines if animations should run using a deterministic lock step
  30703. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30704. */
  30705. deterministicLockstep?: boolean;
  30706. /** Defines the maximum steps to use with deterministic lock step mode */
  30707. lockstepMaxSteps?: number;
  30708. /**
  30709. * Defines that engine should ignore context lost events
  30710. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30711. */
  30712. doNotHandleContextLost?: boolean;
  30713. /**
  30714. * Defines that engine should ignore modifying touch action attribute and style
  30715. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30716. */
  30717. doNotHandleTouchAction?: boolean;
  30718. /**
  30719. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30720. */
  30721. useHighPrecisionFloats?: boolean;
  30722. }
  30723. /**
  30724. * Defines the interface used by display changed events
  30725. */
  30726. export interface IDisplayChangedEventArgs {
  30727. /** Gets the vrDisplay object (if any) */
  30728. vrDisplay: Nullable<any>;
  30729. /** Gets a boolean indicating if webVR is supported */
  30730. vrSupported: boolean;
  30731. }
  30732. /**
  30733. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  30734. */
  30735. export class Engine {
  30736. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30737. static ExceptionList: ({
  30738. key: string;
  30739. capture: string;
  30740. captureConstraint: number;
  30741. targets: string[];
  30742. } | {
  30743. key: string;
  30744. capture: null;
  30745. captureConstraint: null;
  30746. targets: string[];
  30747. })[];
  30748. /** Gets the list of created engines */
  30749. static readonly Instances: Engine[];
  30750. /**
  30751. * Gets the latest created engine
  30752. */
  30753. static readonly LastCreatedEngine: Nullable<Engine>;
  30754. /**
  30755. * Gets the latest created scene
  30756. */
  30757. static readonly LastCreatedScene: Nullable<Scene>;
  30758. /**
  30759. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  30760. * @param flag defines which part of the materials must be marked as dirty
  30761. * @param predicate defines a predicate used to filter which materials should be affected
  30762. */
  30763. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  30764. /** @hidden */
  30765. static _TextureLoaders: IInternalTextureLoader[];
  30766. /** Defines that alpha blending is disabled */
  30767. static readonly ALPHA_DISABLE: number;
  30768. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  30769. static readonly ALPHA_ADD: number;
  30770. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  30771. static readonly ALPHA_COMBINE: number;
  30772. /** Defines that alpha blending to DEST - SRC * DEST */
  30773. static readonly ALPHA_SUBTRACT: number;
  30774. /** Defines that alpha blending to SRC * DEST */
  30775. static readonly ALPHA_MULTIPLY: number;
  30776. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  30777. static readonly ALPHA_MAXIMIZED: number;
  30778. /** Defines that alpha blending to SRC + DEST */
  30779. static readonly ALPHA_ONEONE: number;
  30780. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  30781. static readonly ALPHA_PREMULTIPLIED: number;
  30782. /**
  30783. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  30784. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  30785. */
  30786. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  30787. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  30788. static readonly ALPHA_INTERPOLATE: number;
  30789. /**
  30790. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  30791. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  30792. */
  30793. static readonly ALPHA_SCREENMODE: number;
  30794. /** Defines that the ressource is not delayed*/
  30795. static readonly DELAYLOADSTATE_NONE: number;
  30796. /** Defines that the ressource was successfully delay loaded */
  30797. static readonly DELAYLOADSTATE_LOADED: number;
  30798. /** Defines that the ressource is currently delay loading */
  30799. static readonly DELAYLOADSTATE_LOADING: number;
  30800. /** Defines that the ressource is delayed and has not started loading */
  30801. static readonly DELAYLOADSTATE_NOTLOADED: number;
  30802. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  30803. static readonly NEVER: number;
  30804. /** 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 */
  30805. static readonly ALWAYS: number;
  30806. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  30807. static readonly LESS: number;
  30808. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  30809. static readonly EQUAL: number;
  30810. /** 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 */
  30811. static readonly LEQUAL: number;
  30812. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  30813. static readonly GREATER: number;
  30814. /** 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 */
  30815. static readonly GEQUAL: number;
  30816. /** 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 */
  30817. static readonly NOTEQUAL: number;
  30818. /** Passed to stencilOperation to specify that stencil value must be kept */
  30819. static readonly KEEP: number;
  30820. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30821. static readonly REPLACE: number;
  30822. /** Passed to stencilOperation to specify that stencil value must be incremented */
  30823. static readonly INCR: number;
  30824. /** Passed to stencilOperation to specify that stencil value must be decremented */
  30825. static readonly DECR: number;
  30826. /** Passed to stencilOperation to specify that stencil value must be inverted */
  30827. static readonly INVERT: number;
  30828. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  30829. static readonly INCR_WRAP: number;
  30830. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  30831. static readonly DECR_WRAP: number;
  30832. /** Texture is not repeating outside of 0..1 UVs */
  30833. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  30834. /** Texture is repeating outside of 0..1 UVs */
  30835. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  30836. /** Texture is repeating and mirrored */
  30837. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  30838. /** ALPHA */
  30839. static readonly TEXTUREFORMAT_ALPHA: number;
  30840. /** LUMINANCE */
  30841. static readonly TEXTUREFORMAT_LUMINANCE: number;
  30842. /** LUMINANCE_ALPHA */
  30843. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  30844. /** RGB */
  30845. static readonly TEXTUREFORMAT_RGB: number;
  30846. /** RGBA */
  30847. static readonly TEXTUREFORMAT_RGBA: number;
  30848. /** RED */
  30849. static readonly TEXTUREFORMAT_RED: number;
  30850. /** RED (2nd reference) */
  30851. static readonly TEXTUREFORMAT_R: number;
  30852. /** RG */
  30853. static readonly TEXTUREFORMAT_RG: number;
  30854. /** RED_INTEGER */
  30855. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  30856. /** RED_INTEGER (2nd reference) */
  30857. static readonly TEXTUREFORMAT_R_INTEGER: number;
  30858. /** RG_INTEGER */
  30859. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  30860. /** RGB_INTEGER */
  30861. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  30862. /** RGBA_INTEGER */
  30863. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  30864. /** UNSIGNED_BYTE */
  30865. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  30866. /** UNSIGNED_BYTE (2nd reference) */
  30867. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  30868. /** FLOAT */
  30869. static readonly TEXTURETYPE_FLOAT: number;
  30870. /** HALF_FLOAT */
  30871. static readonly TEXTURETYPE_HALF_FLOAT: number;
  30872. /** BYTE */
  30873. static readonly TEXTURETYPE_BYTE: number;
  30874. /** SHORT */
  30875. static readonly TEXTURETYPE_SHORT: number;
  30876. /** UNSIGNED_SHORT */
  30877. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  30878. /** INT */
  30879. static readonly TEXTURETYPE_INT: number;
  30880. /** UNSIGNED_INT */
  30881. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  30882. /** UNSIGNED_SHORT_4_4_4_4 */
  30883. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  30884. /** UNSIGNED_SHORT_5_5_5_1 */
  30885. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  30886. /** UNSIGNED_SHORT_5_6_5 */
  30887. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  30888. /** UNSIGNED_INT_2_10_10_10_REV */
  30889. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  30890. /** UNSIGNED_INT_24_8 */
  30891. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  30892. /** UNSIGNED_INT_10F_11F_11F_REV */
  30893. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  30894. /** UNSIGNED_INT_5_9_9_9_REV */
  30895. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  30896. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  30897. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  30898. /** nearest is mag = nearest and min = nearest and mip = linear */
  30899. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  30900. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30901. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  30902. /** Trilinear is mag = linear and min = linear and mip = linear */
  30903. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  30904. /** nearest is mag = nearest and min = nearest and mip = linear */
  30905. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  30906. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30907. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  30908. /** Trilinear is mag = linear and min = linear and mip = linear */
  30909. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  30910. /** mag = nearest and min = nearest and mip = nearest */
  30911. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  30912. /** mag = nearest and min = linear and mip = nearest */
  30913. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  30914. /** mag = nearest and min = linear and mip = linear */
  30915. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  30916. /** mag = nearest and min = linear and mip = none */
  30917. static readonly TEXTURE_NEAREST_LINEAR: number;
  30918. /** mag = nearest and min = nearest and mip = none */
  30919. static readonly TEXTURE_NEAREST_NEAREST: number;
  30920. /** mag = linear and min = nearest and mip = nearest */
  30921. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  30922. /** mag = linear and min = nearest and mip = linear */
  30923. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  30924. /** mag = linear and min = linear and mip = none */
  30925. static readonly TEXTURE_LINEAR_LINEAR: number;
  30926. /** mag = linear and min = nearest and mip = none */
  30927. static readonly TEXTURE_LINEAR_NEAREST: number;
  30928. /** Explicit coordinates mode */
  30929. static readonly TEXTURE_EXPLICIT_MODE: number;
  30930. /** Spherical coordinates mode */
  30931. static readonly TEXTURE_SPHERICAL_MODE: number;
  30932. /** Planar coordinates mode */
  30933. static readonly TEXTURE_PLANAR_MODE: number;
  30934. /** Cubic coordinates mode */
  30935. static readonly TEXTURE_CUBIC_MODE: number;
  30936. /** Projection coordinates mode */
  30937. static readonly TEXTURE_PROJECTION_MODE: number;
  30938. /** Skybox coordinates mode */
  30939. static readonly TEXTURE_SKYBOX_MODE: number;
  30940. /** Inverse Cubic coordinates mode */
  30941. static readonly TEXTURE_INVCUBIC_MODE: number;
  30942. /** Equirectangular coordinates mode */
  30943. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  30944. /** Equirectangular Fixed coordinates mode */
  30945. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  30946. /** Equirectangular Fixed Mirrored coordinates mode */
  30947. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  30948. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  30949. static readonly SCALEMODE_FLOOR: number;
  30950. /** Defines that texture rescaling will look for the nearest power of 2 size */
  30951. static readonly SCALEMODE_NEAREST: number;
  30952. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  30953. static readonly SCALEMODE_CEILING: number;
  30954. /**
  30955. * Returns the current npm package of the sdk
  30956. */
  30957. static readonly NpmPackage: string;
  30958. /**
  30959. * Returns the current version of the framework
  30960. */
  30961. static readonly Version: string;
  30962. /**
  30963. * Returns a string describing the current engine
  30964. */
  30965. readonly description: string;
  30966. /**
  30967. * Gets or sets the epsilon value used by collision engine
  30968. */
  30969. static CollisionsEpsilon: number;
  30970. /**
  30971. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30972. */
  30973. static ShadersRepository: string;
  30974. /**
  30975. * Method called to create the default loading screen.
  30976. * This can be overriden in your own app.
  30977. * @param canvas The rendering canvas element
  30978. * @returns The loading screen
  30979. */
  30980. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  30981. /**
  30982. * Method called to create the default rescale post process on each engine.
  30983. */
  30984. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  30985. /** @hidden */
  30986. _shaderProcessor: IShaderProcessor;
  30987. /**
  30988. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30989. */
  30990. forcePOTTextures: boolean;
  30991. /**
  30992. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30993. */
  30994. isFullscreen: boolean;
  30995. /**
  30996. * Gets a boolean indicating if the pointer is currently locked
  30997. */
  30998. isPointerLock: boolean;
  30999. /**
  31000. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31001. */
  31002. cullBackFaces: boolean;
  31003. /**
  31004. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31005. */
  31006. renderEvenInBackground: boolean;
  31007. /**
  31008. * Gets or sets a boolean indicating that cache can be kept between frames
  31009. */
  31010. preventCacheWipeBetweenFrames: boolean;
  31011. /**
  31012. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  31013. **/
  31014. enableOfflineSupport: boolean;
  31015. /**
  31016. * 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)
  31017. **/
  31018. disableManifestCheck: boolean;
  31019. /**
  31020. * Gets the list of created scenes
  31021. */
  31022. scenes: Scene[];
  31023. /**
  31024. * Event raised when a new scene is created
  31025. */
  31026. onNewSceneAddedObservable: Observable<Scene>;
  31027. /**
  31028. * Gets the list of created postprocesses
  31029. */
  31030. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  31031. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31032. validateShaderPrograms: boolean;
  31033. /**
  31034. * Observable event triggered each time the rendering canvas is resized
  31035. */
  31036. onResizeObservable: Observable<Engine>;
  31037. /**
  31038. * Observable event triggered each time the canvas loses focus
  31039. */
  31040. onCanvasBlurObservable: Observable<Engine>;
  31041. /**
  31042. * Observable event triggered each time the canvas gains focus
  31043. */
  31044. onCanvasFocusObservable: Observable<Engine>;
  31045. /**
  31046. * Observable event triggered each time the canvas receives pointerout event
  31047. */
  31048. onCanvasPointerOutObservable: Observable<PointerEvent>;
  31049. /**
  31050. * Observable event triggered before each texture is initialized
  31051. */
  31052. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  31053. /**
  31054. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31055. */
  31056. disableUniformBuffers: boolean;
  31057. /** @hidden */
  31058. _uniformBuffers: UniformBuffer[];
  31059. /**
  31060. * Gets a boolean indicating that the engine supports uniform buffers
  31061. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31062. */
  31063. readonly supportsUniformBuffers: boolean;
  31064. /**
  31065. * Observable raised when the engine begins a new frame
  31066. */
  31067. onBeginFrameObservable: Observable<Engine>;
  31068. /**
  31069. * If set, will be used to request the next animation frame for the render loop
  31070. */
  31071. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  31072. /**
  31073. * Observable raised when the engine ends the current frame
  31074. */
  31075. onEndFrameObservable: Observable<Engine>;
  31076. /**
  31077. * Observable raised when the engine is about to compile a shader
  31078. */
  31079. onBeforeShaderCompilationObservable: Observable<Engine>;
  31080. /**
  31081. * Observable raised when the engine has jsut compiled a shader
  31082. */
  31083. onAfterShaderCompilationObservable: Observable<Engine>;
  31084. /** @hidden */
  31085. _gl: WebGLRenderingContext;
  31086. private _renderingCanvas;
  31087. private _windowIsBackground;
  31088. protected _webGLVersion: number;
  31089. protected _highPrecisionShadersAllowed: boolean;
  31090. /** @hidden */
  31091. readonly _shouldUseHighPrecisionShader: boolean;
  31092. /**
  31093. * Gets a boolean indicating that only power of 2 textures are supported
  31094. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31095. */
  31096. readonly needPOTTextures: boolean;
  31097. /** @hidden */
  31098. _badOS: boolean;
  31099. /** @hidden */
  31100. _badDesktopOS: boolean;
  31101. /**
  31102. * Gets the audio engine
  31103. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31104. * @ignorenaming
  31105. */
  31106. static audioEngine: IAudioEngine;
  31107. /**
  31108. * Default AudioEngine factory responsible of creating the Audio Engine.
  31109. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  31110. */
  31111. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  31112. /**
  31113. * Default offline support factory responsible of creating a tool used to store data locally.
  31114. * By default, this will create a Database object if the workload has been embedded.
  31115. */
  31116. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  31117. private _onFocus;
  31118. private _onBlur;
  31119. private _onCanvasPointerOut;
  31120. private _onCanvasBlur;
  31121. private _onCanvasFocus;
  31122. private _onFullscreenChange;
  31123. private _onPointerLockChange;
  31124. private _hardwareScalingLevel;
  31125. /** @hidden */
  31126. _caps: EngineCapabilities;
  31127. private _pointerLockRequested;
  31128. private _isStencilEnable;
  31129. protected _colorWrite: boolean;
  31130. private _loadingScreen;
  31131. /** @hidden */
  31132. _drawCalls: PerfCounter;
  31133. private _glVersion;
  31134. private _glRenderer;
  31135. private _glVendor;
  31136. private _videoTextureSupported;
  31137. private _renderingQueueLaunched;
  31138. private _activeRenderLoops;
  31139. private _deterministicLockstep;
  31140. private _lockstepMaxSteps;
  31141. /**
  31142. * Observable signaled when a context lost event is raised
  31143. */
  31144. onContextLostObservable: Observable<Engine>;
  31145. /**
  31146. * Observable signaled when a context restored event is raised
  31147. */
  31148. onContextRestoredObservable: Observable<Engine>;
  31149. private _onContextLost;
  31150. private _onContextRestored;
  31151. private _contextWasLost;
  31152. /** @hidden */
  31153. _doNotHandleContextLost: boolean;
  31154. /**
  31155. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31156. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31157. */
  31158. doNotHandleContextLost: boolean;
  31159. private _performanceMonitor;
  31160. private _fps;
  31161. private _deltaTime;
  31162. /**
  31163. * Turn this value on if you want to pause FPS computation when in background
  31164. */
  31165. disablePerformanceMonitorInBackground: boolean;
  31166. /**
  31167. * Gets the performance monitor attached to this engine
  31168. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  31169. */
  31170. readonly performanceMonitor: PerformanceMonitor;
  31171. /**
  31172. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31173. */
  31174. disableVertexArrayObjects: boolean;
  31175. /** @hidden */
  31176. protected _depthCullingState: _DepthCullingState;
  31177. /** @hidden */
  31178. protected _stencilState: _StencilState;
  31179. /** @hidden */
  31180. protected _alphaState: _AlphaState;
  31181. /** @hidden */
  31182. protected _alphaMode: number;
  31183. /** @hidden */
  31184. _internalTexturesCache: InternalTexture[];
  31185. /** @hidden */
  31186. protected _activeChannel: number;
  31187. private _currentTextureChannel;
  31188. /** @hidden */
  31189. protected _boundTexturesCache: {
  31190. [key: string]: Nullable<InternalTexture>;
  31191. };
  31192. /** @hidden */
  31193. protected _currentEffect: Nullable<Effect>;
  31194. /** @hidden */
  31195. protected _currentProgram: Nullable<WebGLProgram>;
  31196. private _compiledEffects;
  31197. private _vertexAttribArraysEnabled;
  31198. /** @hidden */
  31199. protected _cachedViewport: Nullable<IViewportLike>;
  31200. private _cachedVertexArrayObject;
  31201. /** @hidden */
  31202. protected _cachedVertexBuffers: any;
  31203. /** @hidden */
  31204. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31205. /** @hidden */
  31206. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31207. /** @hidden */
  31208. _currentRenderTarget: Nullable<InternalTexture>;
  31209. private _uintIndicesCurrentlySet;
  31210. private _currentBoundBuffer;
  31211. /** @hidden */
  31212. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31213. private _currentBufferPointers;
  31214. private _currentInstanceLocations;
  31215. private _currentInstanceBuffers;
  31216. private _textureUnits;
  31217. /** @hidden */
  31218. _workingCanvas: Nullable<HTMLCanvasElement>;
  31219. /** @hidden */
  31220. _workingContext: Nullable<CanvasRenderingContext2D>;
  31221. private _rescalePostProcess;
  31222. private _dummyFramebuffer;
  31223. private _externalData;
  31224. /** @hidden */
  31225. _bindedRenderFunction: any;
  31226. private _vaoRecordInProgress;
  31227. private _mustWipeVertexAttributes;
  31228. private _emptyTexture;
  31229. private _emptyCubeTexture;
  31230. private _emptyTexture3D;
  31231. /** @hidden */
  31232. _frameHandler: number;
  31233. private _nextFreeTextureSlots;
  31234. private _maxSimultaneousTextures;
  31235. private _activeRequests;
  31236. private _texturesSupported;
  31237. /** @hidden */
  31238. _textureFormatInUse: Nullable<string>;
  31239. /**
  31240. * Gets the list of texture formats supported
  31241. */
  31242. readonly texturesSupported: Array<string>;
  31243. /**
  31244. * Gets the list of texture formats in use
  31245. */
  31246. readonly textureFormatInUse: Nullable<string>;
  31247. /**
  31248. * Gets the current viewport
  31249. */
  31250. readonly currentViewport: Nullable<IViewportLike>;
  31251. /**
  31252. * Gets the default empty texture
  31253. */
  31254. readonly emptyTexture: InternalTexture;
  31255. /**
  31256. * Gets the default empty 3D texture
  31257. */
  31258. readonly emptyTexture3D: InternalTexture;
  31259. /**
  31260. * Gets the default empty cube texture
  31261. */
  31262. readonly emptyCubeTexture: InternalTexture;
  31263. /**
  31264. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31265. */
  31266. readonly premultipliedAlpha: boolean;
  31267. /**
  31268. * Creates a new engine
  31269. * @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
  31270. * @param antialias defines enable antialiasing (default: false)
  31271. * @param options defines further options to be sent to the getContext() function
  31272. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31273. */
  31274. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31275. /**
  31276. * Initializes a webVR display and starts listening to display change events
  31277. * The onVRDisplayChangedObservable will be notified upon these changes
  31278. * @returns The onVRDisplayChangedObservable
  31279. */
  31280. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31281. /** @hidden */
  31282. _prepareVRComponent(): void;
  31283. /** @hidden */
  31284. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  31285. /** @hidden */
  31286. _submitVRFrame(): void;
  31287. /**
  31288. * Call this function to leave webVR mode
  31289. * Will do nothing if webVR is not supported or if there is no webVR device
  31290. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31291. */
  31292. disableVR(): void;
  31293. /**
  31294. * Gets a boolean indicating that the system is in VR mode and is presenting
  31295. * @returns true if VR mode is engaged
  31296. */
  31297. isVRPresenting(): boolean;
  31298. /** @hidden */
  31299. _requestVRFrame(): void;
  31300. private _disableTouchAction;
  31301. private _rebuildInternalTextures;
  31302. private _rebuildEffects;
  31303. /**
  31304. * Gets a boolean indicating if all created effects are ready
  31305. * @returns true if all effects are ready
  31306. */
  31307. areAllEffectsReady(): boolean;
  31308. private _rebuildBuffers;
  31309. private _initGLContext;
  31310. /**
  31311. * Gets version of the current webGL context
  31312. */
  31313. readonly webGLVersion: number;
  31314. /**
  31315. * Gets a string idenfifying the name of the class
  31316. * @returns "Engine" string
  31317. */
  31318. getClassName(): string;
  31319. /**
  31320. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31321. */
  31322. readonly isStencilEnable: boolean;
  31323. /** @hidden */
  31324. _prepareWorkingCanvas(): void;
  31325. /**
  31326. * Reset the texture cache to empty state
  31327. */
  31328. resetTextureCache(): void;
  31329. /**
  31330. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  31331. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31332. * @returns true if engine is in deterministic lock step mode
  31333. */
  31334. isDeterministicLockStep(): boolean;
  31335. /**
  31336. * Gets the max steps when engine is running in deterministic lock step
  31337. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31338. * @returns the max steps
  31339. */
  31340. getLockstepMaxSteps(): number;
  31341. /**
  31342. * Gets an object containing information about the current webGL context
  31343. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31344. */
  31345. getGlInfo(): {
  31346. vendor: string;
  31347. renderer: string;
  31348. version: string;
  31349. };
  31350. /**
  31351. * Gets current aspect ratio
  31352. * @param viewportOwner defines the camera to use to get the aspect ratio
  31353. * @param useScreen defines if screen size must be used (or the current render target if any)
  31354. * @returns a number defining the aspect ratio
  31355. */
  31356. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  31357. /**
  31358. * Gets current screen aspect ratio
  31359. * @returns a number defining the aspect ratio
  31360. */
  31361. getScreenAspectRatio(): number;
  31362. /**
  31363. * Gets the current render width
  31364. * @param useScreen defines if screen size must be used (or the current render target if any)
  31365. * @returns a number defining the current render width
  31366. */
  31367. getRenderWidth(useScreen?: boolean): number;
  31368. /**
  31369. * Gets the current render height
  31370. * @param useScreen defines if screen size must be used (or the current render target if any)
  31371. * @returns a number defining the current render height
  31372. */
  31373. getRenderHeight(useScreen?: boolean): number;
  31374. /**
  31375. * Gets the HTML canvas attached with the current webGL context
  31376. * @returns a HTML canvas
  31377. */
  31378. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31379. /**
  31380. * Gets host window
  31381. * @returns the host window object
  31382. */
  31383. getHostWindow(): Window;
  31384. /**
  31385. * Gets host document
  31386. * @returns the host document object
  31387. */
  31388. getHostDocument(): Document;
  31389. /**
  31390. * Gets the client rect of the HTML canvas attached with the current webGL context
  31391. * @returns a client rectanglee
  31392. */
  31393. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  31394. /**
  31395. * Defines the hardware scaling level.
  31396. * By default the hardware scaling level is computed from the window device ratio.
  31397. * 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.
  31398. * @param level defines the level to use
  31399. */
  31400. setHardwareScalingLevel(level: number): void;
  31401. /**
  31402. * Gets the current hardware scaling level.
  31403. * By default the hardware scaling level is computed from the window device ratio.
  31404. * 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.
  31405. * @returns a number indicating the current hardware scaling level
  31406. */
  31407. getHardwareScalingLevel(): number;
  31408. /**
  31409. * Gets the list of loaded textures
  31410. * @returns an array containing all loaded textures
  31411. */
  31412. getLoadedTexturesCache(): InternalTexture[];
  31413. /**
  31414. * Gets the object containing all engine capabilities
  31415. * @returns the EngineCapabilities object
  31416. */
  31417. getCaps(): EngineCapabilities;
  31418. /**
  31419. * Gets the current depth function
  31420. * @returns a number defining the depth function
  31421. */
  31422. getDepthFunction(): Nullable<number>;
  31423. /**
  31424. * Sets the current depth function
  31425. * @param depthFunc defines the function to use
  31426. */
  31427. setDepthFunction(depthFunc: number): void;
  31428. /**
  31429. * Sets the current depth function to GREATER
  31430. */
  31431. setDepthFunctionToGreater(): void;
  31432. /**
  31433. * Sets the current depth function to GEQUAL
  31434. */
  31435. setDepthFunctionToGreaterOrEqual(): void;
  31436. /**
  31437. * Sets the current depth function to LESS
  31438. */
  31439. setDepthFunctionToLess(): void;
  31440. private _cachedStencilBuffer;
  31441. private _cachedStencilFunction;
  31442. private _cachedStencilMask;
  31443. private _cachedStencilOperationPass;
  31444. private _cachedStencilOperationFail;
  31445. private _cachedStencilOperationDepthFail;
  31446. private _cachedStencilReference;
  31447. /**
  31448. * Caches the the state of the stencil buffer
  31449. */
  31450. cacheStencilState(): void;
  31451. /**
  31452. * Restores the state of the stencil buffer
  31453. */
  31454. restoreStencilState(): void;
  31455. /**
  31456. * Sets the current depth function to LEQUAL
  31457. */
  31458. setDepthFunctionToLessOrEqual(): void;
  31459. /**
  31460. * Gets a boolean indicating if stencil buffer is enabled
  31461. * @returns the current stencil buffer state
  31462. */
  31463. getStencilBuffer(): boolean;
  31464. /**
  31465. * Enable or disable the stencil buffer
  31466. * @param enable defines if the stencil buffer must be enabled or disabled
  31467. */
  31468. setStencilBuffer(enable: boolean): void;
  31469. /**
  31470. * Gets the current stencil mask
  31471. * @returns a number defining the new stencil mask to use
  31472. */
  31473. getStencilMask(): number;
  31474. /**
  31475. * Sets the current stencil mask
  31476. * @param mask defines the new stencil mask to use
  31477. */
  31478. setStencilMask(mask: number): void;
  31479. /**
  31480. * Gets the current stencil function
  31481. * @returns a number defining the stencil function to use
  31482. */
  31483. getStencilFunction(): number;
  31484. /**
  31485. * Gets the current stencil reference value
  31486. * @returns a number defining the stencil reference value to use
  31487. */
  31488. getStencilFunctionReference(): number;
  31489. /**
  31490. * Gets the current stencil mask
  31491. * @returns a number defining the stencil mask to use
  31492. */
  31493. getStencilFunctionMask(): number;
  31494. /**
  31495. * Sets the current stencil function
  31496. * @param stencilFunc defines the new stencil function to use
  31497. */
  31498. setStencilFunction(stencilFunc: number): void;
  31499. /**
  31500. * Sets the current stencil reference
  31501. * @param reference defines the new stencil reference to use
  31502. */
  31503. setStencilFunctionReference(reference: number): void;
  31504. /**
  31505. * Sets the current stencil mask
  31506. * @param mask defines the new stencil mask to use
  31507. */
  31508. setStencilFunctionMask(mask: number): void;
  31509. /**
  31510. * Gets the current stencil operation when stencil fails
  31511. * @returns a number defining stencil operation to use when stencil fails
  31512. */
  31513. getStencilOperationFail(): number;
  31514. /**
  31515. * Gets the current stencil operation when depth fails
  31516. * @returns a number defining stencil operation to use when depth fails
  31517. */
  31518. getStencilOperationDepthFail(): number;
  31519. /**
  31520. * Gets the current stencil operation when stencil passes
  31521. * @returns a number defining stencil operation to use when stencil passes
  31522. */
  31523. getStencilOperationPass(): number;
  31524. /**
  31525. * Sets the stencil operation to use when stencil fails
  31526. * @param operation defines the stencil operation to use when stencil fails
  31527. */
  31528. setStencilOperationFail(operation: number): void;
  31529. /**
  31530. * Sets the stencil operation to use when depth fails
  31531. * @param operation defines the stencil operation to use when depth fails
  31532. */
  31533. setStencilOperationDepthFail(operation: number): void;
  31534. /**
  31535. * Sets the stencil operation to use when stencil passes
  31536. * @param operation defines the stencil operation to use when stencil passes
  31537. */
  31538. setStencilOperationPass(operation: number): void;
  31539. /**
  31540. * Sets a boolean indicating if the dithering state is enabled or disabled
  31541. * @param value defines the dithering state
  31542. */
  31543. setDitheringState(value: boolean): void;
  31544. /**
  31545. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  31546. * @param value defines the rasterizer state
  31547. */
  31548. setRasterizerState(value: boolean): void;
  31549. /**
  31550. * stop executing a render loop function and remove it from the execution array
  31551. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31552. */
  31553. stopRenderLoop(renderFunction?: () => void): void;
  31554. /** @hidden */
  31555. _renderLoop(): void;
  31556. /**
  31557. * Can be used to override the current requestAnimationFrame requester.
  31558. * @hidden
  31559. */
  31560. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31561. /**
  31562. * Register and execute a render loop. The engine can have more than one render function
  31563. * @param renderFunction defines the function to continuously execute
  31564. */
  31565. runRenderLoop(renderFunction: () => void): void;
  31566. /**
  31567. * Toggle full screen mode
  31568. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31569. */
  31570. switchFullscreen(requestPointerLock: boolean): void;
  31571. /**
  31572. * Enters full screen mode
  31573. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31574. */
  31575. enterFullscreen(requestPointerLock: boolean): void;
  31576. /**
  31577. * Exits full screen mode
  31578. */
  31579. exitFullscreen(): void;
  31580. /**
  31581. * Enters Pointerlock mode
  31582. */
  31583. enterPointerlock(): void;
  31584. /**
  31585. * Exits Pointerlock mode
  31586. */
  31587. exitPointerlock(): void;
  31588. /**
  31589. * Clear the current render buffer or the current render target (if any is set up)
  31590. * @param color defines the color to use
  31591. * @param backBuffer defines if the back buffer must be cleared
  31592. * @param depth defines if the depth buffer must be cleared
  31593. * @param stencil defines if the stencil buffer must be cleared
  31594. */
  31595. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31596. /**
  31597. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  31598. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31599. * @param y defines the y-coordinate of the corner of the clear rectangle
  31600. * @param width defines the width of the clear rectangle
  31601. * @param height defines the height of the clear rectangle
  31602. * @param clearColor defines the clear color
  31603. */
  31604. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  31605. /**
  31606. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  31607. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31608. * @param y defines the y-coordinate of the corner of the clear rectangle
  31609. * @param width defines the width of the clear rectangle
  31610. * @param height defines the height of the clear rectangle
  31611. */
  31612. enableScissor(x: number, y: number, width: number, height: number): void;
  31613. /**
  31614. * Disable previously set scissor test rectangle
  31615. */
  31616. disableScissor(): void;
  31617. private _viewportCached;
  31618. /** @hidden */
  31619. _viewport(x: number, y: number, width: number, height: number): void;
  31620. /**
  31621. * Set the WebGL's viewport
  31622. * @param viewport defines the viewport element to be used
  31623. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31624. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31625. */
  31626. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31627. /**
  31628. * Directly set the WebGL Viewport
  31629. * @param x defines the x coordinate of the viewport (in screen space)
  31630. * @param y defines the y coordinate of the viewport (in screen space)
  31631. * @param width defines the width of the viewport (in screen space)
  31632. * @param height defines the height of the viewport (in screen space)
  31633. * @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
  31634. */
  31635. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  31636. /**
  31637. * Begin a new frame
  31638. */
  31639. beginFrame(): void;
  31640. /**
  31641. * Enf the current frame
  31642. */
  31643. endFrame(): void;
  31644. /**
  31645. * Resize the view according to the canvas' size
  31646. */
  31647. resize(): void;
  31648. /**
  31649. * Force a specific size of the canvas
  31650. * @param width defines the new canvas' width
  31651. * @param height defines the new canvas' height
  31652. */
  31653. setSize(width: number, height: number): void;
  31654. /**
  31655. * Binds the frame buffer to the specified texture.
  31656. * @param texture The texture to render to or null for the default canvas
  31657. * @param faceIndex The face of the texture to render to in case of cube texture
  31658. * @param requiredWidth The width of the target to render to
  31659. * @param requiredHeight The height of the target to render to
  31660. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31661. * @param depthStencilTexture The depth stencil texture to use to render
  31662. * @param lodLevel defines le lod level to bind to the frame buffer
  31663. */
  31664. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  31665. /** @hidden */
  31666. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31667. /**
  31668. * Unbind the current render target texture from the webGL context
  31669. * @param texture defines the render target texture to unbind
  31670. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31671. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31672. */
  31673. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31674. /**
  31675. * Force the mipmap generation for the given render target texture
  31676. * @param texture defines the render target texture to use
  31677. */
  31678. generateMipMapsForCubemap(texture: InternalTexture): void;
  31679. /**
  31680. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31681. */
  31682. flushFramebuffer(): void;
  31683. /**
  31684. * Unbind the current render target and bind the default framebuffer
  31685. */
  31686. restoreDefaultFramebuffer(): void;
  31687. /**
  31688. * Create an uniform buffer
  31689. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31690. * @param elements defines the content of the uniform buffer
  31691. * @returns the webGL uniform buffer
  31692. */
  31693. createUniformBuffer(elements: FloatArray): DataBuffer;
  31694. /**
  31695. * Create a dynamic uniform buffer
  31696. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31697. * @param elements defines the content of the uniform buffer
  31698. * @returns the webGL uniform buffer
  31699. */
  31700. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  31701. /**
  31702. * Update an existing uniform buffer
  31703. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31704. * @param uniformBuffer defines the target uniform buffer
  31705. * @param elements defines the content to update
  31706. * @param offset defines the offset in the uniform buffer where update should start
  31707. * @param count defines the size of the data to update
  31708. */
  31709. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  31710. private _resetVertexBufferBinding;
  31711. /**
  31712. * Creates a vertex buffer
  31713. * @param data the data for the vertex buffer
  31714. * @returns the new WebGL static buffer
  31715. */
  31716. createVertexBuffer(data: DataArray): DataBuffer;
  31717. /**
  31718. * Creates a dynamic vertex buffer
  31719. * @param data the data for the dynamic vertex buffer
  31720. * @returns the new WebGL dynamic buffer
  31721. */
  31722. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31723. /**
  31724. * Update a dynamic index buffer
  31725. * @param indexBuffer defines the target index buffer
  31726. * @param indices defines the data to update
  31727. * @param offset defines the offset in the target index buffer where update should start
  31728. */
  31729. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  31730. /**
  31731. * Updates a dynamic vertex buffer.
  31732. * @param vertexBuffer the vertex buffer to update
  31733. * @param data the data used to update the vertex buffer
  31734. * @param byteOffset the byte offset of the data
  31735. * @param byteLength the byte length of the data
  31736. */
  31737. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  31738. private _resetIndexBufferBinding;
  31739. /**
  31740. * Creates a new index buffer
  31741. * @param indices defines the content of the index buffer
  31742. * @param updatable defines if the index buffer must be updatable
  31743. * @returns a new webGL buffer
  31744. */
  31745. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31746. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31747. /**
  31748. * Bind a webGL buffer to the webGL context
  31749. * @param buffer defines the buffer to bind
  31750. */
  31751. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31752. /**
  31753. * Bind an uniform buffer to the current webGL context
  31754. * @param buffer defines the buffer to bind
  31755. */
  31756. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  31757. /**
  31758. * Bind a buffer to the current webGL context at a given location
  31759. * @param buffer defines the buffer to bind
  31760. * @param location defines the index where to bind the buffer
  31761. */
  31762. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  31763. /**
  31764. * Bind a specific block at a given index in a specific shader program
  31765. * @param pipelineContext defines the pipeline context to use
  31766. * @param blockName defines the block name
  31767. * @param index defines the index where to bind the block
  31768. */
  31769. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  31770. private bindIndexBuffer;
  31771. private bindBuffer;
  31772. /**
  31773. * update the bound buffer with the given data
  31774. * @param data defines the data to update
  31775. */
  31776. updateArrayBuffer(data: Float32Array): void;
  31777. private _vertexAttribPointer;
  31778. private _bindIndexBufferWithCache;
  31779. private _bindVertexBuffersAttributes;
  31780. /**
  31781. * Records a vertex array object
  31782. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31783. * @param vertexBuffers defines the list of vertex buffers to store
  31784. * @param indexBuffer defines the index buffer to store
  31785. * @param effect defines the effect to store
  31786. * @returns the new vertex array object
  31787. */
  31788. recordVertexArrayObject(vertexBuffers: {
  31789. [key: string]: VertexBuffer;
  31790. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31791. /**
  31792. * Bind a specific vertex array object
  31793. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31794. * @param vertexArrayObject defines the vertex array object to bind
  31795. * @param indexBuffer defines the index buffer to bind
  31796. */
  31797. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31798. /**
  31799. * Bind webGl buffers directly to the webGL context
  31800. * @param vertexBuffer defines the vertex buffer to bind
  31801. * @param indexBuffer defines the index buffer to bind
  31802. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31803. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31804. * @param effect defines the effect associated with the vertex buffer
  31805. */
  31806. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31807. private _unbindVertexArrayObject;
  31808. /**
  31809. * Bind a list of vertex buffers to the webGL context
  31810. * @param vertexBuffers defines the list of vertex buffers to bind
  31811. * @param indexBuffer defines the index buffer to bind
  31812. * @param effect defines the effect associated with the vertex buffers
  31813. */
  31814. bindBuffers(vertexBuffers: {
  31815. [key: string]: Nullable<VertexBuffer>;
  31816. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31817. /**
  31818. * Unbind all instance attributes
  31819. */
  31820. unbindInstanceAttributes(): void;
  31821. /**
  31822. * Release and free the memory of a vertex array object
  31823. * @param vao defines the vertex array object to delete
  31824. */
  31825. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31826. /** @hidden */
  31827. _releaseBuffer(buffer: DataBuffer): boolean;
  31828. protected _deleteBuffer(buffer: DataBuffer): void;
  31829. /**
  31830. * Creates a webGL buffer to use with instanciation
  31831. * @param capacity defines the size of the buffer
  31832. * @returns the webGL buffer
  31833. */
  31834. createInstancesBuffer(capacity: number): DataBuffer;
  31835. /**
  31836. * Delete a webGL buffer used with instanciation
  31837. * @param buffer defines the webGL buffer to delete
  31838. */
  31839. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  31840. /**
  31841. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31842. * @param instancesBuffer defines the webGL buffer to update and bind
  31843. * @param data defines the data to store in the buffer
  31844. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31845. */
  31846. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31847. /**
  31848. * Apply all cached states (depth, culling, stencil and alpha)
  31849. */
  31850. applyStates(): void;
  31851. /**
  31852. * Send a draw order
  31853. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31854. * @param indexStart defines the starting index
  31855. * @param indexCount defines the number of index to draw
  31856. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31857. */
  31858. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31859. /**
  31860. * Draw a list of points
  31861. * @param verticesStart defines the index of first vertex to draw
  31862. * @param verticesCount defines the count of vertices to draw
  31863. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31864. */
  31865. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31866. /**
  31867. * Draw a list of unindexed primitives
  31868. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31869. * @param verticesStart defines the index of first vertex to draw
  31870. * @param verticesCount defines the count of vertices to draw
  31871. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31872. */
  31873. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31874. /**
  31875. * Draw a list of indexed primitives
  31876. * @param fillMode defines the primitive to use
  31877. * @param indexStart defines the starting index
  31878. * @param indexCount defines the number of index to draw
  31879. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31880. */
  31881. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31882. /**
  31883. * Draw a list of unindexed primitives
  31884. * @param fillMode defines the primitive to use
  31885. * @param verticesStart defines the index of first vertex to draw
  31886. * @param verticesCount defines the count of vertices to draw
  31887. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31888. */
  31889. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31890. private _drawMode;
  31891. /** @hidden */
  31892. _releaseEffect(effect: Effect): void;
  31893. /** @hidden */
  31894. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31895. /**
  31896. * Create a new effect (used to store vertex/fragment shaders)
  31897. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31898. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  31899. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31900. * @param samplers defines an array of string used to represent textures
  31901. * @param defines defines the string containing the defines to use to compile the shaders
  31902. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31903. * @param onCompiled defines a function to call when the effect creation is successful
  31904. * @param onError defines a function to call when the effect creation has failed
  31905. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31906. * @returns the new Effect
  31907. */
  31908. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  31909. protected static _concatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31910. private _compileShader;
  31911. private _compileRawShader;
  31912. /**
  31913. * Directly creates a webGL program
  31914. * @param pipelineContext defines the pipeline context to attach to
  31915. * @param vertexCode defines the vertex shader code to use
  31916. * @param fragmentCode defines the fragment shader code to use
  31917. * @param context defines the webGL context to use (if not set, the current one will be used)
  31918. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31919. * @returns the new webGL program
  31920. */
  31921. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31922. /**
  31923. * Creates a webGL program
  31924. * @param pipelineContext defines the pipeline context to attach to
  31925. * @param vertexCode defines the vertex shader code to use
  31926. * @param fragmentCode defines the fragment shader code to use
  31927. * @param defines defines the string containing the defines to use to compile the shaders
  31928. * @param context defines the webGL context to use (if not set, the current one will be used)
  31929. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31930. * @returns the new webGL program
  31931. */
  31932. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31933. /**
  31934. * Creates a new pipeline context
  31935. * @returns the new pipeline
  31936. */
  31937. createPipelineContext(): IPipelineContext;
  31938. private _createShaderProgram;
  31939. private _finalizePipelineContext;
  31940. /** @hidden */
  31941. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31942. /** @hidden */
  31943. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31944. /** @hidden */
  31945. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31946. /**
  31947. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31948. * @param pipelineContext defines the pipeline context to use
  31949. * @param uniformsNames defines the list of uniform names
  31950. * @returns an array of webGL uniform locations
  31951. */
  31952. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31953. /**
  31954. * Gets the lsit of active attributes for a given webGL program
  31955. * @param pipelineContext defines the pipeline context to use
  31956. * @param attributesNames defines the list of attribute names to get
  31957. * @returns an array of indices indicating the offset of each attribute
  31958. */
  31959. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31960. /**
  31961. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31962. * @param effect defines the effect to activate
  31963. */
  31964. enableEffect(effect: Nullable<Effect>): void;
  31965. /**
  31966. * Set the value of an uniform to an array of int32
  31967. * @param uniform defines the webGL uniform location where to store the value
  31968. * @param array defines the array of int32 to store
  31969. */
  31970. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31971. /**
  31972. * Set the value of an uniform to an array of int32 (stored as vec2)
  31973. * @param uniform defines the webGL uniform location where to store the value
  31974. * @param array defines the array of int32 to store
  31975. */
  31976. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31977. /**
  31978. * Set the value of an uniform to an array of int32 (stored as vec3)
  31979. * @param uniform defines the webGL uniform location where to store the value
  31980. * @param array defines the array of int32 to store
  31981. */
  31982. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31983. /**
  31984. * Set the value of an uniform to an array of int32 (stored as vec4)
  31985. * @param uniform defines the webGL uniform location where to store the value
  31986. * @param array defines the array of int32 to store
  31987. */
  31988. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31989. /**
  31990. * Set the value of an uniform to an array of float32
  31991. * @param uniform defines the webGL uniform location where to store the value
  31992. * @param array defines the array of float32 to store
  31993. */
  31994. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31995. /**
  31996. * Set the value of an uniform to an array of float32 (stored as vec2)
  31997. * @param uniform defines the webGL uniform location where to store the value
  31998. * @param array defines the array of float32 to store
  31999. */
  32000. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  32001. /**
  32002. * Set the value of an uniform to an array of float32 (stored as vec3)
  32003. * @param uniform defines the webGL uniform location where to store the value
  32004. * @param array defines the array of float32 to store
  32005. */
  32006. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  32007. /**
  32008. * Set the value of an uniform to an array of float32 (stored as vec4)
  32009. * @param uniform defines the webGL uniform location where to store the value
  32010. * @param array defines the array of float32 to store
  32011. */
  32012. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  32013. /**
  32014. * Set the value of an uniform to an array of number
  32015. * @param uniform defines the webGL uniform location where to store the value
  32016. * @param array defines the array of number to store
  32017. */
  32018. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  32019. /**
  32020. * Set the value of an uniform to an array of number (stored as vec2)
  32021. * @param uniform defines the webGL uniform location where to store the value
  32022. * @param array defines the array of number to store
  32023. */
  32024. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  32025. /**
  32026. * Set the value of an uniform to an array of number (stored as vec3)
  32027. * @param uniform defines the webGL uniform location where to store the value
  32028. * @param array defines the array of number to store
  32029. */
  32030. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  32031. /**
  32032. * Set the value of an uniform to an array of number (stored as vec4)
  32033. * @param uniform defines the webGL uniform location where to store the value
  32034. * @param array defines the array of number to store
  32035. */
  32036. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  32037. /**
  32038. * Set the value of an uniform to an array of float32 (stored as matrices)
  32039. * @param uniform defines the webGL uniform location where to store the value
  32040. * @param matrices defines the array of float32 to store
  32041. */
  32042. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32043. /**
  32044. * Set the value of an uniform to a matrix (3x3)
  32045. * @param uniform defines the webGL uniform location where to store the value
  32046. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32047. */
  32048. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32049. /**
  32050. * Set the value of an uniform to a matrix (2x2)
  32051. * @param uniform defines the webGL uniform location where to store the value
  32052. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32053. */
  32054. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32055. /**
  32056. * Set the value of an uniform to a number (int)
  32057. * @param uniform defines the webGL uniform location where to store the value
  32058. * @param value defines the int number to store
  32059. */
  32060. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32061. /**
  32062. * Set the value of an uniform to a number (float)
  32063. * @param uniform defines the webGL uniform location where to store the value
  32064. * @param value defines the float number to store
  32065. */
  32066. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32067. /**
  32068. * Set the value of an uniform to a vec2
  32069. * @param uniform defines the webGL uniform location where to store the value
  32070. * @param x defines the 1st component of the value
  32071. * @param y defines the 2nd component of the value
  32072. */
  32073. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32074. /**
  32075. * Set the value of an uniform to a vec3
  32076. * @param uniform defines the webGL uniform location where to store the value
  32077. * @param x defines the 1st component of the value
  32078. * @param y defines the 2nd component of the value
  32079. * @param z defines the 3rd component of the value
  32080. */
  32081. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32082. /**
  32083. * Set the value of an uniform to a boolean
  32084. * @param uniform defines the webGL uniform location where to store the value
  32085. * @param bool defines the boolean to store
  32086. */
  32087. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  32088. /**
  32089. * Set the value of an uniform to a vec4
  32090. * @param uniform defines the webGL uniform location where to store the value
  32091. * @param x defines the 1st component of the value
  32092. * @param y defines the 2nd component of the value
  32093. * @param z defines the 3rd component of the value
  32094. * @param w defines the 4th component of the value
  32095. */
  32096. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32097. /**
  32098. * Sets a Color4 on a uniform variable
  32099. * @param uniform defines the uniform location
  32100. * @param color4 defines the value to be set
  32101. */
  32102. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  32103. /**
  32104. * Set various states to the webGL context
  32105. * @param culling defines backface culling state
  32106. * @param zOffset defines the value to apply to zOffset (0 by default)
  32107. * @param force defines if states must be applied even if cache is up to date
  32108. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32109. */
  32110. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32111. /**
  32112. * Set the z offset to apply to current rendering
  32113. * @param value defines the offset to apply
  32114. */
  32115. setZOffset(value: number): void;
  32116. /**
  32117. * Gets the current value of the zOffset
  32118. * @returns the current zOffset state
  32119. */
  32120. getZOffset(): number;
  32121. /**
  32122. * Enable or disable depth buffering
  32123. * @param enable defines the state to set
  32124. */
  32125. setDepthBuffer(enable: boolean): void;
  32126. /**
  32127. * Gets a boolean indicating if depth writing is enabled
  32128. * @returns the current depth writing state
  32129. */
  32130. getDepthWrite(): boolean;
  32131. /**
  32132. * Enable or disable depth writing
  32133. * @param enable defines the state to set
  32134. */
  32135. setDepthWrite(enable: boolean): void;
  32136. /**
  32137. * Enable or disable color writing
  32138. * @param enable defines the state to set
  32139. */
  32140. setColorWrite(enable: boolean): void;
  32141. /**
  32142. * Gets a boolean indicating if color writing is enabled
  32143. * @returns the current color writing state
  32144. */
  32145. getColorWrite(): boolean;
  32146. /**
  32147. * Sets alpha constants used by some alpha blending modes
  32148. * @param r defines the red component
  32149. * @param g defines the green component
  32150. * @param b defines the blue component
  32151. * @param a defines the alpha component
  32152. */
  32153. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32154. /**
  32155. * Sets the current alpha mode
  32156. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32157. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32158. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32159. */
  32160. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32161. /**
  32162. * Gets the current alpha mode
  32163. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32164. * @returns the current alpha mode
  32165. */
  32166. getAlphaMode(): number;
  32167. /**
  32168. * Clears the list of texture accessible through engine.
  32169. * This can help preventing texture load conflict due to name collision.
  32170. */
  32171. clearInternalTexturesCache(): void;
  32172. /**
  32173. * Force the entire cache to be cleared
  32174. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32175. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32176. */
  32177. wipeCaches(bruteForce?: boolean): void;
  32178. /**
  32179. * Set the compressed texture format to use, based on the formats you have, and the formats
  32180. * supported by the hardware / browser.
  32181. *
  32182. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32183. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32184. * to API arguments needed to compressed textures. This puts the burden on the container
  32185. * generator to house the arcane code for determining these for current & future formats.
  32186. *
  32187. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32188. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32189. *
  32190. * Note: The result of this call is not taken into account when a texture is base64.
  32191. *
  32192. * @param formatsAvailable defines the list of those format families you have created
  32193. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32194. *
  32195. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32196. * @returns The extension selected.
  32197. */
  32198. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32199. /** @hidden */
  32200. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32201. min: number;
  32202. mag: number;
  32203. };
  32204. /** @hidden */
  32205. _createTexture(): WebGLTexture;
  32206. /**
  32207. * Usually called from Texture.ts.
  32208. * Passed information to create a WebGLTexture
  32209. * @param urlArg defines a value which contains one of the following:
  32210. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32211. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32212. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32213. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32214. * @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)
  32215. * @param scene needed for loading to the correct scene
  32216. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32217. * @param onLoad optional callback to be called upon successful completion
  32218. * @param onError optional callback to be called upon failure
  32219. * @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
  32220. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32221. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32222. * @param forcedExtension defines the extension to use to pick the right loader
  32223. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32224. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32225. */
  32226. 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 | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  32227. /**
  32228. * @hidden
  32229. * Rescales a texture
  32230. * @param source input texutre
  32231. * @param destination destination texture
  32232. * @param scene scene to use to render the resize
  32233. * @param internalFormat format to use when resizing
  32234. * @param onComplete callback to be called when resize has completed
  32235. */
  32236. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  32237. private _unpackFlipYCached;
  32238. /**
  32239. * In case you are sharing the context with other applications, it might
  32240. * be interested to not cache the unpack flip y state to ensure a consistent
  32241. * value would be set.
  32242. */
  32243. enableUnpackFlipYCached: boolean;
  32244. /** @hidden */
  32245. _unpackFlipY(value: boolean): void;
  32246. /** @hidden */
  32247. _getUnpackAlignement(): number;
  32248. /**
  32249. * Creates a dynamic texture
  32250. * @param width defines the width of the texture
  32251. * @param height defines the height of the texture
  32252. * @param generateMipMaps defines if the engine should generate the mip levels
  32253. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32254. * @returns the dynamic texture inside an InternalTexture
  32255. */
  32256. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  32257. /**
  32258. * Update the sampling mode of a given texture
  32259. * @param samplingMode defines the required sampling mode
  32260. * @param texture defines the texture to update
  32261. */
  32262. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  32263. /**
  32264. * Update the content of a dynamic texture
  32265. * @param texture defines the texture to update
  32266. * @param canvas defines the canvas containing the source
  32267. * @param invertY defines if data must be stored with Y axis inverted
  32268. * @param premulAlpha defines if alpha is stored as premultiplied
  32269. * @param format defines the format of the data
  32270. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  32271. */
  32272. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  32273. /**
  32274. * Update a video texture
  32275. * @param texture defines the texture to update
  32276. * @param video defines the video element to use
  32277. * @param invertY defines if data must be stored with Y axis inverted
  32278. */
  32279. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  32280. /**
  32281. * Updates a depth texture Comparison Mode and Function.
  32282. * If the comparison Function is equal to 0, the mode will be set to none.
  32283. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  32284. * @param texture The texture to set the comparison function for
  32285. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  32286. */
  32287. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  32288. /** @hidden */
  32289. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32290. width: number;
  32291. height: number;
  32292. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32293. /**
  32294. * Creates a depth stencil texture.
  32295. * This is only available in WebGL 2 or with the depth texture extension available.
  32296. * @param size The size of face edge in the texture.
  32297. * @param options The options defining the texture.
  32298. * @returns The texture
  32299. */
  32300. createDepthStencilTexture(size: number | {
  32301. width: number;
  32302. height: number;
  32303. }, options: DepthTextureCreationOptions): InternalTexture;
  32304. /**
  32305. * Creates a depth stencil texture.
  32306. * This is only available in WebGL 2 or with the depth texture extension available.
  32307. * @param size The size of face edge in the texture.
  32308. * @param options The options defining the texture.
  32309. * @returns The texture
  32310. */
  32311. private _createDepthStencilTexture;
  32312. /**
  32313. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32314. * @param renderTarget The render target to set the frame buffer for
  32315. */
  32316. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32317. /**
  32318. * Creates a new render target texture
  32319. * @param size defines the size of the texture
  32320. * @param options defines the options used to create the texture
  32321. * @returns a new render target texture stored in an InternalTexture
  32322. */
  32323. createRenderTargetTexture(size: number | {
  32324. width: number;
  32325. height: number;
  32326. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  32327. /** @hidden */
  32328. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32329. /**
  32330. * Updates the sample count of a render target texture
  32331. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32332. * @param texture defines the texture to update
  32333. * @param samples defines the sample count to set
  32334. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32335. */
  32336. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32337. /** @hidden */
  32338. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32339. /** @hidden */
  32340. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32341. /** @hidden */
  32342. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32343. /** @hidden */
  32344. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  32345. /**
  32346. * @hidden
  32347. */
  32348. _setCubeMapTextureParams(loadMipmap: boolean): void;
  32349. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<Scene>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32350. private _prepareWebGLTexture;
  32351. /** @hidden */
  32352. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32353. /** @hidden */
  32354. _releaseFramebufferObjects(texture: InternalTexture): void;
  32355. /** @hidden */
  32356. _releaseTexture(texture: InternalTexture): void;
  32357. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32358. protected _setProgram(program: WebGLProgram): void;
  32359. protected _boundUniforms: {
  32360. [key: number]: WebGLUniformLocation;
  32361. };
  32362. /**
  32363. * Binds an effect to the webGL context
  32364. * @param effect defines the effect to bind
  32365. */
  32366. bindSamplers(effect: Effect): void;
  32367. private _activateCurrentTexture;
  32368. /** @hidden */
  32369. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32370. /** @hidden */
  32371. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32372. /**
  32373. * Sets a texture to the webGL context from a postprocess
  32374. * @param channel defines the channel to use
  32375. * @param postProcess defines the source postprocess
  32376. */
  32377. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32378. /**
  32379. * Binds the output of the passed in post process to the texture channel specified
  32380. * @param channel The channel the texture should be bound to
  32381. * @param postProcess The post process which's output should be bound
  32382. */
  32383. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32384. /**
  32385. * Unbind all textures from the webGL context
  32386. */
  32387. unbindAllTextures(): void;
  32388. /**
  32389. * Sets a texture to the according uniform.
  32390. * @param channel The texture channel
  32391. * @param uniform The uniform to set
  32392. * @param texture The texture to apply
  32393. */
  32394. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32395. /**
  32396. * Sets a depth stencil texture from a render target to the according uniform.
  32397. * @param channel The texture channel
  32398. * @param uniform The uniform to set
  32399. * @param texture The render target texture containing the depth stencil texture to apply
  32400. */
  32401. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32402. private _bindSamplerUniformToChannel;
  32403. private _getTextureWrapMode;
  32404. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32405. /**
  32406. * Sets an array of texture to the webGL context
  32407. * @param channel defines the channel where the texture array must be set
  32408. * @param uniform defines the associated uniform location
  32409. * @param textures defines the array of textures to bind
  32410. */
  32411. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32412. /** @hidden */
  32413. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  32414. private _setTextureParameterFloat;
  32415. private _setTextureParameterInteger;
  32416. /**
  32417. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32418. * @param x defines the x coordinate of the rectangle where pixels must be read
  32419. * @param y defines the y coordinate of the rectangle where pixels must be read
  32420. * @param width defines the width of the rectangle where pixels must be read
  32421. * @param height defines the height of the rectangle where pixels must be read
  32422. * @returns a Uint8Array containing RGBA colors
  32423. */
  32424. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32425. /**
  32426. * Add an externaly attached data from its key.
  32427. * This method call will fail and return false, if such key already exists.
  32428. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32429. * @param key the unique key that identifies the data
  32430. * @param data the data object to associate to the key for this Engine instance
  32431. * @return true if no such key were already present and the data was added successfully, false otherwise
  32432. */
  32433. addExternalData<T>(key: string, data: T): boolean;
  32434. /**
  32435. * Get an externaly attached data from its key
  32436. * @param key the unique key that identifies the data
  32437. * @return the associated data, if present (can be null), or undefined if not present
  32438. */
  32439. getExternalData<T>(key: string): T;
  32440. /**
  32441. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32442. * @param key the unique key that identifies the data
  32443. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32444. * @return the associated data, can be null if the factory returned null.
  32445. */
  32446. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  32447. /**
  32448. * Remove an externaly attached data from the Engine instance
  32449. * @param key the unique key that identifies the data
  32450. * @return true if the data was successfully removed, false if it doesn't exist
  32451. */
  32452. removeExternalData(key: string): boolean;
  32453. /**
  32454. * Unbind all vertex attributes from the webGL context
  32455. */
  32456. unbindAllAttributes(): void;
  32457. /**
  32458. * 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
  32459. */
  32460. releaseEffects(): void;
  32461. /**
  32462. * Dispose and release all associated resources
  32463. */
  32464. dispose(): void;
  32465. /**
  32466. * Display the loading screen
  32467. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32468. */
  32469. displayLoadingUI(): void;
  32470. /**
  32471. * Hide the loading screen
  32472. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32473. */
  32474. hideLoadingUI(): void;
  32475. /**
  32476. * Gets the current loading screen object
  32477. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32478. */
  32479. /**
  32480. * Sets the current loading screen object
  32481. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32482. */
  32483. loadingScreen: ILoadingScreen;
  32484. /**
  32485. * Sets the current loading screen text
  32486. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32487. */
  32488. loadingUIText: string;
  32489. /**
  32490. * Sets the current loading screen background color
  32491. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32492. */
  32493. loadingUIBackgroundColor: string;
  32494. /**
  32495. * Attach a new callback raised when context lost event is fired
  32496. * @param callback defines the callback to call
  32497. */
  32498. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32499. /**
  32500. * Attach a new callback raised when context restored event is fired
  32501. * @param callback defines the callback to call
  32502. */
  32503. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32504. /**
  32505. * Gets the source code of the vertex shader associated with a specific webGL program
  32506. * @param program defines the program to use
  32507. * @returns a string containing the source code of the vertex shader associated with the program
  32508. */
  32509. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32510. /**
  32511. * Gets the source code of the fragment shader associated with a specific webGL program
  32512. * @param program defines the program to use
  32513. * @returns a string containing the source code of the fragment shader associated with the program
  32514. */
  32515. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32516. /**
  32517. * Get the current error code of the webGL context
  32518. * @returns the error code
  32519. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32520. */
  32521. getError(): number;
  32522. /**
  32523. * Gets the current framerate
  32524. * @returns a number representing the framerate
  32525. */
  32526. getFps(): number;
  32527. /**
  32528. * Gets the time spent between current and previous frame
  32529. * @returns a number representing the delta time in ms
  32530. */
  32531. getDeltaTime(): number;
  32532. private _measureFps;
  32533. /** @hidden */
  32534. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32535. private _canRenderToFloatFramebuffer;
  32536. private _canRenderToHalfFloatFramebuffer;
  32537. private _canRenderToFramebuffer;
  32538. /** @hidden */
  32539. _getWebGLTextureType(type: number): number;
  32540. /** @hidden */
  32541. _getInternalFormat(format: number): number;
  32542. /** @hidden */
  32543. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32544. /** @hidden */
  32545. _getRGBAMultiSampleBufferFormat(type: number): number;
  32546. /** @hidden */
  32547. _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;
  32548. /** @hidden */
  32549. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32550. /**
  32551. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32552. * @returns true if the engine can be created
  32553. * @ignorenaming
  32554. */
  32555. static isSupported(): boolean;
  32556. /**
  32557. * Find the next highest power of two.
  32558. * @param x Number to start search from.
  32559. * @return Next highest power of two.
  32560. */
  32561. static CeilingPOT(x: number): number;
  32562. /**
  32563. * Find the next lowest power of two.
  32564. * @param x Number to start search from.
  32565. * @return Next lowest power of two.
  32566. */
  32567. static FloorPOT(x: number): number;
  32568. /**
  32569. * Find the nearest power of two.
  32570. * @param x Number to start search from.
  32571. * @return Next nearest power of two.
  32572. */
  32573. static NearestPOT(x: number): number;
  32574. /**
  32575. * Get the closest exponent of two
  32576. * @param value defines the value to approximate
  32577. * @param max defines the maximum value to return
  32578. * @param mode defines how to define the closest value
  32579. * @returns closest exponent of two of the given value
  32580. */
  32581. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32582. /**
  32583. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32584. * @param func - the function to be called
  32585. * @param requester - the object that will request the next frame. Falls back to window.
  32586. * @returns frame number
  32587. */
  32588. static QueueNewFrame(func: () => void, requester?: any): number;
  32589. /**
  32590. * Ask the browser to promote the current element to pointerlock mode
  32591. * @param element defines the DOM element to promote
  32592. */
  32593. static _RequestPointerlock(element: HTMLElement): void;
  32594. /**
  32595. * Asks the browser to exit pointerlock mode
  32596. */
  32597. static _ExitPointerlock(): void;
  32598. /**
  32599. * Ask the browser to promote the current element to fullscreen rendering mode
  32600. * @param element defines the DOM element to promote
  32601. */
  32602. static _RequestFullscreen(element: HTMLElement): void;
  32603. /**
  32604. * Asks the browser to exit fullscreen mode
  32605. */
  32606. static _ExitFullscreen(): void;
  32607. }
  32608. }
  32609. declare module "babylonjs/Engines/engineStore" {
  32610. import { Nullable } from "babylonjs/types";
  32611. import { Engine } from "babylonjs/Engines/engine";
  32612. import { Scene } from "babylonjs/scene";
  32613. /**
  32614. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32615. * during the life time of the application.
  32616. */
  32617. export class EngineStore {
  32618. /** Gets the list of created engines */
  32619. static Instances: import("babylonjs/Engines/engine").Engine[];
  32620. /** @hidden */
  32621. static _LastCreatedScene: Nullable<Scene>;
  32622. /**
  32623. * Gets the latest created engine
  32624. */
  32625. static readonly LastCreatedEngine: Nullable<Engine>;
  32626. /**
  32627. * Gets the latest created scene
  32628. */
  32629. static readonly LastCreatedScene: Nullable<Scene>;
  32630. /**
  32631. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32632. * @ignorenaming
  32633. */
  32634. static UseFallbackTexture: boolean;
  32635. /**
  32636. * Texture content used if a texture cannot loaded
  32637. * @ignorenaming
  32638. */
  32639. static FallbackTexture: string;
  32640. }
  32641. }
  32642. declare module "babylonjs/Misc/promise" {
  32643. /**
  32644. * Helper class that provides a small promise polyfill
  32645. */
  32646. export class PromisePolyfill {
  32647. /**
  32648. * Static function used to check if the polyfill is required
  32649. * If this is the case then the function will inject the polyfill to window.Promise
  32650. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32651. */
  32652. static Apply(force?: boolean): void;
  32653. }
  32654. }
  32655. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  32656. /**
  32657. * Interface for screenshot methods with describe argument called `size` as object with options
  32658. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32659. */
  32660. export interface IScreenshotSize {
  32661. /**
  32662. * number in pixels for canvas height
  32663. */
  32664. height?: number;
  32665. /**
  32666. * multiplier allowing render at a higher or lower resolution
  32667. * If value is defined then height and width will be ignored and taken from camera
  32668. */
  32669. precision?: number;
  32670. /**
  32671. * number in pixels for canvas width
  32672. */
  32673. width?: number;
  32674. }
  32675. }
  32676. declare module "babylonjs/Misc/tools" {
  32677. import { Nullable, float } from "babylonjs/types";
  32678. import { DomManagement } from "babylonjs/Misc/domManagement";
  32679. import { WebRequest } from "babylonjs/Misc/webRequest";
  32680. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32681. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32682. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  32683. import { Camera } from "babylonjs/Cameras/camera";
  32684. import { Engine } from "babylonjs/Engines/engine";
  32685. interface IColor4Like {
  32686. r: float;
  32687. g: float;
  32688. b: float;
  32689. a: float;
  32690. }
  32691. /**
  32692. * Class containing a set of static utilities functions
  32693. */
  32694. export class Tools {
  32695. /**
  32696. * Gets or sets the base URL to use to load assets
  32697. */
  32698. static BaseUrl: string;
  32699. /**
  32700. * Enable/Disable Custom HTTP Request Headers globally.
  32701. * default = false
  32702. * @see CustomRequestHeaders
  32703. */
  32704. static UseCustomRequestHeaders: boolean;
  32705. /**
  32706. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32707. * i.e. when loading files, where the server/service expects an Authorization header
  32708. */
  32709. static CustomRequestHeaders: {
  32710. [key: string]: string;
  32711. };
  32712. /**
  32713. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32714. */
  32715. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32716. /**
  32717. * Default behaviour for cors in the application.
  32718. * It can be a string if the expected behavior is identical in the entire app.
  32719. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32720. */
  32721. static CorsBehavior: string | ((url: string | string[]) => string);
  32722. /**
  32723. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32724. * @ignorenaming
  32725. */
  32726. static UseFallbackTexture: boolean;
  32727. /**
  32728. * Use this object to register external classes like custom textures or material
  32729. * to allow the laoders to instantiate them
  32730. */
  32731. static RegisteredExternalClasses: {
  32732. [key: string]: Object;
  32733. };
  32734. /**
  32735. * Texture content used if a texture cannot loaded
  32736. * @ignorenaming
  32737. */
  32738. static fallbackTexture: string;
  32739. /**
  32740. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32741. * @param u defines the coordinate on X axis
  32742. * @param v defines the coordinate on Y axis
  32743. * @param width defines the width of the source data
  32744. * @param height defines the height of the source data
  32745. * @param pixels defines the source byte array
  32746. * @param color defines the output color
  32747. */
  32748. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32749. /**
  32750. * Interpolates between a and b via alpha
  32751. * @param a The lower value (returned when alpha = 0)
  32752. * @param b The upper value (returned when alpha = 1)
  32753. * @param alpha The interpolation-factor
  32754. * @return The mixed value
  32755. */
  32756. static Mix(a: number, b: number, alpha: number): number;
  32757. /**
  32758. * Tries to instantiate a new object from a given class name
  32759. * @param className defines the class name to instantiate
  32760. * @returns the new object or null if the system was not able to do the instantiation
  32761. */
  32762. static Instantiate(className: string): any;
  32763. /**
  32764. * Provides a slice function that will work even on IE
  32765. * @param data defines the array to slice
  32766. * @param start defines the start of the data (optional)
  32767. * @param end defines the end of the data (optional)
  32768. * @returns the new sliced array
  32769. */
  32770. static Slice<T>(data: T, start?: number, end?: number): T;
  32771. /**
  32772. * Polyfill for setImmediate
  32773. * @param action defines the action to execute after the current execution block
  32774. */
  32775. static SetImmediate(action: () => void): void;
  32776. /**
  32777. * Function indicating if a number is an exponent of 2
  32778. * @param value defines the value to test
  32779. * @returns true if the value is an exponent of 2
  32780. */
  32781. static IsExponentOfTwo(value: number): boolean;
  32782. private static _tmpFloatArray;
  32783. /**
  32784. * Returns the nearest 32-bit single precision float representation of a Number
  32785. * @param value A Number. If the parameter is of a different type, it will get converted
  32786. * to a number or to NaN if it cannot be converted
  32787. * @returns number
  32788. */
  32789. static FloatRound(value: number): number;
  32790. /**
  32791. * Extracts the filename from a path
  32792. * @param path defines the path to use
  32793. * @returns the filename
  32794. */
  32795. static GetFilename(path: string): string;
  32796. /**
  32797. * Extracts the "folder" part of a path (everything before the filename).
  32798. * @param uri The URI to extract the info from
  32799. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32800. * @returns The "folder" part of the path
  32801. */
  32802. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32803. /**
  32804. * Extracts text content from a DOM element hierarchy
  32805. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32806. */
  32807. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32808. /**
  32809. * Convert an angle in radians to degrees
  32810. * @param angle defines the angle to convert
  32811. * @returns the angle in degrees
  32812. */
  32813. static ToDegrees(angle: number): number;
  32814. /**
  32815. * Convert an angle in degrees to radians
  32816. * @param angle defines the angle to convert
  32817. * @returns the angle in radians
  32818. */
  32819. static ToRadians(angle: number): number;
  32820. /**
  32821. * Encode a buffer to a base64 string
  32822. * @param buffer defines the buffer to encode
  32823. * @returns the encoded string
  32824. */
  32825. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32826. /**
  32827. * Returns an array if obj is not an array
  32828. * @param obj defines the object to evaluate as an array
  32829. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32830. * @returns either obj directly if obj is an array or a new array containing obj
  32831. */
  32832. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32833. /**
  32834. * Gets the pointer prefix to use
  32835. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32836. */
  32837. static GetPointerPrefix(): string;
  32838. /**
  32839. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32840. * @param url define the url we are trying
  32841. * @param element define the dom element where to configure the cors policy
  32842. */
  32843. static SetCorsBehavior(url: string | string[], element: {
  32844. crossOrigin: string | null;
  32845. }): void;
  32846. /**
  32847. * Removes unwanted characters from an url
  32848. * @param url defines the url to clean
  32849. * @returns the cleaned url
  32850. */
  32851. static CleanUrl(url: string): string;
  32852. /**
  32853. * Gets or sets a function used to pre-process url before using them to load assets
  32854. */
  32855. static PreprocessUrl: (url: string) => string;
  32856. /**
  32857. * Loads an image as an HTMLImageElement.
  32858. * @param input url string, ArrayBuffer, or Blob to load
  32859. * @param onLoad callback called when the image successfully loads
  32860. * @param onError callback called when the image fails to load
  32861. * @param offlineProvider offline provider for caching
  32862. * @returns the HTMLImageElement of the loaded image
  32863. */
  32864. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32865. /**
  32866. * Loads a file
  32867. * @param url url string, ArrayBuffer, or Blob to load
  32868. * @param onSuccess callback called when the file successfully loads
  32869. * @param onProgress callback called while file is loading (if the server supports this mode)
  32870. * @param offlineProvider defines the offline provider for caching
  32871. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32872. * @param onError callback called when the file fails to load
  32873. * @returns a file request object
  32874. */
  32875. 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;
  32876. /**
  32877. * Loads a file from a url
  32878. * @param url the file url to load
  32879. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32880. */
  32881. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32882. /**
  32883. * Load a script (identified by an url). When the url returns, the
  32884. * content of this file is added into a new script element, attached to the DOM (body element)
  32885. * @param scriptUrl defines the url of the script to laod
  32886. * @param onSuccess defines the callback called when the script is loaded
  32887. * @param onError defines the callback to call if an error occurs
  32888. * @param scriptId defines the id of the script element
  32889. */
  32890. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32891. /**
  32892. * Load an asynchronous script (identified by an url). When the url returns, the
  32893. * content of this file is added into a new script element, attached to the DOM (body element)
  32894. * @param scriptUrl defines the url of the script to laod
  32895. * @param scriptId defines the id of the script element
  32896. * @returns a promise request object
  32897. */
  32898. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32899. /**
  32900. * Loads a file from a blob
  32901. * @param fileToLoad defines the blob to use
  32902. * @param callback defines the callback to call when data is loaded
  32903. * @param progressCallback defines the callback to call during loading process
  32904. * @returns a file request object
  32905. */
  32906. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32907. /**
  32908. * Loads a file
  32909. * @param fileToLoad defines the file to load
  32910. * @param callback defines the callback to call when data is loaded
  32911. * @param progressCallBack defines the callback to call during loading process
  32912. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32913. * @returns a file request object
  32914. */
  32915. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32916. /**
  32917. * Creates a data url from a given string content
  32918. * @param content defines the content to convert
  32919. * @returns the new data url link
  32920. */
  32921. static FileAsURL(content: string): string;
  32922. /**
  32923. * Format the given number to a specific decimal format
  32924. * @param value defines the number to format
  32925. * @param decimals defines the number of decimals to use
  32926. * @returns the formatted string
  32927. */
  32928. static Format(value: number, decimals?: number): string;
  32929. /**
  32930. * Tries to copy an object by duplicating every property
  32931. * @param source defines the source object
  32932. * @param destination defines the target object
  32933. * @param doNotCopyList defines a list of properties to avoid
  32934. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32935. */
  32936. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32937. /**
  32938. * Gets a boolean indicating if the given object has no own property
  32939. * @param obj defines the object to test
  32940. * @returns true if object has no own property
  32941. */
  32942. static IsEmpty(obj: any): boolean;
  32943. /**
  32944. * Function used to register events at window level
  32945. * @param windowElement defines the Window object to use
  32946. * @param events defines the events to register
  32947. */
  32948. static RegisterTopRootEvents(windowElement: Window, events: {
  32949. name: string;
  32950. handler: Nullable<(e: FocusEvent) => any>;
  32951. }[]): void;
  32952. /**
  32953. * Function used to unregister events from window level
  32954. * @param windowElement defines the Window object to use
  32955. * @param events defines the events to unregister
  32956. */
  32957. static UnregisterTopRootEvents(windowElement: Window, events: {
  32958. name: string;
  32959. handler: Nullable<(e: FocusEvent) => any>;
  32960. }[]): void;
  32961. /**
  32962. * @ignore
  32963. */
  32964. static _ScreenshotCanvas: HTMLCanvasElement;
  32965. /**
  32966. * Dumps the current bound framebuffer
  32967. * @param width defines the rendering width
  32968. * @param height defines the rendering height
  32969. * @param engine defines the hosting engine
  32970. * @param successCallback defines the callback triggered once the data are available
  32971. * @param mimeType defines the mime type of the result
  32972. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32973. */
  32974. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32975. /**
  32976. * Converts the canvas data to blob.
  32977. * This acts as a polyfill for browsers not supporting the to blob function.
  32978. * @param canvas Defines the canvas to extract the data from
  32979. * @param successCallback Defines the callback triggered once the data are available
  32980. * @param mimeType Defines the mime type of the result
  32981. */
  32982. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32983. /**
  32984. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32985. * @param successCallback defines the callback triggered once the data are available
  32986. * @param mimeType defines the mime type of the result
  32987. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32988. */
  32989. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32990. /**
  32991. * Downloads a blob in the browser
  32992. * @param blob defines the blob to download
  32993. * @param fileName defines the name of the downloaded file
  32994. */
  32995. static Download(blob: Blob, fileName: string): void;
  32996. /**
  32997. * Captures a screenshot of the current rendering
  32998. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32999. * @param engine defines the rendering engine
  33000. * @param camera defines the source camera
  33001. * @param size This parameter can be set to a single number or to an object with the
  33002. * following (optional) properties: precision, width, height. If a single number is passed,
  33003. * it will be used for both width and height. If an object is passed, the screenshot size
  33004. * will be derived from the parameters. The precision property is a multiplier allowing
  33005. * rendering at a higher or lower resolution
  33006. * @param successCallback defines the callback receives a single parameter which contains the
  33007. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33008. * src parameter of an <img> to display it
  33009. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33010. * Check your browser for supported MIME types
  33011. */
  33012. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  33013. /**
  33014. * Captures a screenshot of the current rendering
  33015. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33016. * @param engine defines the rendering engine
  33017. * @param camera defines the source camera
  33018. * @param size This parameter can be set to a single number or to an object with the
  33019. * following (optional) properties: precision, width, height. If a single number is passed,
  33020. * it will be used for both width and height. If an object is passed, the screenshot size
  33021. * will be derived from the parameters. The precision property is a multiplier allowing
  33022. * rendering at a higher or lower resolution
  33023. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33024. * Check your browser for supported MIME types
  33025. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33026. * to the src parameter of an <img> to display it
  33027. */
  33028. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  33029. /**
  33030. * Generates an image screenshot from the specified camera.
  33031. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33032. * @param engine The engine to use for rendering
  33033. * @param camera The camera to use for rendering
  33034. * @param size This parameter can be set to a single number or to an object with the
  33035. * following (optional) properties: precision, width, height. If a single number is passed,
  33036. * it will be used for both width and height. If an object is passed, the screenshot size
  33037. * will be derived from the parameters. The precision property is a multiplier allowing
  33038. * rendering at a higher or lower resolution
  33039. * @param successCallback The callback receives a single parameter which contains the
  33040. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33041. * src parameter of an <img> to display it
  33042. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33043. * Check your browser for supported MIME types
  33044. * @param samples Texture samples (default: 1)
  33045. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33046. * @param fileName A name for for the downloaded file.
  33047. */
  33048. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33049. /**
  33050. * Generates an image screenshot from the specified camera.
  33051. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33052. * @param engine The engine to use for rendering
  33053. * @param camera The camera to use for rendering
  33054. * @param size This parameter can be set to a single number or to an object with the
  33055. * following (optional) properties: precision, width, height. If a single number is passed,
  33056. * it will be used for both width and height. If an object is passed, the screenshot size
  33057. * will be derived from the parameters. The precision property is a multiplier allowing
  33058. * rendering at a higher or lower resolution
  33059. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33060. * Check your browser for supported MIME types
  33061. * @param samples Texture samples (default: 1)
  33062. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33063. * @param fileName A name for for the downloaded file.
  33064. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33065. * to the src parameter of an <img> to display it
  33066. */
  33067. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  33068. /**
  33069. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33070. * Be aware Math.random() could cause collisions, but:
  33071. * "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"
  33072. * @returns a pseudo random id
  33073. */
  33074. static RandomId(): string;
  33075. /**
  33076. * Test if the given uri is a base64 string
  33077. * @param uri The uri to test
  33078. * @return True if the uri is a base64 string or false otherwise
  33079. */
  33080. static IsBase64(uri: string): boolean;
  33081. /**
  33082. * Decode the given base64 uri.
  33083. * @param uri The uri to decode
  33084. * @return The decoded base64 data.
  33085. */
  33086. static DecodeBase64(uri: string): ArrayBuffer;
  33087. /**
  33088. * Gets the absolute url.
  33089. * @param url the input url
  33090. * @return the absolute url
  33091. */
  33092. static GetAbsoluteUrl(url: string): string;
  33093. /**
  33094. * No log
  33095. */
  33096. static readonly NoneLogLevel: number;
  33097. /**
  33098. * Only message logs
  33099. */
  33100. static readonly MessageLogLevel: number;
  33101. /**
  33102. * Only warning logs
  33103. */
  33104. static readonly WarningLogLevel: number;
  33105. /**
  33106. * Only error logs
  33107. */
  33108. static readonly ErrorLogLevel: number;
  33109. /**
  33110. * All logs
  33111. */
  33112. static readonly AllLogLevel: number;
  33113. /**
  33114. * Gets a value indicating the number of loading errors
  33115. * @ignorenaming
  33116. */
  33117. static readonly errorsCount: number;
  33118. /**
  33119. * Callback called when a new log is added
  33120. */
  33121. static OnNewCacheEntry: (entry: string) => void;
  33122. /**
  33123. * Log a message to the console
  33124. * @param message defines the message to log
  33125. */
  33126. static Log(message: string): void;
  33127. /**
  33128. * Write a warning message to the console
  33129. * @param message defines the message to log
  33130. */
  33131. static Warn(message: string): void;
  33132. /**
  33133. * Write an error message to the console
  33134. * @param message defines the message to log
  33135. */
  33136. static Error(message: string): void;
  33137. /**
  33138. * Gets current log cache (list of logs)
  33139. */
  33140. static readonly LogCache: string;
  33141. /**
  33142. * Clears the log cache
  33143. */
  33144. static ClearLogCache(): void;
  33145. /**
  33146. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33147. */
  33148. static LogLevels: number;
  33149. /**
  33150. * Checks if the window object exists
  33151. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33152. */
  33153. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33154. /**
  33155. * No performance log
  33156. */
  33157. static readonly PerformanceNoneLogLevel: number;
  33158. /**
  33159. * Use user marks to log performance
  33160. */
  33161. static readonly PerformanceUserMarkLogLevel: number;
  33162. /**
  33163. * Log performance to the console
  33164. */
  33165. static readonly PerformanceConsoleLogLevel: number;
  33166. private static _performance;
  33167. /**
  33168. * Sets the current performance log level
  33169. */
  33170. static PerformanceLogLevel: number;
  33171. private static _StartPerformanceCounterDisabled;
  33172. private static _EndPerformanceCounterDisabled;
  33173. private static _StartUserMark;
  33174. private static _EndUserMark;
  33175. private static _StartPerformanceConsole;
  33176. private static _EndPerformanceConsole;
  33177. /**
  33178. * Starts a performance counter
  33179. */
  33180. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33181. /**
  33182. * Ends a specific performance coutner
  33183. */
  33184. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33185. /**
  33186. * Gets either window.performance.now() if supported or Date.now() else
  33187. */
  33188. static readonly Now: number;
  33189. /**
  33190. * This method will return the name of the class used to create the instance of the given object.
  33191. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33192. * @param object the object to get the class name from
  33193. * @param isType defines if the object is actually a type
  33194. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33195. */
  33196. static GetClassName(object: any, isType?: boolean): string;
  33197. /**
  33198. * Gets the first element of an array satisfying a given predicate
  33199. * @param array defines the array to browse
  33200. * @param predicate defines the predicate to use
  33201. * @returns null if not found or the element
  33202. */
  33203. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33204. /**
  33205. * This method will return the name of the full name of the class, including its owning module (if any).
  33206. * 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).
  33207. * @param object the object to get the class name from
  33208. * @param isType defines if the object is actually a type
  33209. * @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.
  33210. * @ignorenaming
  33211. */
  33212. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33213. /**
  33214. * Returns a promise that resolves after the given amount of time.
  33215. * @param delay Number of milliseconds to delay
  33216. * @returns Promise that resolves after the given amount of time
  33217. */
  33218. static DelayAsync(delay: number): Promise<void>;
  33219. }
  33220. /**
  33221. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33222. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33223. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33224. * @param name The name of the class, case should be preserved
  33225. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33226. */
  33227. export function className(name: string, module?: string): (target: Object) => void;
  33228. /**
  33229. * An implementation of a loop for asynchronous functions.
  33230. */
  33231. export class AsyncLoop {
  33232. /**
  33233. * Defines the number of iterations for the loop
  33234. */
  33235. iterations: number;
  33236. /**
  33237. * Defines the current index of the loop.
  33238. */
  33239. index: number;
  33240. private _done;
  33241. private _fn;
  33242. private _successCallback;
  33243. /**
  33244. * Constructor.
  33245. * @param iterations the number of iterations.
  33246. * @param func the function to run each iteration
  33247. * @param successCallback the callback that will be called upon succesful execution
  33248. * @param offset starting offset.
  33249. */
  33250. constructor(
  33251. /**
  33252. * Defines the number of iterations for the loop
  33253. */
  33254. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33255. /**
  33256. * Execute the next iteration. Must be called after the last iteration was finished.
  33257. */
  33258. executeNext(): void;
  33259. /**
  33260. * Break the loop and run the success callback.
  33261. */
  33262. breakLoop(): void;
  33263. /**
  33264. * Create and run an async loop.
  33265. * @param iterations the number of iterations.
  33266. * @param fn the function to run each iteration
  33267. * @param successCallback the callback that will be called upon succesful execution
  33268. * @param offset starting offset.
  33269. * @returns the created async loop object
  33270. */
  33271. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33272. /**
  33273. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33274. * @param iterations total number of iterations
  33275. * @param syncedIterations number of synchronous iterations in each async iteration.
  33276. * @param fn the function to call each iteration.
  33277. * @param callback a success call back that will be called when iterating stops.
  33278. * @param breakFunction a break condition (optional)
  33279. * @param timeout timeout settings for the setTimeout function. default - 0.
  33280. * @returns the created async loop object
  33281. */
  33282. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33283. }
  33284. }
  33285. declare module "babylonjs/Collisions/collisionCoordinator" {
  33286. import { Nullable } from "babylonjs/types";
  33287. import { Scene } from "babylonjs/scene";
  33288. import { Vector3 } from "babylonjs/Maths/math.vector";
  33289. import { Collider } from "babylonjs/Collisions/collider";
  33290. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33291. /** @hidden */
  33292. export interface ICollisionCoordinator {
  33293. createCollider(): Collider;
  33294. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33295. init(scene: Scene): void;
  33296. }
  33297. /** @hidden */
  33298. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33299. private _scene;
  33300. private _scaledPosition;
  33301. private _scaledVelocity;
  33302. private _finalPosition;
  33303. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33304. createCollider(): Collider;
  33305. init(scene: Scene): void;
  33306. private _collideWithWorld;
  33307. }
  33308. }
  33309. declare module "babylonjs/Inputs/scene.inputManager" {
  33310. import { Nullable } from "babylonjs/types";
  33311. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33312. import { Vector2 } from "babylonjs/Maths/math.vector";
  33313. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33314. import { Scene } from "babylonjs/scene";
  33315. /**
  33316. * Class used to manage all inputs for the scene.
  33317. */
  33318. export class InputManager {
  33319. /** The distance in pixel that you have to move to prevent some events */
  33320. static DragMovementThreshold: number;
  33321. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33322. static LongPressDelay: number;
  33323. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33324. static DoubleClickDelay: number;
  33325. /** If you need to check double click without raising a single click at first click, enable this flag */
  33326. static ExclusiveDoubleClickMode: boolean;
  33327. private _wheelEventName;
  33328. private _onPointerMove;
  33329. private _onPointerDown;
  33330. private _onPointerUp;
  33331. private _initClickEvent;
  33332. private _initActionManager;
  33333. private _delayedSimpleClick;
  33334. private _delayedSimpleClickTimeout;
  33335. private _previousDelayedSimpleClickTimeout;
  33336. private _meshPickProceed;
  33337. private _previousButtonPressed;
  33338. private _currentPickResult;
  33339. private _previousPickResult;
  33340. private _totalPointersPressed;
  33341. private _doubleClickOccured;
  33342. private _pointerOverMesh;
  33343. private _pickedDownMesh;
  33344. private _pickedUpMesh;
  33345. private _pointerX;
  33346. private _pointerY;
  33347. private _unTranslatedPointerX;
  33348. private _unTranslatedPointerY;
  33349. private _startingPointerPosition;
  33350. private _previousStartingPointerPosition;
  33351. private _startingPointerTime;
  33352. private _previousStartingPointerTime;
  33353. private _pointerCaptures;
  33354. private _onKeyDown;
  33355. private _onKeyUp;
  33356. private _onCanvasFocusObserver;
  33357. private _onCanvasBlurObserver;
  33358. private _scene;
  33359. /**
  33360. * Creates a new InputManager
  33361. * @param scene defines the hosting scene
  33362. */
  33363. constructor(scene: Scene);
  33364. /**
  33365. * Gets the mesh that is currently under the pointer
  33366. */
  33367. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33368. /**
  33369. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33370. */
  33371. readonly unTranslatedPointer: Vector2;
  33372. /**
  33373. * Gets or sets the current on-screen X position of the pointer
  33374. */
  33375. pointerX: number;
  33376. /**
  33377. * Gets or sets the current on-screen Y position of the pointer
  33378. */
  33379. pointerY: number;
  33380. private _updatePointerPosition;
  33381. private _processPointerMove;
  33382. private _setRayOnPointerInfo;
  33383. private _checkPrePointerObservable;
  33384. /**
  33385. * Use this method to simulate a pointer move on a mesh
  33386. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33387. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33388. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33389. */
  33390. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33391. /**
  33392. * Use this method to simulate a pointer down on a mesh
  33393. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33394. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33395. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33396. */
  33397. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33398. private _processPointerDown;
  33399. /** @hidden */
  33400. _isPointerSwiping(): boolean;
  33401. /**
  33402. * Use this method to simulate a pointer up on a mesh
  33403. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33404. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33405. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33406. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33407. */
  33408. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33409. private _processPointerUp;
  33410. /**
  33411. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33412. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33413. * @returns true if the pointer was captured
  33414. */
  33415. isPointerCaptured(pointerId?: number): boolean;
  33416. /**
  33417. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33418. * @param attachUp defines if you want to attach events to pointerup
  33419. * @param attachDown defines if you want to attach events to pointerdown
  33420. * @param attachMove defines if you want to attach events to pointermove
  33421. */
  33422. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33423. /**
  33424. * Detaches all event handlers
  33425. */
  33426. detachControl(): void;
  33427. /**
  33428. * Force the value of meshUnderPointer
  33429. * @param mesh defines the mesh to use
  33430. */
  33431. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33432. /**
  33433. * Gets the mesh under the pointer
  33434. * @returns a Mesh or null if no mesh is under the pointer
  33435. */
  33436. getPointerOverMesh(): Nullable<AbstractMesh>;
  33437. }
  33438. }
  33439. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33440. /**
  33441. * Helper class used to generate session unique ID
  33442. */
  33443. export class UniqueIdGenerator {
  33444. private static _UniqueIdCounter;
  33445. /**
  33446. * Gets an unique (relatively to the current scene) Id
  33447. */
  33448. static readonly UniqueId: number;
  33449. }
  33450. }
  33451. declare module "babylonjs/Animations/animationGroup" {
  33452. import { Animatable } from "babylonjs/Animations/animatable";
  33453. import { Animation } from "babylonjs/Animations/animation";
  33454. import { Scene, IDisposable } from "babylonjs/scene";
  33455. import { Observable } from "babylonjs/Misc/observable";
  33456. import { Nullable } from "babylonjs/types";
  33457. import "babylonjs/Animations/animatable";
  33458. /**
  33459. * This class defines the direct association between an animation and a target
  33460. */
  33461. export class TargetedAnimation {
  33462. /**
  33463. * Animation to perform
  33464. */
  33465. animation: Animation;
  33466. /**
  33467. * Target to animate
  33468. */
  33469. target: any;
  33470. /**
  33471. * Serialize the object
  33472. * @returns the JSON object representing the current entity
  33473. */
  33474. serialize(): any;
  33475. }
  33476. /**
  33477. * Use this class to create coordinated animations on multiple targets
  33478. */
  33479. export class AnimationGroup implements IDisposable {
  33480. /** The name of the animation group */
  33481. name: string;
  33482. private _scene;
  33483. private _targetedAnimations;
  33484. private _animatables;
  33485. private _from;
  33486. private _to;
  33487. private _isStarted;
  33488. private _isPaused;
  33489. private _speedRatio;
  33490. private _loopAnimation;
  33491. /**
  33492. * Gets or sets the unique id of the node
  33493. */
  33494. uniqueId: number;
  33495. /**
  33496. * This observable will notify when one animation have ended
  33497. */
  33498. onAnimationEndObservable: Observable<TargetedAnimation>;
  33499. /**
  33500. * Observer raised when one animation loops
  33501. */
  33502. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33503. /**
  33504. * This observable will notify when all animations have ended.
  33505. */
  33506. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33507. /**
  33508. * This observable will notify when all animations have paused.
  33509. */
  33510. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33511. /**
  33512. * This observable will notify when all animations are playing.
  33513. */
  33514. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33515. /**
  33516. * Gets the first frame
  33517. */
  33518. readonly from: number;
  33519. /**
  33520. * Gets the last frame
  33521. */
  33522. readonly to: number;
  33523. /**
  33524. * Define if the animations are started
  33525. */
  33526. readonly isStarted: boolean;
  33527. /**
  33528. * Gets a value indicating that the current group is playing
  33529. */
  33530. readonly isPlaying: boolean;
  33531. /**
  33532. * Gets or sets the speed ratio to use for all animations
  33533. */
  33534. /**
  33535. * Gets or sets the speed ratio to use for all animations
  33536. */
  33537. speedRatio: number;
  33538. /**
  33539. * Gets or sets if all animations should loop or not
  33540. */
  33541. loopAnimation: boolean;
  33542. /**
  33543. * Gets the targeted animations for this animation group
  33544. */
  33545. readonly targetedAnimations: Array<TargetedAnimation>;
  33546. /**
  33547. * returning the list of animatables controlled by this animation group.
  33548. */
  33549. readonly animatables: Array<Animatable>;
  33550. /**
  33551. * Instantiates a new Animation Group.
  33552. * This helps managing several animations at once.
  33553. * @see http://doc.babylonjs.com/how_to/group
  33554. * @param name Defines the name of the group
  33555. * @param scene Defines the scene the group belongs to
  33556. */
  33557. constructor(
  33558. /** The name of the animation group */
  33559. name: string, scene?: Nullable<Scene>);
  33560. /**
  33561. * Add an animation (with its target) in the group
  33562. * @param animation defines the animation we want to add
  33563. * @param target defines the target of the animation
  33564. * @returns the TargetedAnimation object
  33565. */
  33566. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33567. /**
  33568. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33569. * It can add constant keys at begin or end
  33570. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33571. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33572. * @returns the animation group
  33573. */
  33574. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33575. /**
  33576. * Start all animations on given targets
  33577. * @param loop defines if animations must loop
  33578. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33579. * @param from defines the from key (optional)
  33580. * @param to defines the to key (optional)
  33581. * @returns the current animation group
  33582. */
  33583. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33584. /**
  33585. * Pause all animations
  33586. * @returns the animation group
  33587. */
  33588. pause(): AnimationGroup;
  33589. /**
  33590. * Play all animations to initial state
  33591. * This function will start() the animations if they were not started or will restart() them if they were paused
  33592. * @param loop defines if animations must loop
  33593. * @returns the animation group
  33594. */
  33595. play(loop?: boolean): AnimationGroup;
  33596. /**
  33597. * Reset all animations to initial state
  33598. * @returns the animation group
  33599. */
  33600. reset(): AnimationGroup;
  33601. /**
  33602. * Restart animations from key 0
  33603. * @returns the animation group
  33604. */
  33605. restart(): AnimationGroup;
  33606. /**
  33607. * Stop all animations
  33608. * @returns the animation group
  33609. */
  33610. stop(): AnimationGroup;
  33611. /**
  33612. * Set animation weight for all animatables
  33613. * @param weight defines the weight to use
  33614. * @return the animationGroup
  33615. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33616. */
  33617. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33618. /**
  33619. * Synchronize and normalize all animatables with a source animatable
  33620. * @param root defines the root animatable to synchronize with
  33621. * @return the animationGroup
  33622. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33623. */
  33624. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33625. /**
  33626. * Goes to a specific frame in this animation group
  33627. * @param frame the frame number to go to
  33628. * @return the animationGroup
  33629. */
  33630. goToFrame(frame: number): AnimationGroup;
  33631. /**
  33632. * Dispose all associated resources
  33633. */
  33634. dispose(): void;
  33635. private _checkAnimationGroupEnded;
  33636. /**
  33637. * Clone the current animation group and returns a copy
  33638. * @param newName defines the name of the new group
  33639. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33640. * @returns the new aniamtion group
  33641. */
  33642. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33643. /**
  33644. * Serializes the animationGroup to an object
  33645. * @returns Serialized object
  33646. */
  33647. serialize(): any;
  33648. /**
  33649. * Returns a new AnimationGroup object parsed from the source provided.
  33650. * @param parsedAnimationGroup defines the source
  33651. * @param scene defines the scene that will receive the animationGroup
  33652. * @returns a new AnimationGroup
  33653. */
  33654. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33655. /**
  33656. * Returns the string "AnimationGroup"
  33657. * @returns "AnimationGroup"
  33658. */
  33659. getClassName(): string;
  33660. /**
  33661. * Creates a detailled string about the object
  33662. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33663. * @returns a string representing the object
  33664. */
  33665. toString(fullDetails?: boolean): string;
  33666. }
  33667. }
  33668. declare module "babylonjs/scene" {
  33669. import { Nullable } from "babylonjs/types";
  33670. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33671. import { Observable } from "babylonjs/Misc/observable";
  33672. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33673. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33674. import { Geometry } from "babylonjs/Meshes/geometry";
  33675. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33676. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33677. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33678. import { Mesh } from "babylonjs/Meshes/mesh";
  33679. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33680. import { Bone } from "babylonjs/Bones/bone";
  33681. import { Skeleton } from "babylonjs/Bones/skeleton";
  33682. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33683. import { Camera } from "babylonjs/Cameras/camera";
  33684. import { AbstractScene } from "babylonjs/abstractScene";
  33685. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33686. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33687. import { Material } from "babylonjs/Materials/material";
  33688. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33689. import { Effect } from "babylonjs/Materials/effect";
  33690. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33691. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33692. import { Light } from "babylonjs/Lights/light";
  33693. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33694. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33695. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33696. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33697. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33698. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33699. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33700. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33701. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33702. import { Engine } from "babylonjs/Engines/engine";
  33703. import { Node } from "babylonjs/node";
  33704. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33705. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33706. import { WebRequest } from "babylonjs/Misc/webRequest";
  33707. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33708. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33709. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33710. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  33711. import { Plane } from "babylonjs/Maths/math.plane";
  33712. import { Ray } from "babylonjs/Culling/ray";
  33713. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33714. import { Animation } from "babylonjs/Animations/animation";
  33715. import { Animatable } from "babylonjs/Animations/animatable";
  33716. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33717. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33718. import { Collider } from "babylonjs/Collisions/collider";
  33719. /**
  33720. * Define an interface for all classes that will hold resources
  33721. */
  33722. export interface IDisposable {
  33723. /**
  33724. * Releases all held resources
  33725. */
  33726. dispose(): void;
  33727. }
  33728. /** Interface defining initialization parameters for Scene class */
  33729. export interface SceneOptions {
  33730. /**
  33731. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33732. * It will improve performance when the number of geometries becomes important.
  33733. */
  33734. useGeometryUniqueIdsMap?: boolean;
  33735. /**
  33736. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33737. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33738. */
  33739. useMaterialMeshMap?: boolean;
  33740. /**
  33741. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33742. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33743. */
  33744. useClonedMeshhMap?: boolean;
  33745. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33746. virtual?: boolean;
  33747. }
  33748. /**
  33749. * Represents a scene to be rendered by the engine.
  33750. * @see http://doc.babylonjs.com/features/scene
  33751. */
  33752. export class Scene extends AbstractScene implements IAnimatable {
  33753. /** The fog is deactivated */
  33754. static readonly FOGMODE_NONE: number;
  33755. /** The fog density is following an exponential function */
  33756. static readonly FOGMODE_EXP: number;
  33757. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33758. static readonly FOGMODE_EXP2: number;
  33759. /** The fog density is following a linear function. */
  33760. static readonly FOGMODE_LINEAR: number;
  33761. /**
  33762. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33763. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33764. */
  33765. static MinDeltaTime: number;
  33766. /**
  33767. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33768. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33769. */
  33770. static MaxDeltaTime: number;
  33771. /**
  33772. * Factory used to create the default material.
  33773. * @param name The name of the material to create
  33774. * @param scene The scene to create the material for
  33775. * @returns The default material
  33776. */
  33777. static DefaultMaterialFactory(scene: Scene): Material;
  33778. /**
  33779. * Factory used to create the a collision coordinator.
  33780. * @returns The collision coordinator
  33781. */
  33782. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33783. /** @hidden */
  33784. _inputManager: InputManager;
  33785. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33786. cameraToUseForPointers: Nullable<Camera>;
  33787. /** @hidden */
  33788. readonly _isScene: boolean;
  33789. /**
  33790. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33791. */
  33792. autoClear: boolean;
  33793. /**
  33794. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33795. */
  33796. autoClearDepthAndStencil: boolean;
  33797. /**
  33798. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33799. */
  33800. clearColor: Color4;
  33801. /**
  33802. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33803. */
  33804. ambientColor: Color3;
  33805. /**
  33806. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33807. * It should only be one of the following (if not the default embedded one):
  33808. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33809. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33810. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33811. * The material properties need to be setup according to the type of texture in use.
  33812. */
  33813. environmentBRDFTexture: BaseTexture;
  33814. /** @hidden */
  33815. protected _environmentTexture: Nullable<BaseTexture>;
  33816. /**
  33817. * Texture used in all pbr material as the reflection texture.
  33818. * As in the majority of the scene they are the same (exception for multi room and so on),
  33819. * this is easier to reference from here than from all the materials.
  33820. */
  33821. /**
  33822. * Texture used in all pbr material as the reflection texture.
  33823. * As in the majority of the scene they are the same (exception for multi room and so on),
  33824. * this is easier to set here than in all the materials.
  33825. */
  33826. environmentTexture: Nullable<BaseTexture>;
  33827. /** @hidden */
  33828. protected _environmentIntensity: number;
  33829. /**
  33830. * Intensity of the environment in all pbr material.
  33831. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33832. * As in the majority of the scene they are the same (exception for multi room and so on),
  33833. * this is easier to reference from here than from all the materials.
  33834. */
  33835. /**
  33836. * Intensity of the environment in all pbr material.
  33837. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33838. * As in the majority of the scene they are the same (exception for multi room and so on),
  33839. * this is easier to set here than in all the materials.
  33840. */
  33841. environmentIntensity: number;
  33842. /** @hidden */
  33843. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33844. /**
  33845. * Default image processing configuration used either in the rendering
  33846. * Forward main pass or through the imageProcessingPostProcess if present.
  33847. * As in the majority of the scene they are the same (exception for multi camera),
  33848. * this is easier to reference from here than from all the materials and post process.
  33849. *
  33850. * No setter as we it is a shared configuration, you can set the values instead.
  33851. */
  33852. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33853. private _forceWireframe;
  33854. /**
  33855. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33856. */
  33857. forceWireframe: boolean;
  33858. private _forcePointsCloud;
  33859. /**
  33860. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33861. */
  33862. forcePointsCloud: boolean;
  33863. /**
  33864. * Gets or sets the active clipplane 1
  33865. */
  33866. clipPlane: Nullable<Plane>;
  33867. /**
  33868. * Gets or sets the active clipplane 2
  33869. */
  33870. clipPlane2: Nullable<Plane>;
  33871. /**
  33872. * Gets or sets the active clipplane 3
  33873. */
  33874. clipPlane3: Nullable<Plane>;
  33875. /**
  33876. * Gets or sets the active clipplane 4
  33877. */
  33878. clipPlane4: Nullable<Plane>;
  33879. /**
  33880. * Gets or sets a boolean indicating if animations are enabled
  33881. */
  33882. animationsEnabled: boolean;
  33883. private _animationPropertiesOverride;
  33884. /**
  33885. * Gets or sets the animation properties override
  33886. */
  33887. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33888. /**
  33889. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33890. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33891. */
  33892. useConstantAnimationDeltaTime: boolean;
  33893. /**
  33894. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33895. * Please note that it requires to run a ray cast through the scene on every frame
  33896. */
  33897. constantlyUpdateMeshUnderPointer: boolean;
  33898. /**
  33899. * Defines the HTML cursor to use when hovering over interactive elements
  33900. */
  33901. hoverCursor: string;
  33902. /**
  33903. * Defines the HTML default cursor to use (empty by default)
  33904. */
  33905. defaultCursor: string;
  33906. /**
  33907. * This is used to call preventDefault() on pointer down
  33908. * in order to block unwanted artifacts like system double clicks
  33909. */
  33910. preventDefaultOnPointerDown: boolean;
  33911. /**
  33912. * This is used to call preventDefault() on pointer up
  33913. * in order to block unwanted artifacts like system double clicks
  33914. */
  33915. preventDefaultOnPointerUp: boolean;
  33916. /**
  33917. * Gets or sets user defined metadata
  33918. */
  33919. metadata: any;
  33920. /**
  33921. * For internal use only. Please do not use.
  33922. */
  33923. reservedDataStore: any;
  33924. /**
  33925. * Gets the name of the plugin used to load this scene (null by default)
  33926. */
  33927. loadingPluginName: string;
  33928. /**
  33929. * Use this array to add regular expressions used to disable offline support for specific urls
  33930. */
  33931. disableOfflineSupportExceptionRules: RegExp[];
  33932. /**
  33933. * An event triggered when the scene is disposed.
  33934. */
  33935. onDisposeObservable: Observable<Scene>;
  33936. private _onDisposeObserver;
  33937. /** Sets a function to be executed when this scene is disposed. */
  33938. onDispose: () => void;
  33939. /**
  33940. * An event triggered before rendering the scene (right after animations and physics)
  33941. */
  33942. onBeforeRenderObservable: Observable<Scene>;
  33943. private _onBeforeRenderObserver;
  33944. /** Sets a function to be executed before rendering this scene */
  33945. beforeRender: Nullable<() => void>;
  33946. /**
  33947. * An event triggered after rendering the scene
  33948. */
  33949. onAfterRenderObservable: Observable<Scene>;
  33950. /**
  33951. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33952. */
  33953. onAfterRenderCameraObservable: Observable<Camera>;
  33954. private _onAfterRenderObserver;
  33955. /** Sets a function to be executed after rendering this scene */
  33956. afterRender: Nullable<() => void>;
  33957. /**
  33958. * An event triggered before animating the scene
  33959. */
  33960. onBeforeAnimationsObservable: Observable<Scene>;
  33961. /**
  33962. * An event triggered after animations processing
  33963. */
  33964. onAfterAnimationsObservable: Observable<Scene>;
  33965. /**
  33966. * An event triggered before draw calls are ready to be sent
  33967. */
  33968. onBeforeDrawPhaseObservable: Observable<Scene>;
  33969. /**
  33970. * An event triggered after draw calls have been sent
  33971. */
  33972. onAfterDrawPhaseObservable: Observable<Scene>;
  33973. /**
  33974. * An event triggered when the scene is ready
  33975. */
  33976. onReadyObservable: Observable<Scene>;
  33977. /**
  33978. * An event triggered before rendering a camera
  33979. */
  33980. onBeforeCameraRenderObservable: Observable<Camera>;
  33981. private _onBeforeCameraRenderObserver;
  33982. /** Sets a function to be executed before rendering a camera*/
  33983. beforeCameraRender: () => void;
  33984. /**
  33985. * An event triggered after rendering a camera
  33986. */
  33987. onAfterCameraRenderObservable: Observable<Camera>;
  33988. private _onAfterCameraRenderObserver;
  33989. /** Sets a function to be executed after rendering a camera*/
  33990. afterCameraRender: () => void;
  33991. /**
  33992. * An event triggered when active meshes evaluation is about to start
  33993. */
  33994. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33995. /**
  33996. * An event triggered when active meshes evaluation is done
  33997. */
  33998. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33999. /**
  34000. * An event triggered when particles rendering is about to start
  34001. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34002. */
  34003. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34004. /**
  34005. * An event triggered when particles rendering is done
  34006. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34007. */
  34008. onAfterParticlesRenderingObservable: Observable<Scene>;
  34009. /**
  34010. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34011. */
  34012. onDataLoadedObservable: Observable<Scene>;
  34013. /**
  34014. * An event triggered when a camera is created
  34015. */
  34016. onNewCameraAddedObservable: Observable<Camera>;
  34017. /**
  34018. * An event triggered when a camera is removed
  34019. */
  34020. onCameraRemovedObservable: Observable<Camera>;
  34021. /**
  34022. * An event triggered when a light is created
  34023. */
  34024. onNewLightAddedObservable: Observable<Light>;
  34025. /**
  34026. * An event triggered when a light is removed
  34027. */
  34028. onLightRemovedObservable: Observable<Light>;
  34029. /**
  34030. * An event triggered when a geometry is created
  34031. */
  34032. onNewGeometryAddedObservable: Observable<Geometry>;
  34033. /**
  34034. * An event triggered when a geometry is removed
  34035. */
  34036. onGeometryRemovedObservable: Observable<Geometry>;
  34037. /**
  34038. * An event triggered when a transform node is created
  34039. */
  34040. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34041. /**
  34042. * An event triggered when a transform node is removed
  34043. */
  34044. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34045. /**
  34046. * An event triggered when a mesh is created
  34047. */
  34048. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34049. /**
  34050. * An event triggered when a mesh is removed
  34051. */
  34052. onMeshRemovedObservable: Observable<AbstractMesh>;
  34053. /**
  34054. * An event triggered when a skeleton is created
  34055. */
  34056. onNewSkeletonAddedObservable: Observable<Skeleton>;
  34057. /**
  34058. * An event triggered when a skeleton is removed
  34059. */
  34060. onSkeletonRemovedObservable: Observable<Skeleton>;
  34061. /**
  34062. * An event triggered when a material is created
  34063. */
  34064. onNewMaterialAddedObservable: Observable<Material>;
  34065. /**
  34066. * An event triggered when a material is removed
  34067. */
  34068. onMaterialRemovedObservable: Observable<Material>;
  34069. /**
  34070. * An event triggered when a texture is created
  34071. */
  34072. onNewTextureAddedObservable: Observable<BaseTexture>;
  34073. /**
  34074. * An event triggered when a texture is removed
  34075. */
  34076. onTextureRemovedObservable: Observable<BaseTexture>;
  34077. /**
  34078. * An event triggered when render targets are about to be rendered
  34079. * Can happen multiple times per frame.
  34080. */
  34081. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34082. /**
  34083. * An event triggered when render targets were rendered.
  34084. * Can happen multiple times per frame.
  34085. */
  34086. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34087. /**
  34088. * An event triggered before calculating deterministic simulation step
  34089. */
  34090. onBeforeStepObservable: Observable<Scene>;
  34091. /**
  34092. * An event triggered after calculating deterministic simulation step
  34093. */
  34094. onAfterStepObservable: Observable<Scene>;
  34095. /**
  34096. * An event triggered when the activeCamera property is updated
  34097. */
  34098. onActiveCameraChanged: Observable<Scene>;
  34099. /**
  34100. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34101. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34102. * 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)
  34103. */
  34104. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34105. /**
  34106. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34107. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34108. * 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)
  34109. */
  34110. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34111. /**
  34112. * This Observable will when a mesh has been imported into the scene.
  34113. */
  34114. onMeshImportedObservable: Observable<AbstractMesh>;
  34115. /**
  34116. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34117. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34118. */
  34119. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34120. /** @hidden */
  34121. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34122. /**
  34123. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34124. */
  34125. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34126. /**
  34127. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34128. */
  34129. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34130. /**
  34131. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34132. */
  34133. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34134. /** Callback called when a pointer move is detected */
  34135. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34136. /** Callback called when a pointer down is detected */
  34137. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34138. /** Callback called when a pointer up is detected */
  34139. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34140. /** Callback called when a pointer pick is detected */
  34141. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34142. /**
  34143. * 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).
  34144. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34145. */
  34146. onPrePointerObservable: Observable<PointerInfoPre>;
  34147. /**
  34148. * Observable event triggered each time an input event is received from the rendering canvas
  34149. */
  34150. onPointerObservable: Observable<PointerInfo>;
  34151. /**
  34152. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34153. */
  34154. readonly unTranslatedPointer: Vector2;
  34155. /**
  34156. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34157. */
  34158. static DragMovementThreshold: number;
  34159. /**
  34160. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34161. */
  34162. static LongPressDelay: number;
  34163. /**
  34164. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34165. */
  34166. static DoubleClickDelay: number;
  34167. /** If you need to check double click without raising a single click at first click, enable this flag */
  34168. static ExclusiveDoubleClickMode: boolean;
  34169. /** @hidden */
  34170. _mirroredCameraPosition: Nullable<Vector3>;
  34171. /**
  34172. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34173. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34174. */
  34175. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34176. /**
  34177. * Observable event triggered each time an keyboard event is received from the hosting window
  34178. */
  34179. onKeyboardObservable: Observable<KeyboardInfo>;
  34180. private _useRightHandedSystem;
  34181. /**
  34182. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34183. */
  34184. useRightHandedSystem: boolean;
  34185. private _timeAccumulator;
  34186. private _currentStepId;
  34187. private _currentInternalStep;
  34188. /**
  34189. * Sets the step Id used by deterministic lock step
  34190. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34191. * @param newStepId defines the step Id
  34192. */
  34193. setStepId(newStepId: number): void;
  34194. /**
  34195. * Gets the step Id used by deterministic lock step
  34196. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34197. * @returns the step Id
  34198. */
  34199. getStepId(): number;
  34200. /**
  34201. * Gets the internal step used by deterministic lock step
  34202. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34203. * @returns the internal step
  34204. */
  34205. getInternalStep(): number;
  34206. private _fogEnabled;
  34207. /**
  34208. * Gets or sets a boolean indicating if fog is enabled on this scene
  34209. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34210. * (Default is true)
  34211. */
  34212. fogEnabled: boolean;
  34213. private _fogMode;
  34214. /**
  34215. * Gets or sets the fog mode to use
  34216. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34217. * | mode | value |
  34218. * | --- | --- |
  34219. * | FOGMODE_NONE | 0 |
  34220. * | FOGMODE_EXP | 1 |
  34221. * | FOGMODE_EXP2 | 2 |
  34222. * | FOGMODE_LINEAR | 3 |
  34223. */
  34224. fogMode: number;
  34225. /**
  34226. * Gets or sets the fog color to use
  34227. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34228. * (Default is Color3(0.2, 0.2, 0.3))
  34229. */
  34230. fogColor: Color3;
  34231. /**
  34232. * Gets or sets the fog density to use
  34233. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34234. * (Default is 0.1)
  34235. */
  34236. fogDensity: number;
  34237. /**
  34238. * Gets or sets the fog start distance to use
  34239. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34240. * (Default is 0)
  34241. */
  34242. fogStart: number;
  34243. /**
  34244. * Gets or sets the fog end distance to use
  34245. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34246. * (Default is 1000)
  34247. */
  34248. fogEnd: number;
  34249. private _shadowsEnabled;
  34250. /**
  34251. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34252. */
  34253. shadowsEnabled: boolean;
  34254. private _lightsEnabled;
  34255. /**
  34256. * Gets or sets a boolean indicating if lights are enabled on this scene
  34257. */
  34258. lightsEnabled: boolean;
  34259. /** All of the active cameras added to this scene. */
  34260. activeCameras: Camera[];
  34261. /** @hidden */
  34262. _activeCamera: Nullable<Camera>;
  34263. /** Gets or sets the current active camera */
  34264. activeCamera: Nullable<Camera>;
  34265. private _defaultMaterial;
  34266. /** The default material used on meshes when no material is affected */
  34267. /** The default material used on meshes when no material is affected */
  34268. defaultMaterial: Material;
  34269. private _texturesEnabled;
  34270. /**
  34271. * Gets or sets a boolean indicating if textures are enabled on this scene
  34272. */
  34273. texturesEnabled: boolean;
  34274. /**
  34275. * Gets or sets a boolean indicating if particles are enabled on this scene
  34276. */
  34277. particlesEnabled: boolean;
  34278. /**
  34279. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34280. */
  34281. spritesEnabled: boolean;
  34282. private _skeletonsEnabled;
  34283. /**
  34284. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34285. */
  34286. skeletonsEnabled: boolean;
  34287. /**
  34288. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34289. */
  34290. lensFlaresEnabled: boolean;
  34291. /**
  34292. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34293. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34294. */
  34295. collisionsEnabled: boolean;
  34296. private _collisionCoordinator;
  34297. /** @hidden */
  34298. readonly collisionCoordinator: ICollisionCoordinator;
  34299. /**
  34300. * Defines the gravity applied to this scene (used only for collisions)
  34301. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34302. */
  34303. gravity: Vector3;
  34304. /**
  34305. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34306. */
  34307. postProcessesEnabled: boolean;
  34308. /**
  34309. * The list of postprocesses added to the scene
  34310. */
  34311. postProcesses: PostProcess[];
  34312. /**
  34313. * Gets the current postprocess manager
  34314. */
  34315. postProcessManager: PostProcessManager;
  34316. /**
  34317. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34318. */
  34319. renderTargetsEnabled: boolean;
  34320. /**
  34321. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34322. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34323. */
  34324. dumpNextRenderTargets: boolean;
  34325. /**
  34326. * The list of user defined render targets added to the scene
  34327. */
  34328. customRenderTargets: RenderTargetTexture[];
  34329. /**
  34330. * Defines if texture loading must be delayed
  34331. * If true, textures will only be loaded when they need to be rendered
  34332. */
  34333. useDelayedTextureLoading: boolean;
  34334. /**
  34335. * Gets the list of meshes imported to the scene through SceneLoader
  34336. */
  34337. importedMeshesFiles: String[];
  34338. /**
  34339. * Gets or sets a boolean indicating if probes are enabled on this scene
  34340. */
  34341. probesEnabled: boolean;
  34342. /**
  34343. * Gets or sets the current offline provider to use to store scene data
  34344. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34345. */
  34346. offlineProvider: IOfflineProvider;
  34347. /**
  34348. * Gets or sets the action manager associated with the scene
  34349. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34350. */
  34351. actionManager: AbstractActionManager;
  34352. private _meshesForIntersections;
  34353. /**
  34354. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34355. */
  34356. proceduralTexturesEnabled: boolean;
  34357. private _engine;
  34358. private _totalVertices;
  34359. /** @hidden */
  34360. _activeIndices: PerfCounter;
  34361. /** @hidden */
  34362. _activeParticles: PerfCounter;
  34363. /** @hidden */
  34364. _activeBones: PerfCounter;
  34365. private _animationRatio;
  34366. /** @hidden */
  34367. _animationTimeLast: number;
  34368. /** @hidden */
  34369. _animationTime: number;
  34370. /**
  34371. * Gets or sets a general scale for animation speed
  34372. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34373. */
  34374. animationTimeScale: number;
  34375. /** @hidden */
  34376. _cachedMaterial: Nullable<Material>;
  34377. /** @hidden */
  34378. _cachedEffect: Nullable<Effect>;
  34379. /** @hidden */
  34380. _cachedVisibility: Nullable<number>;
  34381. private _renderId;
  34382. private _frameId;
  34383. private _executeWhenReadyTimeoutId;
  34384. private _intermediateRendering;
  34385. private _viewUpdateFlag;
  34386. private _projectionUpdateFlag;
  34387. /** @hidden */
  34388. _toBeDisposed: Nullable<IDisposable>[];
  34389. private _activeRequests;
  34390. /** @hidden */
  34391. _pendingData: any[];
  34392. private _isDisposed;
  34393. /**
  34394. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34395. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34396. */
  34397. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34398. private _activeMeshes;
  34399. private _processedMaterials;
  34400. private _renderTargets;
  34401. /** @hidden */
  34402. _activeParticleSystems: SmartArray<IParticleSystem>;
  34403. private _activeSkeletons;
  34404. private _softwareSkinnedMeshes;
  34405. private _renderingManager;
  34406. /** @hidden */
  34407. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34408. private _transformMatrix;
  34409. private _sceneUbo;
  34410. /** @hidden */
  34411. _viewMatrix: Matrix;
  34412. private _projectionMatrix;
  34413. /** @hidden */
  34414. _forcedViewPosition: Nullable<Vector3>;
  34415. /** @hidden */
  34416. _frustumPlanes: Plane[];
  34417. /**
  34418. * Gets the list of frustum planes (built from the active camera)
  34419. */
  34420. readonly frustumPlanes: Plane[];
  34421. /**
  34422. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34423. * This is useful if there are more lights that the maximum simulteanous authorized
  34424. */
  34425. requireLightSorting: boolean;
  34426. /** @hidden */
  34427. readonly useMaterialMeshMap: boolean;
  34428. /** @hidden */
  34429. readonly useClonedMeshhMap: boolean;
  34430. private _externalData;
  34431. private _uid;
  34432. /**
  34433. * @hidden
  34434. * Backing store of defined scene components.
  34435. */
  34436. _components: ISceneComponent[];
  34437. /**
  34438. * @hidden
  34439. * Backing store of defined scene components.
  34440. */
  34441. _serializableComponents: ISceneSerializableComponent[];
  34442. /**
  34443. * List of components to register on the next registration step.
  34444. */
  34445. private _transientComponents;
  34446. /**
  34447. * Registers the transient components if needed.
  34448. */
  34449. private _registerTransientComponents;
  34450. /**
  34451. * @hidden
  34452. * Add a component to the scene.
  34453. * Note that the ccomponent could be registered on th next frame if this is called after
  34454. * the register component stage.
  34455. * @param component Defines the component to add to the scene
  34456. */
  34457. _addComponent(component: ISceneComponent): void;
  34458. /**
  34459. * @hidden
  34460. * Gets a component from the scene.
  34461. * @param name defines the name of the component to retrieve
  34462. * @returns the component or null if not present
  34463. */
  34464. _getComponent(name: string): Nullable<ISceneComponent>;
  34465. /**
  34466. * @hidden
  34467. * Defines the actions happening before camera updates.
  34468. */
  34469. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34470. /**
  34471. * @hidden
  34472. * Defines the actions happening before clear the canvas.
  34473. */
  34474. _beforeClearStage: Stage<SimpleStageAction>;
  34475. /**
  34476. * @hidden
  34477. * Defines the actions when collecting render targets for the frame.
  34478. */
  34479. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34480. /**
  34481. * @hidden
  34482. * Defines the actions happening for one camera in the frame.
  34483. */
  34484. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34485. /**
  34486. * @hidden
  34487. * Defines the actions happening during the per mesh ready checks.
  34488. */
  34489. _isReadyForMeshStage: Stage<MeshStageAction>;
  34490. /**
  34491. * @hidden
  34492. * Defines the actions happening before evaluate active mesh checks.
  34493. */
  34494. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34495. /**
  34496. * @hidden
  34497. * Defines the actions happening during the evaluate sub mesh checks.
  34498. */
  34499. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34500. /**
  34501. * @hidden
  34502. * Defines the actions happening during the active mesh stage.
  34503. */
  34504. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34505. /**
  34506. * @hidden
  34507. * Defines the actions happening during the per camera render target step.
  34508. */
  34509. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34510. /**
  34511. * @hidden
  34512. * Defines the actions happening just before the active camera is drawing.
  34513. */
  34514. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34515. /**
  34516. * @hidden
  34517. * Defines the actions happening just before a render target is drawing.
  34518. */
  34519. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34520. /**
  34521. * @hidden
  34522. * Defines the actions happening just before a rendering group is drawing.
  34523. */
  34524. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34525. /**
  34526. * @hidden
  34527. * Defines the actions happening just before a mesh is drawing.
  34528. */
  34529. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34530. /**
  34531. * @hidden
  34532. * Defines the actions happening just after a mesh has been drawn.
  34533. */
  34534. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34535. /**
  34536. * @hidden
  34537. * Defines the actions happening just after a rendering group has been drawn.
  34538. */
  34539. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34540. /**
  34541. * @hidden
  34542. * Defines the actions happening just after the active camera has been drawn.
  34543. */
  34544. _afterCameraDrawStage: Stage<CameraStageAction>;
  34545. /**
  34546. * @hidden
  34547. * Defines the actions happening just after a render target has been drawn.
  34548. */
  34549. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34550. /**
  34551. * @hidden
  34552. * Defines the actions happening just after rendering all cameras and computing intersections.
  34553. */
  34554. _afterRenderStage: Stage<SimpleStageAction>;
  34555. /**
  34556. * @hidden
  34557. * Defines the actions happening when a pointer move event happens.
  34558. */
  34559. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34560. /**
  34561. * @hidden
  34562. * Defines the actions happening when a pointer down event happens.
  34563. */
  34564. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34565. /**
  34566. * @hidden
  34567. * Defines the actions happening when a pointer up event happens.
  34568. */
  34569. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34570. /**
  34571. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34572. */
  34573. private geometriesByUniqueId;
  34574. /**
  34575. * Creates a new Scene
  34576. * @param engine defines the engine to use to render this scene
  34577. * @param options defines the scene options
  34578. */
  34579. constructor(engine: Engine, options?: SceneOptions);
  34580. /**
  34581. * Gets a string idenfifying the name of the class
  34582. * @returns "Scene" string
  34583. */
  34584. getClassName(): string;
  34585. private _defaultMeshCandidates;
  34586. /**
  34587. * @hidden
  34588. */
  34589. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34590. private _defaultSubMeshCandidates;
  34591. /**
  34592. * @hidden
  34593. */
  34594. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34595. /**
  34596. * Sets the default candidate providers for the scene.
  34597. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34598. * and getCollidingSubMeshCandidates to their default function
  34599. */
  34600. setDefaultCandidateProviders(): void;
  34601. /**
  34602. * Gets the mesh that is currently under the pointer
  34603. */
  34604. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34605. /**
  34606. * Gets or sets the current on-screen X position of the pointer
  34607. */
  34608. pointerX: number;
  34609. /**
  34610. * Gets or sets the current on-screen Y position of the pointer
  34611. */
  34612. pointerY: number;
  34613. /**
  34614. * Gets the cached material (ie. the latest rendered one)
  34615. * @returns the cached material
  34616. */
  34617. getCachedMaterial(): Nullable<Material>;
  34618. /**
  34619. * Gets the cached effect (ie. the latest rendered one)
  34620. * @returns the cached effect
  34621. */
  34622. getCachedEffect(): Nullable<Effect>;
  34623. /**
  34624. * Gets the cached visibility state (ie. the latest rendered one)
  34625. * @returns the cached visibility state
  34626. */
  34627. getCachedVisibility(): Nullable<number>;
  34628. /**
  34629. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34630. * @param material defines the current material
  34631. * @param effect defines the current effect
  34632. * @param visibility defines the current visibility state
  34633. * @returns true if one parameter is not cached
  34634. */
  34635. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34636. /**
  34637. * Gets the engine associated with the scene
  34638. * @returns an Engine
  34639. */
  34640. getEngine(): Engine;
  34641. /**
  34642. * Gets the total number of vertices rendered per frame
  34643. * @returns the total number of vertices rendered per frame
  34644. */
  34645. getTotalVertices(): number;
  34646. /**
  34647. * Gets the performance counter for total vertices
  34648. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34649. */
  34650. readonly totalVerticesPerfCounter: PerfCounter;
  34651. /**
  34652. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34653. * @returns the total number of active indices rendered per frame
  34654. */
  34655. getActiveIndices(): number;
  34656. /**
  34657. * Gets the performance counter for active indices
  34658. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34659. */
  34660. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34661. /**
  34662. * Gets the total number of active particles rendered per frame
  34663. * @returns the total number of active particles rendered per frame
  34664. */
  34665. getActiveParticles(): number;
  34666. /**
  34667. * Gets the performance counter for active particles
  34668. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34669. */
  34670. readonly activeParticlesPerfCounter: PerfCounter;
  34671. /**
  34672. * Gets the total number of active bones rendered per frame
  34673. * @returns the total number of active bones rendered per frame
  34674. */
  34675. getActiveBones(): number;
  34676. /**
  34677. * Gets the performance counter for active bones
  34678. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34679. */
  34680. readonly activeBonesPerfCounter: PerfCounter;
  34681. /**
  34682. * Gets the array of active meshes
  34683. * @returns an array of AbstractMesh
  34684. */
  34685. getActiveMeshes(): SmartArray<AbstractMesh>;
  34686. /**
  34687. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34688. * @returns a number
  34689. */
  34690. getAnimationRatio(): number;
  34691. /**
  34692. * Gets an unique Id for the current render phase
  34693. * @returns a number
  34694. */
  34695. getRenderId(): number;
  34696. /**
  34697. * Gets an unique Id for the current frame
  34698. * @returns a number
  34699. */
  34700. getFrameId(): number;
  34701. /** Call this function if you want to manually increment the render Id*/
  34702. incrementRenderId(): void;
  34703. private _createUbo;
  34704. /**
  34705. * Use this method to simulate a pointer move on a mesh
  34706. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34707. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34708. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34709. * @returns the current scene
  34710. */
  34711. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34712. /**
  34713. * Use this method to simulate a pointer down on a mesh
  34714. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34715. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34716. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34717. * @returns the current scene
  34718. */
  34719. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34720. /**
  34721. * Use this method to simulate a pointer up on a mesh
  34722. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34723. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34724. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34725. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34726. * @returns the current scene
  34727. */
  34728. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34729. /**
  34730. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34731. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34732. * @returns true if the pointer was captured
  34733. */
  34734. isPointerCaptured(pointerId?: number): boolean;
  34735. /**
  34736. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34737. * @param attachUp defines if you want to attach events to pointerup
  34738. * @param attachDown defines if you want to attach events to pointerdown
  34739. * @param attachMove defines if you want to attach events to pointermove
  34740. */
  34741. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34742. /** Detaches all event handlers*/
  34743. detachControl(): void;
  34744. /**
  34745. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34746. * Delay loaded resources are not taking in account
  34747. * @return true if all required resources are ready
  34748. */
  34749. isReady(): boolean;
  34750. /** Resets all cached information relative to material (including effect and visibility) */
  34751. resetCachedMaterial(): void;
  34752. /**
  34753. * Registers a function to be called before every frame render
  34754. * @param func defines the function to register
  34755. */
  34756. registerBeforeRender(func: () => void): void;
  34757. /**
  34758. * Unregisters a function called before every frame render
  34759. * @param func defines the function to unregister
  34760. */
  34761. unregisterBeforeRender(func: () => void): void;
  34762. /**
  34763. * Registers a function to be called after every frame render
  34764. * @param func defines the function to register
  34765. */
  34766. registerAfterRender(func: () => void): void;
  34767. /**
  34768. * Unregisters a function called after every frame render
  34769. * @param func defines the function to unregister
  34770. */
  34771. unregisterAfterRender(func: () => void): void;
  34772. private _executeOnceBeforeRender;
  34773. /**
  34774. * The provided function will run before render once and will be disposed afterwards.
  34775. * A timeout delay can be provided so that the function will be executed in N ms.
  34776. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34777. * @param func The function to be executed.
  34778. * @param timeout optional delay in ms
  34779. */
  34780. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34781. /** @hidden */
  34782. _addPendingData(data: any): void;
  34783. /** @hidden */
  34784. _removePendingData(data: any): void;
  34785. /**
  34786. * Returns the number of items waiting to be loaded
  34787. * @returns the number of items waiting to be loaded
  34788. */
  34789. getWaitingItemsCount(): number;
  34790. /**
  34791. * Returns a boolean indicating if the scene is still loading data
  34792. */
  34793. readonly isLoading: boolean;
  34794. /**
  34795. * Registers a function to be executed when the scene is ready
  34796. * @param {Function} func - the function to be executed
  34797. */
  34798. executeWhenReady(func: () => void): void;
  34799. /**
  34800. * Returns a promise that resolves when the scene is ready
  34801. * @returns A promise that resolves when the scene is ready
  34802. */
  34803. whenReadyAsync(): Promise<void>;
  34804. /** @hidden */
  34805. _checkIsReady(): void;
  34806. /**
  34807. * Gets all animatable attached to the scene
  34808. */
  34809. readonly animatables: Animatable[];
  34810. /**
  34811. * Resets the last animation time frame.
  34812. * Useful to override when animations start running when loading a scene for the first time.
  34813. */
  34814. resetLastAnimationTimeFrame(): void;
  34815. /**
  34816. * Gets the current view matrix
  34817. * @returns a Matrix
  34818. */
  34819. getViewMatrix(): Matrix;
  34820. /**
  34821. * Gets the current projection matrix
  34822. * @returns a Matrix
  34823. */
  34824. getProjectionMatrix(): Matrix;
  34825. /**
  34826. * Gets the current transform matrix
  34827. * @returns a Matrix made of View * Projection
  34828. */
  34829. getTransformMatrix(): Matrix;
  34830. /**
  34831. * Sets the current transform matrix
  34832. * @param viewL defines the View matrix to use
  34833. * @param projectionL defines the Projection matrix to use
  34834. * @param viewR defines the right View matrix to use (if provided)
  34835. * @param projectionR defines the right Projection matrix to use (if provided)
  34836. */
  34837. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34838. /**
  34839. * Gets the uniform buffer used to store scene data
  34840. * @returns a UniformBuffer
  34841. */
  34842. getSceneUniformBuffer(): UniformBuffer;
  34843. /**
  34844. * Gets an unique (relatively to the current scene) Id
  34845. * @returns an unique number for the scene
  34846. */
  34847. getUniqueId(): number;
  34848. /**
  34849. * Add a mesh to the list of scene's meshes
  34850. * @param newMesh defines the mesh to add
  34851. * @param recursive if all child meshes should also be added to the scene
  34852. */
  34853. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34854. /**
  34855. * Remove a mesh for the list of scene's meshes
  34856. * @param toRemove defines the mesh to remove
  34857. * @param recursive if all child meshes should also be removed from the scene
  34858. * @returns the index where the mesh was in the mesh list
  34859. */
  34860. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34861. /**
  34862. * Add a transform node to the list of scene's transform nodes
  34863. * @param newTransformNode defines the transform node to add
  34864. */
  34865. addTransformNode(newTransformNode: TransformNode): void;
  34866. /**
  34867. * Remove a transform node for the list of scene's transform nodes
  34868. * @param toRemove defines the transform node to remove
  34869. * @returns the index where the transform node was in the transform node list
  34870. */
  34871. removeTransformNode(toRemove: TransformNode): number;
  34872. /**
  34873. * Remove a skeleton for the list of scene's skeletons
  34874. * @param toRemove defines the skeleton to remove
  34875. * @returns the index where the skeleton was in the skeleton list
  34876. */
  34877. removeSkeleton(toRemove: Skeleton): number;
  34878. /**
  34879. * Remove a morph target for the list of scene's morph targets
  34880. * @param toRemove defines the morph target to remove
  34881. * @returns the index where the morph target was in the morph target list
  34882. */
  34883. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34884. /**
  34885. * Remove a light for the list of scene's lights
  34886. * @param toRemove defines the light to remove
  34887. * @returns the index where the light was in the light list
  34888. */
  34889. removeLight(toRemove: Light): number;
  34890. /**
  34891. * Remove a camera for the list of scene's cameras
  34892. * @param toRemove defines the camera to remove
  34893. * @returns the index where the camera was in the camera list
  34894. */
  34895. removeCamera(toRemove: Camera): number;
  34896. /**
  34897. * Remove a particle system for the list of scene's particle systems
  34898. * @param toRemove defines the particle system to remove
  34899. * @returns the index where the particle system was in the particle system list
  34900. */
  34901. removeParticleSystem(toRemove: IParticleSystem): number;
  34902. /**
  34903. * Remove a animation for the list of scene's animations
  34904. * @param toRemove defines the animation to remove
  34905. * @returns the index where the animation was in the animation list
  34906. */
  34907. removeAnimation(toRemove: Animation): number;
  34908. /**
  34909. * Will stop the animation of the given target
  34910. * @param target - the target
  34911. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34912. * @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)
  34913. */
  34914. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34915. /**
  34916. * Removes the given animation group from this scene.
  34917. * @param toRemove The animation group to remove
  34918. * @returns The index of the removed animation group
  34919. */
  34920. removeAnimationGroup(toRemove: AnimationGroup): number;
  34921. /**
  34922. * Removes the given multi-material from this scene.
  34923. * @param toRemove The multi-material to remove
  34924. * @returns The index of the removed multi-material
  34925. */
  34926. removeMultiMaterial(toRemove: MultiMaterial): number;
  34927. /**
  34928. * Removes the given material from this scene.
  34929. * @param toRemove The material to remove
  34930. * @returns The index of the removed material
  34931. */
  34932. removeMaterial(toRemove: Material): number;
  34933. /**
  34934. * Removes the given action manager from this scene.
  34935. * @param toRemove The action manager to remove
  34936. * @returns The index of the removed action manager
  34937. */
  34938. removeActionManager(toRemove: AbstractActionManager): number;
  34939. /**
  34940. * Removes the given texture from this scene.
  34941. * @param toRemove The texture to remove
  34942. * @returns The index of the removed texture
  34943. */
  34944. removeTexture(toRemove: BaseTexture): number;
  34945. /**
  34946. * Adds the given light to this scene
  34947. * @param newLight The light to add
  34948. */
  34949. addLight(newLight: Light): void;
  34950. /**
  34951. * Sorts the list list based on light priorities
  34952. */
  34953. sortLightsByPriority(): void;
  34954. /**
  34955. * Adds the given camera to this scene
  34956. * @param newCamera The camera to add
  34957. */
  34958. addCamera(newCamera: Camera): void;
  34959. /**
  34960. * Adds the given skeleton to this scene
  34961. * @param newSkeleton The skeleton to add
  34962. */
  34963. addSkeleton(newSkeleton: Skeleton): void;
  34964. /**
  34965. * Adds the given particle system to this scene
  34966. * @param newParticleSystem The particle system to add
  34967. */
  34968. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34969. /**
  34970. * Adds the given animation to this scene
  34971. * @param newAnimation The animation to add
  34972. */
  34973. addAnimation(newAnimation: Animation): void;
  34974. /**
  34975. * Adds the given animation group to this scene.
  34976. * @param newAnimationGroup The animation group to add
  34977. */
  34978. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34979. /**
  34980. * Adds the given multi-material to this scene
  34981. * @param newMultiMaterial The multi-material to add
  34982. */
  34983. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34984. /**
  34985. * Adds the given material to this scene
  34986. * @param newMaterial The material to add
  34987. */
  34988. addMaterial(newMaterial: Material): void;
  34989. /**
  34990. * Adds the given morph target to this scene
  34991. * @param newMorphTargetManager The morph target to add
  34992. */
  34993. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34994. /**
  34995. * Adds the given geometry to this scene
  34996. * @param newGeometry The geometry to add
  34997. */
  34998. addGeometry(newGeometry: Geometry): void;
  34999. /**
  35000. * Adds the given action manager to this scene
  35001. * @param newActionManager The action manager to add
  35002. */
  35003. addActionManager(newActionManager: AbstractActionManager): void;
  35004. /**
  35005. * Adds the given texture to this scene.
  35006. * @param newTexture The texture to add
  35007. */
  35008. addTexture(newTexture: BaseTexture): void;
  35009. /**
  35010. * Switch active camera
  35011. * @param newCamera defines the new active camera
  35012. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35013. */
  35014. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35015. /**
  35016. * sets the active camera of the scene using its ID
  35017. * @param id defines the camera's ID
  35018. * @return the new active camera or null if none found.
  35019. */
  35020. setActiveCameraByID(id: string): Nullable<Camera>;
  35021. /**
  35022. * sets the active camera of the scene using its name
  35023. * @param name defines the camera's name
  35024. * @returns the new active camera or null if none found.
  35025. */
  35026. setActiveCameraByName(name: string): Nullable<Camera>;
  35027. /**
  35028. * get an animation group using its name
  35029. * @param name defines the material's name
  35030. * @return the animation group or null if none found.
  35031. */
  35032. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35033. /**
  35034. * Get a material using its unique id
  35035. * @param uniqueId defines the material's unique id
  35036. * @return the material or null if none found.
  35037. */
  35038. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  35039. /**
  35040. * get a material using its id
  35041. * @param id defines the material's ID
  35042. * @return the material or null if none found.
  35043. */
  35044. getMaterialByID(id: string): Nullable<Material>;
  35045. /**
  35046. * Gets a the last added material using a given id
  35047. * @param id defines the material's ID
  35048. * @return the last material with the given id or null if none found.
  35049. */
  35050. getLastMaterialByID(id: string): Nullable<Material>;
  35051. /**
  35052. * Gets a material using its name
  35053. * @param name defines the material's name
  35054. * @return the material or null if none found.
  35055. */
  35056. getMaterialByName(name: string): Nullable<Material>;
  35057. /**
  35058. * Get a texture using its unique id
  35059. * @param uniqueId defines the texture's unique id
  35060. * @return the texture or null if none found.
  35061. */
  35062. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  35063. /**
  35064. * Gets a camera using its id
  35065. * @param id defines the id to look for
  35066. * @returns the camera or null if not found
  35067. */
  35068. getCameraByID(id: string): Nullable<Camera>;
  35069. /**
  35070. * Gets a camera using its unique id
  35071. * @param uniqueId defines the unique id to look for
  35072. * @returns the camera or null if not found
  35073. */
  35074. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35075. /**
  35076. * Gets a camera using its name
  35077. * @param name defines the camera's name
  35078. * @return the camera or null if none found.
  35079. */
  35080. getCameraByName(name: string): Nullable<Camera>;
  35081. /**
  35082. * Gets a bone using its id
  35083. * @param id defines the bone's id
  35084. * @return the bone or null if not found
  35085. */
  35086. getBoneByID(id: string): Nullable<Bone>;
  35087. /**
  35088. * Gets a bone using its id
  35089. * @param name defines the bone's name
  35090. * @return the bone or null if not found
  35091. */
  35092. getBoneByName(name: string): Nullable<Bone>;
  35093. /**
  35094. * Gets a light node using its name
  35095. * @param name defines the the light's name
  35096. * @return the light or null if none found.
  35097. */
  35098. getLightByName(name: string): Nullable<Light>;
  35099. /**
  35100. * Gets a light node using its id
  35101. * @param id defines the light's id
  35102. * @return the light or null if none found.
  35103. */
  35104. getLightByID(id: string): Nullable<Light>;
  35105. /**
  35106. * Gets a light node using its scene-generated unique ID
  35107. * @param uniqueId defines the light's unique id
  35108. * @return the light or null if none found.
  35109. */
  35110. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35111. /**
  35112. * Gets a particle system by id
  35113. * @param id defines the particle system id
  35114. * @return the corresponding system or null if none found
  35115. */
  35116. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35117. /**
  35118. * Gets a geometry using its ID
  35119. * @param id defines the geometry's id
  35120. * @return the geometry or null if none found.
  35121. */
  35122. getGeometryByID(id: string): Nullable<Geometry>;
  35123. private _getGeometryByUniqueID;
  35124. /**
  35125. * Add a new geometry to this scene
  35126. * @param geometry defines the geometry to be added to the scene.
  35127. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35128. * @return a boolean defining if the geometry was added or not
  35129. */
  35130. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35131. /**
  35132. * Removes an existing geometry
  35133. * @param geometry defines the geometry to be removed from the scene
  35134. * @return a boolean defining if the geometry was removed or not
  35135. */
  35136. removeGeometry(geometry: Geometry): boolean;
  35137. /**
  35138. * Gets the list of geometries attached to the scene
  35139. * @returns an array of Geometry
  35140. */
  35141. getGeometries(): Geometry[];
  35142. /**
  35143. * Gets the first added mesh found of a given ID
  35144. * @param id defines the id to search for
  35145. * @return the mesh found or null if not found at all
  35146. */
  35147. getMeshByID(id: string): Nullable<AbstractMesh>;
  35148. /**
  35149. * Gets a list of meshes using their id
  35150. * @param id defines the id to search for
  35151. * @returns a list of meshes
  35152. */
  35153. getMeshesByID(id: string): Array<AbstractMesh>;
  35154. /**
  35155. * Gets the first added transform node found of a given ID
  35156. * @param id defines the id to search for
  35157. * @return the found transform node or null if not found at all.
  35158. */
  35159. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35160. /**
  35161. * Gets a transform node with its auto-generated unique id
  35162. * @param uniqueId efines the unique id to search for
  35163. * @return the found transform node or null if not found at all.
  35164. */
  35165. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35166. /**
  35167. * Gets a list of transform nodes using their id
  35168. * @param id defines the id to search for
  35169. * @returns a list of transform nodes
  35170. */
  35171. getTransformNodesByID(id: string): Array<TransformNode>;
  35172. /**
  35173. * Gets a mesh with its auto-generated unique id
  35174. * @param uniqueId defines the unique id to search for
  35175. * @return the found mesh or null if not found at all.
  35176. */
  35177. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35178. /**
  35179. * Gets a the last added mesh using a given id
  35180. * @param id defines the id to search for
  35181. * @return the found mesh or null if not found at all.
  35182. */
  35183. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35184. /**
  35185. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35186. * @param id defines the id to search for
  35187. * @return the found node or null if not found at all
  35188. */
  35189. getLastEntryByID(id: string): Nullable<Node>;
  35190. /**
  35191. * Gets a node (Mesh, Camera, Light) using a given id
  35192. * @param id defines the id to search for
  35193. * @return the found node or null if not found at all
  35194. */
  35195. getNodeByID(id: string): Nullable<Node>;
  35196. /**
  35197. * Gets a node (Mesh, Camera, Light) using a given name
  35198. * @param name defines the name to search for
  35199. * @return the found node or null if not found at all.
  35200. */
  35201. getNodeByName(name: string): Nullable<Node>;
  35202. /**
  35203. * Gets a mesh using a given name
  35204. * @param name defines the name to search for
  35205. * @return the found mesh or null if not found at all.
  35206. */
  35207. getMeshByName(name: string): Nullable<AbstractMesh>;
  35208. /**
  35209. * Gets a transform node using a given name
  35210. * @param name defines the name to search for
  35211. * @return the found transform node or null if not found at all.
  35212. */
  35213. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35214. /**
  35215. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35216. * @param id defines the id to search for
  35217. * @return the found skeleton or null if not found at all.
  35218. */
  35219. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35220. /**
  35221. * Gets a skeleton using a given auto generated unique id
  35222. * @param uniqueId defines the unique id to search for
  35223. * @return the found skeleton or null if not found at all.
  35224. */
  35225. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35226. /**
  35227. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35228. * @param id defines the id to search for
  35229. * @return the found skeleton or null if not found at all.
  35230. */
  35231. getSkeletonById(id: string): Nullable<Skeleton>;
  35232. /**
  35233. * Gets a skeleton using a given name
  35234. * @param name defines the name to search for
  35235. * @return the found skeleton or null if not found at all.
  35236. */
  35237. getSkeletonByName(name: string): Nullable<Skeleton>;
  35238. /**
  35239. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35240. * @param id defines the id to search for
  35241. * @return the found morph target manager or null if not found at all.
  35242. */
  35243. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35244. /**
  35245. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35246. * @param id defines the id to search for
  35247. * @return the found morph target or null if not found at all.
  35248. */
  35249. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35250. /**
  35251. * Gets a boolean indicating if the given mesh is active
  35252. * @param mesh defines the mesh to look for
  35253. * @returns true if the mesh is in the active list
  35254. */
  35255. isActiveMesh(mesh: AbstractMesh): boolean;
  35256. /**
  35257. * Return a unique id as a string which can serve as an identifier for the scene
  35258. */
  35259. readonly uid: string;
  35260. /**
  35261. * Add an externaly attached data from its key.
  35262. * This method call will fail and return false, if such key already exists.
  35263. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35264. * @param key the unique key that identifies the data
  35265. * @param data the data object to associate to the key for this Engine instance
  35266. * @return true if no such key were already present and the data was added successfully, false otherwise
  35267. */
  35268. addExternalData<T>(key: string, data: T): boolean;
  35269. /**
  35270. * Get an externaly attached data from its key
  35271. * @param key the unique key that identifies the data
  35272. * @return the associated data, if present (can be null), or undefined if not present
  35273. */
  35274. getExternalData<T>(key: string): Nullable<T>;
  35275. /**
  35276. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35277. * @param key the unique key that identifies the data
  35278. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35279. * @return the associated data, can be null if the factory returned null.
  35280. */
  35281. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35282. /**
  35283. * Remove an externaly attached data from the Engine instance
  35284. * @param key the unique key that identifies the data
  35285. * @return true if the data was successfully removed, false if it doesn't exist
  35286. */
  35287. removeExternalData(key: string): boolean;
  35288. private _evaluateSubMesh;
  35289. /**
  35290. * Clear the processed materials smart array preventing retention point in material dispose.
  35291. */
  35292. freeProcessedMaterials(): void;
  35293. private _preventFreeActiveMeshesAndRenderingGroups;
  35294. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35295. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35296. * when disposing several meshes in a row or a hierarchy of meshes.
  35297. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35298. */
  35299. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35300. /**
  35301. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35302. */
  35303. freeActiveMeshes(): void;
  35304. /**
  35305. * Clear the info related to rendering groups preventing retention points during dispose.
  35306. */
  35307. freeRenderingGroups(): void;
  35308. /** @hidden */
  35309. _isInIntermediateRendering(): boolean;
  35310. /**
  35311. * Lambda returning the list of potentially active meshes.
  35312. */
  35313. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35314. /**
  35315. * Lambda returning the list of potentially active sub meshes.
  35316. */
  35317. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35318. /**
  35319. * Lambda returning the list of potentially intersecting sub meshes.
  35320. */
  35321. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35322. /**
  35323. * Lambda returning the list of potentially colliding sub meshes.
  35324. */
  35325. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35326. private _activeMeshesFrozen;
  35327. /**
  35328. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35329. * @returns the current scene
  35330. */
  35331. freezeActiveMeshes(): Scene;
  35332. /**
  35333. * Use this function to restart evaluating active meshes on every frame
  35334. * @returns the current scene
  35335. */
  35336. unfreezeActiveMeshes(): Scene;
  35337. private _evaluateActiveMeshes;
  35338. private _activeMesh;
  35339. /**
  35340. * Update the transform matrix to update from the current active camera
  35341. * @param force defines a boolean used to force the update even if cache is up to date
  35342. */
  35343. updateTransformMatrix(force?: boolean): void;
  35344. private _bindFrameBuffer;
  35345. /** @hidden */
  35346. _allowPostProcessClearColor: boolean;
  35347. /** @hidden */
  35348. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35349. private _processSubCameras;
  35350. private _checkIntersections;
  35351. /** @hidden */
  35352. _advancePhysicsEngineStep(step: number): void;
  35353. /**
  35354. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35355. */
  35356. getDeterministicFrameTime: () => number;
  35357. /** @hidden */
  35358. _animate(): void;
  35359. /** Execute all animations (for a frame) */
  35360. animate(): void;
  35361. /**
  35362. * Render the scene
  35363. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35364. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35365. */
  35366. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35367. /**
  35368. * Freeze all materials
  35369. * A frozen material will not be updatable but should be faster to render
  35370. */
  35371. freezeMaterials(): void;
  35372. /**
  35373. * Unfreeze all materials
  35374. * A frozen material will not be updatable but should be faster to render
  35375. */
  35376. unfreezeMaterials(): void;
  35377. /**
  35378. * Releases all held ressources
  35379. */
  35380. dispose(): void;
  35381. /**
  35382. * Gets if the scene is already disposed
  35383. */
  35384. readonly isDisposed: boolean;
  35385. /**
  35386. * Call this function to reduce memory footprint of the scene.
  35387. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35388. */
  35389. clearCachedVertexData(): void;
  35390. /**
  35391. * This function will remove the local cached buffer data from texture.
  35392. * It will save memory but will prevent the texture from being rebuilt
  35393. */
  35394. cleanCachedTextureBuffer(): void;
  35395. /**
  35396. * Get the world extend vectors with an optional filter
  35397. *
  35398. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35399. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35400. */
  35401. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35402. min: Vector3;
  35403. max: Vector3;
  35404. };
  35405. /**
  35406. * Creates a ray that can be used to pick in the scene
  35407. * @param x defines the x coordinate of the origin (on-screen)
  35408. * @param y defines the y coordinate of the origin (on-screen)
  35409. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35410. * @param camera defines the camera to use for the picking
  35411. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35412. * @returns a Ray
  35413. */
  35414. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35415. /**
  35416. * Creates a ray that can be used to pick in the scene
  35417. * @param x defines the x coordinate of the origin (on-screen)
  35418. * @param y defines the y coordinate of the origin (on-screen)
  35419. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35420. * @param result defines the ray where to store the picking ray
  35421. * @param camera defines the camera to use for the picking
  35422. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35423. * @returns the current scene
  35424. */
  35425. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35426. /**
  35427. * Creates a ray that can be used to pick in the scene
  35428. * @param x defines the x coordinate of the origin (on-screen)
  35429. * @param y defines the y coordinate of the origin (on-screen)
  35430. * @param camera defines the camera to use for the picking
  35431. * @returns a Ray
  35432. */
  35433. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35434. /**
  35435. * Creates a ray that can be used to pick in the scene
  35436. * @param x defines the x coordinate of the origin (on-screen)
  35437. * @param y defines the y coordinate of the origin (on-screen)
  35438. * @param result defines the ray where to store the picking ray
  35439. * @param camera defines the camera to use for the picking
  35440. * @returns the current scene
  35441. */
  35442. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35443. /** Launch a ray to try to pick a mesh in the scene
  35444. * @param x position on screen
  35445. * @param y position on screen
  35446. * @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
  35447. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35448. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35449. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35450. * @returns a PickingInfo
  35451. */
  35452. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35453. /** Use the given ray to pick a mesh in the scene
  35454. * @param ray The ray to use to pick meshes
  35455. * @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
  35456. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35457. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35458. * @returns a PickingInfo
  35459. */
  35460. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35461. /**
  35462. * Launch a ray to try to pick a mesh in the scene
  35463. * @param x X position on screen
  35464. * @param y Y position on screen
  35465. * @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
  35466. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35467. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35468. * @returns an array of PickingInfo
  35469. */
  35470. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35471. /**
  35472. * Launch a ray to try to pick a mesh in the scene
  35473. * @param ray Ray to use
  35474. * @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
  35475. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35476. * @returns an array of PickingInfo
  35477. */
  35478. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35479. /**
  35480. * Force the value of meshUnderPointer
  35481. * @param mesh defines the mesh to use
  35482. */
  35483. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35484. /**
  35485. * Gets the mesh under the pointer
  35486. * @returns a Mesh or null if no mesh is under the pointer
  35487. */
  35488. getPointerOverMesh(): Nullable<AbstractMesh>;
  35489. /** @hidden */
  35490. _rebuildGeometries(): void;
  35491. /** @hidden */
  35492. _rebuildTextures(): void;
  35493. private _getByTags;
  35494. /**
  35495. * Get a list of meshes by tags
  35496. * @param tagsQuery defines the tags query to use
  35497. * @param forEach defines a predicate used to filter results
  35498. * @returns an array of Mesh
  35499. */
  35500. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35501. /**
  35502. * Get a list of cameras by tags
  35503. * @param tagsQuery defines the tags query to use
  35504. * @param forEach defines a predicate used to filter results
  35505. * @returns an array of Camera
  35506. */
  35507. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35508. /**
  35509. * Get a list of lights by tags
  35510. * @param tagsQuery defines the tags query to use
  35511. * @param forEach defines a predicate used to filter results
  35512. * @returns an array of Light
  35513. */
  35514. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35515. /**
  35516. * Get a list of materials by tags
  35517. * @param tagsQuery defines the tags query to use
  35518. * @param forEach defines a predicate used to filter results
  35519. * @returns an array of Material
  35520. */
  35521. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35522. /**
  35523. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35524. * This allowed control for front to back rendering or reversly depending of the special needs.
  35525. *
  35526. * @param renderingGroupId The rendering group id corresponding to its index
  35527. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35528. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35529. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35530. */
  35531. 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;
  35532. /**
  35533. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35534. *
  35535. * @param renderingGroupId The rendering group id corresponding to its index
  35536. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35537. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35538. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35539. */
  35540. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35541. /**
  35542. * Gets the current auto clear configuration for one rendering group of the rendering
  35543. * manager.
  35544. * @param index the rendering group index to get the information for
  35545. * @returns The auto clear setup for the requested rendering group
  35546. */
  35547. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35548. private _blockMaterialDirtyMechanism;
  35549. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35550. blockMaterialDirtyMechanism: boolean;
  35551. /**
  35552. * Will flag all materials as dirty to trigger new shader compilation
  35553. * @param flag defines the flag used to specify which material part must be marked as dirty
  35554. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35555. */
  35556. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35557. /** @hidden */
  35558. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  35559. /** @hidden */
  35560. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35561. }
  35562. }
  35563. declare module "babylonjs/assetContainer" {
  35564. import { AbstractScene } from "babylonjs/abstractScene";
  35565. import { Scene } from "babylonjs/scene";
  35566. import { Mesh } from "babylonjs/Meshes/mesh";
  35567. /**
  35568. * Set of assets to keep when moving a scene into an asset container.
  35569. */
  35570. export class KeepAssets extends AbstractScene {
  35571. }
  35572. /**
  35573. * Container with a set of assets that can be added or removed from a scene.
  35574. */
  35575. export class AssetContainer extends AbstractScene {
  35576. /**
  35577. * The scene the AssetContainer belongs to.
  35578. */
  35579. scene: Scene;
  35580. /**
  35581. * Instantiates an AssetContainer.
  35582. * @param scene The scene the AssetContainer belongs to.
  35583. */
  35584. constructor(scene: Scene);
  35585. /**
  35586. * Adds all the assets from the container to the scene.
  35587. */
  35588. addAllToScene(): void;
  35589. /**
  35590. * Removes all the assets in the container from the scene
  35591. */
  35592. removeAllFromScene(): void;
  35593. /**
  35594. * Disposes all the assets in the container
  35595. */
  35596. dispose(): void;
  35597. private _moveAssets;
  35598. /**
  35599. * Removes all the assets contained in the scene and adds them to the container.
  35600. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35601. */
  35602. moveAllFromScene(keepAssets?: KeepAssets): void;
  35603. /**
  35604. * 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.
  35605. * @returns the root mesh
  35606. */
  35607. createRootMesh(): Mesh;
  35608. }
  35609. }
  35610. declare module "babylonjs/abstractScene" {
  35611. import { Scene } from "babylonjs/scene";
  35612. import { Nullable } from "babylonjs/types";
  35613. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35614. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35615. import { Geometry } from "babylonjs/Meshes/geometry";
  35616. import { Skeleton } from "babylonjs/Bones/skeleton";
  35617. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35618. import { AssetContainer } from "babylonjs/assetContainer";
  35619. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35620. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35621. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35622. import { Material } from "babylonjs/Materials/material";
  35623. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35624. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35625. import { Camera } from "babylonjs/Cameras/camera";
  35626. import { Light } from "babylonjs/Lights/light";
  35627. import { Node } from "babylonjs/node";
  35628. import { Animation } from "babylonjs/Animations/animation";
  35629. /**
  35630. * Defines how the parser contract is defined.
  35631. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35632. */
  35633. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35634. /**
  35635. * Defines how the individual parser contract is defined.
  35636. * These parser can parse an individual asset
  35637. */
  35638. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35639. /**
  35640. * Base class of the scene acting as a container for the different elements composing a scene.
  35641. * This class is dynamically extended by the different components of the scene increasing
  35642. * flexibility and reducing coupling
  35643. */
  35644. export abstract class AbstractScene {
  35645. /**
  35646. * Stores the list of available parsers in the application.
  35647. */
  35648. private static _BabylonFileParsers;
  35649. /**
  35650. * Stores the list of available individual parsers in the application.
  35651. */
  35652. private static _IndividualBabylonFileParsers;
  35653. /**
  35654. * Adds a parser in the list of available ones
  35655. * @param name Defines the name of the parser
  35656. * @param parser Defines the parser to add
  35657. */
  35658. static AddParser(name: string, parser: BabylonFileParser): void;
  35659. /**
  35660. * Gets a general parser from the list of avaialble ones
  35661. * @param name Defines the name of the parser
  35662. * @returns the requested parser or null
  35663. */
  35664. static GetParser(name: string): Nullable<BabylonFileParser>;
  35665. /**
  35666. * Adds n individual parser in the list of available ones
  35667. * @param name Defines the name of the parser
  35668. * @param parser Defines the parser to add
  35669. */
  35670. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35671. /**
  35672. * Gets an individual parser from the list of avaialble ones
  35673. * @param name Defines the name of the parser
  35674. * @returns the requested parser or null
  35675. */
  35676. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35677. /**
  35678. * Parser json data and populate both a scene and its associated container object
  35679. * @param jsonData Defines the data to parse
  35680. * @param scene Defines the scene to parse the data for
  35681. * @param container Defines the container attached to the parsing sequence
  35682. * @param rootUrl Defines the root url of the data
  35683. */
  35684. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35685. /**
  35686. * Gets the list of root nodes (ie. nodes with no parent)
  35687. */
  35688. rootNodes: Node[];
  35689. /** All of the cameras added to this scene
  35690. * @see http://doc.babylonjs.com/babylon101/cameras
  35691. */
  35692. cameras: Camera[];
  35693. /**
  35694. * All of the lights added to this scene
  35695. * @see http://doc.babylonjs.com/babylon101/lights
  35696. */
  35697. lights: Light[];
  35698. /**
  35699. * All of the (abstract) meshes added to this scene
  35700. */
  35701. meshes: AbstractMesh[];
  35702. /**
  35703. * The list of skeletons added to the scene
  35704. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35705. */
  35706. skeletons: Skeleton[];
  35707. /**
  35708. * All of the particle systems added to this scene
  35709. * @see http://doc.babylonjs.com/babylon101/particles
  35710. */
  35711. particleSystems: IParticleSystem[];
  35712. /**
  35713. * Gets a list of Animations associated with the scene
  35714. */
  35715. animations: Animation[];
  35716. /**
  35717. * All of the animation groups added to this scene
  35718. * @see http://doc.babylonjs.com/how_to/group
  35719. */
  35720. animationGroups: AnimationGroup[];
  35721. /**
  35722. * All of the multi-materials added to this scene
  35723. * @see http://doc.babylonjs.com/how_to/multi_materials
  35724. */
  35725. multiMaterials: MultiMaterial[];
  35726. /**
  35727. * All of the materials added to this scene
  35728. * In the context of a Scene, it is not supposed to be modified manually.
  35729. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35730. * Note also that the order of the Material wihin the array is not significant and might change.
  35731. * @see http://doc.babylonjs.com/babylon101/materials
  35732. */
  35733. materials: Material[];
  35734. /**
  35735. * The list of morph target managers added to the scene
  35736. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35737. */
  35738. morphTargetManagers: MorphTargetManager[];
  35739. /**
  35740. * The list of geometries used in the scene.
  35741. */
  35742. geometries: Geometry[];
  35743. /**
  35744. * All of the tranform nodes added to this scene
  35745. * In the context of a Scene, it is not supposed to be modified manually.
  35746. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35747. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35748. * @see http://doc.babylonjs.com/how_to/transformnode
  35749. */
  35750. transformNodes: TransformNode[];
  35751. /**
  35752. * ActionManagers available on the scene.
  35753. */
  35754. actionManagers: AbstractActionManager[];
  35755. /**
  35756. * Textures to keep.
  35757. */
  35758. textures: BaseTexture[];
  35759. /**
  35760. * Environment texture for the scene
  35761. */
  35762. environmentTexture: Nullable<BaseTexture>;
  35763. }
  35764. }
  35765. declare module "babylonjs/Audio/sound" {
  35766. import { Observable } from "babylonjs/Misc/observable";
  35767. import { Vector3 } from "babylonjs/Maths/math.vector";
  35768. import { Nullable } from "babylonjs/types";
  35769. import { Scene } from "babylonjs/scene";
  35770. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35771. /**
  35772. * Interface used to define options for Sound class
  35773. */
  35774. export interface ISoundOptions {
  35775. /**
  35776. * Does the sound autoplay once loaded.
  35777. */
  35778. autoplay?: boolean;
  35779. /**
  35780. * Does the sound loop after it finishes playing once.
  35781. */
  35782. loop?: boolean;
  35783. /**
  35784. * Sound's volume
  35785. */
  35786. volume?: number;
  35787. /**
  35788. * Is it a spatial sound?
  35789. */
  35790. spatialSound?: boolean;
  35791. /**
  35792. * Maximum distance to hear that sound
  35793. */
  35794. maxDistance?: number;
  35795. /**
  35796. * Uses user defined attenuation function
  35797. */
  35798. useCustomAttenuation?: boolean;
  35799. /**
  35800. * Define the roll off factor of spatial sounds.
  35801. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35802. */
  35803. rolloffFactor?: number;
  35804. /**
  35805. * Define the reference distance the sound should be heard perfectly.
  35806. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35807. */
  35808. refDistance?: number;
  35809. /**
  35810. * Define the distance attenuation model the sound will follow.
  35811. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35812. */
  35813. distanceModel?: string;
  35814. /**
  35815. * Defines the playback speed (1 by default)
  35816. */
  35817. playbackRate?: number;
  35818. /**
  35819. * Defines if the sound is from a streaming source
  35820. */
  35821. streaming?: boolean;
  35822. /**
  35823. * Defines an optional length (in seconds) inside the sound file
  35824. */
  35825. length?: number;
  35826. /**
  35827. * Defines an optional offset (in seconds) inside the sound file
  35828. */
  35829. offset?: number;
  35830. /**
  35831. * If true, URLs will not be required to state the audio file codec to use.
  35832. */
  35833. skipCodecCheck?: boolean;
  35834. }
  35835. /**
  35836. * Defines a sound that can be played in the application.
  35837. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35838. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35839. */
  35840. export class Sound {
  35841. /**
  35842. * The name of the sound in the scene.
  35843. */
  35844. name: string;
  35845. /**
  35846. * Does the sound autoplay once loaded.
  35847. */
  35848. autoplay: boolean;
  35849. /**
  35850. * Does the sound loop after it finishes playing once.
  35851. */
  35852. loop: boolean;
  35853. /**
  35854. * Does the sound use a custom attenuation curve to simulate the falloff
  35855. * happening when the source gets further away from the camera.
  35856. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35857. */
  35858. useCustomAttenuation: boolean;
  35859. /**
  35860. * The sound track id this sound belongs to.
  35861. */
  35862. soundTrackId: number;
  35863. /**
  35864. * Is this sound currently played.
  35865. */
  35866. isPlaying: boolean;
  35867. /**
  35868. * Is this sound currently paused.
  35869. */
  35870. isPaused: boolean;
  35871. /**
  35872. * Does this sound enables spatial sound.
  35873. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35874. */
  35875. spatialSound: boolean;
  35876. /**
  35877. * Define the reference distance the sound should be heard perfectly.
  35878. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35879. */
  35880. refDistance: number;
  35881. /**
  35882. * Define the roll off factor of spatial sounds.
  35883. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35884. */
  35885. rolloffFactor: number;
  35886. /**
  35887. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35888. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35889. */
  35890. maxDistance: number;
  35891. /**
  35892. * Define the distance attenuation model the sound will follow.
  35893. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35894. */
  35895. distanceModel: string;
  35896. /**
  35897. * @hidden
  35898. * Back Compat
  35899. **/
  35900. onended: () => any;
  35901. /**
  35902. * Observable event when the current playing sound finishes.
  35903. */
  35904. onEndedObservable: Observable<Sound>;
  35905. private _panningModel;
  35906. private _playbackRate;
  35907. private _streaming;
  35908. private _startTime;
  35909. private _startOffset;
  35910. private _position;
  35911. /** @hidden */
  35912. _positionInEmitterSpace: boolean;
  35913. private _localDirection;
  35914. private _volume;
  35915. private _isReadyToPlay;
  35916. private _isDirectional;
  35917. private _readyToPlayCallback;
  35918. private _audioBuffer;
  35919. private _soundSource;
  35920. private _streamingSource;
  35921. private _soundPanner;
  35922. private _soundGain;
  35923. private _inputAudioNode;
  35924. private _outputAudioNode;
  35925. private _coneInnerAngle;
  35926. private _coneOuterAngle;
  35927. private _coneOuterGain;
  35928. private _scene;
  35929. private _connectedTransformNode;
  35930. private _customAttenuationFunction;
  35931. private _registerFunc;
  35932. private _isOutputConnected;
  35933. private _htmlAudioElement;
  35934. private _urlType;
  35935. private _length?;
  35936. private _offset?;
  35937. /** @hidden */
  35938. static _SceneComponentInitialization: (scene: Scene) => void;
  35939. /**
  35940. * Create a sound and attach it to a scene
  35941. * @param name Name of your sound
  35942. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35943. * @param scene defines the scene the sound belongs to
  35944. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35945. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35946. */
  35947. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35948. /**
  35949. * Release the sound and its associated resources
  35950. */
  35951. dispose(): void;
  35952. /**
  35953. * Gets if the sounds is ready to be played or not.
  35954. * @returns true if ready, otherwise false
  35955. */
  35956. isReady(): boolean;
  35957. private _soundLoaded;
  35958. /**
  35959. * Sets the data of the sound from an audiobuffer
  35960. * @param audioBuffer The audioBuffer containing the data
  35961. */
  35962. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35963. /**
  35964. * Updates the current sounds options such as maxdistance, loop...
  35965. * @param options A JSON object containing values named as the object properties
  35966. */
  35967. updateOptions(options: ISoundOptions): void;
  35968. private _createSpatialParameters;
  35969. private _updateSpatialParameters;
  35970. /**
  35971. * Switch the panning model to HRTF:
  35972. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35973. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35974. */
  35975. switchPanningModelToHRTF(): void;
  35976. /**
  35977. * Switch the panning model to Equal Power:
  35978. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35979. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35980. */
  35981. switchPanningModelToEqualPower(): void;
  35982. private _switchPanningModel;
  35983. /**
  35984. * Connect this sound to a sound track audio node like gain...
  35985. * @param soundTrackAudioNode the sound track audio node to connect to
  35986. */
  35987. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35988. /**
  35989. * Transform this sound into a directional source
  35990. * @param coneInnerAngle Size of the inner cone in degree
  35991. * @param coneOuterAngle Size of the outer cone in degree
  35992. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35993. */
  35994. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35995. /**
  35996. * Gets or sets the inner angle for the directional cone.
  35997. */
  35998. /**
  35999. * Gets or sets the inner angle for the directional cone.
  36000. */
  36001. directionalConeInnerAngle: number;
  36002. /**
  36003. * Gets or sets the outer angle for the directional cone.
  36004. */
  36005. /**
  36006. * Gets or sets the outer angle for the directional cone.
  36007. */
  36008. directionalConeOuterAngle: number;
  36009. /**
  36010. * Sets the position of the emitter if spatial sound is enabled
  36011. * @param newPosition Defines the new posisiton
  36012. */
  36013. setPosition(newPosition: Vector3): void;
  36014. /**
  36015. * Sets the local direction of the emitter if spatial sound is enabled
  36016. * @param newLocalDirection Defines the new local direction
  36017. */
  36018. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36019. private _updateDirection;
  36020. /** @hidden */
  36021. updateDistanceFromListener(): void;
  36022. /**
  36023. * Sets a new custom attenuation function for the sound.
  36024. * @param callback Defines the function used for the attenuation
  36025. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36026. */
  36027. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36028. /**
  36029. * Play the sound
  36030. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36031. * @param offset (optional) Start the sound at a specific time in seconds
  36032. * @param length (optional) Sound duration (in seconds)
  36033. */
  36034. play(time?: number, offset?: number, length?: number): void;
  36035. private _onended;
  36036. /**
  36037. * Stop the sound
  36038. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36039. */
  36040. stop(time?: number): void;
  36041. /**
  36042. * Put the sound in pause
  36043. */
  36044. pause(): void;
  36045. /**
  36046. * Sets a dedicated volume for this sounds
  36047. * @param newVolume Define the new volume of the sound
  36048. * @param time Define time for gradual change to new volume
  36049. */
  36050. setVolume(newVolume: number, time?: number): void;
  36051. /**
  36052. * Set the sound play back rate
  36053. * @param newPlaybackRate Define the playback rate the sound should be played at
  36054. */
  36055. setPlaybackRate(newPlaybackRate: number): void;
  36056. /**
  36057. * Gets the volume of the sound.
  36058. * @returns the volume of the sound
  36059. */
  36060. getVolume(): number;
  36061. /**
  36062. * Attach the sound to a dedicated mesh
  36063. * @param transformNode The transform node to connect the sound with
  36064. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36065. */
  36066. attachToMesh(transformNode: TransformNode): void;
  36067. /**
  36068. * Detach the sound from the previously attached mesh
  36069. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36070. */
  36071. detachFromMesh(): void;
  36072. private _onRegisterAfterWorldMatrixUpdate;
  36073. /**
  36074. * Clone the current sound in the scene.
  36075. * @returns the new sound clone
  36076. */
  36077. clone(): Nullable<Sound>;
  36078. /**
  36079. * Gets the current underlying audio buffer containing the data
  36080. * @returns the audio buffer
  36081. */
  36082. getAudioBuffer(): Nullable<AudioBuffer>;
  36083. /**
  36084. * Serializes the Sound in a JSON representation
  36085. * @returns the JSON representation of the sound
  36086. */
  36087. serialize(): any;
  36088. /**
  36089. * Parse a JSON representation of a sound to innstantiate in a given scene
  36090. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36091. * @param scene Define the scene the new parsed sound should be created in
  36092. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36093. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36094. * @returns the newly parsed sound
  36095. */
  36096. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36097. }
  36098. }
  36099. declare module "babylonjs/Actions/directAudioActions" {
  36100. import { Action } from "babylonjs/Actions/action";
  36101. import { Condition } from "babylonjs/Actions/condition";
  36102. import { Sound } from "babylonjs/Audio/sound";
  36103. /**
  36104. * This defines an action helpful to play a defined sound on a triggered action.
  36105. */
  36106. export class PlaySoundAction extends Action {
  36107. private _sound;
  36108. /**
  36109. * Instantiate the action
  36110. * @param triggerOptions defines the trigger options
  36111. * @param sound defines the sound to play
  36112. * @param condition defines the trigger related conditions
  36113. */
  36114. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36115. /** @hidden */
  36116. _prepare(): void;
  36117. /**
  36118. * Execute the action and play the sound.
  36119. */
  36120. execute(): void;
  36121. /**
  36122. * Serializes the actions and its related information.
  36123. * @param parent defines the object to serialize in
  36124. * @returns the serialized object
  36125. */
  36126. serialize(parent: any): any;
  36127. }
  36128. /**
  36129. * This defines an action helpful to stop a defined sound on a triggered action.
  36130. */
  36131. export class StopSoundAction extends Action {
  36132. private _sound;
  36133. /**
  36134. * Instantiate the action
  36135. * @param triggerOptions defines the trigger options
  36136. * @param sound defines the sound to stop
  36137. * @param condition defines the trigger related conditions
  36138. */
  36139. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36140. /** @hidden */
  36141. _prepare(): void;
  36142. /**
  36143. * Execute the action and stop the sound.
  36144. */
  36145. execute(): void;
  36146. /**
  36147. * Serializes the actions and its related information.
  36148. * @param parent defines the object to serialize in
  36149. * @returns the serialized object
  36150. */
  36151. serialize(parent: any): any;
  36152. }
  36153. }
  36154. declare module "babylonjs/Actions/interpolateValueAction" {
  36155. import { Action } from "babylonjs/Actions/action";
  36156. import { Condition } from "babylonjs/Actions/condition";
  36157. import { Observable } from "babylonjs/Misc/observable";
  36158. /**
  36159. * This defines an action responsible to change the value of a property
  36160. * by interpolating between its current value and the newly set one once triggered.
  36161. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36162. */
  36163. export class InterpolateValueAction extends Action {
  36164. /**
  36165. * Defines the path of the property where the value should be interpolated
  36166. */
  36167. propertyPath: string;
  36168. /**
  36169. * Defines the target value at the end of the interpolation.
  36170. */
  36171. value: any;
  36172. /**
  36173. * Defines the time it will take for the property to interpolate to the value.
  36174. */
  36175. duration: number;
  36176. /**
  36177. * Defines if the other scene animations should be stopped when the action has been triggered
  36178. */
  36179. stopOtherAnimations?: boolean;
  36180. /**
  36181. * Defines a callback raised once the interpolation animation has been done.
  36182. */
  36183. onInterpolationDone?: () => void;
  36184. /**
  36185. * Observable triggered once the interpolation animation has been done.
  36186. */
  36187. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36188. private _target;
  36189. private _effectiveTarget;
  36190. private _property;
  36191. /**
  36192. * Instantiate the action
  36193. * @param triggerOptions defines the trigger options
  36194. * @param target defines the object containing the value to interpolate
  36195. * @param propertyPath defines the path to the property in the target object
  36196. * @param value defines the target value at the end of the interpolation
  36197. * @param duration deines the time it will take for the property to interpolate to the value.
  36198. * @param condition defines the trigger related conditions
  36199. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36200. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36201. */
  36202. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36203. /** @hidden */
  36204. _prepare(): void;
  36205. /**
  36206. * Execute the action starts the value interpolation.
  36207. */
  36208. execute(): void;
  36209. /**
  36210. * Serializes the actions and its related information.
  36211. * @param parent defines the object to serialize in
  36212. * @returns the serialized object
  36213. */
  36214. serialize(parent: any): any;
  36215. }
  36216. }
  36217. declare module "babylonjs/Actions/index" {
  36218. export * from "babylonjs/Actions/abstractActionManager";
  36219. export * from "babylonjs/Actions/action";
  36220. export * from "babylonjs/Actions/actionEvent";
  36221. export * from "babylonjs/Actions/actionManager";
  36222. export * from "babylonjs/Actions/condition";
  36223. export * from "babylonjs/Actions/directActions";
  36224. export * from "babylonjs/Actions/directAudioActions";
  36225. export * from "babylonjs/Actions/interpolateValueAction";
  36226. }
  36227. declare module "babylonjs/Animations/index" {
  36228. export * from "babylonjs/Animations/animatable";
  36229. export * from "babylonjs/Animations/animation";
  36230. export * from "babylonjs/Animations/animationGroup";
  36231. export * from "babylonjs/Animations/animationPropertiesOverride";
  36232. export * from "babylonjs/Animations/easing";
  36233. export * from "babylonjs/Animations/runtimeAnimation";
  36234. export * from "babylonjs/Animations/animationEvent";
  36235. export * from "babylonjs/Animations/animationGroup";
  36236. export * from "babylonjs/Animations/animationKey";
  36237. export * from "babylonjs/Animations/animationRange";
  36238. export * from "babylonjs/Animations/animatable.interface";
  36239. }
  36240. declare module "babylonjs/Audio/soundTrack" {
  36241. import { Sound } from "babylonjs/Audio/sound";
  36242. import { Analyser } from "babylonjs/Audio/analyser";
  36243. import { Scene } from "babylonjs/scene";
  36244. /**
  36245. * Options allowed during the creation of a sound track.
  36246. */
  36247. export interface ISoundTrackOptions {
  36248. /**
  36249. * The volume the sound track should take during creation
  36250. */
  36251. volume?: number;
  36252. /**
  36253. * Define if the sound track is the main sound track of the scene
  36254. */
  36255. mainTrack?: boolean;
  36256. }
  36257. /**
  36258. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36259. * It will be also used in a future release to apply effects on a specific track.
  36260. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36261. */
  36262. export class SoundTrack {
  36263. /**
  36264. * The unique identifier of the sound track in the scene.
  36265. */
  36266. id: number;
  36267. /**
  36268. * The list of sounds included in the sound track.
  36269. */
  36270. soundCollection: Array<Sound>;
  36271. private _outputAudioNode;
  36272. private _scene;
  36273. private _isMainTrack;
  36274. private _connectedAnalyser;
  36275. private _options;
  36276. private _isInitialized;
  36277. /**
  36278. * Creates a new sound track.
  36279. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36280. * @param scene Define the scene the sound track belongs to
  36281. * @param options
  36282. */
  36283. constructor(scene: Scene, options?: ISoundTrackOptions);
  36284. private _initializeSoundTrackAudioGraph;
  36285. /**
  36286. * Release the sound track and its associated resources
  36287. */
  36288. dispose(): void;
  36289. /**
  36290. * Adds a sound to this sound track
  36291. * @param sound define the cound to add
  36292. * @ignoreNaming
  36293. */
  36294. AddSound(sound: Sound): void;
  36295. /**
  36296. * Removes a sound to this sound track
  36297. * @param sound define the cound to remove
  36298. * @ignoreNaming
  36299. */
  36300. RemoveSound(sound: Sound): void;
  36301. /**
  36302. * Set a global volume for the full sound track.
  36303. * @param newVolume Define the new volume of the sound track
  36304. */
  36305. setVolume(newVolume: number): void;
  36306. /**
  36307. * Switch the panning model to HRTF:
  36308. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36309. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36310. */
  36311. switchPanningModelToHRTF(): void;
  36312. /**
  36313. * Switch the panning model to Equal Power:
  36314. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36315. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36316. */
  36317. switchPanningModelToEqualPower(): void;
  36318. /**
  36319. * Connect the sound track to an audio analyser allowing some amazing
  36320. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36321. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36322. * @param analyser The analyser to connect to the engine
  36323. */
  36324. connectToAnalyser(analyser: Analyser): void;
  36325. }
  36326. }
  36327. declare module "babylonjs/Audio/audioSceneComponent" {
  36328. import { Sound } from "babylonjs/Audio/sound";
  36329. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36330. import { Nullable } from "babylonjs/types";
  36331. import { Vector3 } from "babylonjs/Maths/math.vector";
  36332. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36333. import { Scene } from "babylonjs/scene";
  36334. import { AbstractScene } from "babylonjs/abstractScene";
  36335. import "babylonjs/Audio/audioEngine";
  36336. module "babylonjs/abstractScene" {
  36337. interface AbstractScene {
  36338. /**
  36339. * The list of sounds used in the scene.
  36340. */
  36341. sounds: Nullable<Array<Sound>>;
  36342. }
  36343. }
  36344. module "babylonjs/scene" {
  36345. interface Scene {
  36346. /**
  36347. * @hidden
  36348. * Backing field
  36349. */
  36350. _mainSoundTrack: SoundTrack;
  36351. /**
  36352. * The main sound track played by the scene.
  36353. * It cotains your primary collection of sounds.
  36354. */
  36355. mainSoundTrack: SoundTrack;
  36356. /**
  36357. * The list of sound tracks added to the scene
  36358. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36359. */
  36360. soundTracks: Nullable<Array<SoundTrack>>;
  36361. /**
  36362. * Gets a sound using a given name
  36363. * @param name defines the name to search for
  36364. * @return the found sound or null if not found at all.
  36365. */
  36366. getSoundByName(name: string): Nullable<Sound>;
  36367. /**
  36368. * Gets or sets if audio support is enabled
  36369. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36370. */
  36371. audioEnabled: boolean;
  36372. /**
  36373. * Gets or sets if audio will be output to headphones
  36374. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36375. */
  36376. headphone: boolean;
  36377. /**
  36378. * Gets or sets custom audio listener position provider
  36379. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36380. */
  36381. audioListenerPositionProvider: Nullable<() => Vector3>;
  36382. }
  36383. }
  36384. /**
  36385. * Defines the sound scene component responsible to manage any sounds
  36386. * in a given scene.
  36387. */
  36388. export class AudioSceneComponent implements ISceneSerializableComponent {
  36389. /**
  36390. * The component name helpfull to identify the component in the list of scene components.
  36391. */
  36392. readonly name: string;
  36393. /**
  36394. * The scene the component belongs to.
  36395. */
  36396. scene: Scene;
  36397. private _audioEnabled;
  36398. /**
  36399. * Gets whether audio is enabled or not.
  36400. * Please use related enable/disable method to switch state.
  36401. */
  36402. readonly audioEnabled: boolean;
  36403. private _headphone;
  36404. /**
  36405. * Gets whether audio is outputing to headphone or not.
  36406. * Please use the according Switch methods to change output.
  36407. */
  36408. readonly headphone: boolean;
  36409. private _audioListenerPositionProvider;
  36410. /**
  36411. * Gets the current audio listener position provider
  36412. */
  36413. /**
  36414. * Sets a custom listener position for all sounds in the scene
  36415. * By default, this is the position of the first active camera
  36416. */
  36417. audioListenerPositionProvider: Nullable<() => Vector3>;
  36418. /**
  36419. * Creates a new instance of the component for the given scene
  36420. * @param scene Defines the scene to register the component in
  36421. */
  36422. constructor(scene: Scene);
  36423. /**
  36424. * Registers the component in a given scene
  36425. */
  36426. register(): void;
  36427. /**
  36428. * Rebuilds the elements related to this component in case of
  36429. * context lost for instance.
  36430. */
  36431. rebuild(): void;
  36432. /**
  36433. * Serializes the component data to the specified json object
  36434. * @param serializationObject The object to serialize to
  36435. */
  36436. serialize(serializationObject: any): void;
  36437. /**
  36438. * Adds all the elements from the container to the scene
  36439. * @param container the container holding the elements
  36440. */
  36441. addFromContainer(container: AbstractScene): void;
  36442. /**
  36443. * Removes all the elements in the container from the scene
  36444. * @param container contains the elements to remove
  36445. * @param dispose if the removed element should be disposed (default: false)
  36446. */
  36447. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36448. /**
  36449. * Disposes the component and the associated ressources.
  36450. */
  36451. dispose(): void;
  36452. /**
  36453. * Disables audio in the associated scene.
  36454. */
  36455. disableAudio(): void;
  36456. /**
  36457. * Enables audio in the associated scene.
  36458. */
  36459. enableAudio(): void;
  36460. /**
  36461. * Switch audio to headphone output.
  36462. */
  36463. switchAudioModeForHeadphones(): void;
  36464. /**
  36465. * Switch audio to normal speakers.
  36466. */
  36467. switchAudioModeForNormalSpeakers(): void;
  36468. private _afterRender;
  36469. }
  36470. }
  36471. declare module "babylonjs/Audio/weightedsound" {
  36472. import { Sound } from "babylonjs/Audio/sound";
  36473. /**
  36474. * Wraps one or more Sound objects and selects one with random weight for playback.
  36475. */
  36476. export class WeightedSound {
  36477. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36478. loop: boolean;
  36479. private _coneInnerAngle;
  36480. private _coneOuterAngle;
  36481. private _volume;
  36482. /** A Sound is currently playing. */
  36483. isPlaying: boolean;
  36484. /** A Sound is currently paused. */
  36485. isPaused: boolean;
  36486. private _sounds;
  36487. private _weights;
  36488. private _currentIndex?;
  36489. /**
  36490. * Creates a new WeightedSound from the list of sounds given.
  36491. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36492. * @param sounds Array of Sounds that will be selected from.
  36493. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36494. */
  36495. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36496. /**
  36497. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36498. */
  36499. /**
  36500. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36501. */
  36502. directionalConeInnerAngle: number;
  36503. /**
  36504. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36505. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36506. */
  36507. /**
  36508. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36509. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36510. */
  36511. directionalConeOuterAngle: number;
  36512. /**
  36513. * Playback volume.
  36514. */
  36515. /**
  36516. * Playback volume.
  36517. */
  36518. volume: number;
  36519. private _onended;
  36520. /**
  36521. * Suspend playback
  36522. */
  36523. pause(): void;
  36524. /**
  36525. * Stop playback
  36526. */
  36527. stop(): void;
  36528. /**
  36529. * Start playback.
  36530. * @param startOffset Position the clip head at a specific time in seconds.
  36531. */
  36532. play(startOffset?: number): void;
  36533. }
  36534. }
  36535. declare module "babylonjs/Audio/index" {
  36536. export * from "babylonjs/Audio/analyser";
  36537. export * from "babylonjs/Audio/audioEngine";
  36538. export * from "babylonjs/Audio/audioSceneComponent";
  36539. export * from "babylonjs/Audio/sound";
  36540. export * from "babylonjs/Audio/soundTrack";
  36541. export * from "babylonjs/Audio/weightedsound";
  36542. }
  36543. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36544. import { Behavior } from "babylonjs/Behaviors/behavior";
  36545. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36546. import { BackEase } from "babylonjs/Animations/easing";
  36547. /**
  36548. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36549. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36550. */
  36551. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36552. /**
  36553. * Gets the name of the behavior.
  36554. */
  36555. readonly name: string;
  36556. /**
  36557. * The easing function used by animations
  36558. */
  36559. static EasingFunction: BackEase;
  36560. /**
  36561. * The easing mode used by animations
  36562. */
  36563. static EasingMode: number;
  36564. /**
  36565. * The duration of the animation, in milliseconds
  36566. */
  36567. transitionDuration: number;
  36568. /**
  36569. * Length of the distance animated by the transition when lower radius is reached
  36570. */
  36571. lowerRadiusTransitionRange: number;
  36572. /**
  36573. * Length of the distance animated by the transition when upper radius is reached
  36574. */
  36575. upperRadiusTransitionRange: number;
  36576. private _autoTransitionRange;
  36577. /**
  36578. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36579. */
  36580. /**
  36581. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36582. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36583. */
  36584. autoTransitionRange: boolean;
  36585. private _attachedCamera;
  36586. private _onAfterCheckInputsObserver;
  36587. private _onMeshTargetChangedObserver;
  36588. /**
  36589. * Initializes the behavior.
  36590. */
  36591. init(): void;
  36592. /**
  36593. * Attaches the behavior to its arc rotate camera.
  36594. * @param camera Defines the camera to attach the behavior to
  36595. */
  36596. attach(camera: ArcRotateCamera): void;
  36597. /**
  36598. * Detaches the behavior from its current arc rotate camera.
  36599. */
  36600. detach(): void;
  36601. private _radiusIsAnimating;
  36602. private _radiusBounceTransition;
  36603. private _animatables;
  36604. private _cachedWheelPrecision;
  36605. /**
  36606. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36607. * @param radiusLimit The limit to check against.
  36608. * @return Bool to indicate if at limit.
  36609. */
  36610. private _isRadiusAtLimit;
  36611. /**
  36612. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36613. * @param radiusDelta The delta by which to animate to. Can be negative.
  36614. */
  36615. private _applyBoundRadiusAnimation;
  36616. /**
  36617. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36618. */
  36619. protected _clearAnimationLocks(): void;
  36620. /**
  36621. * Stops and removes all animations that have been applied to the camera
  36622. */
  36623. stopAllAnimations(): void;
  36624. }
  36625. }
  36626. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36627. import { Behavior } from "babylonjs/Behaviors/behavior";
  36628. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36629. import { ExponentialEase } from "babylonjs/Animations/easing";
  36630. import { Nullable } from "babylonjs/types";
  36631. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36632. import { Vector3 } from "babylonjs/Maths/math.vector";
  36633. /**
  36634. * 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.
  36635. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36636. */
  36637. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36638. /**
  36639. * Gets the name of the behavior.
  36640. */
  36641. readonly name: string;
  36642. private _mode;
  36643. private _radiusScale;
  36644. private _positionScale;
  36645. private _defaultElevation;
  36646. private _elevationReturnTime;
  36647. private _elevationReturnWaitTime;
  36648. private _zoomStopsAnimation;
  36649. private _framingTime;
  36650. /**
  36651. * The easing function used by animations
  36652. */
  36653. static EasingFunction: ExponentialEase;
  36654. /**
  36655. * The easing mode used by animations
  36656. */
  36657. static EasingMode: number;
  36658. /**
  36659. * Sets the current mode used by the behavior
  36660. */
  36661. /**
  36662. * Gets current mode used by the behavior.
  36663. */
  36664. mode: number;
  36665. /**
  36666. * Sets the scale applied to the radius (1 by default)
  36667. */
  36668. /**
  36669. * Gets the scale applied to the radius
  36670. */
  36671. radiusScale: number;
  36672. /**
  36673. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36674. */
  36675. /**
  36676. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36677. */
  36678. positionScale: number;
  36679. /**
  36680. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36681. * behaviour is triggered, in radians.
  36682. */
  36683. /**
  36684. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36685. * behaviour is triggered, in radians.
  36686. */
  36687. defaultElevation: number;
  36688. /**
  36689. * Sets the time (in milliseconds) taken to return to the default beta position.
  36690. * Negative value indicates camera should not return to default.
  36691. */
  36692. /**
  36693. * Gets the time (in milliseconds) taken to return to the default beta position.
  36694. * Negative value indicates camera should not return to default.
  36695. */
  36696. elevationReturnTime: number;
  36697. /**
  36698. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36699. */
  36700. /**
  36701. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36702. */
  36703. elevationReturnWaitTime: number;
  36704. /**
  36705. * Sets the flag that indicates if user zooming should stop animation.
  36706. */
  36707. /**
  36708. * Gets the flag that indicates if user zooming should stop animation.
  36709. */
  36710. zoomStopsAnimation: boolean;
  36711. /**
  36712. * Sets the transition time when framing the mesh, in milliseconds
  36713. */
  36714. /**
  36715. * Gets the transition time when framing the mesh, in milliseconds
  36716. */
  36717. framingTime: number;
  36718. /**
  36719. * Define if the behavior should automatically change the configured
  36720. * camera limits and sensibilities.
  36721. */
  36722. autoCorrectCameraLimitsAndSensibility: boolean;
  36723. private _onPrePointerObservableObserver;
  36724. private _onAfterCheckInputsObserver;
  36725. private _onMeshTargetChangedObserver;
  36726. private _attachedCamera;
  36727. private _isPointerDown;
  36728. private _lastInteractionTime;
  36729. /**
  36730. * Initializes the behavior.
  36731. */
  36732. init(): void;
  36733. /**
  36734. * Attaches the behavior to its arc rotate camera.
  36735. * @param camera Defines the camera to attach the behavior to
  36736. */
  36737. attach(camera: ArcRotateCamera): void;
  36738. /**
  36739. * Detaches the behavior from its current arc rotate camera.
  36740. */
  36741. detach(): void;
  36742. private _animatables;
  36743. private _betaIsAnimating;
  36744. private _betaTransition;
  36745. private _radiusTransition;
  36746. private _vectorTransition;
  36747. /**
  36748. * Targets the given mesh and updates zoom level accordingly.
  36749. * @param mesh The mesh to target.
  36750. * @param radius Optional. If a cached radius position already exists, overrides default.
  36751. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36752. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36753. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36754. */
  36755. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36756. /**
  36757. * Targets the given mesh with its children and updates zoom level accordingly.
  36758. * @param mesh The mesh to target.
  36759. * @param radius Optional. If a cached radius position already exists, overrides default.
  36760. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36761. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36762. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36763. */
  36764. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36765. /**
  36766. * Targets the given meshes with their children and updates zoom level accordingly.
  36767. * @param meshes The mesh to target.
  36768. * @param radius Optional. If a cached radius position already exists, overrides default.
  36769. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36770. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36771. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36772. */
  36773. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36774. /**
  36775. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36776. * @param minimumWorld Determines the smaller position of the bounding box extend
  36777. * @param maximumWorld Determines the bigger position of the bounding box extend
  36778. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36779. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36780. */
  36781. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36782. /**
  36783. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36784. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36785. * frustum width.
  36786. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36787. * to fully enclose the mesh in the viewing frustum.
  36788. */
  36789. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36790. /**
  36791. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36792. * is automatically returned to its default position (expected to be above ground plane).
  36793. */
  36794. private _maintainCameraAboveGround;
  36795. /**
  36796. * Returns the frustum slope based on the canvas ratio and camera FOV
  36797. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36798. */
  36799. private _getFrustumSlope;
  36800. /**
  36801. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36802. */
  36803. private _clearAnimationLocks;
  36804. /**
  36805. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36806. */
  36807. private _applyUserInteraction;
  36808. /**
  36809. * Stops and removes all animations that have been applied to the camera
  36810. */
  36811. stopAllAnimations(): void;
  36812. /**
  36813. * Gets a value indicating if the user is moving the camera
  36814. */
  36815. readonly isUserIsMoving: boolean;
  36816. /**
  36817. * The camera can move all the way towards the mesh.
  36818. */
  36819. static IgnoreBoundsSizeMode: number;
  36820. /**
  36821. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36822. */
  36823. static FitFrustumSidesMode: number;
  36824. }
  36825. }
  36826. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  36827. import { Nullable } from "babylonjs/types";
  36828. import { Camera } from "babylonjs/Cameras/camera";
  36829. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36830. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36831. /**
  36832. * Base class for Camera Pointer Inputs.
  36833. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36834. * for example usage.
  36835. */
  36836. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36837. /**
  36838. * Defines the camera the input is attached to.
  36839. */
  36840. abstract camera: Camera;
  36841. /**
  36842. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36843. */
  36844. protected _altKey: boolean;
  36845. protected _ctrlKey: boolean;
  36846. protected _metaKey: boolean;
  36847. protected _shiftKey: boolean;
  36848. /**
  36849. * Which mouse buttons were pressed at time of last mouse event.
  36850. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36851. */
  36852. protected _buttonsPressed: number;
  36853. /**
  36854. * Defines the buttons associated with the input to handle camera move.
  36855. */
  36856. buttons: number[];
  36857. /**
  36858. * Attach the input controls to a specific dom element to get the input from.
  36859. * @param element Defines the element the controls should be listened from
  36860. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36861. */
  36862. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36863. /**
  36864. * Detach the current controls from the specified dom element.
  36865. * @param element Defines the element to stop listening the inputs from
  36866. */
  36867. detachControl(element: Nullable<HTMLElement>): void;
  36868. /**
  36869. * Gets the class name of the current input.
  36870. * @returns the class name
  36871. */
  36872. getClassName(): string;
  36873. /**
  36874. * Get the friendly name associated with the input class.
  36875. * @returns the input friendly name
  36876. */
  36877. getSimpleName(): string;
  36878. /**
  36879. * Called on pointer POINTERDOUBLETAP event.
  36880. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36881. */
  36882. protected onDoubleTap(type: string): void;
  36883. /**
  36884. * Called on pointer POINTERMOVE event if only a single touch is active.
  36885. * Override this method to provide functionality.
  36886. */
  36887. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36888. /**
  36889. * Called on pointer POINTERMOVE event if multiple touches are active.
  36890. * Override this method to provide functionality.
  36891. */
  36892. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36893. /**
  36894. * Called on JS contextmenu event.
  36895. * Override this method to provide functionality.
  36896. */
  36897. protected onContextMenu(evt: PointerEvent): void;
  36898. /**
  36899. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36900. * press.
  36901. * Override this method to provide functionality.
  36902. */
  36903. protected onButtonDown(evt: PointerEvent): void;
  36904. /**
  36905. * Called each time a new POINTERUP event occurs. Ie, for each button
  36906. * release.
  36907. * Override this method to provide functionality.
  36908. */
  36909. protected onButtonUp(evt: PointerEvent): void;
  36910. /**
  36911. * Called when window becomes inactive.
  36912. * Override this method to provide functionality.
  36913. */
  36914. protected onLostFocus(): void;
  36915. private _pointerInput;
  36916. private _observer;
  36917. private _onLostFocus;
  36918. private pointA;
  36919. private pointB;
  36920. }
  36921. }
  36922. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  36923. import { Nullable } from "babylonjs/types";
  36924. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36925. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36926. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36927. /**
  36928. * Manage the pointers inputs to control an arc rotate camera.
  36929. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36930. */
  36931. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36932. /**
  36933. * Defines the camera the input is attached to.
  36934. */
  36935. camera: ArcRotateCamera;
  36936. /**
  36937. * Gets the class name of the current input.
  36938. * @returns the class name
  36939. */
  36940. getClassName(): string;
  36941. /**
  36942. * Defines the buttons associated with the input to handle camera move.
  36943. */
  36944. buttons: number[];
  36945. /**
  36946. * Defines the pointer angular sensibility along the X axis or how fast is
  36947. * the camera rotating.
  36948. */
  36949. angularSensibilityX: number;
  36950. /**
  36951. * Defines the pointer angular sensibility along the Y axis or how fast is
  36952. * the camera rotating.
  36953. */
  36954. angularSensibilityY: number;
  36955. /**
  36956. * Defines the pointer pinch precision or how fast is the camera zooming.
  36957. */
  36958. pinchPrecision: number;
  36959. /**
  36960. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36961. * from 0.
  36962. * It defines the percentage of current camera.radius to use as delta when
  36963. * pinch zoom is used.
  36964. */
  36965. pinchDeltaPercentage: number;
  36966. /**
  36967. * Defines the pointer panning sensibility or how fast is the camera moving.
  36968. */
  36969. panningSensibility: number;
  36970. /**
  36971. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36972. */
  36973. multiTouchPanning: boolean;
  36974. /**
  36975. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36976. * zoom (pinch) through multitouch.
  36977. */
  36978. multiTouchPanAndZoom: boolean;
  36979. /**
  36980. * Revers pinch action direction.
  36981. */
  36982. pinchInwards: boolean;
  36983. private _isPanClick;
  36984. private _twoFingerActivityCount;
  36985. private _isPinching;
  36986. /**
  36987. * Called on pointer POINTERMOVE event if only a single touch is active.
  36988. */
  36989. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36990. /**
  36991. * Called on pointer POINTERDOUBLETAP event.
  36992. */
  36993. protected onDoubleTap(type: string): void;
  36994. /**
  36995. * Called on pointer POINTERMOVE event if multiple touches are active.
  36996. */
  36997. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36998. /**
  36999. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37000. * press.
  37001. */
  37002. protected onButtonDown(evt: PointerEvent): void;
  37003. /**
  37004. * Called each time a new POINTERUP event occurs. Ie, for each button
  37005. * release.
  37006. */
  37007. protected onButtonUp(evt: PointerEvent): void;
  37008. /**
  37009. * Called when window becomes inactive.
  37010. */
  37011. protected onLostFocus(): void;
  37012. }
  37013. }
  37014. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  37015. import { Nullable } from "babylonjs/types";
  37016. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37017. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37018. /**
  37019. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37020. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37021. */
  37022. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37023. /**
  37024. * Defines the camera the input is attached to.
  37025. */
  37026. camera: ArcRotateCamera;
  37027. /**
  37028. * Defines the list of key codes associated with the up action (increase alpha)
  37029. */
  37030. keysUp: number[];
  37031. /**
  37032. * Defines the list of key codes associated with the down action (decrease alpha)
  37033. */
  37034. keysDown: number[];
  37035. /**
  37036. * Defines the list of key codes associated with the left action (increase beta)
  37037. */
  37038. keysLeft: number[];
  37039. /**
  37040. * Defines the list of key codes associated with the right action (decrease beta)
  37041. */
  37042. keysRight: number[];
  37043. /**
  37044. * Defines the list of key codes associated with the reset action.
  37045. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37046. */
  37047. keysReset: number[];
  37048. /**
  37049. * Defines the panning sensibility of the inputs.
  37050. * (How fast is the camera paning)
  37051. */
  37052. panningSensibility: number;
  37053. /**
  37054. * Defines the zooming sensibility of the inputs.
  37055. * (How fast is the camera zooming)
  37056. */
  37057. zoomingSensibility: number;
  37058. /**
  37059. * Defines wether maintaining the alt key down switch the movement mode from
  37060. * orientation to zoom.
  37061. */
  37062. useAltToZoom: boolean;
  37063. /**
  37064. * Rotation speed of the camera
  37065. */
  37066. angularSpeed: number;
  37067. private _keys;
  37068. private _ctrlPressed;
  37069. private _altPressed;
  37070. private _onCanvasBlurObserver;
  37071. private _onKeyboardObserver;
  37072. private _engine;
  37073. private _scene;
  37074. /**
  37075. * Attach the input controls to a specific dom element to get the input from.
  37076. * @param element Defines the element the controls should be listened from
  37077. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37078. */
  37079. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37080. /**
  37081. * Detach the current controls from the specified dom element.
  37082. * @param element Defines the element to stop listening the inputs from
  37083. */
  37084. detachControl(element: Nullable<HTMLElement>): void;
  37085. /**
  37086. * Update the current camera state depending on the inputs that have been used this frame.
  37087. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37088. */
  37089. checkInputs(): void;
  37090. /**
  37091. * Gets the class name of the current intput.
  37092. * @returns the class name
  37093. */
  37094. getClassName(): string;
  37095. /**
  37096. * Get the friendly name associated with the input class.
  37097. * @returns the input friendly name
  37098. */
  37099. getSimpleName(): string;
  37100. }
  37101. }
  37102. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  37103. import { Nullable } from "babylonjs/types";
  37104. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37105. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37106. /**
  37107. * Manage the mouse wheel inputs to control an arc rotate camera.
  37108. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37109. */
  37110. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37111. /**
  37112. * Defines the camera the input is attached to.
  37113. */
  37114. camera: ArcRotateCamera;
  37115. /**
  37116. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37117. */
  37118. wheelPrecision: number;
  37119. /**
  37120. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37121. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37122. */
  37123. wheelDeltaPercentage: number;
  37124. private _wheel;
  37125. private _observer;
  37126. private computeDeltaFromMouseWheelLegacyEvent;
  37127. /**
  37128. * Attach the input controls to a specific dom element to get the input from.
  37129. * @param element Defines the element the controls should be listened from
  37130. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37131. */
  37132. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37133. /**
  37134. * Detach the current controls from the specified dom element.
  37135. * @param element Defines the element to stop listening the inputs from
  37136. */
  37137. detachControl(element: Nullable<HTMLElement>): void;
  37138. /**
  37139. * Gets the class name of the current intput.
  37140. * @returns the class name
  37141. */
  37142. getClassName(): string;
  37143. /**
  37144. * Get the friendly name associated with the input class.
  37145. * @returns the input friendly name
  37146. */
  37147. getSimpleName(): string;
  37148. }
  37149. }
  37150. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37151. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37152. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37153. /**
  37154. * Default Inputs manager for the ArcRotateCamera.
  37155. * It groups all the default supported inputs for ease of use.
  37156. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37157. */
  37158. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37159. /**
  37160. * Instantiates a new ArcRotateCameraInputsManager.
  37161. * @param camera Defines the camera the inputs belong to
  37162. */
  37163. constructor(camera: ArcRotateCamera);
  37164. /**
  37165. * Add mouse wheel input support to the input manager.
  37166. * @returns the current input manager
  37167. */
  37168. addMouseWheel(): ArcRotateCameraInputsManager;
  37169. /**
  37170. * Add pointers input support to the input manager.
  37171. * @returns the current input manager
  37172. */
  37173. addPointers(): ArcRotateCameraInputsManager;
  37174. /**
  37175. * Add keyboard input support to the input manager.
  37176. * @returns the current input manager
  37177. */
  37178. addKeyboard(): ArcRotateCameraInputsManager;
  37179. }
  37180. }
  37181. declare module "babylonjs/Cameras/arcRotateCamera" {
  37182. import { Observable } from "babylonjs/Misc/observable";
  37183. import { Nullable } from "babylonjs/types";
  37184. import { Scene } from "babylonjs/scene";
  37185. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37186. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37187. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37188. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37189. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37190. import { Camera } from "babylonjs/Cameras/camera";
  37191. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37192. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37193. import { Collider } from "babylonjs/Collisions/collider";
  37194. /**
  37195. * This represents an orbital type of camera.
  37196. *
  37197. * 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.
  37198. * 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.
  37199. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37200. */
  37201. export class ArcRotateCamera extends TargetCamera {
  37202. /**
  37203. * Defines the rotation angle of the camera along the longitudinal axis.
  37204. */
  37205. alpha: number;
  37206. /**
  37207. * Defines the rotation angle of the camera along the latitudinal axis.
  37208. */
  37209. beta: number;
  37210. /**
  37211. * Defines the radius of the camera from it s target point.
  37212. */
  37213. radius: number;
  37214. protected _target: Vector3;
  37215. protected _targetHost: Nullable<AbstractMesh>;
  37216. /**
  37217. * Defines the target point of the camera.
  37218. * The camera looks towards it form the radius distance.
  37219. */
  37220. target: Vector3;
  37221. /**
  37222. * Define the current local position of the camera in the scene
  37223. */
  37224. position: Vector3;
  37225. protected _upVector: Vector3;
  37226. protected _upToYMatrix: Matrix;
  37227. protected _YToUpMatrix: Matrix;
  37228. /**
  37229. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37230. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37231. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37232. */
  37233. upVector: Vector3;
  37234. /**
  37235. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37236. */
  37237. setMatUp(): void;
  37238. /**
  37239. * Current inertia value on the longitudinal axis.
  37240. * The bigger this number the longer it will take for the camera to stop.
  37241. */
  37242. inertialAlphaOffset: number;
  37243. /**
  37244. * Current inertia value on the latitudinal axis.
  37245. * The bigger this number the longer it will take for the camera to stop.
  37246. */
  37247. inertialBetaOffset: number;
  37248. /**
  37249. * Current inertia value on the radius axis.
  37250. * The bigger this number the longer it will take for the camera to stop.
  37251. */
  37252. inertialRadiusOffset: number;
  37253. /**
  37254. * Minimum allowed angle on the longitudinal axis.
  37255. * This can help limiting how the Camera is able to move in the scene.
  37256. */
  37257. lowerAlphaLimit: Nullable<number>;
  37258. /**
  37259. * Maximum allowed angle on the longitudinal axis.
  37260. * This can help limiting how the Camera is able to move in the scene.
  37261. */
  37262. upperAlphaLimit: Nullable<number>;
  37263. /**
  37264. * Minimum allowed angle on the latitudinal axis.
  37265. * This can help limiting how the Camera is able to move in the scene.
  37266. */
  37267. lowerBetaLimit: number;
  37268. /**
  37269. * Maximum allowed angle on the latitudinal axis.
  37270. * This can help limiting how the Camera is able to move in the scene.
  37271. */
  37272. upperBetaLimit: number;
  37273. /**
  37274. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37275. * This can help limiting how the Camera is able to move in the scene.
  37276. */
  37277. lowerRadiusLimit: Nullable<number>;
  37278. /**
  37279. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37280. * This can help limiting how the Camera is able to move in the scene.
  37281. */
  37282. upperRadiusLimit: Nullable<number>;
  37283. /**
  37284. * Defines the current inertia value used during panning of the camera along the X axis.
  37285. */
  37286. inertialPanningX: number;
  37287. /**
  37288. * Defines the current inertia value used during panning of the camera along the Y axis.
  37289. */
  37290. inertialPanningY: number;
  37291. /**
  37292. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37293. * Basically if your fingers moves away from more than this distance you will be considered
  37294. * in pinch mode.
  37295. */
  37296. pinchToPanMaxDistance: number;
  37297. /**
  37298. * Defines the maximum distance the camera can pan.
  37299. * This could help keeping the cammera always in your scene.
  37300. */
  37301. panningDistanceLimit: Nullable<number>;
  37302. /**
  37303. * Defines the target of the camera before paning.
  37304. */
  37305. panningOriginTarget: Vector3;
  37306. /**
  37307. * Defines the value of the inertia used during panning.
  37308. * 0 would mean stop inertia and one would mean no decelleration at all.
  37309. */
  37310. panningInertia: number;
  37311. /**
  37312. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37313. */
  37314. angularSensibilityX: number;
  37315. /**
  37316. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37317. */
  37318. angularSensibilityY: number;
  37319. /**
  37320. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37321. */
  37322. pinchPrecision: number;
  37323. /**
  37324. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37325. * It will be used instead of pinchDeltaPrecision if different from 0.
  37326. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37327. */
  37328. pinchDeltaPercentage: number;
  37329. /**
  37330. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37331. */
  37332. panningSensibility: number;
  37333. /**
  37334. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37335. */
  37336. keysUp: number[];
  37337. /**
  37338. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37339. */
  37340. keysDown: number[];
  37341. /**
  37342. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37343. */
  37344. keysLeft: number[];
  37345. /**
  37346. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37347. */
  37348. keysRight: number[];
  37349. /**
  37350. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37351. */
  37352. wheelPrecision: number;
  37353. /**
  37354. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37355. * It will be used instead of pinchDeltaPrecision if different from 0.
  37356. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37357. */
  37358. wheelDeltaPercentage: number;
  37359. /**
  37360. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37361. */
  37362. zoomOnFactor: number;
  37363. /**
  37364. * Defines a screen offset for the camera position.
  37365. */
  37366. targetScreenOffset: Vector2;
  37367. /**
  37368. * Allows the camera to be completely reversed.
  37369. * If false the camera can not arrive upside down.
  37370. */
  37371. allowUpsideDown: boolean;
  37372. /**
  37373. * Define if double tap/click is used to restore the previously saved state of the camera.
  37374. */
  37375. useInputToRestoreState: boolean;
  37376. /** @hidden */
  37377. _viewMatrix: Matrix;
  37378. /** @hidden */
  37379. _useCtrlForPanning: boolean;
  37380. /** @hidden */
  37381. _panningMouseButton: number;
  37382. /**
  37383. * Defines the input associated to the camera.
  37384. */
  37385. inputs: ArcRotateCameraInputsManager;
  37386. /** @hidden */
  37387. _reset: () => void;
  37388. /**
  37389. * Defines the allowed panning axis.
  37390. */
  37391. panningAxis: Vector3;
  37392. protected _localDirection: Vector3;
  37393. protected _transformedDirection: Vector3;
  37394. private _bouncingBehavior;
  37395. /**
  37396. * Gets the bouncing behavior of the camera if it has been enabled.
  37397. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37398. */
  37399. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37400. /**
  37401. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37402. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37403. */
  37404. useBouncingBehavior: boolean;
  37405. private _framingBehavior;
  37406. /**
  37407. * Gets the framing behavior of the camera if it has been enabled.
  37408. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37409. */
  37410. readonly framingBehavior: Nullable<FramingBehavior>;
  37411. /**
  37412. * Defines if the framing behavior of the camera is enabled on the camera.
  37413. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37414. */
  37415. useFramingBehavior: boolean;
  37416. private _autoRotationBehavior;
  37417. /**
  37418. * Gets the auto rotation behavior of the camera if it has been enabled.
  37419. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37420. */
  37421. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37422. /**
  37423. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37424. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37425. */
  37426. useAutoRotationBehavior: boolean;
  37427. /**
  37428. * Observable triggered when the mesh target has been changed on the camera.
  37429. */
  37430. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37431. /**
  37432. * Event raised when the camera is colliding with a mesh.
  37433. */
  37434. onCollide: (collidedMesh: AbstractMesh) => void;
  37435. /**
  37436. * Defines whether the camera should check collision with the objects oh the scene.
  37437. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37438. */
  37439. checkCollisions: boolean;
  37440. /**
  37441. * Defines the collision radius of the camera.
  37442. * This simulates a sphere around the camera.
  37443. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37444. */
  37445. collisionRadius: Vector3;
  37446. protected _collider: Collider;
  37447. protected _previousPosition: Vector3;
  37448. protected _collisionVelocity: Vector3;
  37449. protected _newPosition: Vector3;
  37450. protected _previousAlpha: number;
  37451. protected _previousBeta: number;
  37452. protected _previousRadius: number;
  37453. protected _collisionTriggered: boolean;
  37454. protected _targetBoundingCenter: Nullable<Vector3>;
  37455. private _computationVector;
  37456. /**
  37457. * Instantiates a new ArcRotateCamera in a given scene
  37458. * @param name Defines the name of the camera
  37459. * @param alpha Defines the camera rotation along the logitudinal axis
  37460. * @param beta Defines the camera rotation along the latitudinal axis
  37461. * @param radius Defines the camera distance from its target
  37462. * @param target Defines the camera target
  37463. * @param scene Defines the scene the camera belongs to
  37464. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37465. */
  37466. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37467. /** @hidden */
  37468. _initCache(): void;
  37469. /** @hidden */
  37470. _updateCache(ignoreParentClass?: boolean): void;
  37471. protected _getTargetPosition(): Vector3;
  37472. private _storedAlpha;
  37473. private _storedBeta;
  37474. private _storedRadius;
  37475. private _storedTarget;
  37476. private _storedTargetScreenOffset;
  37477. /**
  37478. * Stores the current state of the camera (alpha, beta, radius and target)
  37479. * @returns the camera itself
  37480. */
  37481. storeState(): Camera;
  37482. /**
  37483. * @hidden
  37484. * Restored camera state. You must call storeState() first
  37485. */
  37486. _restoreStateValues(): boolean;
  37487. /** @hidden */
  37488. _isSynchronizedViewMatrix(): boolean;
  37489. /**
  37490. * Attached controls to the current camera.
  37491. * @param element Defines the element the controls should be listened from
  37492. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37493. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37494. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37495. */
  37496. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37497. /**
  37498. * Detach the current controls from the camera.
  37499. * The camera will stop reacting to inputs.
  37500. * @param element Defines the element to stop listening the inputs from
  37501. */
  37502. detachControl(element: HTMLElement): void;
  37503. /** @hidden */
  37504. _checkInputs(): void;
  37505. protected _checkLimits(): void;
  37506. /**
  37507. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37508. */
  37509. rebuildAnglesAndRadius(): void;
  37510. /**
  37511. * Use a position to define the current camera related information like aplha, beta and radius
  37512. * @param position Defines the position to set the camera at
  37513. */
  37514. setPosition(position: Vector3): void;
  37515. /**
  37516. * Defines the target the camera should look at.
  37517. * This will automatically adapt alpha beta and radius to fit within the new target.
  37518. * @param target Defines the new target as a Vector or a mesh
  37519. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37520. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37521. */
  37522. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37523. /** @hidden */
  37524. _getViewMatrix(): Matrix;
  37525. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37526. /**
  37527. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37528. * @param meshes Defines the mesh to zoom on
  37529. * @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)
  37530. */
  37531. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37532. /**
  37533. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37534. * The target will be changed but the radius
  37535. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37536. * @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)
  37537. */
  37538. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37539. min: Vector3;
  37540. max: Vector3;
  37541. distance: number;
  37542. }, doNotUpdateMaxZ?: boolean): void;
  37543. /**
  37544. * @override
  37545. * Override Camera.createRigCamera
  37546. */
  37547. createRigCamera(name: string, cameraIndex: number): Camera;
  37548. /**
  37549. * @hidden
  37550. * @override
  37551. * Override Camera._updateRigCameras
  37552. */
  37553. _updateRigCameras(): void;
  37554. /**
  37555. * Destroy the camera and release the current resources hold by it.
  37556. */
  37557. dispose(): void;
  37558. /**
  37559. * Gets the current object class name.
  37560. * @return the class name
  37561. */
  37562. getClassName(): string;
  37563. }
  37564. }
  37565. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37566. import { Behavior } from "babylonjs/Behaviors/behavior";
  37567. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37568. /**
  37569. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37570. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37571. */
  37572. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37573. /**
  37574. * Gets the name of the behavior.
  37575. */
  37576. readonly name: string;
  37577. private _zoomStopsAnimation;
  37578. private _idleRotationSpeed;
  37579. private _idleRotationWaitTime;
  37580. private _idleRotationSpinupTime;
  37581. /**
  37582. * Sets the flag that indicates if user zooming should stop animation.
  37583. */
  37584. /**
  37585. * Gets the flag that indicates if user zooming should stop animation.
  37586. */
  37587. zoomStopsAnimation: boolean;
  37588. /**
  37589. * Sets the default speed at which the camera rotates around the model.
  37590. */
  37591. /**
  37592. * Gets the default speed at which the camera rotates around the model.
  37593. */
  37594. idleRotationSpeed: number;
  37595. /**
  37596. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37597. */
  37598. /**
  37599. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37600. */
  37601. idleRotationWaitTime: number;
  37602. /**
  37603. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37604. */
  37605. /**
  37606. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37607. */
  37608. idleRotationSpinupTime: number;
  37609. /**
  37610. * Gets a value indicating if the camera is currently rotating because of this behavior
  37611. */
  37612. readonly rotationInProgress: boolean;
  37613. private _onPrePointerObservableObserver;
  37614. private _onAfterCheckInputsObserver;
  37615. private _attachedCamera;
  37616. private _isPointerDown;
  37617. private _lastFrameTime;
  37618. private _lastInteractionTime;
  37619. private _cameraRotationSpeed;
  37620. /**
  37621. * Initializes the behavior.
  37622. */
  37623. init(): void;
  37624. /**
  37625. * Attaches the behavior to its arc rotate camera.
  37626. * @param camera Defines the camera to attach the behavior to
  37627. */
  37628. attach(camera: ArcRotateCamera): void;
  37629. /**
  37630. * Detaches the behavior from its current arc rotate camera.
  37631. */
  37632. detach(): void;
  37633. /**
  37634. * Returns true if user is scrolling.
  37635. * @return true if user is scrolling.
  37636. */
  37637. private _userIsZooming;
  37638. private _lastFrameRadius;
  37639. private _shouldAnimationStopForInteraction;
  37640. /**
  37641. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37642. */
  37643. private _applyUserInteraction;
  37644. private _userIsMoving;
  37645. }
  37646. }
  37647. declare module "babylonjs/Behaviors/Cameras/index" {
  37648. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37649. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37650. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37651. }
  37652. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37653. import { Mesh } from "babylonjs/Meshes/mesh";
  37654. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37655. import { Behavior } from "babylonjs/Behaviors/behavior";
  37656. /**
  37657. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37658. */
  37659. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37660. private ui;
  37661. /**
  37662. * The name of the behavior
  37663. */
  37664. name: string;
  37665. /**
  37666. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37667. */
  37668. distanceAwayFromFace: number;
  37669. /**
  37670. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37671. */
  37672. distanceAwayFromBottomOfFace: number;
  37673. private _faceVectors;
  37674. private _target;
  37675. private _scene;
  37676. private _onRenderObserver;
  37677. private _tmpMatrix;
  37678. private _tmpVector;
  37679. /**
  37680. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37681. * @param ui The transform node that should be attched to the mesh
  37682. */
  37683. constructor(ui: TransformNode);
  37684. /**
  37685. * Initializes the behavior
  37686. */
  37687. init(): void;
  37688. private _closestFace;
  37689. private _zeroVector;
  37690. private _lookAtTmpMatrix;
  37691. private _lookAtToRef;
  37692. /**
  37693. * Attaches the AttachToBoxBehavior to the passed in mesh
  37694. * @param target The mesh that the specified node will be attached to
  37695. */
  37696. attach(target: Mesh): void;
  37697. /**
  37698. * Detaches the behavior from the mesh
  37699. */
  37700. detach(): void;
  37701. }
  37702. }
  37703. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37704. import { Behavior } from "babylonjs/Behaviors/behavior";
  37705. import { Mesh } from "babylonjs/Meshes/mesh";
  37706. /**
  37707. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37708. */
  37709. export class FadeInOutBehavior implements Behavior<Mesh> {
  37710. /**
  37711. * Time in milliseconds to delay before fading in (Default: 0)
  37712. */
  37713. delay: number;
  37714. /**
  37715. * Time in milliseconds for the mesh to fade in (Default: 300)
  37716. */
  37717. fadeInTime: number;
  37718. private _millisecondsPerFrame;
  37719. private _hovered;
  37720. private _hoverValue;
  37721. private _ownerNode;
  37722. /**
  37723. * Instatiates the FadeInOutBehavior
  37724. */
  37725. constructor();
  37726. /**
  37727. * The name of the behavior
  37728. */
  37729. readonly name: string;
  37730. /**
  37731. * Initializes the behavior
  37732. */
  37733. init(): void;
  37734. /**
  37735. * Attaches the fade behavior on the passed in mesh
  37736. * @param ownerNode The mesh that will be faded in/out once attached
  37737. */
  37738. attach(ownerNode: Mesh): void;
  37739. /**
  37740. * Detaches the behavior from the mesh
  37741. */
  37742. detach(): void;
  37743. /**
  37744. * Triggers the mesh to begin fading in or out
  37745. * @param value if the object should fade in or out (true to fade in)
  37746. */
  37747. fadeIn(value: boolean): void;
  37748. private _update;
  37749. private _setAllVisibility;
  37750. }
  37751. }
  37752. declare module "babylonjs/Misc/pivotTools" {
  37753. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37754. /**
  37755. * Class containing a set of static utilities functions for managing Pivots
  37756. * @hidden
  37757. */
  37758. export class PivotTools {
  37759. private static _PivotCached;
  37760. private static _OldPivotPoint;
  37761. private static _PivotTranslation;
  37762. private static _PivotTmpVector;
  37763. /** @hidden */
  37764. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37765. /** @hidden */
  37766. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37767. }
  37768. }
  37769. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37770. import { Scene } from "babylonjs/scene";
  37771. import { Vector4 } from "babylonjs/Maths/math.vector";
  37772. import { Mesh } from "babylonjs/Meshes/mesh";
  37773. import { Nullable } from "babylonjs/types";
  37774. import { Plane } from "babylonjs/Maths/math.plane";
  37775. /**
  37776. * Class containing static functions to help procedurally build meshes
  37777. */
  37778. export class PlaneBuilder {
  37779. /**
  37780. * Creates a plane mesh
  37781. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37782. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37783. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37784. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37785. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  37786. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37787. * @param name defines the name of the mesh
  37788. * @param options defines the options used to create the mesh
  37789. * @param scene defines the hosting scene
  37790. * @returns the plane mesh
  37791. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37792. */
  37793. static CreatePlane(name: string, options: {
  37794. size?: number;
  37795. width?: number;
  37796. height?: number;
  37797. sideOrientation?: number;
  37798. frontUVs?: Vector4;
  37799. backUVs?: Vector4;
  37800. updatable?: boolean;
  37801. sourcePlane?: Plane;
  37802. }, scene?: Nullable<Scene>): Mesh;
  37803. }
  37804. }
  37805. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  37806. import { Behavior } from "babylonjs/Behaviors/behavior";
  37807. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37808. import { Observable } from "babylonjs/Misc/observable";
  37809. import { Vector3 } from "babylonjs/Maths/math.vector";
  37810. import { Ray } from "babylonjs/Culling/ray";
  37811. import "babylonjs/Meshes/Builders/planeBuilder";
  37812. /**
  37813. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37814. */
  37815. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37816. private static _AnyMouseID;
  37817. /**
  37818. * Abstract mesh the behavior is set on
  37819. */
  37820. attachedNode: AbstractMesh;
  37821. private _dragPlane;
  37822. private _scene;
  37823. private _pointerObserver;
  37824. private _beforeRenderObserver;
  37825. private static _planeScene;
  37826. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37827. /**
  37828. * 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)
  37829. */
  37830. maxDragAngle: number;
  37831. /**
  37832. * @hidden
  37833. */
  37834. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37835. /**
  37836. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37837. */
  37838. currentDraggingPointerID: number;
  37839. /**
  37840. * The last position where the pointer hit the drag plane in world space
  37841. */
  37842. lastDragPosition: Vector3;
  37843. /**
  37844. * If the behavior is currently in a dragging state
  37845. */
  37846. dragging: boolean;
  37847. /**
  37848. * 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)
  37849. */
  37850. dragDeltaRatio: number;
  37851. /**
  37852. * If the drag plane orientation should be updated during the dragging (Default: true)
  37853. */
  37854. updateDragPlane: boolean;
  37855. private _debugMode;
  37856. private _moving;
  37857. /**
  37858. * Fires each time the attached mesh is dragged with the pointer
  37859. * * delta between last drag position and current drag position in world space
  37860. * * dragDistance along the drag axis
  37861. * * dragPlaneNormal normal of the current drag plane used during the drag
  37862. * * dragPlanePoint in world space where the drag intersects the drag plane
  37863. */
  37864. onDragObservable: Observable<{
  37865. delta: Vector3;
  37866. dragPlanePoint: Vector3;
  37867. dragPlaneNormal: Vector3;
  37868. dragDistance: number;
  37869. pointerId: number;
  37870. }>;
  37871. /**
  37872. * Fires each time a drag begins (eg. mouse down on mesh)
  37873. */
  37874. onDragStartObservable: Observable<{
  37875. dragPlanePoint: Vector3;
  37876. pointerId: number;
  37877. }>;
  37878. /**
  37879. * Fires each time a drag ends (eg. mouse release after drag)
  37880. */
  37881. onDragEndObservable: Observable<{
  37882. dragPlanePoint: Vector3;
  37883. pointerId: number;
  37884. }>;
  37885. /**
  37886. * If the attached mesh should be moved when dragged
  37887. */
  37888. moveAttached: boolean;
  37889. /**
  37890. * If the drag behavior will react to drag events (Default: true)
  37891. */
  37892. enabled: boolean;
  37893. /**
  37894. * If pointer events should start and release the drag (Default: true)
  37895. */
  37896. startAndReleaseDragOnPointerEvents: boolean;
  37897. /**
  37898. * If camera controls should be detached during the drag
  37899. */
  37900. detachCameraControls: boolean;
  37901. /**
  37902. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37903. */
  37904. useObjectOrienationForDragging: boolean;
  37905. private _options;
  37906. /**
  37907. * Creates a pointer drag behavior that can be attached to a mesh
  37908. * @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)
  37909. */
  37910. constructor(options?: {
  37911. dragAxis?: Vector3;
  37912. dragPlaneNormal?: Vector3;
  37913. });
  37914. /**
  37915. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37916. */
  37917. validateDrag: (targetPosition: Vector3) => boolean;
  37918. /**
  37919. * The name of the behavior
  37920. */
  37921. readonly name: string;
  37922. /**
  37923. * Initializes the behavior
  37924. */
  37925. init(): void;
  37926. private _tmpVector;
  37927. private _alternatePickedPoint;
  37928. private _worldDragAxis;
  37929. private _targetPosition;
  37930. private _attachedElement;
  37931. /**
  37932. * Attaches the drag behavior the passed in mesh
  37933. * @param ownerNode The mesh that will be dragged around once attached
  37934. * @param predicate Predicate to use for pick filtering
  37935. */
  37936. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  37937. /**
  37938. * Force relase the drag action by code.
  37939. */
  37940. releaseDrag(): void;
  37941. private _startDragRay;
  37942. private _lastPointerRay;
  37943. /**
  37944. * Simulates the start of a pointer drag event on the behavior
  37945. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37946. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37947. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37948. */
  37949. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37950. private _startDrag;
  37951. private _dragDelta;
  37952. private _moveDrag;
  37953. private _pickWithRayOnDragPlane;
  37954. private _pointA;
  37955. private _pointB;
  37956. private _pointC;
  37957. private _lineA;
  37958. private _lineB;
  37959. private _localAxis;
  37960. private _lookAt;
  37961. private _updateDragPlanePosition;
  37962. /**
  37963. * Detaches the behavior from the mesh
  37964. */
  37965. detach(): void;
  37966. }
  37967. }
  37968. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  37969. import { Mesh } from "babylonjs/Meshes/mesh";
  37970. import { Behavior } from "babylonjs/Behaviors/behavior";
  37971. /**
  37972. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37973. */
  37974. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37975. private _dragBehaviorA;
  37976. private _dragBehaviorB;
  37977. private _startDistance;
  37978. private _initialScale;
  37979. private _targetScale;
  37980. private _ownerNode;
  37981. private _sceneRenderObserver;
  37982. /**
  37983. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37984. */
  37985. constructor();
  37986. /**
  37987. * The name of the behavior
  37988. */
  37989. readonly name: string;
  37990. /**
  37991. * Initializes the behavior
  37992. */
  37993. init(): void;
  37994. private _getCurrentDistance;
  37995. /**
  37996. * Attaches the scale behavior the passed in mesh
  37997. * @param ownerNode The mesh that will be scaled around once attached
  37998. */
  37999. attach(ownerNode: Mesh): void;
  38000. /**
  38001. * Detaches the behavior from the mesh
  38002. */
  38003. detach(): void;
  38004. }
  38005. }
  38006. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  38007. import { Behavior } from "babylonjs/Behaviors/behavior";
  38008. import { Mesh } from "babylonjs/Meshes/mesh";
  38009. import { Observable } from "babylonjs/Misc/observable";
  38010. /**
  38011. * 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
  38012. */
  38013. export class SixDofDragBehavior implements Behavior<Mesh> {
  38014. private static _virtualScene;
  38015. private _ownerNode;
  38016. private _sceneRenderObserver;
  38017. private _scene;
  38018. private _targetPosition;
  38019. private _virtualOriginMesh;
  38020. private _virtualDragMesh;
  38021. private _pointerObserver;
  38022. private _moving;
  38023. private _startingOrientation;
  38024. /**
  38025. * 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)
  38026. */
  38027. private zDragFactor;
  38028. /**
  38029. * If the object should rotate to face the drag origin
  38030. */
  38031. rotateDraggedObject: boolean;
  38032. /**
  38033. * If the behavior is currently in a dragging state
  38034. */
  38035. dragging: boolean;
  38036. /**
  38037. * 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)
  38038. */
  38039. dragDeltaRatio: number;
  38040. /**
  38041. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38042. */
  38043. currentDraggingPointerID: number;
  38044. /**
  38045. * If camera controls should be detached during the drag
  38046. */
  38047. detachCameraControls: boolean;
  38048. /**
  38049. * Fires each time a drag starts
  38050. */
  38051. onDragStartObservable: Observable<{}>;
  38052. /**
  38053. * Fires each time a drag ends (eg. mouse release after drag)
  38054. */
  38055. onDragEndObservable: Observable<{}>;
  38056. /**
  38057. * 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
  38058. */
  38059. constructor();
  38060. /**
  38061. * The name of the behavior
  38062. */
  38063. readonly name: string;
  38064. /**
  38065. * Initializes the behavior
  38066. */
  38067. init(): void;
  38068. /**
  38069. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  38070. */
  38071. private readonly _pointerCamera;
  38072. /**
  38073. * Attaches the scale behavior the passed in mesh
  38074. * @param ownerNode The mesh that will be scaled around once attached
  38075. */
  38076. attach(ownerNode: Mesh): void;
  38077. /**
  38078. * Detaches the behavior from the mesh
  38079. */
  38080. detach(): void;
  38081. }
  38082. }
  38083. declare module "babylonjs/Behaviors/Meshes/index" {
  38084. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  38085. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  38086. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  38087. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  38088. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  38089. }
  38090. declare module "babylonjs/Behaviors/index" {
  38091. export * from "babylonjs/Behaviors/behavior";
  38092. export * from "babylonjs/Behaviors/Cameras/index";
  38093. export * from "babylonjs/Behaviors/Meshes/index";
  38094. }
  38095. declare module "babylonjs/Bones/boneIKController" {
  38096. import { Bone } from "babylonjs/Bones/bone";
  38097. import { Vector3 } from "babylonjs/Maths/math.vector";
  38098. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38099. import { Nullable } from "babylonjs/types";
  38100. /**
  38101. * Class used to apply inverse kinematics to bones
  38102. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38103. */
  38104. export class BoneIKController {
  38105. private static _tmpVecs;
  38106. private static _tmpQuat;
  38107. private static _tmpMats;
  38108. /**
  38109. * Gets or sets the target mesh
  38110. */
  38111. targetMesh: AbstractMesh;
  38112. /** Gets or sets the mesh used as pole */
  38113. poleTargetMesh: AbstractMesh;
  38114. /**
  38115. * Gets or sets the bone used as pole
  38116. */
  38117. poleTargetBone: Nullable<Bone>;
  38118. /**
  38119. * Gets or sets the target position
  38120. */
  38121. targetPosition: Vector3;
  38122. /**
  38123. * Gets or sets the pole target position
  38124. */
  38125. poleTargetPosition: Vector3;
  38126. /**
  38127. * Gets or sets the pole target local offset
  38128. */
  38129. poleTargetLocalOffset: Vector3;
  38130. /**
  38131. * Gets or sets the pole angle
  38132. */
  38133. poleAngle: number;
  38134. /**
  38135. * Gets or sets the mesh associated with the controller
  38136. */
  38137. mesh: AbstractMesh;
  38138. /**
  38139. * 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)
  38140. */
  38141. slerpAmount: number;
  38142. private _bone1Quat;
  38143. private _bone1Mat;
  38144. private _bone2Ang;
  38145. private _bone1;
  38146. private _bone2;
  38147. private _bone1Length;
  38148. private _bone2Length;
  38149. private _maxAngle;
  38150. private _maxReach;
  38151. private _rightHandedSystem;
  38152. private _bendAxis;
  38153. private _slerping;
  38154. private _adjustRoll;
  38155. /**
  38156. * Gets or sets maximum allowed angle
  38157. */
  38158. maxAngle: number;
  38159. /**
  38160. * Creates a new BoneIKController
  38161. * @param mesh defines the mesh to control
  38162. * @param bone defines the bone to control
  38163. * @param options defines options to set up the controller
  38164. */
  38165. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38166. targetMesh?: AbstractMesh;
  38167. poleTargetMesh?: AbstractMesh;
  38168. poleTargetBone?: Bone;
  38169. poleTargetLocalOffset?: Vector3;
  38170. poleAngle?: number;
  38171. bendAxis?: Vector3;
  38172. maxAngle?: number;
  38173. slerpAmount?: number;
  38174. });
  38175. private _setMaxAngle;
  38176. /**
  38177. * Force the controller to update the bones
  38178. */
  38179. update(): void;
  38180. }
  38181. }
  38182. declare module "babylonjs/Bones/boneLookController" {
  38183. import { Vector3 } from "babylonjs/Maths/math.vector";
  38184. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38185. import { Bone } from "babylonjs/Bones/bone";
  38186. import { Space } from "babylonjs/Maths/math.axis";
  38187. /**
  38188. * Class used to make a bone look toward a point in space
  38189. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38190. */
  38191. export class BoneLookController {
  38192. private static _tmpVecs;
  38193. private static _tmpQuat;
  38194. private static _tmpMats;
  38195. /**
  38196. * The target Vector3 that the bone will look at
  38197. */
  38198. target: Vector3;
  38199. /**
  38200. * The mesh that the bone is attached to
  38201. */
  38202. mesh: AbstractMesh;
  38203. /**
  38204. * The bone that will be looking to the target
  38205. */
  38206. bone: Bone;
  38207. /**
  38208. * The up axis of the coordinate system that is used when the bone is rotated
  38209. */
  38210. upAxis: Vector3;
  38211. /**
  38212. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38213. */
  38214. upAxisSpace: Space;
  38215. /**
  38216. * Used to make an adjustment to the yaw of the bone
  38217. */
  38218. adjustYaw: number;
  38219. /**
  38220. * Used to make an adjustment to the pitch of the bone
  38221. */
  38222. adjustPitch: number;
  38223. /**
  38224. * Used to make an adjustment to the roll of the bone
  38225. */
  38226. adjustRoll: number;
  38227. /**
  38228. * 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)
  38229. */
  38230. slerpAmount: number;
  38231. private _minYaw;
  38232. private _maxYaw;
  38233. private _minPitch;
  38234. private _maxPitch;
  38235. private _minYawSin;
  38236. private _minYawCos;
  38237. private _maxYawSin;
  38238. private _maxYawCos;
  38239. private _midYawConstraint;
  38240. private _minPitchTan;
  38241. private _maxPitchTan;
  38242. private _boneQuat;
  38243. private _slerping;
  38244. private _transformYawPitch;
  38245. private _transformYawPitchInv;
  38246. private _firstFrameSkipped;
  38247. private _yawRange;
  38248. private _fowardAxis;
  38249. /**
  38250. * Gets or sets the minimum yaw angle that the bone can look to
  38251. */
  38252. minYaw: number;
  38253. /**
  38254. * Gets or sets the maximum yaw angle that the bone can look to
  38255. */
  38256. maxYaw: number;
  38257. /**
  38258. * Gets or sets the minimum pitch angle that the bone can look to
  38259. */
  38260. minPitch: number;
  38261. /**
  38262. * Gets or sets the maximum pitch angle that the bone can look to
  38263. */
  38264. maxPitch: number;
  38265. /**
  38266. * Create a BoneLookController
  38267. * @param mesh the mesh that the bone belongs to
  38268. * @param bone the bone that will be looking to the target
  38269. * @param target the target Vector3 to look at
  38270. * @param options optional settings:
  38271. * * maxYaw: the maximum angle the bone will yaw to
  38272. * * minYaw: the minimum angle the bone will yaw to
  38273. * * maxPitch: the maximum angle the bone will pitch to
  38274. * * minPitch: the minimum angle the bone will yaw to
  38275. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38276. * * upAxis: the up axis of the coordinate system
  38277. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38278. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38279. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38280. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38281. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38282. * * adjustRoll: used to make an adjustment to the roll of the bone
  38283. **/
  38284. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38285. maxYaw?: number;
  38286. minYaw?: number;
  38287. maxPitch?: number;
  38288. minPitch?: number;
  38289. slerpAmount?: number;
  38290. upAxis?: Vector3;
  38291. upAxisSpace?: Space;
  38292. yawAxis?: Vector3;
  38293. pitchAxis?: Vector3;
  38294. adjustYaw?: number;
  38295. adjustPitch?: number;
  38296. adjustRoll?: number;
  38297. });
  38298. /**
  38299. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38300. */
  38301. update(): void;
  38302. private _getAngleDiff;
  38303. private _getAngleBetween;
  38304. private _isAngleBetween;
  38305. }
  38306. }
  38307. declare module "babylonjs/Bones/index" {
  38308. export * from "babylonjs/Bones/bone";
  38309. export * from "babylonjs/Bones/boneIKController";
  38310. export * from "babylonjs/Bones/boneLookController";
  38311. export * from "babylonjs/Bones/skeleton";
  38312. }
  38313. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38314. import { Nullable } from "babylonjs/types";
  38315. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38316. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38317. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38318. /**
  38319. * Manage the gamepad inputs to control an arc rotate camera.
  38320. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38321. */
  38322. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38323. /**
  38324. * Defines the camera the input is attached to.
  38325. */
  38326. camera: ArcRotateCamera;
  38327. /**
  38328. * Defines the gamepad the input is gathering event from.
  38329. */
  38330. gamepad: Nullable<Gamepad>;
  38331. /**
  38332. * Defines the gamepad rotation sensiblity.
  38333. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38334. */
  38335. gamepadRotationSensibility: number;
  38336. /**
  38337. * Defines the gamepad move sensiblity.
  38338. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38339. */
  38340. gamepadMoveSensibility: number;
  38341. private _onGamepadConnectedObserver;
  38342. private _onGamepadDisconnectedObserver;
  38343. /**
  38344. * Attach the input controls to a specific dom element to get the input from.
  38345. * @param element Defines the element the controls should be listened from
  38346. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38347. */
  38348. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38349. /**
  38350. * Detach the current controls from the specified dom element.
  38351. * @param element Defines the element to stop listening the inputs from
  38352. */
  38353. detachControl(element: Nullable<HTMLElement>): void;
  38354. /**
  38355. * Update the current camera state depending on the inputs that have been used this frame.
  38356. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38357. */
  38358. checkInputs(): void;
  38359. /**
  38360. * Gets the class name of the current intput.
  38361. * @returns the class name
  38362. */
  38363. getClassName(): string;
  38364. /**
  38365. * Get the friendly name associated with the input class.
  38366. * @returns the input friendly name
  38367. */
  38368. getSimpleName(): string;
  38369. }
  38370. }
  38371. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38372. import { Nullable } from "babylonjs/types";
  38373. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38374. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38375. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38376. interface ArcRotateCameraInputsManager {
  38377. /**
  38378. * Add orientation input support to the input manager.
  38379. * @returns the current input manager
  38380. */
  38381. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38382. }
  38383. }
  38384. /**
  38385. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38386. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38387. */
  38388. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38389. /**
  38390. * Defines the camera the input is attached to.
  38391. */
  38392. camera: ArcRotateCamera;
  38393. /**
  38394. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38395. */
  38396. alphaCorrection: number;
  38397. /**
  38398. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38399. */
  38400. gammaCorrection: number;
  38401. private _alpha;
  38402. private _gamma;
  38403. private _dirty;
  38404. private _deviceOrientationHandler;
  38405. /**
  38406. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38407. */
  38408. constructor();
  38409. /**
  38410. * Attach the input controls to a specific dom element to get the input from.
  38411. * @param element Defines the element the controls should be listened from
  38412. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38413. */
  38414. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38415. /** @hidden */
  38416. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38417. /**
  38418. * Update the current camera state depending on the inputs that have been used this frame.
  38419. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38420. */
  38421. checkInputs(): void;
  38422. /**
  38423. * Detach the current controls from the specified dom element.
  38424. * @param element Defines the element to stop listening the inputs from
  38425. */
  38426. detachControl(element: Nullable<HTMLElement>): void;
  38427. /**
  38428. * Gets the class name of the current intput.
  38429. * @returns the class name
  38430. */
  38431. getClassName(): string;
  38432. /**
  38433. * Get the friendly name associated with the input class.
  38434. * @returns the input friendly name
  38435. */
  38436. getSimpleName(): string;
  38437. }
  38438. }
  38439. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38440. import { Nullable } from "babylonjs/types";
  38441. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38442. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38443. /**
  38444. * Listen to mouse events to control the camera.
  38445. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38446. */
  38447. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38448. /**
  38449. * Defines the camera the input is attached to.
  38450. */
  38451. camera: FlyCamera;
  38452. /**
  38453. * Defines if touch is enabled. (Default is true.)
  38454. */
  38455. touchEnabled: boolean;
  38456. /**
  38457. * Defines the buttons associated with the input to handle camera rotation.
  38458. */
  38459. buttons: number[];
  38460. /**
  38461. * Assign buttons for Yaw control.
  38462. */
  38463. buttonsYaw: number[];
  38464. /**
  38465. * Assign buttons for Pitch control.
  38466. */
  38467. buttonsPitch: number[];
  38468. /**
  38469. * Assign buttons for Roll control.
  38470. */
  38471. buttonsRoll: number[];
  38472. /**
  38473. * Detect if any button is being pressed while mouse is moved.
  38474. * -1 = Mouse locked.
  38475. * 0 = Left button.
  38476. * 1 = Middle Button.
  38477. * 2 = Right Button.
  38478. */
  38479. activeButton: number;
  38480. /**
  38481. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38482. * Higher values reduce its sensitivity.
  38483. */
  38484. angularSensibility: number;
  38485. private _mousemoveCallback;
  38486. private _observer;
  38487. private _rollObserver;
  38488. private previousPosition;
  38489. private noPreventDefault;
  38490. private element;
  38491. /**
  38492. * Listen to mouse events to control the camera.
  38493. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38494. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38495. */
  38496. constructor(touchEnabled?: boolean);
  38497. /**
  38498. * Attach the mouse control to the HTML DOM element.
  38499. * @param element Defines the element that listens to the input events.
  38500. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38501. */
  38502. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38503. /**
  38504. * Detach the current controls from the specified dom element.
  38505. * @param element Defines the element to stop listening the inputs from
  38506. */
  38507. detachControl(element: Nullable<HTMLElement>): void;
  38508. /**
  38509. * Gets the class name of the current input.
  38510. * @returns the class name.
  38511. */
  38512. getClassName(): string;
  38513. /**
  38514. * Get the friendly name associated with the input class.
  38515. * @returns the input's friendly name.
  38516. */
  38517. getSimpleName(): string;
  38518. private _pointerInput;
  38519. private _onMouseMove;
  38520. /**
  38521. * Rotate camera by mouse offset.
  38522. */
  38523. private rotateCamera;
  38524. }
  38525. }
  38526. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38527. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38528. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38529. /**
  38530. * Default Inputs manager for the FlyCamera.
  38531. * It groups all the default supported inputs for ease of use.
  38532. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38533. */
  38534. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38535. /**
  38536. * Instantiates a new FlyCameraInputsManager.
  38537. * @param camera Defines the camera the inputs belong to.
  38538. */
  38539. constructor(camera: FlyCamera);
  38540. /**
  38541. * Add keyboard input support to the input manager.
  38542. * @returns the new FlyCameraKeyboardMoveInput().
  38543. */
  38544. addKeyboard(): FlyCameraInputsManager;
  38545. /**
  38546. * Add mouse input support to the input manager.
  38547. * @param touchEnabled Enable touch screen support.
  38548. * @returns the new FlyCameraMouseInput().
  38549. */
  38550. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38551. }
  38552. }
  38553. declare module "babylonjs/Cameras/flyCamera" {
  38554. import { Scene } from "babylonjs/scene";
  38555. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38556. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38557. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38558. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38559. /**
  38560. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38561. * such as in a 3D Space Shooter or a Flight Simulator.
  38562. */
  38563. export class FlyCamera extends TargetCamera {
  38564. /**
  38565. * Define the collision ellipsoid of the camera.
  38566. * This is helpful for simulating a camera body, like a player's body.
  38567. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38568. */
  38569. ellipsoid: Vector3;
  38570. /**
  38571. * Define an offset for the position of the ellipsoid around the camera.
  38572. * This can be helpful if the camera is attached away from the player's body center,
  38573. * such as at its head.
  38574. */
  38575. ellipsoidOffset: Vector3;
  38576. /**
  38577. * Enable or disable collisions of the camera with the rest of the scene objects.
  38578. */
  38579. checkCollisions: boolean;
  38580. /**
  38581. * Enable or disable gravity on the camera.
  38582. */
  38583. applyGravity: boolean;
  38584. /**
  38585. * Define the current direction the camera is moving to.
  38586. */
  38587. cameraDirection: Vector3;
  38588. /**
  38589. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38590. * This overrides and empties cameraRotation.
  38591. */
  38592. rotationQuaternion: Quaternion;
  38593. /**
  38594. * Track Roll to maintain the wanted Rolling when looking around.
  38595. */
  38596. _trackRoll: number;
  38597. /**
  38598. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38599. */
  38600. rollCorrect: number;
  38601. /**
  38602. * Mimic a banked turn, Rolling the camera when Yawing.
  38603. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38604. */
  38605. bankedTurn: boolean;
  38606. /**
  38607. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38608. */
  38609. bankedTurnLimit: number;
  38610. /**
  38611. * Value of 0 disables the banked Roll.
  38612. * Value of 1 is equal to the Yaw angle in radians.
  38613. */
  38614. bankedTurnMultiplier: number;
  38615. /**
  38616. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38617. */
  38618. inputs: FlyCameraInputsManager;
  38619. /**
  38620. * Gets the input sensibility for mouse input.
  38621. * Higher values reduce sensitivity.
  38622. */
  38623. /**
  38624. * Sets the input sensibility for a mouse input.
  38625. * Higher values reduce sensitivity.
  38626. */
  38627. angularSensibility: number;
  38628. /**
  38629. * Get the keys for camera movement forward.
  38630. */
  38631. /**
  38632. * Set the keys for camera movement forward.
  38633. */
  38634. keysForward: number[];
  38635. /**
  38636. * Get the keys for camera movement backward.
  38637. */
  38638. keysBackward: number[];
  38639. /**
  38640. * Get the keys for camera movement up.
  38641. */
  38642. /**
  38643. * Set the keys for camera movement up.
  38644. */
  38645. keysUp: number[];
  38646. /**
  38647. * Get the keys for camera movement down.
  38648. */
  38649. /**
  38650. * Set the keys for camera movement down.
  38651. */
  38652. keysDown: number[];
  38653. /**
  38654. * Get the keys for camera movement left.
  38655. */
  38656. /**
  38657. * Set the keys for camera movement left.
  38658. */
  38659. keysLeft: number[];
  38660. /**
  38661. * Set the keys for camera movement right.
  38662. */
  38663. /**
  38664. * Set the keys for camera movement right.
  38665. */
  38666. keysRight: number[];
  38667. /**
  38668. * Event raised when the camera collides with a mesh in the scene.
  38669. */
  38670. onCollide: (collidedMesh: AbstractMesh) => void;
  38671. private _collider;
  38672. private _needMoveForGravity;
  38673. private _oldPosition;
  38674. private _diffPosition;
  38675. private _newPosition;
  38676. /** @hidden */
  38677. _localDirection: Vector3;
  38678. /** @hidden */
  38679. _transformedDirection: Vector3;
  38680. /**
  38681. * Instantiates a FlyCamera.
  38682. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38683. * such as in a 3D Space Shooter or a Flight Simulator.
  38684. * @param name Define the name of the camera in the scene.
  38685. * @param position Define the starting position of the camera in the scene.
  38686. * @param scene Define the scene the camera belongs to.
  38687. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38688. */
  38689. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38690. /**
  38691. * Attach a control to the HTML DOM element.
  38692. * @param element Defines the element that listens to the input events.
  38693. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38694. */
  38695. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38696. /**
  38697. * Detach a control from the HTML DOM element.
  38698. * The camera will stop reacting to that input.
  38699. * @param element Defines the element that listens to the input events.
  38700. */
  38701. detachControl(element: HTMLElement): void;
  38702. private _collisionMask;
  38703. /**
  38704. * Get the mask that the camera ignores in collision events.
  38705. */
  38706. /**
  38707. * Set the mask that the camera ignores in collision events.
  38708. */
  38709. collisionMask: number;
  38710. /** @hidden */
  38711. _collideWithWorld(displacement: Vector3): void;
  38712. /** @hidden */
  38713. private _onCollisionPositionChange;
  38714. /** @hidden */
  38715. _checkInputs(): void;
  38716. /** @hidden */
  38717. _decideIfNeedsToMove(): boolean;
  38718. /** @hidden */
  38719. _updatePosition(): void;
  38720. /**
  38721. * Restore the Roll to its target value at the rate specified.
  38722. * @param rate - Higher means slower restoring.
  38723. * @hidden
  38724. */
  38725. restoreRoll(rate: number): void;
  38726. /**
  38727. * Destroy the camera and release the current resources held by it.
  38728. */
  38729. dispose(): void;
  38730. /**
  38731. * Get the current object class name.
  38732. * @returns the class name.
  38733. */
  38734. getClassName(): string;
  38735. }
  38736. }
  38737. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38738. import { Nullable } from "babylonjs/types";
  38739. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38740. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38741. /**
  38742. * Listen to keyboard events to control the camera.
  38743. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38744. */
  38745. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38746. /**
  38747. * Defines the camera the input is attached to.
  38748. */
  38749. camera: FlyCamera;
  38750. /**
  38751. * The list of keyboard keys used to control the forward move of the camera.
  38752. */
  38753. keysForward: number[];
  38754. /**
  38755. * The list of keyboard keys used to control the backward move of the camera.
  38756. */
  38757. keysBackward: number[];
  38758. /**
  38759. * The list of keyboard keys used to control the forward move of the camera.
  38760. */
  38761. keysUp: number[];
  38762. /**
  38763. * The list of keyboard keys used to control the backward move of the camera.
  38764. */
  38765. keysDown: number[];
  38766. /**
  38767. * The list of keyboard keys used to control the right strafe move of the camera.
  38768. */
  38769. keysRight: number[];
  38770. /**
  38771. * The list of keyboard keys used to control the left strafe move of the camera.
  38772. */
  38773. keysLeft: number[];
  38774. private _keys;
  38775. private _onCanvasBlurObserver;
  38776. private _onKeyboardObserver;
  38777. private _engine;
  38778. private _scene;
  38779. /**
  38780. * Attach the input controls to a specific dom element to get the input from.
  38781. * @param element Defines the element the controls should be listened from
  38782. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38783. */
  38784. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38785. /**
  38786. * Detach the current controls from the specified dom element.
  38787. * @param element Defines the element to stop listening the inputs from
  38788. */
  38789. detachControl(element: Nullable<HTMLElement>): void;
  38790. /**
  38791. * Gets the class name of the current intput.
  38792. * @returns the class name
  38793. */
  38794. getClassName(): string;
  38795. /** @hidden */
  38796. _onLostFocus(e: FocusEvent): void;
  38797. /**
  38798. * Get the friendly name associated with the input class.
  38799. * @returns the input friendly name
  38800. */
  38801. getSimpleName(): string;
  38802. /**
  38803. * Update the current camera state depending on the inputs that have been used this frame.
  38804. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38805. */
  38806. checkInputs(): void;
  38807. }
  38808. }
  38809. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  38810. import { Nullable } from "babylonjs/types";
  38811. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38812. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38813. /**
  38814. * Manage the mouse wheel inputs to control a follow camera.
  38815. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38816. */
  38817. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38818. /**
  38819. * Defines the camera the input is attached to.
  38820. */
  38821. camera: FollowCamera;
  38822. /**
  38823. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38824. */
  38825. axisControlRadius: boolean;
  38826. /**
  38827. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38828. */
  38829. axisControlHeight: boolean;
  38830. /**
  38831. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38832. */
  38833. axisControlRotation: boolean;
  38834. /**
  38835. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38836. * relation to mouseWheel events.
  38837. */
  38838. wheelPrecision: number;
  38839. /**
  38840. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38841. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38842. */
  38843. wheelDeltaPercentage: number;
  38844. private _wheel;
  38845. private _observer;
  38846. /**
  38847. * Attach the input controls to a specific dom element to get the input from.
  38848. * @param element Defines the element the controls should be listened from
  38849. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38850. */
  38851. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38852. /**
  38853. * Detach the current controls from the specified dom element.
  38854. * @param element Defines the element to stop listening the inputs from
  38855. */
  38856. detachControl(element: Nullable<HTMLElement>): void;
  38857. /**
  38858. * Gets the class name of the current intput.
  38859. * @returns the class name
  38860. */
  38861. getClassName(): string;
  38862. /**
  38863. * Get the friendly name associated with the input class.
  38864. * @returns the input friendly name
  38865. */
  38866. getSimpleName(): string;
  38867. }
  38868. }
  38869. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  38870. import { Nullable } from "babylonjs/types";
  38871. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38872. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38873. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38874. /**
  38875. * Manage the pointers inputs to control an follow camera.
  38876. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38877. */
  38878. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38879. /**
  38880. * Defines the camera the input is attached to.
  38881. */
  38882. camera: FollowCamera;
  38883. /**
  38884. * Gets the class name of the current input.
  38885. * @returns the class name
  38886. */
  38887. getClassName(): string;
  38888. /**
  38889. * Defines the pointer angular sensibility along the X axis or how fast is
  38890. * the camera rotating.
  38891. * A negative number will reverse the axis direction.
  38892. */
  38893. angularSensibilityX: number;
  38894. /**
  38895. * Defines the pointer angular sensibility along the Y axis or how fast is
  38896. * the camera rotating.
  38897. * A negative number will reverse the axis direction.
  38898. */
  38899. angularSensibilityY: number;
  38900. /**
  38901. * Defines the pointer pinch precision or how fast is the camera zooming.
  38902. * A negative number will reverse the axis direction.
  38903. */
  38904. pinchPrecision: number;
  38905. /**
  38906. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38907. * from 0.
  38908. * It defines the percentage of current camera.radius to use as delta when
  38909. * pinch zoom is used.
  38910. */
  38911. pinchDeltaPercentage: number;
  38912. /**
  38913. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38914. */
  38915. axisXControlRadius: boolean;
  38916. /**
  38917. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38918. */
  38919. axisXControlHeight: boolean;
  38920. /**
  38921. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38922. */
  38923. axisXControlRotation: boolean;
  38924. /**
  38925. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38926. */
  38927. axisYControlRadius: boolean;
  38928. /**
  38929. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38930. */
  38931. axisYControlHeight: boolean;
  38932. /**
  38933. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38934. */
  38935. axisYControlRotation: boolean;
  38936. /**
  38937. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38938. */
  38939. axisPinchControlRadius: boolean;
  38940. /**
  38941. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38942. */
  38943. axisPinchControlHeight: boolean;
  38944. /**
  38945. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38946. */
  38947. axisPinchControlRotation: boolean;
  38948. /**
  38949. * Log error messages if basic misconfiguration has occurred.
  38950. */
  38951. warningEnable: boolean;
  38952. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38953. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38954. private _warningCounter;
  38955. private _warning;
  38956. }
  38957. }
  38958. declare module "babylonjs/Cameras/followCameraInputsManager" {
  38959. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38960. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38961. /**
  38962. * Default Inputs manager for the FollowCamera.
  38963. * It groups all the default supported inputs for ease of use.
  38964. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38965. */
  38966. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38967. /**
  38968. * Instantiates a new FollowCameraInputsManager.
  38969. * @param camera Defines the camera the inputs belong to
  38970. */
  38971. constructor(camera: FollowCamera);
  38972. /**
  38973. * Add keyboard input support to the input manager.
  38974. * @returns the current input manager
  38975. */
  38976. addKeyboard(): FollowCameraInputsManager;
  38977. /**
  38978. * Add mouse wheel input support to the input manager.
  38979. * @returns the current input manager
  38980. */
  38981. addMouseWheel(): FollowCameraInputsManager;
  38982. /**
  38983. * Add pointers input support to the input manager.
  38984. * @returns the current input manager
  38985. */
  38986. addPointers(): FollowCameraInputsManager;
  38987. /**
  38988. * Add orientation input support to the input manager.
  38989. * @returns the current input manager
  38990. */
  38991. addVRDeviceOrientation(): FollowCameraInputsManager;
  38992. }
  38993. }
  38994. declare module "babylonjs/Cameras/followCamera" {
  38995. import { Nullable } from "babylonjs/types";
  38996. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38997. import { Scene } from "babylonjs/scene";
  38998. import { Vector3 } from "babylonjs/Maths/math.vector";
  38999. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39000. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  39001. /**
  39002. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39003. * an arc rotate version arcFollowCamera are available.
  39004. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39005. */
  39006. export class FollowCamera extends TargetCamera {
  39007. /**
  39008. * Distance the follow camera should follow an object at
  39009. */
  39010. radius: number;
  39011. /**
  39012. * Minimum allowed distance of the camera to the axis of rotation
  39013. * (The camera can not get closer).
  39014. * This can help limiting how the Camera is able to move in the scene.
  39015. */
  39016. lowerRadiusLimit: Nullable<number>;
  39017. /**
  39018. * Maximum allowed distance of the camera to the axis of rotation
  39019. * (The camera can not get further).
  39020. * This can help limiting how the Camera is able to move in the scene.
  39021. */
  39022. upperRadiusLimit: Nullable<number>;
  39023. /**
  39024. * Define a rotation offset between the camera and the object it follows
  39025. */
  39026. rotationOffset: number;
  39027. /**
  39028. * Minimum allowed angle to camera position relative to target object.
  39029. * This can help limiting how the Camera is able to move in the scene.
  39030. */
  39031. lowerRotationOffsetLimit: Nullable<number>;
  39032. /**
  39033. * Maximum allowed angle to camera position relative to target object.
  39034. * This can help limiting how the Camera is able to move in the scene.
  39035. */
  39036. upperRotationOffsetLimit: Nullable<number>;
  39037. /**
  39038. * Define a height offset between the camera and the object it follows.
  39039. * It can help following an object from the top (like a car chaing a plane)
  39040. */
  39041. heightOffset: number;
  39042. /**
  39043. * Minimum allowed height of camera position relative to target object.
  39044. * This can help limiting how the Camera is able to move in the scene.
  39045. */
  39046. lowerHeightOffsetLimit: Nullable<number>;
  39047. /**
  39048. * Maximum allowed height of camera position relative to target object.
  39049. * This can help limiting how the Camera is able to move in the scene.
  39050. */
  39051. upperHeightOffsetLimit: Nullable<number>;
  39052. /**
  39053. * Define how fast the camera can accelerate to follow it s target.
  39054. */
  39055. cameraAcceleration: number;
  39056. /**
  39057. * Define the speed limit of the camera following an object.
  39058. */
  39059. maxCameraSpeed: number;
  39060. /**
  39061. * Define the target of the camera.
  39062. */
  39063. lockedTarget: Nullable<AbstractMesh>;
  39064. /**
  39065. * Defines the input associated with the camera.
  39066. */
  39067. inputs: FollowCameraInputsManager;
  39068. /**
  39069. * Instantiates the follow camera.
  39070. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39071. * @param name Define the name of the camera in the scene
  39072. * @param position Define the position of the camera
  39073. * @param scene Define the scene the camera belong to
  39074. * @param lockedTarget Define the target of the camera
  39075. */
  39076. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39077. private _follow;
  39078. /**
  39079. * Attached controls to the current camera.
  39080. * @param element Defines the element the controls should be listened from
  39081. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39082. */
  39083. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39084. /**
  39085. * Detach the current controls from the camera.
  39086. * The camera will stop reacting to inputs.
  39087. * @param element Defines the element to stop listening the inputs from
  39088. */
  39089. detachControl(element: HTMLElement): void;
  39090. /** @hidden */
  39091. _checkInputs(): void;
  39092. private _checkLimits;
  39093. /**
  39094. * Gets the camera class name.
  39095. * @returns the class name
  39096. */
  39097. getClassName(): string;
  39098. }
  39099. /**
  39100. * Arc Rotate version of the follow camera.
  39101. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39102. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39103. */
  39104. export class ArcFollowCamera extends TargetCamera {
  39105. /** The longitudinal angle of the camera */
  39106. alpha: number;
  39107. /** The latitudinal angle of the camera */
  39108. beta: number;
  39109. /** The radius of the camera from its target */
  39110. radius: number;
  39111. /** Define the camera target (the messh it should follow) */
  39112. target: Nullable<AbstractMesh>;
  39113. private _cartesianCoordinates;
  39114. /**
  39115. * Instantiates a new ArcFollowCamera
  39116. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39117. * @param name Define the name of the camera
  39118. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39119. * @param beta Define the rotation angle of the camera around the elevation axis
  39120. * @param radius Define the radius of the camera from its target point
  39121. * @param target Define the target of the camera
  39122. * @param scene Define the scene the camera belongs to
  39123. */
  39124. constructor(name: string,
  39125. /** The longitudinal angle of the camera */
  39126. alpha: number,
  39127. /** The latitudinal angle of the camera */
  39128. beta: number,
  39129. /** The radius of the camera from its target */
  39130. radius: number,
  39131. /** Define the camera target (the messh it should follow) */
  39132. target: Nullable<AbstractMesh>, scene: Scene);
  39133. private _follow;
  39134. /** @hidden */
  39135. _checkInputs(): void;
  39136. /**
  39137. * Returns the class name of the object.
  39138. * It is mostly used internally for serialization purposes.
  39139. */
  39140. getClassName(): string;
  39141. }
  39142. }
  39143. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39144. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39145. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39146. import { Nullable } from "babylonjs/types";
  39147. /**
  39148. * Manage the keyboard inputs to control the movement of a follow camera.
  39149. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39150. */
  39151. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39152. /**
  39153. * Defines the camera the input is attached to.
  39154. */
  39155. camera: FollowCamera;
  39156. /**
  39157. * Defines the list of key codes associated with the up action (increase heightOffset)
  39158. */
  39159. keysHeightOffsetIncr: number[];
  39160. /**
  39161. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39162. */
  39163. keysHeightOffsetDecr: number[];
  39164. /**
  39165. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39166. */
  39167. keysHeightOffsetModifierAlt: boolean;
  39168. /**
  39169. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39170. */
  39171. keysHeightOffsetModifierCtrl: boolean;
  39172. /**
  39173. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39174. */
  39175. keysHeightOffsetModifierShift: boolean;
  39176. /**
  39177. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39178. */
  39179. keysRotationOffsetIncr: number[];
  39180. /**
  39181. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39182. */
  39183. keysRotationOffsetDecr: number[];
  39184. /**
  39185. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39186. */
  39187. keysRotationOffsetModifierAlt: boolean;
  39188. /**
  39189. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39190. */
  39191. keysRotationOffsetModifierCtrl: boolean;
  39192. /**
  39193. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39194. */
  39195. keysRotationOffsetModifierShift: boolean;
  39196. /**
  39197. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39198. */
  39199. keysRadiusIncr: number[];
  39200. /**
  39201. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39202. */
  39203. keysRadiusDecr: number[];
  39204. /**
  39205. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39206. */
  39207. keysRadiusModifierAlt: boolean;
  39208. /**
  39209. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39210. */
  39211. keysRadiusModifierCtrl: boolean;
  39212. /**
  39213. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39214. */
  39215. keysRadiusModifierShift: boolean;
  39216. /**
  39217. * Defines the rate of change of heightOffset.
  39218. */
  39219. heightSensibility: number;
  39220. /**
  39221. * Defines the rate of change of rotationOffset.
  39222. */
  39223. rotationSensibility: number;
  39224. /**
  39225. * Defines the rate of change of radius.
  39226. */
  39227. radiusSensibility: number;
  39228. private _keys;
  39229. private _ctrlPressed;
  39230. private _altPressed;
  39231. private _shiftPressed;
  39232. private _onCanvasBlurObserver;
  39233. private _onKeyboardObserver;
  39234. private _engine;
  39235. private _scene;
  39236. /**
  39237. * Attach the input controls to a specific dom element to get the input from.
  39238. * @param element Defines the element the controls should be listened from
  39239. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39240. */
  39241. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39242. /**
  39243. * Detach the current controls from the specified dom element.
  39244. * @param element Defines the element to stop listening the inputs from
  39245. */
  39246. detachControl(element: Nullable<HTMLElement>): void;
  39247. /**
  39248. * Update the current camera state depending on the inputs that have been used this frame.
  39249. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39250. */
  39251. checkInputs(): void;
  39252. /**
  39253. * Gets the class name of the current input.
  39254. * @returns the class name
  39255. */
  39256. getClassName(): string;
  39257. /**
  39258. * Get the friendly name associated with the input class.
  39259. * @returns the input friendly name
  39260. */
  39261. getSimpleName(): string;
  39262. /**
  39263. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39264. * allow modification of the heightOffset value.
  39265. */
  39266. private _modifierHeightOffset;
  39267. /**
  39268. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39269. * allow modification of the rotationOffset value.
  39270. */
  39271. private _modifierRotationOffset;
  39272. /**
  39273. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39274. * allow modification of the radius value.
  39275. */
  39276. private _modifierRadius;
  39277. }
  39278. }
  39279. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39280. import { Nullable } from "babylonjs/types";
  39281. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39282. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39283. import { Observable } from "babylonjs/Misc/observable";
  39284. module "babylonjs/Cameras/freeCameraInputsManager" {
  39285. interface FreeCameraInputsManager {
  39286. /**
  39287. * @hidden
  39288. */
  39289. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39290. /**
  39291. * Add orientation input support to the input manager.
  39292. * @returns the current input manager
  39293. */
  39294. addDeviceOrientation(): FreeCameraInputsManager;
  39295. }
  39296. }
  39297. /**
  39298. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39299. * Screen rotation is taken into account.
  39300. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39301. */
  39302. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39303. private _camera;
  39304. private _screenOrientationAngle;
  39305. private _constantTranform;
  39306. private _screenQuaternion;
  39307. private _alpha;
  39308. private _beta;
  39309. private _gamma;
  39310. /**
  39311. * Can be used to detect if a device orientation sensor is availible on a device
  39312. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39313. * @returns a promise that will resolve on orientation change
  39314. */
  39315. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39316. /**
  39317. * @hidden
  39318. */
  39319. _onDeviceOrientationChangedObservable: Observable<void>;
  39320. /**
  39321. * Instantiates a new input
  39322. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39323. */
  39324. constructor();
  39325. /**
  39326. * Define the camera controlled by the input.
  39327. */
  39328. camera: FreeCamera;
  39329. /**
  39330. * Attach the input controls to a specific dom element to get the input from.
  39331. * @param element Defines the element the controls should be listened from
  39332. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39333. */
  39334. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39335. private _orientationChanged;
  39336. private _deviceOrientation;
  39337. /**
  39338. * Detach the current controls from the specified dom element.
  39339. * @param element Defines the element to stop listening the inputs from
  39340. */
  39341. detachControl(element: Nullable<HTMLElement>): void;
  39342. /**
  39343. * Update the current camera state depending on the inputs that have been used this frame.
  39344. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39345. */
  39346. checkInputs(): void;
  39347. /**
  39348. * Gets the class name of the current intput.
  39349. * @returns the class name
  39350. */
  39351. getClassName(): string;
  39352. /**
  39353. * Get the friendly name associated with the input class.
  39354. * @returns the input friendly name
  39355. */
  39356. getSimpleName(): string;
  39357. }
  39358. }
  39359. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39360. import { Nullable } from "babylonjs/types";
  39361. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39362. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39363. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39364. /**
  39365. * Manage the gamepad inputs to control a free camera.
  39366. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39367. */
  39368. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39369. /**
  39370. * Define the camera the input is attached to.
  39371. */
  39372. camera: FreeCamera;
  39373. /**
  39374. * Define the Gamepad controlling the input
  39375. */
  39376. gamepad: Nullable<Gamepad>;
  39377. /**
  39378. * Defines the gamepad rotation sensiblity.
  39379. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39380. */
  39381. gamepadAngularSensibility: number;
  39382. /**
  39383. * Defines the gamepad move sensiblity.
  39384. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39385. */
  39386. gamepadMoveSensibility: number;
  39387. private _onGamepadConnectedObserver;
  39388. private _onGamepadDisconnectedObserver;
  39389. private _cameraTransform;
  39390. private _deltaTransform;
  39391. private _vector3;
  39392. private _vector2;
  39393. /**
  39394. * Attach the input controls to a specific dom element to get the input from.
  39395. * @param element Defines the element the controls should be listened from
  39396. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39397. */
  39398. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39399. /**
  39400. * Detach the current controls from the specified dom element.
  39401. * @param element Defines the element to stop listening the inputs from
  39402. */
  39403. detachControl(element: Nullable<HTMLElement>): void;
  39404. /**
  39405. * Update the current camera state depending on the inputs that have been used this frame.
  39406. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39407. */
  39408. checkInputs(): void;
  39409. /**
  39410. * Gets the class name of the current intput.
  39411. * @returns the class name
  39412. */
  39413. getClassName(): string;
  39414. /**
  39415. * Get the friendly name associated with the input class.
  39416. * @returns the input friendly name
  39417. */
  39418. getSimpleName(): string;
  39419. }
  39420. }
  39421. declare module "babylonjs/Misc/virtualJoystick" {
  39422. import { Nullable } from "babylonjs/types";
  39423. import { Vector3 } from "babylonjs/Maths/math.vector";
  39424. /**
  39425. * Defines the potential axis of a Joystick
  39426. */
  39427. export enum JoystickAxis {
  39428. /** X axis */
  39429. X = 0,
  39430. /** Y axis */
  39431. Y = 1,
  39432. /** Z axis */
  39433. Z = 2
  39434. }
  39435. /**
  39436. * Class used to define virtual joystick (used in touch mode)
  39437. */
  39438. export class VirtualJoystick {
  39439. /**
  39440. * Gets or sets a boolean indicating that left and right values must be inverted
  39441. */
  39442. reverseLeftRight: boolean;
  39443. /**
  39444. * Gets or sets a boolean indicating that up and down values must be inverted
  39445. */
  39446. reverseUpDown: boolean;
  39447. /**
  39448. * Gets the offset value for the position (ie. the change of the position value)
  39449. */
  39450. deltaPosition: Vector3;
  39451. /**
  39452. * Gets a boolean indicating if the virtual joystick was pressed
  39453. */
  39454. pressed: boolean;
  39455. /**
  39456. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39457. */
  39458. static Canvas: Nullable<HTMLCanvasElement>;
  39459. private static _globalJoystickIndex;
  39460. private static vjCanvasContext;
  39461. private static vjCanvasWidth;
  39462. private static vjCanvasHeight;
  39463. private static halfWidth;
  39464. private _action;
  39465. private _axisTargetedByLeftAndRight;
  39466. private _axisTargetedByUpAndDown;
  39467. private _joystickSensibility;
  39468. private _inversedSensibility;
  39469. private _joystickPointerID;
  39470. private _joystickColor;
  39471. private _joystickPointerPos;
  39472. private _joystickPreviousPointerPos;
  39473. private _joystickPointerStartPos;
  39474. private _deltaJoystickVector;
  39475. private _leftJoystick;
  39476. private _touches;
  39477. private _onPointerDownHandlerRef;
  39478. private _onPointerMoveHandlerRef;
  39479. private _onPointerUpHandlerRef;
  39480. private _onResize;
  39481. /**
  39482. * Creates a new virtual joystick
  39483. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39484. */
  39485. constructor(leftJoystick?: boolean);
  39486. /**
  39487. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39488. * @param newJoystickSensibility defines the new sensibility
  39489. */
  39490. setJoystickSensibility(newJoystickSensibility: number): void;
  39491. private _onPointerDown;
  39492. private _onPointerMove;
  39493. private _onPointerUp;
  39494. /**
  39495. * Change the color of the virtual joystick
  39496. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39497. */
  39498. setJoystickColor(newColor: string): void;
  39499. /**
  39500. * Defines a callback to call when the joystick is touched
  39501. * @param action defines the callback
  39502. */
  39503. setActionOnTouch(action: () => any): void;
  39504. /**
  39505. * Defines which axis you'd like to control for left & right
  39506. * @param axis defines the axis to use
  39507. */
  39508. setAxisForLeftRight(axis: JoystickAxis): void;
  39509. /**
  39510. * Defines which axis you'd like to control for up & down
  39511. * @param axis defines the axis to use
  39512. */
  39513. setAxisForUpDown(axis: JoystickAxis): void;
  39514. private _drawVirtualJoystick;
  39515. /**
  39516. * Release internal HTML canvas
  39517. */
  39518. releaseCanvas(): void;
  39519. }
  39520. }
  39521. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39522. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39523. import { Nullable } from "babylonjs/types";
  39524. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39525. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39526. module "babylonjs/Cameras/freeCameraInputsManager" {
  39527. interface FreeCameraInputsManager {
  39528. /**
  39529. * Add virtual joystick input support to the input manager.
  39530. * @returns the current input manager
  39531. */
  39532. addVirtualJoystick(): FreeCameraInputsManager;
  39533. }
  39534. }
  39535. /**
  39536. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39537. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39538. */
  39539. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39540. /**
  39541. * Defines the camera the input is attached to.
  39542. */
  39543. camera: FreeCamera;
  39544. private _leftjoystick;
  39545. private _rightjoystick;
  39546. /**
  39547. * Gets the left stick of the virtual joystick.
  39548. * @returns The virtual Joystick
  39549. */
  39550. getLeftJoystick(): VirtualJoystick;
  39551. /**
  39552. * Gets the right stick of the virtual joystick.
  39553. * @returns The virtual Joystick
  39554. */
  39555. getRightJoystick(): VirtualJoystick;
  39556. /**
  39557. * Update the current camera state depending on the inputs that have been used this frame.
  39558. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39559. */
  39560. checkInputs(): void;
  39561. /**
  39562. * Attach the input controls to a specific dom element to get the input from.
  39563. * @param element Defines the element the controls should be listened from
  39564. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39565. */
  39566. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39567. /**
  39568. * Detach the current controls from the specified dom element.
  39569. * @param element Defines the element to stop listening the inputs from
  39570. */
  39571. detachControl(element: Nullable<HTMLElement>): void;
  39572. /**
  39573. * Gets the class name of the current intput.
  39574. * @returns the class name
  39575. */
  39576. getClassName(): string;
  39577. /**
  39578. * Get the friendly name associated with the input class.
  39579. * @returns the input friendly name
  39580. */
  39581. getSimpleName(): string;
  39582. }
  39583. }
  39584. declare module "babylonjs/Cameras/Inputs/index" {
  39585. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39586. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39587. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39588. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39589. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39590. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39591. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39592. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39593. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39594. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39595. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39596. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39597. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39598. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39599. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39600. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39601. }
  39602. declare module "babylonjs/Cameras/touchCamera" {
  39603. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39604. import { Scene } from "babylonjs/scene";
  39605. import { Vector3 } from "babylonjs/Maths/math.vector";
  39606. /**
  39607. * This represents a FPS type of camera controlled by touch.
  39608. * This is like a universal camera minus the Gamepad controls.
  39609. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39610. */
  39611. export class TouchCamera extends FreeCamera {
  39612. /**
  39613. * Defines the touch sensibility for rotation.
  39614. * The higher the faster.
  39615. */
  39616. touchAngularSensibility: number;
  39617. /**
  39618. * Defines the touch sensibility for move.
  39619. * The higher the faster.
  39620. */
  39621. touchMoveSensibility: number;
  39622. /**
  39623. * Instantiates a new touch camera.
  39624. * This represents a FPS type of camera controlled by touch.
  39625. * This is like a universal camera minus the Gamepad controls.
  39626. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39627. * @param name Define the name of the camera in the scene
  39628. * @param position Define the start position of the camera in the scene
  39629. * @param scene Define the scene the camera belongs to
  39630. */
  39631. constructor(name: string, position: Vector3, scene: Scene);
  39632. /**
  39633. * Gets the current object class name.
  39634. * @return the class name
  39635. */
  39636. getClassName(): string;
  39637. /** @hidden */
  39638. _setupInputs(): void;
  39639. }
  39640. }
  39641. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39642. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39643. import { Scene } from "babylonjs/scene";
  39644. import { Vector3 } from "babylonjs/Maths/math.vector";
  39645. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39646. import { Axis } from "babylonjs/Maths/math.axis";
  39647. /**
  39648. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39649. * being tilted forward or back and left or right.
  39650. */
  39651. export class DeviceOrientationCamera extends FreeCamera {
  39652. private _initialQuaternion;
  39653. private _quaternionCache;
  39654. private _tmpDragQuaternion;
  39655. private _disablePointerInputWhenUsingDeviceOrientation;
  39656. /**
  39657. * Creates a new device orientation camera
  39658. * @param name The name of the camera
  39659. * @param position The start position camera
  39660. * @param scene The scene the camera belongs to
  39661. */
  39662. constructor(name: string, position: Vector3, scene: Scene);
  39663. /**
  39664. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  39665. */
  39666. disablePointerInputWhenUsingDeviceOrientation: boolean;
  39667. private _dragFactor;
  39668. /**
  39669. * Enabled turning on the y axis when the orientation sensor is active
  39670. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39671. */
  39672. enableHorizontalDragging(dragFactor?: number): void;
  39673. /**
  39674. * Gets the current instance class name ("DeviceOrientationCamera").
  39675. * This helps avoiding instanceof at run time.
  39676. * @returns the class name
  39677. */
  39678. getClassName(): string;
  39679. /**
  39680. * @hidden
  39681. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39682. */
  39683. _checkInputs(): void;
  39684. /**
  39685. * Reset the camera to its default orientation on the specified axis only.
  39686. * @param axis The axis to reset
  39687. */
  39688. resetToCurrentRotation(axis?: Axis): void;
  39689. }
  39690. }
  39691. declare module "babylonjs/Gamepads/xboxGamepad" {
  39692. import { Observable } from "babylonjs/Misc/observable";
  39693. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39694. /**
  39695. * Defines supported buttons for XBox360 compatible gamepads
  39696. */
  39697. export enum Xbox360Button {
  39698. /** A */
  39699. A = 0,
  39700. /** B */
  39701. B = 1,
  39702. /** X */
  39703. X = 2,
  39704. /** Y */
  39705. Y = 3,
  39706. /** Start */
  39707. Start = 4,
  39708. /** Back */
  39709. Back = 5,
  39710. /** Left button */
  39711. LB = 6,
  39712. /** Right button */
  39713. RB = 7,
  39714. /** Left stick */
  39715. LeftStick = 8,
  39716. /** Right stick */
  39717. RightStick = 9
  39718. }
  39719. /** Defines values for XBox360 DPad */
  39720. export enum Xbox360Dpad {
  39721. /** Up */
  39722. Up = 0,
  39723. /** Down */
  39724. Down = 1,
  39725. /** Left */
  39726. Left = 2,
  39727. /** Right */
  39728. Right = 3
  39729. }
  39730. /**
  39731. * Defines a XBox360 gamepad
  39732. */
  39733. export class Xbox360Pad extends Gamepad {
  39734. private _leftTrigger;
  39735. private _rightTrigger;
  39736. private _onlefttriggerchanged;
  39737. private _onrighttriggerchanged;
  39738. private _onbuttondown;
  39739. private _onbuttonup;
  39740. private _ondpaddown;
  39741. private _ondpadup;
  39742. /** Observable raised when a button is pressed */
  39743. onButtonDownObservable: Observable<Xbox360Button>;
  39744. /** Observable raised when a button is released */
  39745. onButtonUpObservable: Observable<Xbox360Button>;
  39746. /** Observable raised when a pad is pressed */
  39747. onPadDownObservable: Observable<Xbox360Dpad>;
  39748. /** Observable raised when a pad is released */
  39749. onPadUpObservable: Observable<Xbox360Dpad>;
  39750. private _buttonA;
  39751. private _buttonB;
  39752. private _buttonX;
  39753. private _buttonY;
  39754. private _buttonBack;
  39755. private _buttonStart;
  39756. private _buttonLB;
  39757. private _buttonRB;
  39758. private _buttonLeftStick;
  39759. private _buttonRightStick;
  39760. private _dPadUp;
  39761. private _dPadDown;
  39762. private _dPadLeft;
  39763. private _dPadRight;
  39764. private _isXboxOnePad;
  39765. /**
  39766. * Creates a new XBox360 gamepad object
  39767. * @param id defines the id of this gamepad
  39768. * @param index defines its index
  39769. * @param gamepad defines the internal HTML gamepad object
  39770. * @param xboxOne defines if it is a XBox One gamepad
  39771. */
  39772. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39773. /**
  39774. * Defines the callback to call when left trigger is pressed
  39775. * @param callback defines the callback to use
  39776. */
  39777. onlefttriggerchanged(callback: (value: number) => void): void;
  39778. /**
  39779. * Defines the callback to call when right trigger is pressed
  39780. * @param callback defines the callback to use
  39781. */
  39782. onrighttriggerchanged(callback: (value: number) => void): void;
  39783. /**
  39784. * Gets the left trigger value
  39785. */
  39786. /**
  39787. * Sets the left trigger value
  39788. */
  39789. leftTrigger: number;
  39790. /**
  39791. * Gets the right trigger value
  39792. */
  39793. /**
  39794. * Sets the right trigger value
  39795. */
  39796. rightTrigger: number;
  39797. /**
  39798. * Defines the callback to call when a button is pressed
  39799. * @param callback defines the callback to use
  39800. */
  39801. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39802. /**
  39803. * Defines the callback to call when a button is released
  39804. * @param callback defines the callback to use
  39805. */
  39806. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39807. /**
  39808. * Defines the callback to call when a pad is pressed
  39809. * @param callback defines the callback to use
  39810. */
  39811. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39812. /**
  39813. * Defines the callback to call when a pad is released
  39814. * @param callback defines the callback to use
  39815. */
  39816. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39817. private _setButtonValue;
  39818. private _setDPadValue;
  39819. /**
  39820. * Gets the value of the `A` button
  39821. */
  39822. /**
  39823. * Sets the value of the `A` button
  39824. */
  39825. buttonA: number;
  39826. /**
  39827. * Gets the value of the `B` button
  39828. */
  39829. /**
  39830. * Sets the value of the `B` button
  39831. */
  39832. buttonB: number;
  39833. /**
  39834. * Gets the value of the `X` button
  39835. */
  39836. /**
  39837. * Sets the value of the `X` button
  39838. */
  39839. buttonX: number;
  39840. /**
  39841. * Gets the value of the `Y` button
  39842. */
  39843. /**
  39844. * Sets the value of the `Y` button
  39845. */
  39846. buttonY: number;
  39847. /**
  39848. * Gets the value of the `Start` button
  39849. */
  39850. /**
  39851. * Sets the value of the `Start` button
  39852. */
  39853. buttonStart: number;
  39854. /**
  39855. * Gets the value of the `Back` button
  39856. */
  39857. /**
  39858. * Sets the value of the `Back` button
  39859. */
  39860. buttonBack: number;
  39861. /**
  39862. * Gets the value of the `Left` button
  39863. */
  39864. /**
  39865. * Sets the value of the `Left` button
  39866. */
  39867. buttonLB: number;
  39868. /**
  39869. * Gets the value of the `Right` button
  39870. */
  39871. /**
  39872. * Sets the value of the `Right` button
  39873. */
  39874. buttonRB: number;
  39875. /**
  39876. * Gets the value of the Left joystick
  39877. */
  39878. /**
  39879. * Sets the value of the Left joystick
  39880. */
  39881. buttonLeftStick: number;
  39882. /**
  39883. * Gets the value of the Right joystick
  39884. */
  39885. /**
  39886. * Sets the value of the Right joystick
  39887. */
  39888. buttonRightStick: number;
  39889. /**
  39890. * Gets the value of D-pad up
  39891. */
  39892. /**
  39893. * Sets the value of D-pad up
  39894. */
  39895. dPadUp: number;
  39896. /**
  39897. * Gets the value of D-pad down
  39898. */
  39899. /**
  39900. * Sets the value of D-pad down
  39901. */
  39902. dPadDown: number;
  39903. /**
  39904. * Gets the value of D-pad left
  39905. */
  39906. /**
  39907. * Sets the value of D-pad left
  39908. */
  39909. dPadLeft: number;
  39910. /**
  39911. * Gets the value of D-pad right
  39912. */
  39913. /**
  39914. * Sets the value of D-pad right
  39915. */
  39916. dPadRight: number;
  39917. /**
  39918. * Force the gamepad to synchronize with device values
  39919. */
  39920. update(): void;
  39921. /**
  39922. * Disposes the gamepad
  39923. */
  39924. dispose(): void;
  39925. }
  39926. }
  39927. declare module "babylonjs/Gamepads/dualShockGamepad" {
  39928. import { Observable } from "babylonjs/Misc/observable";
  39929. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39930. /**
  39931. * Defines supported buttons for DualShock compatible gamepads
  39932. */
  39933. export enum DualShockButton {
  39934. /** Cross */
  39935. Cross = 0,
  39936. /** Circle */
  39937. Circle = 1,
  39938. /** Square */
  39939. Square = 2,
  39940. /** Triangle */
  39941. Triangle = 3,
  39942. /** Options */
  39943. Options = 4,
  39944. /** Share */
  39945. Share = 5,
  39946. /** L1 */
  39947. L1 = 6,
  39948. /** R1 */
  39949. R1 = 7,
  39950. /** Left stick */
  39951. LeftStick = 8,
  39952. /** Right stick */
  39953. RightStick = 9
  39954. }
  39955. /** Defines values for DualShock DPad */
  39956. export enum DualShockDpad {
  39957. /** Up */
  39958. Up = 0,
  39959. /** Down */
  39960. Down = 1,
  39961. /** Left */
  39962. Left = 2,
  39963. /** Right */
  39964. Right = 3
  39965. }
  39966. /**
  39967. * Defines a DualShock gamepad
  39968. */
  39969. export class DualShockPad extends Gamepad {
  39970. private _leftTrigger;
  39971. private _rightTrigger;
  39972. private _onlefttriggerchanged;
  39973. private _onrighttriggerchanged;
  39974. private _onbuttondown;
  39975. private _onbuttonup;
  39976. private _ondpaddown;
  39977. private _ondpadup;
  39978. /** Observable raised when a button is pressed */
  39979. onButtonDownObservable: Observable<DualShockButton>;
  39980. /** Observable raised when a button is released */
  39981. onButtonUpObservable: Observable<DualShockButton>;
  39982. /** Observable raised when a pad is pressed */
  39983. onPadDownObservable: Observable<DualShockDpad>;
  39984. /** Observable raised when a pad is released */
  39985. onPadUpObservable: Observable<DualShockDpad>;
  39986. private _buttonCross;
  39987. private _buttonCircle;
  39988. private _buttonSquare;
  39989. private _buttonTriangle;
  39990. private _buttonShare;
  39991. private _buttonOptions;
  39992. private _buttonL1;
  39993. private _buttonR1;
  39994. private _buttonLeftStick;
  39995. private _buttonRightStick;
  39996. private _dPadUp;
  39997. private _dPadDown;
  39998. private _dPadLeft;
  39999. private _dPadRight;
  40000. /**
  40001. * Creates a new DualShock gamepad object
  40002. * @param id defines the id of this gamepad
  40003. * @param index defines its index
  40004. * @param gamepad defines the internal HTML gamepad object
  40005. */
  40006. constructor(id: string, index: number, gamepad: any);
  40007. /**
  40008. * Defines the callback to call when left trigger is pressed
  40009. * @param callback defines the callback to use
  40010. */
  40011. onlefttriggerchanged(callback: (value: number) => void): void;
  40012. /**
  40013. * Defines the callback to call when right trigger is pressed
  40014. * @param callback defines the callback to use
  40015. */
  40016. onrighttriggerchanged(callback: (value: number) => void): void;
  40017. /**
  40018. * Gets the left trigger value
  40019. */
  40020. /**
  40021. * Sets the left trigger value
  40022. */
  40023. leftTrigger: number;
  40024. /**
  40025. * Gets the right trigger value
  40026. */
  40027. /**
  40028. * Sets the right trigger value
  40029. */
  40030. rightTrigger: number;
  40031. /**
  40032. * Defines the callback to call when a button is pressed
  40033. * @param callback defines the callback to use
  40034. */
  40035. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40036. /**
  40037. * Defines the callback to call when a button is released
  40038. * @param callback defines the callback to use
  40039. */
  40040. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40041. /**
  40042. * Defines the callback to call when a pad is pressed
  40043. * @param callback defines the callback to use
  40044. */
  40045. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40046. /**
  40047. * Defines the callback to call when a pad is released
  40048. * @param callback defines the callback to use
  40049. */
  40050. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  40051. private _setButtonValue;
  40052. private _setDPadValue;
  40053. /**
  40054. * Gets the value of the `Cross` button
  40055. */
  40056. /**
  40057. * Sets the value of the `Cross` button
  40058. */
  40059. buttonCross: number;
  40060. /**
  40061. * Gets the value of the `Circle` button
  40062. */
  40063. /**
  40064. * Sets the value of the `Circle` button
  40065. */
  40066. buttonCircle: number;
  40067. /**
  40068. * Gets the value of the `Square` button
  40069. */
  40070. /**
  40071. * Sets the value of the `Square` button
  40072. */
  40073. buttonSquare: number;
  40074. /**
  40075. * Gets the value of the `Triangle` button
  40076. */
  40077. /**
  40078. * Sets the value of the `Triangle` button
  40079. */
  40080. buttonTriangle: number;
  40081. /**
  40082. * Gets the value of the `Options` button
  40083. */
  40084. /**
  40085. * Sets the value of the `Options` button
  40086. */
  40087. buttonOptions: number;
  40088. /**
  40089. * Gets the value of the `Share` button
  40090. */
  40091. /**
  40092. * Sets the value of the `Share` button
  40093. */
  40094. buttonShare: number;
  40095. /**
  40096. * Gets the value of the `L1` button
  40097. */
  40098. /**
  40099. * Sets the value of the `L1` button
  40100. */
  40101. buttonL1: number;
  40102. /**
  40103. * Gets the value of the `R1` button
  40104. */
  40105. /**
  40106. * Sets the value of the `R1` button
  40107. */
  40108. buttonR1: number;
  40109. /**
  40110. * Gets the value of the Left joystick
  40111. */
  40112. /**
  40113. * Sets the value of the Left joystick
  40114. */
  40115. buttonLeftStick: number;
  40116. /**
  40117. * Gets the value of the Right joystick
  40118. */
  40119. /**
  40120. * Sets the value of the Right joystick
  40121. */
  40122. buttonRightStick: number;
  40123. /**
  40124. * Gets the value of D-pad up
  40125. */
  40126. /**
  40127. * Sets the value of D-pad up
  40128. */
  40129. dPadUp: number;
  40130. /**
  40131. * Gets the value of D-pad down
  40132. */
  40133. /**
  40134. * Sets the value of D-pad down
  40135. */
  40136. dPadDown: number;
  40137. /**
  40138. * Gets the value of D-pad left
  40139. */
  40140. /**
  40141. * Sets the value of D-pad left
  40142. */
  40143. dPadLeft: number;
  40144. /**
  40145. * Gets the value of D-pad right
  40146. */
  40147. /**
  40148. * Sets the value of D-pad right
  40149. */
  40150. dPadRight: number;
  40151. /**
  40152. * Force the gamepad to synchronize with device values
  40153. */
  40154. update(): void;
  40155. /**
  40156. * Disposes the gamepad
  40157. */
  40158. dispose(): void;
  40159. }
  40160. }
  40161. declare module "babylonjs/Gamepads/gamepadManager" {
  40162. import { Observable } from "babylonjs/Misc/observable";
  40163. import { Nullable } from "babylonjs/types";
  40164. import { Scene } from "babylonjs/scene";
  40165. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40166. /**
  40167. * Manager for handling gamepads
  40168. */
  40169. export class GamepadManager {
  40170. private _scene?;
  40171. private _babylonGamepads;
  40172. private _oneGamepadConnected;
  40173. /** @hidden */
  40174. _isMonitoring: boolean;
  40175. private _gamepadEventSupported;
  40176. private _gamepadSupport;
  40177. /**
  40178. * observable to be triggered when the gamepad controller has been connected
  40179. */
  40180. onGamepadConnectedObservable: Observable<Gamepad>;
  40181. /**
  40182. * observable to be triggered when the gamepad controller has been disconnected
  40183. */
  40184. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40185. private _onGamepadConnectedEvent;
  40186. private _onGamepadDisconnectedEvent;
  40187. /**
  40188. * Initializes the gamepad manager
  40189. * @param _scene BabylonJS scene
  40190. */
  40191. constructor(_scene?: Scene | undefined);
  40192. /**
  40193. * The gamepads in the game pad manager
  40194. */
  40195. readonly gamepads: Gamepad[];
  40196. /**
  40197. * Get the gamepad controllers based on type
  40198. * @param type The type of gamepad controller
  40199. * @returns Nullable gamepad
  40200. */
  40201. getGamepadByType(type?: number): Nullable<Gamepad>;
  40202. /**
  40203. * Disposes the gamepad manager
  40204. */
  40205. dispose(): void;
  40206. private _addNewGamepad;
  40207. private _startMonitoringGamepads;
  40208. private _stopMonitoringGamepads;
  40209. /** @hidden */
  40210. _checkGamepadsStatus(): void;
  40211. private _updateGamepadObjects;
  40212. }
  40213. }
  40214. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40215. import { Nullable } from "babylonjs/types";
  40216. import { Scene } from "babylonjs/scene";
  40217. import { ISceneComponent } from "babylonjs/sceneComponent";
  40218. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40219. module "babylonjs/scene" {
  40220. interface Scene {
  40221. /** @hidden */
  40222. _gamepadManager: Nullable<GamepadManager>;
  40223. /**
  40224. * Gets the gamepad manager associated with the scene
  40225. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40226. */
  40227. gamepadManager: GamepadManager;
  40228. }
  40229. }
  40230. module "babylonjs/Cameras/freeCameraInputsManager" {
  40231. /**
  40232. * Interface representing a free camera inputs manager
  40233. */
  40234. interface FreeCameraInputsManager {
  40235. /**
  40236. * Adds gamepad input support to the FreeCameraInputsManager.
  40237. * @returns the FreeCameraInputsManager
  40238. */
  40239. addGamepad(): FreeCameraInputsManager;
  40240. }
  40241. }
  40242. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40243. /**
  40244. * Interface representing an arc rotate camera inputs manager
  40245. */
  40246. interface ArcRotateCameraInputsManager {
  40247. /**
  40248. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40249. * @returns the camera inputs manager
  40250. */
  40251. addGamepad(): ArcRotateCameraInputsManager;
  40252. }
  40253. }
  40254. /**
  40255. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40256. */
  40257. export class GamepadSystemSceneComponent implements ISceneComponent {
  40258. /**
  40259. * The component name helpfull to identify the component in the list of scene components.
  40260. */
  40261. readonly name: string;
  40262. /**
  40263. * The scene the component belongs to.
  40264. */
  40265. scene: Scene;
  40266. /**
  40267. * Creates a new instance of the component for the given scene
  40268. * @param scene Defines the scene to register the component in
  40269. */
  40270. constructor(scene: Scene);
  40271. /**
  40272. * Registers the component in a given scene
  40273. */
  40274. register(): void;
  40275. /**
  40276. * Rebuilds the elements related to this component in case of
  40277. * context lost for instance.
  40278. */
  40279. rebuild(): void;
  40280. /**
  40281. * Disposes the component and the associated ressources
  40282. */
  40283. dispose(): void;
  40284. private _beforeCameraUpdate;
  40285. }
  40286. }
  40287. declare module "babylonjs/Cameras/universalCamera" {
  40288. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40289. import { Scene } from "babylonjs/scene";
  40290. import { Vector3 } from "babylonjs/Maths/math.vector";
  40291. import "babylonjs/Gamepads/gamepadSceneComponent";
  40292. /**
  40293. * 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,
  40294. * which still works and will still be found in many Playgrounds.
  40295. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40296. */
  40297. export class UniversalCamera extends TouchCamera {
  40298. /**
  40299. * Defines the gamepad rotation sensiblity.
  40300. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40301. */
  40302. gamepadAngularSensibility: number;
  40303. /**
  40304. * Defines the gamepad move sensiblity.
  40305. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40306. */
  40307. gamepadMoveSensibility: number;
  40308. /**
  40309. * 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,
  40310. * which still works and will still be found in many Playgrounds.
  40311. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40312. * @param name Define the name of the camera in the scene
  40313. * @param position Define the start position of the camera in the scene
  40314. * @param scene Define the scene the camera belongs to
  40315. */
  40316. constructor(name: string, position: Vector3, scene: Scene);
  40317. /**
  40318. * Gets the current object class name.
  40319. * @return the class name
  40320. */
  40321. getClassName(): string;
  40322. }
  40323. }
  40324. declare module "babylonjs/Cameras/gamepadCamera" {
  40325. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40326. import { Scene } from "babylonjs/scene";
  40327. import { Vector3 } from "babylonjs/Maths/math.vector";
  40328. /**
  40329. * This represents a FPS type of camera. This is only here for back compat purpose.
  40330. * Please use the UniversalCamera instead as both are identical.
  40331. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40332. */
  40333. export class GamepadCamera extends UniversalCamera {
  40334. /**
  40335. * Instantiates a new Gamepad Camera
  40336. * This represents a FPS type of camera. This is only here for back compat purpose.
  40337. * Please use the UniversalCamera instead as both are identical.
  40338. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40339. * @param name Define the name of the camera in the scene
  40340. * @param position Define the start position of the camera in the scene
  40341. * @param scene Define the scene the camera belongs to
  40342. */
  40343. constructor(name: string, position: Vector3, scene: Scene);
  40344. /**
  40345. * Gets the current object class name.
  40346. * @return the class name
  40347. */
  40348. getClassName(): string;
  40349. }
  40350. }
  40351. declare module "babylonjs/Shaders/pass.fragment" {
  40352. /** @hidden */
  40353. export var passPixelShader: {
  40354. name: string;
  40355. shader: string;
  40356. };
  40357. }
  40358. declare module "babylonjs/Shaders/passCube.fragment" {
  40359. /** @hidden */
  40360. export var passCubePixelShader: {
  40361. name: string;
  40362. shader: string;
  40363. };
  40364. }
  40365. declare module "babylonjs/PostProcesses/passPostProcess" {
  40366. import { Nullable } from "babylonjs/types";
  40367. import { Camera } from "babylonjs/Cameras/camera";
  40368. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40369. import { Engine } from "babylonjs/Engines/engine";
  40370. import "babylonjs/Shaders/pass.fragment";
  40371. import "babylonjs/Shaders/passCube.fragment";
  40372. /**
  40373. * PassPostProcess which produces an output the same as it's input
  40374. */
  40375. export class PassPostProcess extends PostProcess {
  40376. /**
  40377. * Creates the PassPostProcess
  40378. * @param name The name of the effect.
  40379. * @param options The required width/height ratio to downsize to before computing the render pass.
  40380. * @param camera The camera to apply the render pass to.
  40381. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40382. * @param engine The engine which the post process will be applied. (default: current engine)
  40383. * @param reusable If the post process can be reused on the same frame. (default: false)
  40384. * @param textureType The type of texture to be used when performing the post processing.
  40385. * @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)
  40386. */
  40387. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40388. }
  40389. /**
  40390. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40391. */
  40392. export class PassCubePostProcess extends PostProcess {
  40393. private _face;
  40394. /**
  40395. * Gets or sets the cube face to display.
  40396. * * 0 is +X
  40397. * * 1 is -X
  40398. * * 2 is +Y
  40399. * * 3 is -Y
  40400. * * 4 is +Z
  40401. * * 5 is -Z
  40402. */
  40403. face: number;
  40404. /**
  40405. * Creates the PassCubePostProcess
  40406. * @param name The name of the effect.
  40407. * @param options The required width/height ratio to downsize to before computing the render pass.
  40408. * @param camera The camera to apply the render pass to.
  40409. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40410. * @param engine The engine which the post process will be applied. (default: current engine)
  40411. * @param reusable If the post process can be reused on the same frame. (default: false)
  40412. * @param textureType The type of texture to be used when performing the post processing.
  40413. * @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)
  40414. */
  40415. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40416. }
  40417. }
  40418. declare module "babylonjs/Shaders/anaglyph.fragment" {
  40419. /** @hidden */
  40420. export var anaglyphPixelShader: {
  40421. name: string;
  40422. shader: string;
  40423. };
  40424. }
  40425. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  40426. import { Engine } from "babylonjs/Engines/engine";
  40427. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40428. import { Camera } from "babylonjs/Cameras/camera";
  40429. import "babylonjs/Shaders/anaglyph.fragment";
  40430. /**
  40431. * Postprocess used to generate anaglyphic rendering
  40432. */
  40433. export class AnaglyphPostProcess extends PostProcess {
  40434. private _passedProcess;
  40435. /**
  40436. * Creates a new AnaglyphPostProcess
  40437. * @param name defines postprocess name
  40438. * @param options defines creation options or target ratio scale
  40439. * @param rigCameras defines cameras using this postprocess
  40440. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40441. * @param engine defines hosting engine
  40442. * @param reusable defines if the postprocess will be reused multiple times per frame
  40443. */
  40444. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40445. }
  40446. }
  40447. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  40448. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  40449. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40450. import { Scene } from "babylonjs/scene";
  40451. import { Vector3 } from "babylonjs/Maths/math.vector";
  40452. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40453. /**
  40454. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40455. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40456. */
  40457. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40458. /**
  40459. * Creates a new AnaglyphArcRotateCamera
  40460. * @param name defines camera name
  40461. * @param alpha defines alpha angle (in radians)
  40462. * @param beta defines beta angle (in radians)
  40463. * @param radius defines radius
  40464. * @param target defines camera target
  40465. * @param interaxialDistance defines distance between each color axis
  40466. * @param scene defines the hosting scene
  40467. */
  40468. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40469. /**
  40470. * Gets camera class name
  40471. * @returns AnaglyphArcRotateCamera
  40472. */
  40473. getClassName(): string;
  40474. }
  40475. }
  40476. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  40477. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40478. import { Scene } from "babylonjs/scene";
  40479. import { Vector3 } from "babylonjs/Maths/math.vector";
  40480. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40481. /**
  40482. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40483. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40484. */
  40485. export class AnaglyphFreeCamera extends FreeCamera {
  40486. /**
  40487. * Creates a new AnaglyphFreeCamera
  40488. * @param name defines camera name
  40489. * @param position defines initial position
  40490. * @param interaxialDistance defines distance between each color axis
  40491. * @param scene defines the hosting scene
  40492. */
  40493. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40494. /**
  40495. * Gets camera class name
  40496. * @returns AnaglyphFreeCamera
  40497. */
  40498. getClassName(): string;
  40499. }
  40500. }
  40501. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  40502. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40503. import { Scene } from "babylonjs/scene";
  40504. import { Vector3 } from "babylonjs/Maths/math.vector";
  40505. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40506. /**
  40507. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40508. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40509. */
  40510. export class AnaglyphGamepadCamera extends GamepadCamera {
  40511. /**
  40512. * Creates a new AnaglyphGamepadCamera
  40513. * @param name defines camera name
  40514. * @param position defines initial position
  40515. * @param interaxialDistance defines distance between each color axis
  40516. * @param scene defines the hosting scene
  40517. */
  40518. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40519. /**
  40520. * Gets camera class name
  40521. * @returns AnaglyphGamepadCamera
  40522. */
  40523. getClassName(): string;
  40524. }
  40525. }
  40526. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  40527. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40528. import { Scene } from "babylonjs/scene";
  40529. import { Vector3 } from "babylonjs/Maths/math.vector";
  40530. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40531. /**
  40532. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40533. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40534. */
  40535. export class AnaglyphUniversalCamera extends UniversalCamera {
  40536. /**
  40537. * Creates a new AnaglyphUniversalCamera
  40538. * @param name defines camera name
  40539. * @param position defines initial position
  40540. * @param interaxialDistance defines distance between each color axis
  40541. * @param scene defines the hosting scene
  40542. */
  40543. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40544. /**
  40545. * Gets camera class name
  40546. * @returns AnaglyphUniversalCamera
  40547. */
  40548. getClassName(): string;
  40549. }
  40550. }
  40551. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  40552. /** @hidden */
  40553. export var stereoscopicInterlacePixelShader: {
  40554. name: string;
  40555. shader: string;
  40556. };
  40557. }
  40558. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  40559. import { Camera } from "babylonjs/Cameras/camera";
  40560. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40561. import { Engine } from "babylonjs/Engines/engine";
  40562. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  40563. /**
  40564. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  40565. */
  40566. export class StereoscopicInterlacePostProcess extends PostProcess {
  40567. private _stepSize;
  40568. private _passedProcess;
  40569. /**
  40570. * Initializes a StereoscopicInterlacePostProcess
  40571. * @param name The name of the effect.
  40572. * @param rigCameras The rig cameras to be appled to the post process
  40573. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40574. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40575. * @param engine The engine which the post process will be applied. (default: current engine)
  40576. * @param reusable If the post process can be reused on the same frame. (default: false)
  40577. */
  40578. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40579. }
  40580. }
  40581. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40582. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40583. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40584. import { Scene } from "babylonjs/scene";
  40585. import { Vector3 } from "babylonjs/Maths/math.vector";
  40586. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40587. /**
  40588. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40589. * @see http://doc.babylonjs.com/features/cameras
  40590. */
  40591. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40592. /**
  40593. * Creates a new StereoscopicArcRotateCamera
  40594. * @param name defines camera name
  40595. * @param alpha defines alpha angle (in radians)
  40596. * @param beta defines beta angle (in radians)
  40597. * @param radius defines radius
  40598. * @param target defines camera target
  40599. * @param interaxialDistance defines distance between each color axis
  40600. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40601. * @param scene defines the hosting scene
  40602. */
  40603. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40604. /**
  40605. * Gets camera class name
  40606. * @returns StereoscopicArcRotateCamera
  40607. */
  40608. getClassName(): string;
  40609. }
  40610. }
  40611. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40612. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40613. import { Scene } from "babylonjs/scene";
  40614. import { Vector3 } from "babylonjs/Maths/math.vector";
  40615. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40616. /**
  40617. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40618. * @see http://doc.babylonjs.com/features/cameras
  40619. */
  40620. export class StereoscopicFreeCamera extends FreeCamera {
  40621. /**
  40622. * Creates a new StereoscopicFreeCamera
  40623. * @param name defines camera name
  40624. * @param position defines initial position
  40625. * @param interaxialDistance defines distance between each color axis
  40626. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40627. * @param scene defines the hosting scene
  40628. */
  40629. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40630. /**
  40631. * Gets camera class name
  40632. * @returns StereoscopicFreeCamera
  40633. */
  40634. getClassName(): string;
  40635. }
  40636. }
  40637. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40638. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40639. import { Scene } from "babylonjs/scene";
  40640. import { Vector3 } from "babylonjs/Maths/math.vector";
  40641. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40642. /**
  40643. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40644. * @see http://doc.babylonjs.com/features/cameras
  40645. */
  40646. export class StereoscopicGamepadCamera extends GamepadCamera {
  40647. /**
  40648. * Creates a new StereoscopicGamepadCamera
  40649. * @param name defines camera name
  40650. * @param position defines initial position
  40651. * @param interaxialDistance defines distance between each color axis
  40652. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40653. * @param scene defines the hosting scene
  40654. */
  40655. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40656. /**
  40657. * Gets camera class name
  40658. * @returns StereoscopicGamepadCamera
  40659. */
  40660. getClassName(): string;
  40661. }
  40662. }
  40663. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  40664. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40665. import { Scene } from "babylonjs/scene";
  40666. import { Vector3 } from "babylonjs/Maths/math.vector";
  40667. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40668. /**
  40669. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40670. * @see http://doc.babylonjs.com/features/cameras
  40671. */
  40672. export class StereoscopicUniversalCamera extends UniversalCamera {
  40673. /**
  40674. * Creates a new StereoscopicUniversalCamera
  40675. * @param name defines camera name
  40676. * @param position defines initial position
  40677. * @param interaxialDistance defines distance between each color axis
  40678. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40679. * @param scene defines the hosting scene
  40680. */
  40681. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40682. /**
  40683. * Gets camera class name
  40684. * @returns StereoscopicUniversalCamera
  40685. */
  40686. getClassName(): string;
  40687. }
  40688. }
  40689. declare module "babylonjs/Cameras/Stereoscopic/index" {
  40690. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  40691. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  40692. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  40693. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  40694. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  40695. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  40696. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  40697. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  40698. }
  40699. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  40700. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40701. import { Scene } from "babylonjs/scene";
  40702. import { Vector3 } from "babylonjs/Maths/math.vector";
  40703. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40704. /**
  40705. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  40706. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40707. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40708. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40709. */
  40710. export class VirtualJoysticksCamera extends FreeCamera {
  40711. /**
  40712. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  40713. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40714. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40715. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40716. * @param name Define the name of the camera in the scene
  40717. * @param position Define the start position of the camera in the scene
  40718. * @param scene Define the scene the camera belongs to
  40719. */
  40720. constructor(name: string, position: Vector3, scene: Scene);
  40721. /**
  40722. * Gets the current object class name.
  40723. * @return the class name
  40724. */
  40725. getClassName(): string;
  40726. }
  40727. }
  40728. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  40729. import { Matrix } from "babylonjs/Maths/math.vector";
  40730. /**
  40731. * This represents all the required metrics to create a VR camera.
  40732. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  40733. */
  40734. export class VRCameraMetrics {
  40735. /**
  40736. * Define the horizontal resolution off the screen.
  40737. */
  40738. hResolution: number;
  40739. /**
  40740. * Define the vertical resolution off the screen.
  40741. */
  40742. vResolution: number;
  40743. /**
  40744. * Define the horizontal screen size.
  40745. */
  40746. hScreenSize: number;
  40747. /**
  40748. * Define the vertical screen size.
  40749. */
  40750. vScreenSize: number;
  40751. /**
  40752. * Define the vertical screen center position.
  40753. */
  40754. vScreenCenter: number;
  40755. /**
  40756. * Define the distance of the eyes to the screen.
  40757. */
  40758. eyeToScreenDistance: number;
  40759. /**
  40760. * Define the distance between both lenses
  40761. */
  40762. lensSeparationDistance: number;
  40763. /**
  40764. * Define the distance between both viewer's eyes.
  40765. */
  40766. interpupillaryDistance: number;
  40767. /**
  40768. * Define the distortion factor of the VR postprocess.
  40769. * Please, touch with care.
  40770. */
  40771. distortionK: number[];
  40772. /**
  40773. * Define the chromatic aberration correction factors for the VR post process.
  40774. */
  40775. chromaAbCorrection: number[];
  40776. /**
  40777. * Define the scale factor of the post process.
  40778. * The smaller the better but the slower.
  40779. */
  40780. postProcessScaleFactor: number;
  40781. /**
  40782. * Define an offset for the lens center.
  40783. */
  40784. lensCenterOffset: number;
  40785. /**
  40786. * Define if the current vr camera should compensate the distortion of the lense or not.
  40787. */
  40788. compensateDistortion: boolean;
  40789. /**
  40790. * Defines if multiview should be enabled when rendering (Default: false)
  40791. */
  40792. multiviewEnabled: boolean;
  40793. /**
  40794. * Gets the rendering aspect ratio based on the provided resolutions.
  40795. */
  40796. readonly aspectRatio: number;
  40797. /**
  40798. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  40799. */
  40800. readonly aspectRatioFov: number;
  40801. /**
  40802. * @hidden
  40803. */
  40804. readonly leftHMatrix: Matrix;
  40805. /**
  40806. * @hidden
  40807. */
  40808. readonly rightHMatrix: Matrix;
  40809. /**
  40810. * @hidden
  40811. */
  40812. readonly leftPreViewMatrix: Matrix;
  40813. /**
  40814. * @hidden
  40815. */
  40816. readonly rightPreViewMatrix: Matrix;
  40817. /**
  40818. * Get the default VRMetrics based on the most generic setup.
  40819. * @returns the default vr metrics
  40820. */
  40821. static GetDefault(): VRCameraMetrics;
  40822. }
  40823. }
  40824. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  40825. /** @hidden */
  40826. export var vrDistortionCorrectionPixelShader: {
  40827. name: string;
  40828. shader: string;
  40829. };
  40830. }
  40831. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  40832. import { Camera } from "babylonjs/Cameras/camera";
  40833. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40834. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40835. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  40836. /**
  40837. * VRDistortionCorrectionPostProcess used for mobile VR
  40838. */
  40839. export class VRDistortionCorrectionPostProcess extends PostProcess {
  40840. private _isRightEye;
  40841. private _distortionFactors;
  40842. private _postProcessScaleFactor;
  40843. private _lensCenterOffset;
  40844. private _scaleIn;
  40845. private _scaleFactor;
  40846. private _lensCenter;
  40847. /**
  40848. * Initializes the VRDistortionCorrectionPostProcess
  40849. * @param name The name of the effect.
  40850. * @param camera The camera to apply the render pass to.
  40851. * @param isRightEye If this is for the right eye distortion
  40852. * @param vrMetrics All the required metrics for the VR camera
  40853. */
  40854. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  40855. }
  40856. }
  40857. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  40858. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  40859. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40860. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40861. import { Scene } from "babylonjs/scene";
  40862. import { Vector3 } from "babylonjs/Maths/math.vector";
  40863. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  40864. import "babylonjs/Cameras/RigModes/vrRigMode";
  40865. /**
  40866. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  40867. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40868. */
  40869. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  40870. /**
  40871. * Creates a new VRDeviceOrientationArcRotateCamera
  40872. * @param name defines camera name
  40873. * @param alpha defines the camera rotation along the logitudinal axis
  40874. * @param beta defines the camera rotation along the latitudinal axis
  40875. * @param radius defines the camera distance from its target
  40876. * @param target defines the camera target
  40877. * @param scene defines the scene the camera belongs to
  40878. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40879. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40880. */
  40881. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40882. /**
  40883. * Gets camera class name
  40884. * @returns VRDeviceOrientationArcRotateCamera
  40885. */
  40886. getClassName(): string;
  40887. }
  40888. }
  40889. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  40890. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40891. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40892. import { Scene } from "babylonjs/scene";
  40893. import { Vector3 } from "babylonjs/Maths/math.vector";
  40894. import "babylonjs/Cameras/RigModes/vrRigMode";
  40895. /**
  40896. * Camera used to simulate VR rendering (based on FreeCamera)
  40897. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40898. */
  40899. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  40900. /**
  40901. * Creates a new VRDeviceOrientationFreeCamera
  40902. * @param name defines camera name
  40903. * @param position defines the start position of the camera
  40904. * @param scene defines the scene the camera belongs to
  40905. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40906. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40907. */
  40908. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40909. /**
  40910. * Gets camera class name
  40911. * @returns VRDeviceOrientationFreeCamera
  40912. */
  40913. getClassName(): string;
  40914. }
  40915. }
  40916. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  40917. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40918. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40919. import { Scene } from "babylonjs/scene";
  40920. import { Vector3 } from "babylonjs/Maths/math.vector";
  40921. import "babylonjs/Gamepads/gamepadSceneComponent";
  40922. /**
  40923. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  40924. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40925. */
  40926. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  40927. /**
  40928. * Creates a new VRDeviceOrientationGamepadCamera
  40929. * @param name defines camera name
  40930. * @param position defines the start position of the camera
  40931. * @param scene defines the scene the camera belongs to
  40932. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40933. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40934. */
  40935. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40936. /**
  40937. * Gets camera class name
  40938. * @returns VRDeviceOrientationGamepadCamera
  40939. */
  40940. getClassName(): string;
  40941. }
  40942. }
  40943. declare module "babylonjs/Materials/pushMaterial" {
  40944. import { Nullable } from "babylonjs/types";
  40945. import { Scene } from "babylonjs/scene";
  40946. import { Matrix } from "babylonjs/Maths/math.vector";
  40947. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40948. import { Mesh } from "babylonjs/Meshes/mesh";
  40949. import { Material } from "babylonjs/Materials/material";
  40950. import { Effect } from "babylonjs/Materials/effect";
  40951. /**
  40952. * Base class of materials working in push mode in babylon JS
  40953. * @hidden
  40954. */
  40955. export class PushMaterial extends Material {
  40956. protected _activeEffect: Effect;
  40957. protected _normalMatrix: Matrix;
  40958. /**
  40959. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  40960. * This means that the material can keep using a previous shader while a new one is being compiled.
  40961. * This is mostly used when shader parallel compilation is supported (true by default)
  40962. */
  40963. allowShaderHotSwapping: boolean;
  40964. constructor(name: string, scene: Scene);
  40965. getEffect(): Effect;
  40966. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  40967. /**
  40968. * Binds the given world matrix to the active effect
  40969. *
  40970. * @param world the matrix to bind
  40971. */
  40972. bindOnlyWorldMatrix(world: Matrix): void;
  40973. /**
  40974. * Binds the given normal matrix to the active effect
  40975. *
  40976. * @param normalMatrix the matrix to bind
  40977. */
  40978. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  40979. bind(world: Matrix, mesh?: Mesh): void;
  40980. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  40981. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  40982. }
  40983. }
  40984. declare module "babylonjs/Materials/materialFlags" {
  40985. /**
  40986. * This groups all the flags used to control the materials channel.
  40987. */
  40988. export class MaterialFlags {
  40989. private static _DiffuseTextureEnabled;
  40990. /**
  40991. * Are diffuse textures enabled in the application.
  40992. */
  40993. static DiffuseTextureEnabled: boolean;
  40994. private static _AmbientTextureEnabled;
  40995. /**
  40996. * Are ambient textures enabled in the application.
  40997. */
  40998. static AmbientTextureEnabled: boolean;
  40999. private static _OpacityTextureEnabled;
  41000. /**
  41001. * Are opacity textures enabled in the application.
  41002. */
  41003. static OpacityTextureEnabled: boolean;
  41004. private static _ReflectionTextureEnabled;
  41005. /**
  41006. * Are reflection textures enabled in the application.
  41007. */
  41008. static ReflectionTextureEnabled: boolean;
  41009. private static _EmissiveTextureEnabled;
  41010. /**
  41011. * Are emissive textures enabled in the application.
  41012. */
  41013. static EmissiveTextureEnabled: boolean;
  41014. private static _SpecularTextureEnabled;
  41015. /**
  41016. * Are specular textures enabled in the application.
  41017. */
  41018. static SpecularTextureEnabled: boolean;
  41019. private static _BumpTextureEnabled;
  41020. /**
  41021. * Are bump textures enabled in the application.
  41022. */
  41023. static BumpTextureEnabled: boolean;
  41024. private static _LightmapTextureEnabled;
  41025. /**
  41026. * Are lightmap textures enabled in the application.
  41027. */
  41028. static LightmapTextureEnabled: boolean;
  41029. private static _RefractionTextureEnabled;
  41030. /**
  41031. * Are refraction textures enabled in the application.
  41032. */
  41033. static RefractionTextureEnabled: boolean;
  41034. private static _ColorGradingTextureEnabled;
  41035. /**
  41036. * Are color grading textures enabled in the application.
  41037. */
  41038. static ColorGradingTextureEnabled: boolean;
  41039. private static _FresnelEnabled;
  41040. /**
  41041. * Are fresnels enabled in the application.
  41042. */
  41043. static FresnelEnabled: boolean;
  41044. private static _ClearCoatTextureEnabled;
  41045. /**
  41046. * Are clear coat textures enabled in the application.
  41047. */
  41048. static ClearCoatTextureEnabled: boolean;
  41049. private static _ClearCoatBumpTextureEnabled;
  41050. /**
  41051. * Are clear coat bump textures enabled in the application.
  41052. */
  41053. static ClearCoatBumpTextureEnabled: boolean;
  41054. private static _ClearCoatTintTextureEnabled;
  41055. /**
  41056. * Are clear coat tint textures enabled in the application.
  41057. */
  41058. static ClearCoatTintTextureEnabled: boolean;
  41059. private static _SheenTextureEnabled;
  41060. /**
  41061. * Are sheen textures enabled in the application.
  41062. */
  41063. static SheenTextureEnabled: boolean;
  41064. private static _AnisotropicTextureEnabled;
  41065. /**
  41066. * Are anisotropic textures enabled in the application.
  41067. */
  41068. static AnisotropicTextureEnabled: boolean;
  41069. private static _ThicknessTextureEnabled;
  41070. /**
  41071. * Are thickness textures enabled in the application.
  41072. */
  41073. static ThicknessTextureEnabled: boolean;
  41074. }
  41075. }
  41076. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  41077. /** @hidden */
  41078. export var defaultFragmentDeclaration: {
  41079. name: string;
  41080. shader: string;
  41081. };
  41082. }
  41083. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  41084. /** @hidden */
  41085. export var defaultUboDeclaration: {
  41086. name: string;
  41087. shader: string;
  41088. };
  41089. }
  41090. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  41091. /** @hidden */
  41092. export var lightFragmentDeclaration: {
  41093. name: string;
  41094. shader: string;
  41095. };
  41096. }
  41097. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  41098. /** @hidden */
  41099. export var lightUboDeclaration: {
  41100. name: string;
  41101. shader: string;
  41102. };
  41103. }
  41104. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  41105. /** @hidden */
  41106. export var lightsFragmentFunctions: {
  41107. name: string;
  41108. shader: string;
  41109. };
  41110. }
  41111. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  41112. /** @hidden */
  41113. export var shadowsFragmentFunctions: {
  41114. name: string;
  41115. shader: string;
  41116. };
  41117. }
  41118. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  41119. /** @hidden */
  41120. export var fresnelFunction: {
  41121. name: string;
  41122. shader: string;
  41123. };
  41124. }
  41125. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  41126. /** @hidden */
  41127. export var reflectionFunction: {
  41128. name: string;
  41129. shader: string;
  41130. };
  41131. }
  41132. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41133. /** @hidden */
  41134. export var bumpFragmentFunctions: {
  41135. name: string;
  41136. shader: string;
  41137. };
  41138. }
  41139. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41140. /** @hidden */
  41141. export var logDepthDeclaration: {
  41142. name: string;
  41143. shader: string;
  41144. };
  41145. }
  41146. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41147. /** @hidden */
  41148. export var bumpFragment: {
  41149. name: string;
  41150. shader: string;
  41151. };
  41152. }
  41153. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41154. /** @hidden */
  41155. export var depthPrePass: {
  41156. name: string;
  41157. shader: string;
  41158. };
  41159. }
  41160. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41161. /** @hidden */
  41162. export var lightFragment: {
  41163. name: string;
  41164. shader: string;
  41165. };
  41166. }
  41167. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41168. /** @hidden */
  41169. export var logDepthFragment: {
  41170. name: string;
  41171. shader: string;
  41172. };
  41173. }
  41174. declare module "babylonjs/Shaders/default.fragment" {
  41175. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41176. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41177. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41178. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41179. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41180. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41181. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41182. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41183. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41184. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41185. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41186. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41187. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41188. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41189. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41190. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41191. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41192. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41193. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41194. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41195. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41196. /** @hidden */
  41197. export var defaultPixelShader: {
  41198. name: string;
  41199. shader: string;
  41200. };
  41201. }
  41202. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41203. /** @hidden */
  41204. export var defaultVertexDeclaration: {
  41205. name: string;
  41206. shader: string;
  41207. };
  41208. }
  41209. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41210. /** @hidden */
  41211. export var bumpVertexDeclaration: {
  41212. name: string;
  41213. shader: string;
  41214. };
  41215. }
  41216. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41217. /** @hidden */
  41218. export var bumpVertex: {
  41219. name: string;
  41220. shader: string;
  41221. };
  41222. }
  41223. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41224. /** @hidden */
  41225. export var fogVertex: {
  41226. name: string;
  41227. shader: string;
  41228. };
  41229. }
  41230. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41231. /** @hidden */
  41232. export var shadowsVertex: {
  41233. name: string;
  41234. shader: string;
  41235. };
  41236. }
  41237. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41238. /** @hidden */
  41239. export var pointCloudVertex: {
  41240. name: string;
  41241. shader: string;
  41242. };
  41243. }
  41244. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41245. /** @hidden */
  41246. export var logDepthVertex: {
  41247. name: string;
  41248. shader: string;
  41249. };
  41250. }
  41251. declare module "babylonjs/Shaders/default.vertex" {
  41252. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41253. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41254. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41255. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41256. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41257. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41258. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41259. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41260. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41261. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41262. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41263. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41264. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41265. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41266. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41267. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41268. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41269. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41270. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41271. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41272. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41273. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41274. /** @hidden */
  41275. export var defaultVertexShader: {
  41276. name: string;
  41277. shader: string;
  41278. };
  41279. }
  41280. declare module "babylonjs/Materials/standardMaterial" {
  41281. import { SmartArray } from "babylonjs/Misc/smartArray";
  41282. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41283. import { Nullable } from "babylonjs/types";
  41284. import { Scene } from "babylonjs/scene";
  41285. import { Matrix } from "babylonjs/Maths/math.vector";
  41286. import { Color3 } from "babylonjs/Maths/math.color";
  41287. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41288. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41289. import { Mesh } from "babylonjs/Meshes/mesh";
  41290. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41291. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41292. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41293. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41294. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41295. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41296. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41297. import "babylonjs/Shaders/default.fragment";
  41298. import "babylonjs/Shaders/default.vertex";
  41299. /** @hidden */
  41300. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41301. MAINUV1: boolean;
  41302. MAINUV2: boolean;
  41303. DIFFUSE: boolean;
  41304. DIFFUSEDIRECTUV: number;
  41305. AMBIENT: boolean;
  41306. AMBIENTDIRECTUV: number;
  41307. OPACITY: boolean;
  41308. OPACITYDIRECTUV: number;
  41309. OPACITYRGB: boolean;
  41310. REFLECTION: boolean;
  41311. EMISSIVE: boolean;
  41312. EMISSIVEDIRECTUV: number;
  41313. SPECULAR: boolean;
  41314. SPECULARDIRECTUV: number;
  41315. BUMP: boolean;
  41316. BUMPDIRECTUV: number;
  41317. PARALLAX: boolean;
  41318. PARALLAXOCCLUSION: boolean;
  41319. SPECULAROVERALPHA: boolean;
  41320. CLIPPLANE: boolean;
  41321. CLIPPLANE2: boolean;
  41322. CLIPPLANE3: boolean;
  41323. CLIPPLANE4: boolean;
  41324. ALPHATEST: boolean;
  41325. DEPTHPREPASS: boolean;
  41326. ALPHAFROMDIFFUSE: boolean;
  41327. POINTSIZE: boolean;
  41328. FOG: boolean;
  41329. SPECULARTERM: boolean;
  41330. DIFFUSEFRESNEL: boolean;
  41331. OPACITYFRESNEL: boolean;
  41332. REFLECTIONFRESNEL: boolean;
  41333. REFRACTIONFRESNEL: boolean;
  41334. EMISSIVEFRESNEL: boolean;
  41335. FRESNEL: boolean;
  41336. NORMAL: boolean;
  41337. UV1: boolean;
  41338. UV2: boolean;
  41339. VERTEXCOLOR: boolean;
  41340. VERTEXALPHA: boolean;
  41341. NUM_BONE_INFLUENCERS: number;
  41342. BonesPerMesh: number;
  41343. BONETEXTURE: boolean;
  41344. INSTANCES: boolean;
  41345. GLOSSINESS: boolean;
  41346. ROUGHNESS: boolean;
  41347. EMISSIVEASILLUMINATION: boolean;
  41348. LINKEMISSIVEWITHDIFFUSE: boolean;
  41349. REFLECTIONFRESNELFROMSPECULAR: boolean;
  41350. LIGHTMAP: boolean;
  41351. LIGHTMAPDIRECTUV: number;
  41352. OBJECTSPACE_NORMALMAP: boolean;
  41353. USELIGHTMAPASSHADOWMAP: boolean;
  41354. REFLECTIONMAP_3D: boolean;
  41355. REFLECTIONMAP_SPHERICAL: boolean;
  41356. REFLECTIONMAP_PLANAR: boolean;
  41357. REFLECTIONMAP_CUBIC: boolean;
  41358. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  41359. REFLECTIONMAP_PROJECTION: boolean;
  41360. REFLECTIONMAP_SKYBOX: boolean;
  41361. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  41362. REFLECTIONMAP_EXPLICIT: boolean;
  41363. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  41364. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  41365. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  41366. INVERTCUBICMAP: boolean;
  41367. LOGARITHMICDEPTH: boolean;
  41368. REFRACTION: boolean;
  41369. REFRACTIONMAP_3D: boolean;
  41370. REFLECTIONOVERALPHA: boolean;
  41371. TWOSIDEDLIGHTING: boolean;
  41372. SHADOWFLOAT: boolean;
  41373. MORPHTARGETS: boolean;
  41374. MORPHTARGETS_NORMAL: boolean;
  41375. MORPHTARGETS_TANGENT: boolean;
  41376. MORPHTARGETS_UV: boolean;
  41377. NUM_MORPH_INFLUENCERS: number;
  41378. NONUNIFORMSCALING: boolean;
  41379. PREMULTIPLYALPHA: boolean;
  41380. IMAGEPROCESSING: boolean;
  41381. VIGNETTE: boolean;
  41382. VIGNETTEBLENDMODEMULTIPLY: boolean;
  41383. VIGNETTEBLENDMODEOPAQUE: boolean;
  41384. TONEMAPPING: boolean;
  41385. TONEMAPPING_ACES: boolean;
  41386. CONTRAST: boolean;
  41387. COLORCURVES: boolean;
  41388. COLORGRADING: boolean;
  41389. COLORGRADING3D: boolean;
  41390. SAMPLER3DGREENDEPTH: boolean;
  41391. SAMPLER3DBGRMAP: boolean;
  41392. IMAGEPROCESSINGPOSTPROCESS: boolean;
  41393. MULTIVIEW: boolean;
  41394. /**
  41395. * If the reflection texture on this material is in linear color space
  41396. * @hidden
  41397. */
  41398. IS_REFLECTION_LINEAR: boolean;
  41399. /**
  41400. * If the refraction texture on this material is in linear color space
  41401. * @hidden
  41402. */
  41403. IS_REFRACTION_LINEAR: boolean;
  41404. EXPOSURE: boolean;
  41405. constructor();
  41406. setReflectionMode(modeToEnable: string): void;
  41407. }
  41408. /**
  41409. * This is the default material used in Babylon. It is the best trade off between quality
  41410. * and performances.
  41411. * @see http://doc.babylonjs.com/babylon101/materials
  41412. */
  41413. export class StandardMaterial extends PushMaterial {
  41414. private _diffuseTexture;
  41415. /**
  41416. * The basic texture of the material as viewed under a light.
  41417. */
  41418. diffuseTexture: Nullable<BaseTexture>;
  41419. private _ambientTexture;
  41420. /**
  41421. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  41422. */
  41423. ambientTexture: Nullable<BaseTexture>;
  41424. private _opacityTexture;
  41425. /**
  41426. * Define the transparency of the material from a texture.
  41427. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  41428. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  41429. */
  41430. opacityTexture: Nullable<BaseTexture>;
  41431. private _reflectionTexture;
  41432. /**
  41433. * Define the texture used to display the reflection.
  41434. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41435. */
  41436. reflectionTexture: Nullable<BaseTexture>;
  41437. private _emissiveTexture;
  41438. /**
  41439. * Define texture of the material as if self lit.
  41440. * This will be mixed in the final result even in the absence of light.
  41441. */
  41442. emissiveTexture: Nullable<BaseTexture>;
  41443. private _specularTexture;
  41444. /**
  41445. * Define how the color and intensity of the highlight given by the light in the material.
  41446. */
  41447. specularTexture: Nullable<BaseTexture>;
  41448. private _bumpTexture;
  41449. /**
  41450. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  41451. * 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.
  41452. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  41453. */
  41454. bumpTexture: Nullable<BaseTexture>;
  41455. private _lightmapTexture;
  41456. /**
  41457. * Complex lighting can be computationally expensive to compute at runtime.
  41458. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  41459. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  41460. */
  41461. lightmapTexture: Nullable<BaseTexture>;
  41462. private _refractionTexture;
  41463. /**
  41464. * Define the texture used to display the refraction.
  41465. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41466. */
  41467. refractionTexture: Nullable<BaseTexture>;
  41468. /**
  41469. * The color of the material lit by the environmental background lighting.
  41470. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  41471. */
  41472. ambientColor: Color3;
  41473. /**
  41474. * The basic color of the material as viewed under a light.
  41475. */
  41476. diffuseColor: Color3;
  41477. /**
  41478. * Define how the color and intensity of the highlight given by the light in the material.
  41479. */
  41480. specularColor: Color3;
  41481. /**
  41482. * Define the color of the material as if self lit.
  41483. * This will be mixed in the final result even in the absence of light.
  41484. */
  41485. emissiveColor: Color3;
  41486. /**
  41487. * Defines how sharp are the highlights in the material.
  41488. * The bigger the value the sharper giving a more glossy feeling to the result.
  41489. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  41490. */
  41491. specularPower: number;
  41492. private _useAlphaFromDiffuseTexture;
  41493. /**
  41494. * Does the transparency come from the diffuse texture alpha channel.
  41495. */
  41496. useAlphaFromDiffuseTexture: boolean;
  41497. private _useEmissiveAsIllumination;
  41498. /**
  41499. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  41500. */
  41501. useEmissiveAsIllumination: boolean;
  41502. private _linkEmissiveWithDiffuse;
  41503. /**
  41504. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  41505. * the emissive level when the final color is close to one.
  41506. */
  41507. linkEmissiveWithDiffuse: boolean;
  41508. private _useSpecularOverAlpha;
  41509. /**
  41510. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  41511. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41512. */
  41513. useSpecularOverAlpha: boolean;
  41514. private _useReflectionOverAlpha;
  41515. /**
  41516. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41517. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41518. */
  41519. useReflectionOverAlpha: boolean;
  41520. private _disableLighting;
  41521. /**
  41522. * Does lights from the scene impacts this material.
  41523. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  41524. */
  41525. disableLighting: boolean;
  41526. private _useObjectSpaceNormalMap;
  41527. /**
  41528. * Allows using an object space normal map (instead of tangent space).
  41529. */
  41530. useObjectSpaceNormalMap: boolean;
  41531. private _useParallax;
  41532. /**
  41533. * Is parallax enabled or not.
  41534. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41535. */
  41536. useParallax: boolean;
  41537. private _useParallaxOcclusion;
  41538. /**
  41539. * Is parallax occlusion enabled or not.
  41540. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41541. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41542. */
  41543. useParallaxOcclusion: boolean;
  41544. /**
  41545. * 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.
  41546. */
  41547. parallaxScaleBias: number;
  41548. private _roughness;
  41549. /**
  41550. * Helps to define how blurry the reflections should appears in the material.
  41551. */
  41552. roughness: number;
  41553. /**
  41554. * In case of refraction, define the value of the index of refraction.
  41555. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41556. */
  41557. indexOfRefraction: number;
  41558. /**
  41559. * Invert the refraction texture alongside the y axis.
  41560. * It can be useful with procedural textures or probe for instance.
  41561. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41562. */
  41563. invertRefractionY: boolean;
  41564. /**
  41565. * Defines the alpha limits in alpha test mode.
  41566. */
  41567. alphaCutOff: number;
  41568. private _useLightmapAsShadowmap;
  41569. /**
  41570. * In case of light mapping, define whether the map contains light or shadow informations.
  41571. */
  41572. useLightmapAsShadowmap: boolean;
  41573. private _diffuseFresnelParameters;
  41574. /**
  41575. * Define the diffuse fresnel parameters of the material.
  41576. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41577. */
  41578. diffuseFresnelParameters: FresnelParameters;
  41579. private _opacityFresnelParameters;
  41580. /**
  41581. * Define the opacity fresnel parameters of the material.
  41582. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41583. */
  41584. opacityFresnelParameters: FresnelParameters;
  41585. private _reflectionFresnelParameters;
  41586. /**
  41587. * Define the reflection fresnel parameters of the material.
  41588. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41589. */
  41590. reflectionFresnelParameters: FresnelParameters;
  41591. private _refractionFresnelParameters;
  41592. /**
  41593. * Define the refraction fresnel parameters of the material.
  41594. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41595. */
  41596. refractionFresnelParameters: FresnelParameters;
  41597. private _emissiveFresnelParameters;
  41598. /**
  41599. * Define the emissive fresnel parameters of the material.
  41600. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41601. */
  41602. emissiveFresnelParameters: FresnelParameters;
  41603. private _useReflectionFresnelFromSpecular;
  41604. /**
  41605. * If true automatically deducts the fresnels values from the material specularity.
  41606. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41607. */
  41608. useReflectionFresnelFromSpecular: boolean;
  41609. private _useGlossinessFromSpecularMapAlpha;
  41610. /**
  41611. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41612. */
  41613. useGlossinessFromSpecularMapAlpha: boolean;
  41614. private _maxSimultaneousLights;
  41615. /**
  41616. * Defines the maximum number of lights that can be used in the material
  41617. */
  41618. maxSimultaneousLights: number;
  41619. private _invertNormalMapX;
  41620. /**
  41621. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41622. */
  41623. invertNormalMapX: boolean;
  41624. private _invertNormalMapY;
  41625. /**
  41626. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41627. */
  41628. invertNormalMapY: boolean;
  41629. private _twoSidedLighting;
  41630. /**
  41631. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41632. */
  41633. twoSidedLighting: boolean;
  41634. /**
  41635. * Default configuration related to image processing available in the standard Material.
  41636. */
  41637. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41638. /**
  41639. * Gets the image processing configuration used either in this material.
  41640. */
  41641. /**
  41642. * Sets the Default image processing configuration used either in the this material.
  41643. *
  41644. * If sets to null, the scene one is in use.
  41645. */
  41646. imageProcessingConfiguration: ImageProcessingConfiguration;
  41647. /**
  41648. * Keep track of the image processing observer to allow dispose and replace.
  41649. */
  41650. private _imageProcessingObserver;
  41651. /**
  41652. * Attaches a new image processing configuration to the Standard Material.
  41653. * @param configuration
  41654. */
  41655. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41656. /**
  41657. * Gets wether the color curves effect is enabled.
  41658. */
  41659. /**
  41660. * Sets wether the color curves effect is enabled.
  41661. */
  41662. cameraColorCurvesEnabled: boolean;
  41663. /**
  41664. * Gets wether the color grading effect is enabled.
  41665. */
  41666. /**
  41667. * Gets wether the color grading effect is enabled.
  41668. */
  41669. cameraColorGradingEnabled: boolean;
  41670. /**
  41671. * Gets wether tonemapping is enabled or not.
  41672. */
  41673. /**
  41674. * Sets wether tonemapping is enabled or not
  41675. */
  41676. cameraToneMappingEnabled: boolean;
  41677. /**
  41678. * The camera exposure used on this material.
  41679. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41680. * This corresponds to a photographic exposure.
  41681. */
  41682. /**
  41683. * The camera exposure used on this material.
  41684. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41685. * This corresponds to a photographic exposure.
  41686. */
  41687. cameraExposure: number;
  41688. /**
  41689. * Gets The camera contrast used on this material.
  41690. */
  41691. /**
  41692. * Sets The camera contrast used on this material.
  41693. */
  41694. cameraContrast: number;
  41695. /**
  41696. * Gets the Color Grading 2D Lookup Texture.
  41697. */
  41698. /**
  41699. * Sets the Color Grading 2D Lookup Texture.
  41700. */
  41701. cameraColorGradingTexture: Nullable<BaseTexture>;
  41702. /**
  41703. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41704. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41705. * 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;
  41706. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41707. */
  41708. /**
  41709. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41710. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41711. * 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;
  41712. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41713. */
  41714. cameraColorCurves: Nullable<ColorCurves>;
  41715. /**
  41716. * Custom callback helping to override the default shader used in the material.
  41717. */
  41718. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  41719. protected _renderTargets: SmartArray<RenderTargetTexture>;
  41720. protected _worldViewProjectionMatrix: Matrix;
  41721. protected _globalAmbientColor: Color3;
  41722. protected _useLogarithmicDepth: boolean;
  41723. protected _rebuildInParallel: boolean;
  41724. /**
  41725. * Instantiates a new standard material.
  41726. * This is the default material used in Babylon. It is the best trade off between quality
  41727. * and performances.
  41728. * @see http://doc.babylonjs.com/babylon101/materials
  41729. * @param name Define the name of the material in the scene
  41730. * @param scene Define the scene the material belong to
  41731. */
  41732. constructor(name: string, scene: Scene);
  41733. /**
  41734. * Gets a boolean indicating that current material needs to register RTT
  41735. */
  41736. readonly hasRenderTargetTextures: boolean;
  41737. /**
  41738. * Gets the current class name of the material e.g. "StandardMaterial"
  41739. * Mainly use in serialization.
  41740. * @returns the class name
  41741. */
  41742. getClassName(): string;
  41743. /**
  41744. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  41745. * You can try switching to logarithmic depth.
  41746. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  41747. */
  41748. useLogarithmicDepth: boolean;
  41749. /**
  41750. * Specifies if the material will require alpha blending
  41751. * @returns a boolean specifying if alpha blending is needed
  41752. */
  41753. needAlphaBlending(): boolean;
  41754. /**
  41755. * Specifies if this material should be rendered in alpha test mode
  41756. * @returns a boolean specifying if an alpha test is needed.
  41757. */
  41758. needAlphaTesting(): boolean;
  41759. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  41760. /**
  41761. * Get the texture used for alpha test purpose.
  41762. * @returns the diffuse texture in case of the standard material.
  41763. */
  41764. getAlphaTestTexture(): Nullable<BaseTexture>;
  41765. /**
  41766. * Get if the submesh is ready to be used and all its information available.
  41767. * Child classes can use it to update shaders
  41768. * @param mesh defines the mesh to check
  41769. * @param subMesh defines which submesh to check
  41770. * @param useInstances specifies that instances should be used
  41771. * @returns a boolean indicating that the submesh is ready or not
  41772. */
  41773. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  41774. /**
  41775. * Builds the material UBO layouts.
  41776. * Used internally during the effect preparation.
  41777. */
  41778. buildUniformLayout(): void;
  41779. /**
  41780. * Unbinds the material from the mesh
  41781. */
  41782. unbind(): void;
  41783. /**
  41784. * Binds the submesh to this material by preparing the effect and shader to draw
  41785. * @param world defines the world transformation matrix
  41786. * @param mesh defines the mesh containing the submesh
  41787. * @param subMesh defines the submesh to bind the material to
  41788. */
  41789. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  41790. /**
  41791. * Get the list of animatables in the material.
  41792. * @returns the list of animatables object used in the material
  41793. */
  41794. getAnimatables(): IAnimatable[];
  41795. /**
  41796. * Gets the active textures from the material
  41797. * @returns an array of textures
  41798. */
  41799. getActiveTextures(): BaseTexture[];
  41800. /**
  41801. * Specifies if the material uses a texture
  41802. * @param texture defines the texture to check against the material
  41803. * @returns a boolean specifying if the material uses the texture
  41804. */
  41805. hasTexture(texture: BaseTexture): boolean;
  41806. /**
  41807. * Disposes the material
  41808. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  41809. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  41810. */
  41811. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  41812. /**
  41813. * Makes a duplicate of the material, and gives it a new name
  41814. * @param name defines the new name for the duplicated material
  41815. * @returns the cloned material
  41816. */
  41817. clone(name: string): StandardMaterial;
  41818. /**
  41819. * Serializes this material in a JSON representation
  41820. * @returns the serialized material object
  41821. */
  41822. serialize(): any;
  41823. /**
  41824. * Creates a standard material from parsed material data
  41825. * @param source defines the JSON representation of the material
  41826. * @param scene defines the hosting scene
  41827. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  41828. * @returns a new standard material
  41829. */
  41830. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  41831. /**
  41832. * Are diffuse textures enabled in the application.
  41833. */
  41834. static DiffuseTextureEnabled: boolean;
  41835. /**
  41836. * Are ambient textures enabled in the application.
  41837. */
  41838. static AmbientTextureEnabled: boolean;
  41839. /**
  41840. * Are opacity textures enabled in the application.
  41841. */
  41842. static OpacityTextureEnabled: boolean;
  41843. /**
  41844. * Are reflection textures enabled in the application.
  41845. */
  41846. static ReflectionTextureEnabled: boolean;
  41847. /**
  41848. * Are emissive textures enabled in the application.
  41849. */
  41850. static EmissiveTextureEnabled: boolean;
  41851. /**
  41852. * Are specular textures enabled in the application.
  41853. */
  41854. static SpecularTextureEnabled: boolean;
  41855. /**
  41856. * Are bump textures enabled in the application.
  41857. */
  41858. static BumpTextureEnabled: boolean;
  41859. /**
  41860. * Are lightmap textures enabled in the application.
  41861. */
  41862. static LightmapTextureEnabled: boolean;
  41863. /**
  41864. * Are refraction textures enabled in the application.
  41865. */
  41866. static RefractionTextureEnabled: boolean;
  41867. /**
  41868. * Are color grading textures enabled in the application.
  41869. */
  41870. static ColorGradingTextureEnabled: boolean;
  41871. /**
  41872. * Are fresnels enabled in the application.
  41873. */
  41874. static FresnelEnabled: boolean;
  41875. }
  41876. }
  41877. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  41878. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41879. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41880. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41881. /** @hidden */
  41882. export var imageProcessingPixelShader: {
  41883. name: string;
  41884. shader: string;
  41885. };
  41886. }
  41887. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  41888. import { Nullable } from "babylonjs/types";
  41889. import { Color4 } from "babylonjs/Maths/math.color";
  41890. import { Camera } from "babylonjs/Cameras/camera";
  41891. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41892. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41893. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  41894. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41895. import { Engine } from "babylonjs/Engines/engine";
  41896. import "babylonjs/Shaders/imageProcessing.fragment";
  41897. import "babylonjs/Shaders/postprocess.vertex";
  41898. /**
  41899. * ImageProcessingPostProcess
  41900. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41901. */
  41902. export class ImageProcessingPostProcess extends PostProcess {
  41903. /**
  41904. * Default configuration related to image processing available in the PBR Material.
  41905. */
  41906. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41907. /**
  41908. * Gets the image processing configuration used either in this material.
  41909. */
  41910. /**
  41911. * Sets the Default image processing configuration used either in the this material.
  41912. *
  41913. * If sets to null, the scene one is in use.
  41914. */
  41915. imageProcessingConfiguration: ImageProcessingConfiguration;
  41916. /**
  41917. * Keep track of the image processing observer to allow dispose and replace.
  41918. */
  41919. private _imageProcessingObserver;
  41920. /**
  41921. * Attaches a new image processing configuration to the PBR Material.
  41922. * @param configuration
  41923. */
  41924. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41925. /**
  41926. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41927. */
  41928. /**
  41929. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41930. */
  41931. colorCurves: Nullable<ColorCurves>;
  41932. /**
  41933. * Gets wether the color curves effect is enabled.
  41934. */
  41935. /**
  41936. * Sets wether the color curves effect is enabled.
  41937. */
  41938. colorCurvesEnabled: boolean;
  41939. /**
  41940. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41941. */
  41942. /**
  41943. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41944. */
  41945. colorGradingTexture: Nullable<BaseTexture>;
  41946. /**
  41947. * Gets wether the color grading effect is enabled.
  41948. */
  41949. /**
  41950. * Gets wether the color grading effect is enabled.
  41951. */
  41952. colorGradingEnabled: boolean;
  41953. /**
  41954. * Gets exposure used in the effect.
  41955. */
  41956. /**
  41957. * Sets exposure used in the effect.
  41958. */
  41959. exposure: number;
  41960. /**
  41961. * Gets wether tonemapping is enabled or not.
  41962. */
  41963. /**
  41964. * Sets wether tonemapping is enabled or not
  41965. */
  41966. toneMappingEnabled: boolean;
  41967. /**
  41968. * Gets the type of tone mapping effect.
  41969. */
  41970. /**
  41971. * Sets the type of tone mapping effect.
  41972. */
  41973. toneMappingType: number;
  41974. /**
  41975. * Gets contrast used in the effect.
  41976. */
  41977. /**
  41978. * Sets contrast used in the effect.
  41979. */
  41980. contrast: number;
  41981. /**
  41982. * Gets Vignette stretch size.
  41983. */
  41984. /**
  41985. * Sets Vignette stretch size.
  41986. */
  41987. vignetteStretch: number;
  41988. /**
  41989. * Gets Vignette centre X Offset.
  41990. */
  41991. /**
  41992. * Sets Vignette centre X Offset.
  41993. */
  41994. vignetteCentreX: number;
  41995. /**
  41996. * Gets Vignette centre Y Offset.
  41997. */
  41998. /**
  41999. * Sets Vignette centre Y Offset.
  42000. */
  42001. vignetteCentreY: number;
  42002. /**
  42003. * Gets Vignette weight or intensity of the vignette effect.
  42004. */
  42005. /**
  42006. * Sets Vignette weight or intensity of the vignette effect.
  42007. */
  42008. vignetteWeight: number;
  42009. /**
  42010. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42011. * if vignetteEnabled is set to true.
  42012. */
  42013. /**
  42014. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42015. * if vignetteEnabled is set to true.
  42016. */
  42017. vignetteColor: Color4;
  42018. /**
  42019. * Gets Camera field of view used by the Vignette effect.
  42020. */
  42021. /**
  42022. * Sets Camera field of view used by the Vignette effect.
  42023. */
  42024. vignetteCameraFov: number;
  42025. /**
  42026. * Gets the vignette blend mode allowing different kind of effect.
  42027. */
  42028. /**
  42029. * Sets the vignette blend mode allowing different kind of effect.
  42030. */
  42031. vignetteBlendMode: number;
  42032. /**
  42033. * Gets wether the vignette effect is enabled.
  42034. */
  42035. /**
  42036. * Sets wether the vignette effect is enabled.
  42037. */
  42038. vignetteEnabled: boolean;
  42039. private _fromLinearSpace;
  42040. /**
  42041. * Gets wether the input of the processing is in Gamma or Linear Space.
  42042. */
  42043. /**
  42044. * Sets wether the input of the processing is in Gamma or Linear Space.
  42045. */
  42046. fromLinearSpace: boolean;
  42047. /**
  42048. * Defines cache preventing GC.
  42049. */
  42050. private _defines;
  42051. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42052. /**
  42053. * "ImageProcessingPostProcess"
  42054. * @returns "ImageProcessingPostProcess"
  42055. */
  42056. getClassName(): string;
  42057. protected _updateParameters(): void;
  42058. dispose(camera?: Camera): void;
  42059. }
  42060. }
  42061. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42062. import { Scene } from "babylonjs/scene";
  42063. import { Color3 } from "babylonjs/Maths/math.color";
  42064. import { Mesh } from "babylonjs/Meshes/mesh";
  42065. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42066. import { Nullable } from "babylonjs/types";
  42067. /**
  42068. * Class containing static functions to help procedurally build meshes
  42069. */
  42070. export class GroundBuilder {
  42071. /**
  42072. * Creates a ground mesh
  42073. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42074. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42076. * @param name defines the name of the mesh
  42077. * @param options defines the options used to create the mesh
  42078. * @param scene defines the hosting scene
  42079. * @returns the ground mesh
  42080. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42081. */
  42082. static CreateGround(name: string, options: {
  42083. width?: number;
  42084. height?: number;
  42085. subdivisions?: number;
  42086. subdivisionsX?: number;
  42087. subdivisionsY?: number;
  42088. updatable?: boolean;
  42089. }, scene: any): Mesh;
  42090. /**
  42091. * Creates a tiled ground mesh
  42092. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42093. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42094. * * 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
  42095. * * 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
  42096. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42097. * @param name defines the name of the mesh
  42098. * @param options defines the options used to create the mesh
  42099. * @param scene defines the hosting scene
  42100. * @returns the tiled ground mesh
  42101. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42102. */
  42103. static CreateTiledGround(name: string, options: {
  42104. xmin: number;
  42105. zmin: number;
  42106. xmax: number;
  42107. zmax: number;
  42108. subdivisions?: {
  42109. w: number;
  42110. h: number;
  42111. };
  42112. precision?: {
  42113. w: number;
  42114. h: number;
  42115. };
  42116. updatable?: boolean;
  42117. }, scene?: Nullable<Scene>): Mesh;
  42118. /**
  42119. * Creates a ground mesh from a height map
  42120. * * The parameter `url` sets the URL of the height map image resource.
  42121. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42122. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42123. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42124. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42125. * * 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.
  42126. * * 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).
  42127. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42128. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42129. * @param name defines the name of the mesh
  42130. * @param url defines the url to the height map
  42131. * @param options defines the options used to create the mesh
  42132. * @param scene defines the hosting scene
  42133. * @returns the ground mesh
  42134. * @see https://doc.babylonjs.com/babylon101/height_map
  42135. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42136. */
  42137. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42138. width?: number;
  42139. height?: number;
  42140. subdivisions?: number;
  42141. minHeight?: number;
  42142. maxHeight?: number;
  42143. colorFilter?: Color3;
  42144. alphaFilter?: number;
  42145. updatable?: boolean;
  42146. onReady?: (mesh: GroundMesh) => void;
  42147. }, scene?: Nullable<Scene>): GroundMesh;
  42148. }
  42149. }
  42150. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42151. import { Vector4 } from "babylonjs/Maths/math.vector";
  42152. import { Mesh } from "babylonjs/Meshes/mesh";
  42153. /**
  42154. * Class containing static functions to help procedurally build meshes
  42155. */
  42156. export class TorusBuilder {
  42157. /**
  42158. * Creates a torus mesh
  42159. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42160. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42161. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42162. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42163. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42164. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42165. * @param name defines the name of the mesh
  42166. * @param options defines the options used to create the mesh
  42167. * @param scene defines the hosting scene
  42168. * @returns the torus mesh
  42169. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42170. */
  42171. static CreateTorus(name: string, options: {
  42172. diameter?: number;
  42173. thickness?: number;
  42174. tessellation?: number;
  42175. updatable?: boolean;
  42176. sideOrientation?: number;
  42177. frontUVs?: Vector4;
  42178. backUVs?: Vector4;
  42179. }, scene: any): Mesh;
  42180. }
  42181. }
  42182. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42183. import { Vector4 } from "babylonjs/Maths/math.vector";
  42184. import { Color4 } from "babylonjs/Maths/math.color";
  42185. import { Mesh } from "babylonjs/Meshes/mesh";
  42186. /**
  42187. * Class containing static functions to help procedurally build meshes
  42188. */
  42189. export class CylinderBuilder {
  42190. /**
  42191. * Creates a cylinder or a cone mesh
  42192. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42193. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42194. * * 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.
  42195. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42196. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42197. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42198. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42199. * * 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).
  42200. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42201. * * 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).
  42202. * * 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
  42203. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42204. * * 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
  42205. * * 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.
  42206. * * If `enclose` is false, a ring surface is one element.
  42207. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42208. * * 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
  42209. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42210. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42211. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42212. * @param name defines the name of the mesh
  42213. * @param options defines the options used to create the mesh
  42214. * @param scene defines the hosting scene
  42215. * @returns the cylinder mesh
  42216. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42217. */
  42218. static CreateCylinder(name: string, options: {
  42219. height?: number;
  42220. diameterTop?: number;
  42221. diameterBottom?: number;
  42222. diameter?: number;
  42223. tessellation?: number;
  42224. subdivisions?: number;
  42225. arc?: number;
  42226. faceColors?: Color4[];
  42227. faceUV?: Vector4[];
  42228. updatable?: boolean;
  42229. hasRings?: boolean;
  42230. enclose?: boolean;
  42231. cap?: number;
  42232. sideOrientation?: number;
  42233. frontUVs?: Vector4;
  42234. backUVs?: Vector4;
  42235. }, scene: any): Mesh;
  42236. }
  42237. }
  42238. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42239. import { Observable } from "babylonjs/Misc/observable";
  42240. import { Nullable } from "babylonjs/types";
  42241. import { Camera } from "babylonjs/Cameras/camera";
  42242. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42243. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42244. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42245. import { Scene } from "babylonjs/scene";
  42246. import { Vector3 } from "babylonjs/Maths/math.vector";
  42247. import { Color3 } from "babylonjs/Maths/math.color";
  42248. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42249. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42250. import { Mesh } from "babylonjs/Meshes/mesh";
  42251. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42252. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42253. import "babylonjs/Meshes/Builders/groundBuilder";
  42254. import "babylonjs/Meshes/Builders/torusBuilder";
  42255. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42256. import "babylonjs/Gamepads/gamepadSceneComponent";
  42257. import "babylonjs/Animations/animatable";
  42258. /**
  42259. * Options to modify the vr teleportation behavior.
  42260. */
  42261. export interface VRTeleportationOptions {
  42262. /**
  42263. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42264. */
  42265. floorMeshName?: string;
  42266. /**
  42267. * A list of meshes to be used as the teleportation floor. (default: empty)
  42268. */
  42269. floorMeshes?: Mesh[];
  42270. }
  42271. /**
  42272. * Options to modify the vr experience helper's behavior.
  42273. */
  42274. export interface VRExperienceHelperOptions extends WebVROptions {
  42275. /**
  42276. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42277. */
  42278. createDeviceOrientationCamera?: boolean;
  42279. /**
  42280. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42281. */
  42282. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42283. /**
  42284. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42285. */
  42286. laserToggle?: boolean;
  42287. /**
  42288. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42289. */
  42290. floorMeshes?: Mesh[];
  42291. /**
  42292. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42293. */
  42294. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42295. }
  42296. /**
  42297. * Event containing information after VR has been entered
  42298. */
  42299. export class OnAfterEnteringVRObservableEvent {
  42300. /**
  42301. * If entering vr was successful
  42302. */
  42303. success: boolean;
  42304. }
  42305. /**
  42306. * Helps to quickly add VR support to an existing scene.
  42307. * See http://doc.babylonjs.com/how_to/webvr_helper
  42308. */
  42309. export class VRExperienceHelper {
  42310. /** Options to modify the vr experience helper's behavior. */
  42311. webVROptions: VRExperienceHelperOptions;
  42312. private _scene;
  42313. private _position;
  42314. private _btnVR;
  42315. private _btnVRDisplayed;
  42316. private _webVRsupported;
  42317. private _webVRready;
  42318. private _webVRrequesting;
  42319. private _webVRpresenting;
  42320. private _hasEnteredVR;
  42321. private _fullscreenVRpresenting;
  42322. private _canvas;
  42323. private _webVRCamera;
  42324. private _vrDeviceOrientationCamera;
  42325. private _deviceOrientationCamera;
  42326. private _existingCamera;
  42327. private _onKeyDown;
  42328. private _onVrDisplayPresentChange;
  42329. private _onVRDisplayChanged;
  42330. private _onVRRequestPresentStart;
  42331. private _onVRRequestPresentComplete;
  42332. /**
  42333. * 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)
  42334. */
  42335. enableGazeEvenWhenNoPointerLock: boolean;
  42336. /**
  42337. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  42338. */
  42339. exitVROnDoubleTap: boolean;
  42340. /**
  42341. * Observable raised right before entering VR.
  42342. */
  42343. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42344. /**
  42345. * Observable raised when entering VR has completed.
  42346. */
  42347. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  42348. /**
  42349. * Observable raised when exiting VR.
  42350. */
  42351. onExitingVRObservable: Observable<VRExperienceHelper>;
  42352. /**
  42353. * Observable raised when controller mesh is loaded.
  42354. */
  42355. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42356. /** Return this.onEnteringVRObservable
  42357. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42358. */
  42359. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42360. /** Return this.onExitingVRObservable
  42361. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42362. */
  42363. readonly onExitingVR: Observable<VRExperienceHelper>;
  42364. /** Return this.onControllerMeshLoadedObservable
  42365. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42366. */
  42367. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42368. private _rayLength;
  42369. private _useCustomVRButton;
  42370. private _teleportationRequested;
  42371. private _teleportActive;
  42372. private _floorMeshName;
  42373. private _floorMeshesCollection;
  42374. private _rotationAllowed;
  42375. private _teleportBackwardsVector;
  42376. private _teleportationTarget;
  42377. private _isDefaultTeleportationTarget;
  42378. private _postProcessMove;
  42379. private _teleportationFillColor;
  42380. private _teleportationBorderColor;
  42381. private _rotationAngle;
  42382. private _haloCenter;
  42383. private _cameraGazer;
  42384. private _padSensibilityUp;
  42385. private _padSensibilityDown;
  42386. private _leftController;
  42387. private _rightController;
  42388. /**
  42389. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42390. */
  42391. onNewMeshSelected: Observable<AbstractMesh>;
  42392. /**
  42393. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  42394. * This observable will provide the mesh and the controller used to select the mesh
  42395. */
  42396. onMeshSelectedWithController: Observable<{
  42397. mesh: AbstractMesh;
  42398. controller: WebVRController;
  42399. }>;
  42400. /**
  42401. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42402. */
  42403. onNewMeshPicked: Observable<PickingInfo>;
  42404. private _circleEase;
  42405. /**
  42406. * Observable raised before camera teleportation
  42407. */
  42408. onBeforeCameraTeleport: Observable<Vector3>;
  42409. /**
  42410. * Observable raised after camera teleportation
  42411. */
  42412. onAfterCameraTeleport: Observable<Vector3>;
  42413. /**
  42414. * Observable raised when current selected mesh gets unselected
  42415. */
  42416. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42417. private _raySelectionPredicate;
  42418. /**
  42419. * To be optionaly changed by user to define custom ray selection
  42420. */
  42421. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42422. /**
  42423. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42424. */
  42425. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42426. /**
  42427. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42428. */
  42429. teleportationEnabled: boolean;
  42430. private _defaultHeight;
  42431. private _teleportationInitialized;
  42432. private _interactionsEnabled;
  42433. private _interactionsRequested;
  42434. private _displayGaze;
  42435. private _displayLaserPointer;
  42436. /**
  42437. * The mesh used to display where the user is going to teleport.
  42438. */
  42439. /**
  42440. * Sets the mesh to be used to display where the user is going to teleport.
  42441. */
  42442. teleportationTarget: Mesh;
  42443. /**
  42444. * 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
  42445. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42446. * See http://doc.babylonjs.com/resources/baking_transformations
  42447. */
  42448. gazeTrackerMesh: Mesh;
  42449. /**
  42450. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42451. */
  42452. updateGazeTrackerScale: boolean;
  42453. /**
  42454. * If the gaze trackers color should be updated when selecting meshes
  42455. */
  42456. updateGazeTrackerColor: boolean;
  42457. /**
  42458. * If the controller laser color should be updated when selecting meshes
  42459. */
  42460. updateControllerLaserColor: boolean;
  42461. /**
  42462. * The gaze tracking mesh corresponding to the left controller
  42463. */
  42464. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42465. /**
  42466. * The gaze tracking mesh corresponding to the right controller
  42467. */
  42468. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42469. /**
  42470. * If the ray of the gaze should be displayed.
  42471. */
  42472. /**
  42473. * Sets if the ray of the gaze should be displayed.
  42474. */
  42475. displayGaze: boolean;
  42476. /**
  42477. * If the ray of the LaserPointer should be displayed.
  42478. */
  42479. /**
  42480. * Sets if the ray of the LaserPointer should be displayed.
  42481. */
  42482. displayLaserPointer: boolean;
  42483. /**
  42484. * The deviceOrientationCamera used as the camera when not in VR.
  42485. */
  42486. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42487. /**
  42488. * Based on the current WebVR support, returns the current VR camera used.
  42489. */
  42490. readonly currentVRCamera: Nullable<Camera>;
  42491. /**
  42492. * The webVRCamera which is used when in VR.
  42493. */
  42494. readonly webVRCamera: WebVRFreeCamera;
  42495. /**
  42496. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42497. */
  42498. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42499. /**
  42500. * The html button that is used to trigger entering into VR.
  42501. */
  42502. readonly vrButton: Nullable<HTMLButtonElement>;
  42503. private readonly _teleportationRequestInitiated;
  42504. /**
  42505. * Defines wether or not Pointer lock should be requested when switching to
  42506. * full screen.
  42507. */
  42508. requestPointerLockOnFullScreen: boolean;
  42509. /**
  42510. * Instantiates a VRExperienceHelper.
  42511. * Helps to quickly add VR support to an existing scene.
  42512. * @param scene The scene the VRExperienceHelper belongs to.
  42513. * @param webVROptions Options to modify the vr experience helper's behavior.
  42514. */
  42515. constructor(scene: Scene,
  42516. /** Options to modify the vr experience helper's behavior. */
  42517. webVROptions?: VRExperienceHelperOptions);
  42518. private _onDefaultMeshLoaded;
  42519. private _onResize;
  42520. private _onFullscreenChange;
  42521. /**
  42522. * Gets a value indicating if we are currently in VR mode.
  42523. */
  42524. readonly isInVRMode: boolean;
  42525. private onVrDisplayPresentChange;
  42526. private onVRDisplayChanged;
  42527. private moveButtonToBottomRight;
  42528. private displayVRButton;
  42529. private updateButtonVisibility;
  42530. private _cachedAngularSensibility;
  42531. /**
  42532. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42533. * Otherwise, will use the fullscreen API.
  42534. */
  42535. enterVR(): void;
  42536. /**
  42537. * Attempt to exit VR, or fullscreen.
  42538. */
  42539. exitVR(): void;
  42540. /**
  42541. * The position of the vr experience helper.
  42542. */
  42543. /**
  42544. * Sets the position of the vr experience helper.
  42545. */
  42546. position: Vector3;
  42547. /**
  42548. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42549. */
  42550. enableInteractions(): void;
  42551. private readonly _noControllerIsActive;
  42552. private beforeRender;
  42553. private _isTeleportationFloor;
  42554. /**
  42555. * Adds a floor mesh to be used for teleportation.
  42556. * @param floorMesh the mesh to be used for teleportation.
  42557. */
  42558. addFloorMesh(floorMesh: Mesh): void;
  42559. /**
  42560. * Removes a floor mesh from being used for teleportation.
  42561. * @param floorMesh the mesh to be removed.
  42562. */
  42563. removeFloorMesh(floorMesh: Mesh): void;
  42564. /**
  42565. * Enables interactions and teleportation using the VR controllers and gaze.
  42566. * @param vrTeleportationOptions options to modify teleportation behavior.
  42567. */
  42568. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42569. private _onNewGamepadConnected;
  42570. private _tryEnableInteractionOnController;
  42571. private _onNewGamepadDisconnected;
  42572. private _enableInteractionOnController;
  42573. private _checkTeleportWithRay;
  42574. private _checkRotate;
  42575. private _checkTeleportBackwards;
  42576. private _enableTeleportationOnController;
  42577. private _createTeleportationCircles;
  42578. private _displayTeleportationTarget;
  42579. private _hideTeleportationTarget;
  42580. private _rotateCamera;
  42581. private _moveTeleportationSelectorTo;
  42582. private _workingVector;
  42583. private _workingQuaternion;
  42584. private _workingMatrix;
  42585. /**
  42586. * Teleports the users feet to the desired location
  42587. * @param location The location where the user's feet should be placed
  42588. */
  42589. teleportCamera(location: Vector3): void;
  42590. private _convertNormalToDirectionOfRay;
  42591. private _castRayAndSelectObject;
  42592. private _notifySelectedMeshUnselected;
  42593. /**
  42594. * Sets the color of the laser ray from the vr controllers.
  42595. * @param color new color for the ray.
  42596. */
  42597. changeLaserColor(color: Color3): void;
  42598. /**
  42599. * Sets the color of the ray from the vr headsets gaze.
  42600. * @param color new color for the ray.
  42601. */
  42602. changeGazeColor(color: Color3): void;
  42603. /**
  42604. * Exits VR and disposes of the vr experience helper
  42605. */
  42606. dispose(): void;
  42607. /**
  42608. * Gets the name of the VRExperienceHelper class
  42609. * @returns "VRExperienceHelper"
  42610. */
  42611. getClassName(): string;
  42612. }
  42613. }
  42614. declare module "babylonjs/Cameras/VR/index" {
  42615. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42616. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42617. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42618. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42619. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42620. export * from "babylonjs/Cameras/VR/webVRCamera";
  42621. }
  42622. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  42623. import { Observable } from "babylonjs/Misc/observable";
  42624. import { Nullable } from "babylonjs/types";
  42625. import { IDisposable, Scene } from "babylonjs/scene";
  42626. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42627. /**
  42628. * Manages an XRSession to work with Babylon's engine
  42629. * @see https://doc.babylonjs.com/how_to/webxr
  42630. */
  42631. export class WebXRSessionManager implements IDisposable {
  42632. private scene;
  42633. /**
  42634. * Fires every time a new xrFrame arrives which can be used to update the camera
  42635. */
  42636. onXRFrameObservable: Observable<any>;
  42637. /**
  42638. * Fires when the xr session is ended either by the device or manually done
  42639. */
  42640. onXRSessionEnded: Observable<any>;
  42641. /**
  42642. * Underlying xr session
  42643. */
  42644. session: XRSession;
  42645. /**
  42646. * Type of reference space used when creating the session
  42647. */
  42648. referenceSpace: XRReferenceSpace;
  42649. /** @hidden */
  42650. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42651. /**
  42652. * Current XR frame
  42653. */
  42654. currentFrame: Nullable<XRFrame>;
  42655. private _xrNavigator;
  42656. private baseLayer;
  42657. /**
  42658. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42659. * @param scene The scene which the session should be created for
  42660. */
  42661. constructor(scene: Scene);
  42662. /**
  42663. * Initializes the manager
  42664. * After initialization enterXR can be called to start an XR session
  42665. * @returns Promise which resolves after it is initialized
  42666. */
  42667. initializeAsync(): Promise<void>;
  42668. /**
  42669. * Initializes an xr session
  42670. * @param xrSessionMode mode to initialize
  42671. * @returns a promise which will resolve once the session has been initialized
  42672. */
  42673. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  42674. /**
  42675. * Sets the reference space on the xr session
  42676. * @param referenceSpace space to set
  42677. * @returns a promise that will resolve once the reference space has been set
  42678. */
  42679. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42680. /**
  42681. * Updates the render state of the session
  42682. * @param state state to set
  42683. * @returns a promise that resolves once the render state has been updated
  42684. */
  42685. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42686. /**
  42687. * Starts rendering to the xr layer
  42688. * @returns a promise that will resolve once rendering has started
  42689. */
  42690. startRenderingToXRAsync(): Promise<void>;
  42691. /**
  42692. * Stops the xrSession and restores the renderloop
  42693. * @returns Promise which resolves after it exits XR
  42694. */
  42695. exitXRAsync(): Promise<unknown>;
  42696. /**
  42697. * Checks if a session would be supported for the creation options specified
  42698. * @param sessionMode session mode to check if supported eg. immersive-vr
  42699. * @returns true if supported
  42700. */
  42701. supportsSessionAsync(sessionMode: XRSessionMode): any;
  42702. /**
  42703. * @hidden
  42704. * Converts the render layer of xrSession to a render target
  42705. * @param session session to create render target for
  42706. * @param scene scene the new render target should be created for
  42707. */
  42708. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42709. /**
  42710. * Disposes of the session manager
  42711. */
  42712. dispose(): void;
  42713. }
  42714. }
  42715. declare module "babylonjs/Cameras/XR/webXRCamera" {
  42716. import { Scene } from "babylonjs/scene";
  42717. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42718. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42719. /**
  42720. * WebXR Camera which holds the views for the xrSession
  42721. * @see https://doc.babylonjs.com/how_to/webxr
  42722. */
  42723. export class WebXRCamera extends FreeCamera {
  42724. private static _TmpMatrix;
  42725. /**
  42726. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42727. * @param name the name of the camera
  42728. * @param scene the scene to add the camera to
  42729. */
  42730. constructor(name: string, scene: Scene);
  42731. private _updateNumberOfRigCameras;
  42732. /** @hidden */
  42733. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42734. /**
  42735. * Updates the cameras position from the current pose information of the XR session
  42736. * @param xrSessionManager the session containing pose information
  42737. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42738. */
  42739. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42740. }
  42741. }
  42742. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  42743. import { Nullable } from "babylonjs/types";
  42744. import { IDisposable } from "babylonjs/scene";
  42745. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42746. /**
  42747. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42748. */
  42749. export class WebXRManagedOutputCanvas implements IDisposable {
  42750. private helper;
  42751. private _canvas;
  42752. /**
  42753. * xrpresent context of the canvas which can be used to display/mirror xr content
  42754. */
  42755. canvasContext: WebGLRenderingContext;
  42756. /**
  42757. * xr layer for the canvas
  42758. */
  42759. xrLayer: Nullable<XRWebGLLayer>;
  42760. /**
  42761. * Initializes the xr layer for the session
  42762. * @param xrSession xr session
  42763. * @returns a promise that will resolve once the XR Layer has been created
  42764. */
  42765. initializeXRLayerAsync(xrSession: any): any;
  42766. /**
  42767. * Initializes the canvas to be added/removed upon entering/exiting xr
  42768. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42769. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42770. */
  42771. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42772. /**
  42773. * Disposes of the object
  42774. */
  42775. dispose(): void;
  42776. private _setManagedOutputCanvas;
  42777. private _addCanvas;
  42778. private _removeCanvas;
  42779. }
  42780. }
  42781. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  42782. import { Observable } from "babylonjs/Misc/observable";
  42783. import { IDisposable, Scene } from "babylonjs/scene";
  42784. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  42785. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42786. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42787. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  42788. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42789. /**
  42790. * States of the webXR experience
  42791. */
  42792. export enum WebXRState {
  42793. /**
  42794. * Transitioning to being in XR mode
  42795. */
  42796. ENTERING_XR = 0,
  42797. /**
  42798. * Transitioning to non XR mode
  42799. */
  42800. EXITING_XR = 1,
  42801. /**
  42802. * In XR mode and presenting
  42803. */
  42804. IN_XR = 2,
  42805. /**
  42806. * Not entered XR mode
  42807. */
  42808. NOT_IN_XR = 3
  42809. }
  42810. /**
  42811. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42812. * @see https://doc.babylonjs.com/how_to/webxr
  42813. */
  42814. export class WebXRExperienceHelper implements IDisposable {
  42815. private scene;
  42816. /**
  42817. * 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
  42818. */
  42819. container: AbstractMesh;
  42820. /**
  42821. * Camera used to render xr content
  42822. */
  42823. camera: WebXRCamera;
  42824. /**
  42825. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42826. */
  42827. state: WebXRState;
  42828. private _setState;
  42829. private static _TmpVector;
  42830. /**
  42831. * Fires when the state of the experience helper has changed
  42832. */
  42833. onStateChangedObservable: Observable<WebXRState>;
  42834. /** Session manager used to keep track of xr session */
  42835. sessionManager: WebXRSessionManager;
  42836. private _nonVRCamera;
  42837. private _originalSceneAutoClear;
  42838. private _supported;
  42839. /**
  42840. * Creates the experience helper
  42841. * @param scene the scene to attach the experience helper to
  42842. * @returns a promise for the experience helper
  42843. */
  42844. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42845. /**
  42846. * Creates a WebXRExperienceHelper
  42847. * @param scene The scene the helper should be created in
  42848. */
  42849. private constructor();
  42850. /**
  42851. * Exits XR mode and returns the scene to its original state
  42852. * @returns promise that resolves after xr mode has exited
  42853. */
  42854. exitXRAsync(): Promise<unknown>;
  42855. /**
  42856. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42857. * @param sessionCreationOptions options for the XR session
  42858. * @param referenceSpaceType frame of reference of the XR session
  42859. * @param outputCanvas the output canvas that will be used to enter XR mode
  42860. * @returns promise that resolves after xr mode has entered
  42861. */
  42862. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  42863. /**
  42864. * Updates the global position of the camera by moving the camera's container
  42865. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42866. * @param position The desired global position of the camera
  42867. */
  42868. setPositionOfCameraUsingContainer(position: Vector3): void;
  42869. /**
  42870. * Rotates the xr camera by rotating the camera's container around the camera's position
  42871. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42872. * @param rotation the desired quaternion rotation to apply to the camera
  42873. */
  42874. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42875. /**
  42876. * Disposes of the experience helper
  42877. */
  42878. dispose(): void;
  42879. }
  42880. }
  42881. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  42882. import { Nullable } from "babylonjs/types";
  42883. import { Observable } from "babylonjs/Misc/observable";
  42884. import { IDisposable, Scene } from "babylonjs/scene";
  42885. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42886. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42887. /**
  42888. * Button which can be used to enter a different mode of XR
  42889. */
  42890. export class WebXREnterExitUIButton {
  42891. /** button element */
  42892. element: HTMLElement;
  42893. /** XR initialization options for the button */
  42894. sessionMode: XRSessionMode;
  42895. /** Reference space type */
  42896. referenceSpaceType: XRReferenceSpaceType;
  42897. /**
  42898. * Creates a WebXREnterExitUIButton
  42899. * @param element button element
  42900. * @param sessionMode XR initialization session mode
  42901. * @param referenceSpaceType the type of reference space to be used
  42902. */
  42903. constructor(
  42904. /** button element */
  42905. element: HTMLElement,
  42906. /** XR initialization options for the button */
  42907. sessionMode: XRSessionMode,
  42908. /** Reference space type */
  42909. referenceSpaceType: XRReferenceSpaceType);
  42910. /**
  42911. * Overwritable function which can be used to update the button's visuals when the state changes
  42912. * @param activeButton the current active button in the UI
  42913. */
  42914. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42915. }
  42916. /**
  42917. * Options to create the webXR UI
  42918. */
  42919. export class WebXREnterExitUIOptions {
  42920. /**
  42921. * Context to enter xr with
  42922. */
  42923. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  42924. /**
  42925. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42926. */
  42927. customButtons?: Array<WebXREnterExitUIButton>;
  42928. }
  42929. /**
  42930. * UI to allow the user to enter/exit XR mode
  42931. */
  42932. export class WebXREnterExitUI implements IDisposable {
  42933. private scene;
  42934. private _overlay;
  42935. private _buttons;
  42936. private _activeButton;
  42937. /**
  42938. * Fired every time the active button is changed.
  42939. *
  42940. * When xr is entered via a button that launches xr that button will be the callback parameter
  42941. *
  42942. * When exiting xr the callback parameter will be null)
  42943. */
  42944. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42945. /**
  42946. * Creates UI to allow the user to enter/exit XR mode
  42947. * @param scene the scene to add the ui to
  42948. * @param helper the xr experience helper to enter/exit xr with
  42949. * @param options options to configure the UI
  42950. * @returns the created ui
  42951. */
  42952. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  42953. private constructor();
  42954. private _updateButtons;
  42955. /**
  42956. * Disposes of the object
  42957. */
  42958. dispose(): void;
  42959. }
  42960. }
  42961. declare module "babylonjs/Cameras/XR/webXRController" {
  42962. import { Nullable } from "babylonjs/types";
  42963. import { Observable } from "babylonjs/Misc/observable";
  42964. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42965. import { Ray } from "babylonjs/Culling/ray";
  42966. import { Scene } from "babylonjs/scene";
  42967. /**
  42968. * Represents an XR input
  42969. */
  42970. export class WebXRController {
  42971. private scene;
  42972. /** The underlying input source for the controller */
  42973. inputSource: XRInputSource;
  42974. private parentContainer;
  42975. /**
  42976. * 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
  42977. */
  42978. grip?: AbstractMesh;
  42979. /**
  42980. * Pointer which can be used to select objects or attach a visible laser to
  42981. */
  42982. pointer: AbstractMesh;
  42983. /**
  42984. * Event that fires when the controller is removed/disposed
  42985. */
  42986. onDisposeObservable: Observable<{}>;
  42987. private _tmpMatrix;
  42988. private _tmpQuaternion;
  42989. private _tmpVector;
  42990. /**
  42991. * Creates the controller
  42992. * @see https://doc.babylonjs.com/how_to/webxr
  42993. * @param scene the scene which the controller should be associated to
  42994. * @param inputSource the underlying input source for the controller
  42995. * @param parentContainer parent that the controller meshes should be children of
  42996. */
  42997. constructor(scene: Scene,
  42998. /** The underlying input source for the controller */
  42999. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43000. /**
  43001. * Updates the controller pose based on the given XRFrame
  43002. * @param xrFrame xr frame to update the pose with
  43003. * @param referenceSpace reference space to use
  43004. */
  43005. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43006. /**
  43007. * Gets a world space ray coming from the controller
  43008. * @param result the resulting ray
  43009. */
  43010. getWorldPointerRayToRef(result: Ray): void;
  43011. /**
  43012. * Disposes of the object
  43013. */
  43014. dispose(): void;
  43015. }
  43016. }
  43017. declare module "babylonjs/Cameras/XR/webXRInput" {
  43018. import { Observable } from "babylonjs/Misc/observable";
  43019. import { IDisposable } from "babylonjs/scene";
  43020. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43021. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43022. /**
  43023. * XR input used to track XR inputs such as controllers/rays
  43024. */
  43025. export class WebXRInput implements IDisposable {
  43026. /**
  43027. * Base experience the input listens to
  43028. */
  43029. baseExperience: WebXRExperienceHelper;
  43030. /**
  43031. * XR controllers being tracked
  43032. */
  43033. controllers: Array<WebXRController>;
  43034. private _frameObserver;
  43035. private _stateObserver;
  43036. /**
  43037. * Event when a controller has been connected/added
  43038. */
  43039. onControllerAddedObservable: Observable<WebXRController>;
  43040. /**
  43041. * Event when a controller has been removed/disconnected
  43042. */
  43043. onControllerRemovedObservable: Observable<WebXRController>;
  43044. /**
  43045. * Initializes the WebXRInput
  43046. * @param baseExperience experience helper which the input should be created for
  43047. */
  43048. constructor(
  43049. /**
  43050. * Base experience the input listens to
  43051. */
  43052. baseExperience: WebXRExperienceHelper);
  43053. private _onInputSourcesChange;
  43054. private _addAndRemoveControllers;
  43055. /**
  43056. * Disposes of the object
  43057. */
  43058. dispose(): void;
  43059. }
  43060. }
  43061. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  43062. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43063. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43064. /**
  43065. * Enables teleportation
  43066. */
  43067. export class WebXRControllerTeleportation {
  43068. private _teleportationFillColor;
  43069. private _teleportationBorderColor;
  43070. private _tmpRay;
  43071. private _tmpVector;
  43072. /**
  43073. * Creates a WebXRControllerTeleportation
  43074. * @param input input manager to add teleportation to
  43075. * @param floorMeshes floormeshes which can be teleported to
  43076. */
  43077. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43078. }
  43079. }
  43080. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  43081. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43082. /**
  43083. * Handles pointer input automatically for the pointer of XR controllers
  43084. */
  43085. export class WebXRControllerPointerSelection {
  43086. private static _idCounter;
  43087. private _tmpRay;
  43088. /**
  43089. * Creates a WebXRControllerPointerSelection
  43090. * @param input input manager to setup pointer selection
  43091. */
  43092. constructor(input: WebXRInput);
  43093. private _convertNormalToDirectionOfRay;
  43094. private _updatePointerDistance;
  43095. }
  43096. }
  43097. declare module "babylonjs/Loading/sceneLoader" {
  43098. import { Observable } from "babylonjs/Misc/observable";
  43099. import { Nullable } from "babylonjs/types";
  43100. import { Scene } from "babylonjs/scene";
  43101. import { Engine } from "babylonjs/Engines/engine";
  43102. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43103. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43104. import { AssetContainer } from "babylonjs/assetContainer";
  43105. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43106. import { Skeleton } from "babylonjs/Bones/skeleton";
  43107. /**
  43108. * Class used to represent data loading progression
  43109. */
  43110. export class SceneLoaderProgressEvent {
  43111. /** defines if data length to load can be evaluated */
  43112. readonly lengthComputable: boolean;
  43113. /** defines the loaded data length */
  43114. readonly loaded: number;
  43115. /** defines the data length to load */
  43116. readonly total: number;
  43117. /**
  43118. * Create a new progress event
  43119. * @param lengthComputable defines if data length to load can be evaluated
  43120. * @param loaded defines the loaded data length
  43121. * @param total defines the data length to load
  43122. */
  43123. constructor(
  43124. /** defines if data length to load can be evaluated */
  43125. lengthComputable: boolean,
  43126. /** defines the loaded data length */
  43127. loaded: number,
  43128. /** defines the data length to load */
  43129. total: number);
  43130. /**
  43131. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43132. * @param event defines the source event
  43133. * @returns a new SceneLoaderProgressEvent
  43134. */
  43135. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43136. }
  43137. /**
  43138. * Interface used by SceneLoader plugins to define supported file extensions
  43139. */
  43140. export interface ISceneLoaderPluginExtensions {
  43141. /**
  43142. * Defines the list of supported extensions
  43143. */
  43144. [extension: string]: {
  43145. isBinary: boolean;
  43146. };
  43147. }
  43148. /**
  43149. * Interface used by SceneLoader plugin factory
  43150. */
  43151. export interface ISceneLoaderPluginFactory {
  43152. /**
  43153. * Defines the name of the factory
  43154. */
  43155. name: string;
  43156. /**
  43157. * Function called to create a new plugin
  43158. * @return the new plugin
  43159. */
  43160. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43161. /**
  43162. * Boolean indicating if the plugin can direct load specific data
  43163. */
  43164. canDirectLoad?: (data: string) => boolean;
  43165. }
  43166. /**
  43167. * Interface used to define a SceneLoader plugin
  43168. */
  43169. export interface ISceneLoaderPlugin {
  43170. /**
  43171. * The friendly name of this plugin.
  43172. */
  43173. name: string;
  43174. /**
  43175. * The file extensions supported by this plugin.
  43176. */
  43177. extensions: string | ISceneLoaderPluginExtensions;
  43178. /**
  43179. * Import meshes into a scene.
  43180. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43181. * @param scene The scene to import into
  43182. * @param data The data to import
  43183. * @param rootUrl The root url for scene and resources
  43184. * @param meshes The meshes array to import into
  43185. * @param particleSystems The particle systems array to import into
  43186. * @param skeletons The skeletons array to import into
  43187. * @param onError The callback when import fails
  43188. * @returns True if successful or false otherwise
  43189. */
  43190. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43191. /**
  43192. * Load into a scene.
  43193. * @param scene The scene to load into
  43194. * @param data The data to import
  43195. * @param rootUrl The root url for scene and resources
  43196. * @param onError The callback when import fails
  43197. * @returns true if successful or false otherwise
  43198. */
  43199. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43200. /**
  43201. * The callback that returns true if the data can be directly loaded.
  43202. */
  43203. canDirectLoad?: (data: string) => boolean;
  43204. /**
  43205. * The callback that allows custom handling of the root url based on the response url.
  43206. */
  43207. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43208. /**
  43209. * Load into an asset container.
  43210. * @param scene The scene to load into
  43211. * @param data The data to import
  43212. * @param rootUrl The root url for scene and resources
  43213. * @param onError The callback when import fails
  43214. * @returns The loaded asset container
  43215. */
  43216. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43217. }
  43218. /**
  43219. * Interface used to define an async SceneLoader plugin
  43220. */
  43221. export interface ISceneLoaderPluginAsync {
  43222. /**
  43223. * The friendly name of this plugin.
  43224. */
  43225. name: string;
  43226. /**
  43227. * The file extensions supported by this plugin.
  43228. */
  43229. extensions: string | ISceneLoaderPluginExtensions;
  43230. /**
  43231. * Import meshes into a scene.
  43232. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43233. * @param scene The scene to import into
  43234. * @param data The data to import
  43235. * @param rootUrl The root url for scene and resources
  43236. * @param onProgress The callback when the load progresses
  43237. * @param fileName Defines the name of the file to load
  43238. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43239. */
  43240. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43241. meshes: AbstractMesh[];
  43242. particleSystems: IParticleSystem[];
  43243. skeletons: Skeleton[];
  43244. animationGroups: AnimationGroup[];
  43245. }>;
  43246. /**
  43247. * Load into a scene.
  43248. * @param scene The scene to load into
  43249. * @param data The data to import
  43250. * @param rootUrl The root url for scene and resources
  43251. * @param onProgress The callback when the load progresses
  43252. * @param fileName Defines the name of the file to load
  43253. * @returns Nothing
  43254. */
  43255. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43256. /**
  43257. * The callback that returns true if the data can be directly loaded.
  43258. */
  43259. canDirectLoad?: (data: string) => boolean;
  43260. /**
  43261. * The callback that allows custom handling of the root url based on the response url.
  43262. */
  43263. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43264. /**
  43265. * Load into an asset container.
  43266. * @param scene The scene to load into
  43267. * @param data The data to import
  43268. * @param rootUrl The root url for scene and resources
  43269. * @param onProgress The callback when the load progresses
  43270. * @param fileName Defines the name of the file to load
  43271. * @returns The loaded asset container
  43272. */
  43273. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43274. }
  43275. /**
  43276. * Class used to load scene from various file formats using registered plugins
  43277. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43278. */
  43279. export class SceneLoader {
  43280. /**
  43281. * No logging while loading
  43282. */
  43283. static readonly NO_LOGGING: number;
  43284. /**
  43285. * Minimal logging while loading
  43286. */
  43287. static readonly MINIMAL_LOGGING: number;
  43288. /**
  43289. * Summary logging while loading
  43290. */
  43291. static readonly SUMMARY_LOGGING: number;
  43292. /**
  43293. * Detailled logging while loading
  43294. */
  43295. static readonly DETAILED_LOGGING: number;
  43296. /**
  43297. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43298. */
  43299. static ForceFullSceneLoadingForIncremental: boolean;
  43300. /**
  43301. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43302. */
  43303. static ShowLoadingScreen: boolean;
  43304. /**
  43305. * Defines the current logging level (while loading the scene)
  43306. * @ignorenaming
  43307. */
  43308. static loggingLevel: number;
  43309. /**
  43310. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43311. */
  43312. static CleanBoneMatrixWeights: boolean;
  43313. /**
  43314. * Event raised when a plugin is used to load a scene
  43315. */
  43316. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43317. private static _registeredPlugins;
  43318. private static _getDefaultPlugin;
  43319. private static _getPluginForExtension;
  43320. private static _getPluginForDirectLoad;
  43321. private static _getPluginForFilename;
  43322. private static _getDirectLoad;
  43323. private static _loadData;
  43324. private static _getFileInfo;
  43325. /**
  43326. * Gets a plugin that can load the given extension
  43327. * @param extension defines the extension to load
  43328. * @returns a plugin or null if none works
  43329. */
  43330. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43331. /**
  43332. * Gets a boolean indicating that the given extension can be loaded
  43333. * @param extension defines the extension to load
  43334. * @returns true if the extension is supported
  43335. */
  43336. static IsPluginForExtensionAvailable(extension: string): boolean;
  43337. /**
  43338. * Adds a new plugin to the list of registered plugins
  43339. * @param plugin defines the plugin to add
  43340. */
  43341. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43342. /**
  43343. * Import meshes into a scene
  43344. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43345. * @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)
  43346. * @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)
  43347. * @param scene the instance of BABYLON.Scene to append to
  43348. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43349. * @param onProgress a callback with a progress event for each file being loaded
  43350. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43351. * @param pluginExtension the extension used to determine the plugin
  43352. * @returns The loaded plugin
  43353. */
  43354. 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>;
  43355. /**
  43356. * Import meshes into a scene
  43357. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43358. * @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)
  43359. * @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)
  43360. * @param scene the instance of BABYLON.Scene to append to
  43361. * @param onProgress a callback with a progress event for each file being loaded
  43362. * @param pluginExtension the extension used to determine the plugin
  43363. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43364. */
  43365. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43366. meshes: AbstractMesh[];
  43367. particleSystems: IParticleSystem[];
  43368. skeletons: Skeleton[];
  43369. animationGroups: AnimationGroup[];
  43370. }>;
  43371. /**
  43372. * Load a scene
  43373. * @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)
  43374. * @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)
  43375. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43376. * @param onSuccess a callback with the scene when import succeeds
  43377. * @param onProgress a callback with a progress event for each file being loaded
  43378. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43379. * @param pluginExtension the extension used to determine the plugin
  43380. * @returns The loaded plugin
  43381. */
  43382. 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>;
  43383. /**
  43384. * Load a scene
  43385. * @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)
  43386. * @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)
  43387. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43388. * @param onProgress a callback with a progress event for each file being loaded
  43389. * @param pluginExtension the extension used to determine the plugin
  43390. * @returns The loaded scene
  43391. */
  43392. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43393. /**
  43394. * Append a scene
  43395. * @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)
  43396. * @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)
  43397. * @param scene is the instance of BABYLON.Scene to append to
  43398. * @param onSuccess a callback with the scene when import succeeds
  43399. * @param onProgress a callback with a progress event for each file being loaded
  43400. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43401. * @param pluginExtension the extension used to determine the plugin
  43402. * @returns The loaded plugin
  43403. */
  43404. 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>;
  43405. /**
  43406. * Append a scene
  43407. * @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)
  43408. * @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)
  43409. * @param scene is the instance of BABYLON.Scene to append to
  43410. * @param onProgress a callback with a progress event for each file being loaded
  43411. * @param pluginExtension the extension used to determine the plugin
  43412. * @returns The given scene
  43413. */
  43414. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43415. /**
  43416. * Load a scene into an asset container
  43417. * @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)
  43418. * @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)
  43419. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43420. * @param onSuccess a callback with the scene when import succeeds
  43421. * @param onProgress a callback with a progress event for each file being loaded
  43422. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43423. * @param pluginExtension the extension used to determine the plugin
  43424. * @returns The loaded plugin
  43425. */
  43426. 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>;
  43427. /**
  43428. * Load a scene into an asset container
  43429. * @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)
  43430. * @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)
  43431. * @param scene is the instance of Scene to append to
  43432. * @param onProgress a callback with a progress event for each file being loaded
  43433. * @param pluginExtension the extension used to determine the plugin
  43434. * @returns The loaded asset container
  43435. */
  43436. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43437. }
  43438. }
  43439. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43440. import { Scene } from "babylonjs/scene";
  43441. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43442. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43443. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43444. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43445. /**
  43446. * Generic Controller
  43447. */
  43448. export class GenericController extends WebVRController {
  43449. /**
  43450. * Base Url for the controller model.
  43451. */
  43452. static readonly MODEL_BASE_URL: string;
  43453. /**
  43454. * File name for the controller model.
  43455. */
  43456. static readonly MODEL_FILENAME: string;
  43457. /**
  43458. * Creates a new GenericController from a gamepad
  43459. * @param vrGamepad the gamepad that the controller should be created from
  43460. */
  43461. constructor(vrGamepad: any);
  43462. /**
  43463. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43464. * @param scene scene in which to add meshes
  43465. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43466. */
  43467. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43468. /**
  43469. * Called once for each button that changed state since the last frame
  43470. * @param buttonIdx Which button index changed
  43471. * @param state New state of the button
  43472. * @param changes Which properties on the state changed since last frame
  43473. */
  43474. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43475. }
  43476. }
  43477. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43478. import { Observable } from "babylonjs/Misc/observable";
  43479. import { Scene } from "babylonjs/scene";
  43480. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43481. import { Ray } from "babylonjs/Culling/ray";
  43482. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43483. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43484. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43485. /**
  43486. * Defines the WindowsMotionController object that the state of the windows motion controller
  43487. */
  43488. export class WindowsMotionController extends WebVRController {
  43489. /**
  43490. * The base url used to load the left and right controller models
  43491. */
  43492. static MODEL_BASE_URL: string;
  43493. /**
  43494. * The name of the left controller model file
  43495. */
  43496. static MODEL_LEFT_FILENAME: string;
  43497. /**
  43498. * The name of the right controller model file
  43499. */
  43500. static MODEL_RIGHT_FILENAME: string;
  43501. /**
  43502. * The controller name prefix for this controller type
  43503. */
  43504. static readonly GAMEPAD_ID_PREFIX: string;
  43505. /**
  43506. * The controller id pattern for this controller type
  43507. */
  43508. private static readonly GAMEPAD_ID_PATTERN;
  43509. private _loadedMeshInfo;
  43510. private readonly _mapping;
  43511. /**
  43512. * Fired when the trackpad on this controller is clicked
  43513. */
  43514. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43515. /**
  43516. * Fired when the trackpad on this controller is modified
  43517. */
  43518. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43519. /**
  43520. * The current x and y values of this controller's trackpad
  43521. */
  43522. trackpad: StickValues;
  43523. /**
  43524. * Creates a new WindowsMotionController from a gamepad
  43525. * @param vrGamepad the gamepad that the controller should be created from
  43526. */
  43527. constructor(vrGamepad: any);
  43528. /**
  43529. * Fired when the trigger on this controller is modified
  43530. */
  43531. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43532. /**
  43533. * Fired when the menu button on this controller is modified
  43534. */
  43535. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43536. /**
  43537. * Fired when the grip button on this controller is modified
  43538. */
  43539. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43540. /**
  43541. * Fired when the thumbstick button on this controller is modified
  43542. */
  43543. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43544. /**
  43545. * Fired when the touchpad button on this controller is modified
  43546. */
  43547. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43548. /**
  43549. * Fired when the touchpad values on this controller are modified
  43550. */
  43551. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43552. private _updateTrackpad;
  43553. /**
  43554. * Called once per frame by the engine.
  43555. */
  43556. update(): void;
  43557. /**
  43558. * Called once for each button that changed state since the last frame
  43559. * @param buttonIdx Which button index changed
  43560. * @param state New state of the button
  43561. * @param changes Which properties on the state changed since last frame
  43562. */
  43563. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43564. /**
  43565. * Moves the buttons on the controller mesh based on their current state
  43566. * @param buttonName the name of the button to move
  43567. * @param buttonValue the value of the button which determines the buttons new position
  43568. */
  43569. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43570. /**
  43571. * Moves the axis on the controller mesh based on its current state
  43572. * @param axis the index of the axis
  43573. * @param axisValue the value of the axis which determines the meshes new position
  43574. * @hidden
  43575. */
  43576. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43577. /**
  43578. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43579. * @param scene scene in which to add meshes
  43580. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43581. */
  43582. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43583. /**
  43584. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43585. * can be transformed by button presses and axes values, based on this._mapping.
  43586. *
  43587. * @param scene scene in which the meshes exist
  43588. * @param meshes list of meshes that make up the controller model to process
  43589. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43590. */
  43591. private processModel;
  43592. private createMeshInfo;
  43593. /**
  43594. * Gets the ray of the controller in the direction the controller is pointing
  43595. * @param length the length the resulting ray should be
  43596. * @returns a ray in the direction the controller is pointing
  43597. */
  43598. getForwardRay(length?: number): Ray;
  43599. /**
  43600. * Disposes of the controller
  43601. */
  43602. dispose(): void;
  43603. }
  43604. }
  43605. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43606. import { Observable } from "babylonjs/Misc/observable";
  43607. import { Scene } from "babylonjs/scene";
  43608. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43609. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43610. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43611. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43612. /**
  43613. * Oculus Touch Controller
  43614. */
  43615. export class OculusTouchController extends WebVRController {
  43616. /**
  43617. * Base Url for the controller model.
  43618. */
  43619. static MODEL_BASE_URL: string;
  43620. /**
  43621. * File name for the left controller model.
  43622. */
  43623. static MODEL_LEFT_FILENAME: string;
  43624. /**
  43625. * File name for the right controller model.
  43626. */
  43627. static MODEL_RIGHT_FILENAME: string;
  43628. /**
  43629. * Base Url for the Quest controller model.
  43630. */
  43631. static QUEST_MODEL_BASE_URL: string;
  43632. /**
  43633. * @hidden
  43634. * If the controllers are running on a device that needs the updated Quest controller models
  43635. */
  43636. static _IsQuest: boolean;
  43637. /**
  43638. * Fired when the secondary trigger on this controller is modified
  43639. */
  43640. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43641. /**
  43642. * Fired when the thumb rest on this controller is modified
  43643. */
  43644. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43645. /**
  43646. * Creates a new OculusTouchController from a gamepad
  43647. * @param vrGamepad the gamepad that the controller should be created from
  43648. */
  43649. constructor(vrGamepad: any);
  43650. /**
  43651. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43652. * @param scene scene in which to add meshes
  43653. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43654. */
  43655. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43656. /**
  43657. * Fired when the A button on this controller is modified
  43658. */
  43659. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43660. /**
  43661. * Fired when the B button on this controller is modified
  43662. */
  43663. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43664. /**
  43665. * Fired when the X button on this controller is modified
  43666. */
  43667. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43668. /**
  43669. * Fired when the Y button on this controller is modified
  43670. */
  43671. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43672. /**
  43673. * Called once for each button that changed state since the last frame
  43674. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43675. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43676. * 2) secondary trigger (same)
  43677. * 3) A (right) X (left), touch, pressed = value
  43678. * 4) B / Y
  43679. * 5) thumb rest
  43680. * @param buttonIdx Which button index changed
  43681. * @param state New state of the button
  43682. * @param changes Which properties on the state changed since last frame
  43683. */
  43684. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43685. }
  43686. }
  43687. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43688. import { Scene } from "babylonjs/scene";
  43689. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43690. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43691. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43692. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43693. import { Observable } from "babylonjs/Misc/observable";
  43694. /**
  43695. * Vive Controller
  43696. */
  43697. export class ViveController extends WebVRController {
  43698. /**
  43699. * Base Url for the controller model.
  43700. */
  43701. static MODEL_BASE_URL: string;
  43702. /**
  43703. * File name for the controller model.
  43704. */
  43705. static MODEL_FILENAME: string;
  43706. /**
  43707. * Creates a new ViveController from a gamepad
  43708. * @param vrGamepad the gamepad that the controller should be created from
  43709. */
  43710. constructor(vrGamepad: any);
  43711. /**
  43712. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43713. * @param scene scene in which to add meshes
  43714. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43715. */
  43716. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43717. /**
  43718. * Fired when the left button on this controller is modified
  43719. */
  43720. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43721. /**
  43722. * Fired when the right button on this controller is modified
  43723. */
  43724. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43725. /**
  43726. * Fired when the menu button on this controller is modified
  43727. */
  43728. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43729. /**
  43730. * Called once for each button that changed state since the last frame
  43731. * Vive mapping:
  43732. * 0: touchpad
  43733. * 1: trigger
  43734. * 2: left AND right buttons
  43735. * 3: menu button
  43736. * @param buttonIdx Which button index changed
  43737. * @param state New state of the button
  43738. * @param changes Which properties on the state changed since last frame
  43739. */
  43740. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43741. }
  43742. }
  43743. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  43744. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43745. /**
  43746. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43747. */
  43748. export class WebXRControllerModelLoader {
  43749. /**
  43750. * Creates the WebXRControllerModelLoader
  43751. * @param input xr input that creates the controllers
  43752. */
  43753. constructor(input: WebXRInput);
  43754. }
  43755. }
  43756. declare module "babylonjs/Cameras/XR/index" {
  43757. export * from "babylonjs/Cameras/XR/webXRCamera";
  43758. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  43759. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43760. export * from "babylonjs/Cameras/XR/webXRInput";
  43761. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  43762. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  43763. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  43764. export * from "babylonjs/Cameras/XR/webXRController";
  43765. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43766. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  43767. }
  43768. declare module "babylonjs/Cameras/RigModes/index" {
  43769. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43770. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43771. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  43772. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  43773. }
  43774. declare module "babylonjs/Cameras/index" {
  43775. export * from "babylonjs/Cameras/Inputs/index";
  43776. export * from "babylonjs/Cameras/cameraInputsManager";
  43777. export * from "babylonjs/Cameras/camera";
  43778. export * from "babylonjs/Cameras/targetCamera";
  43779. export * from "babylonjs/Cameras/freeCamera";
  43780. export * from "babylonjs/Cameras/freeCameraInputsManager";
  43781. export * from "babylonjs/Cameras/touchCamera";
  43782. export * from "babylonjs/Cameras/arcRotateCamera";
  43783. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43784. export * from "babylonjs/Cameras/deviceOrientationCamera";
  43785. export * from "babylonjs/Cameras/flyCamera";
  43786. export * from "babylonjs/Cameras/flyCameraInputsManager";
  43787. export * from "babylonjs/Cameras/followCamera";
  43788. export * from "babylonjs/Cameras/followCameraInputsManager";
  43789. export * from "babylonjs/Cameras/gamepadCamera";
  43790. export * from "babylonjs/Cameras/Stereoscopic/index";
  43791. export * from "babylonjs/Cameras/universalCamera";
  43792. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  43793. export * from "babylonjs/Cameras/VR/index";
  43794. export * from "babylonjs/Cameras/XR/index";
  43795. export * from "babylonjs/Cameras/RigModes/index";
  43796. }
  43797. declare module "babylonjs/Collisions/index" {
  43798. export * from "babylonjs/Collisions/collider";
  43799. export * from "babylonjs/Collisions/collisionCoordinator";
  43800. export * from "babylonjs/Collisions/pickingInfo";
  43801. export * from "babylonjs/Collisions/intersectionInfo";
  43802. export * from "babylonjs/Collisions/meshCollisionData";
  43803. }
  43804. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  43805. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  43806. import { Vector3 } from "babylonjs/Maths/math.vector";
  43807. import { Ray } from "babylonjs/Culling/ray";
  43808. import { Plane } from "babylonjs/Maths/math.plane";
  43809. /**
  43810. * Contains an array of blocks representing the octree
  43811. */
  43812. export interface IOctreeContainer<T> {
  43813. /**
  43814. * Blocks within the octree
  43815. */
  43816. blocks: Array<OctreeBlock<T>>;
  43817. }
  43818. /**
  43819. * Class used to store a cell in an octree
  43820. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43821. */
  43822. export class OctreeBlock<T> {
  43823. /**
  43824. * Gets the content of the current block
  43825. */
  43826. entries: T[];
  43827. /**
  43828. * Gets the list of block children
  43829. */
  43830. blocks: Array<OctreeBlock<T>>;
  43831. private _depth;
  43832. private _maxDepth;
  43833. private _capacity;
  43834. private _minPoint;
  43835. private _maxPoint;
  43836. private _boundingVectors;
  43837. private _creationFunc;
  43838. /**
  43839. * Creates a new block
  43840. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  43841. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  43842. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43843. * @param depth defines the current depth of this block in the octree
  43844. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  43845. * @param creationFunc defines a callback to call when an element is added to the block
  43846. */
  43847. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  43848. /**
  43849. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43850. */
  43851. readonly capacity: number;
  43852. /**
  43853. * Gets the minimum vector (in world space) of the block's bounding box
  43854. */
  43855. readonly minPoint: Vector3;
  43856. /**
  43857. * Gets the maximum vector (in world space) of the block's bounding box
  43858. */
  43859. readonly maxPoint: Vector3;
  43860. /**
  43861. * Add a new element to this block
  43862. * @param entry defines the element to add
  43863. */
  43864. addEntry(entry: T): void;
  43865. /**
  43866. * Remove an element from this block
  43867. * @param entry defines the element to remove
  43868. */
  43869. removeEntry(entry: T): void;
  43870. /**
  43871. * Add an array of elements to this block
  43872. * @param entries defines the array of elements to add
  43873. */
  43874. addEntries(entries: T[]): void;
  43875. /**
  43876. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  43877. * @param frustumPlanes defines the frustum planes to test
  43878. * @param selection defines the array to store current content if selection is positive
  43879. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43880. */
  43881. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43882. /**
  43883. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  43884. * @param sphereCenter defines the bounding sphere center
  43885. * @param sphereRadius defines the bounding sphere radius
  43886. * @param selection defines the array to store current content if selection is positive
  43887. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43888. */
  43889. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43890. /**
  43891. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  43892. * @param ray defines the ray to test with
  43893. * @param selection defines the array to store current content if selection is positive
  43894. */
  43895. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  43896. /**
  43897. * Subdivide the content into child blocks (this block will then be empty)
  43898. */
  43899. createInnerBlocks(): void;
  43900. /**
  43901. * @hidden
  43902. */
  43903. 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;
  43904. }
  43905. }
  43906. declare module "babylonjs/Culling/Octrees/octree" {
  43907. import { SmartArray } from "babylonjs/Misc/smartArray";
  43908. import { Vector3 } from "babylonjs/Maths/math.vector";
  43909. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43910. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43911. import { Ray } from "babylonjs/Culling/ray";
  43912. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  43913. import { Plane } from "babylonjs/Maths/math.plane";
  43914. /**
  43915. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  43916. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43917. */
  43918. export class Octree<T> {
  43919. /** 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.) */
  43920. maxDepth: number;
  43921. /**
  43922. * Blocks within the octree containing objects
  43923. */
  43924. blocks: Array<OctreeBlock<T>>;
  43925. /**
  43926. * Content stored in the octree
  43927. */
  43928. dynamicContent: T[];
  43929. private _maxBlockCapacity;
  43930. private _selectionContent;
  43931. private _creationFunc;
  43932. /**
  43933. * Creates a octree
  43934. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43935. * @param creationFunc function to be used to instatiate the octree
  43936. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  43937. * @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.)
  43938. */
  43939. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  43940. /** 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.) */
  43941. maxDepth?: number);
  43942. /**
  43943. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  43944. * @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);
  43945. * @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);
  43946. * @param entries meshes to be added to the octree blocks
  43947. */
  43948. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  43949. /**
  43950. * Adds a mesh to the octree
  43951. * @param entry Mesh to add to the octree
  43952. */
  43953. addMesh(entry: T): void;
  43954. /**
  43955. * Remove an element from the octree
  43956. * @param entry defines the element to remove
  43957. */
  43958. removeMesh(entry: T): void;
  43959. /**
  43960. * Selects an array of meshes within the frustum
  43961. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  43962. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  43963. * @returns array of meshes within the frustum
  43964. */
  43965. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  43966. /**
  43967. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  43968. * @param sphereCenter defines the bounding sphere center
  43969. * @param sphereRadius defines the bounding sphere radius
  43970. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43971. * @returns an array of objects that intersect the sphere
  43972. */
  43973. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  43974. /**
  43975. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  43976. * @param ray defines the ray to test with
  43977. * @returns array of intersected objects
  43978. */
  43979. intersectsRay(ray: Ray): SmartArray<T>;
  43980. /**
  43981. * Adds a mesh into the octree block if it intersects the block
  43982. */
  43983. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  43984. /**
  43985. * Adds a submesh into the octree block if it intersects the block
  43986. */
  43987. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  43988. }
  43989. }
  43990. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  43991. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  43992. import { Scene } from "babylonjs/scene";
  43993. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43994. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43995. import { Ray } from "babylonjs/Culling/ray";
  43996. import { Octree } from "babylonjs/Culling/Octrees/octree";
  43997. import { Collider } from "babylonjs/Collisions/collider";
  43998. module "babylonjs/scene" {
  43999. interface Scene {
  44000. /**
  44001. * @hidden
  44002. * Backing Filed
  44003. */
  44004. _selectionOctree: Octree<AbstractMesh>;
  44005. /**
  44006. * Gets the octree used to boost mesh selection (picking)
  44007. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44008. */
  44009. selectionOctree: Octree<AbstractMesh>;
  44010. /**
  44011. * Creates or updates the octree used to boost selection (picking)
  44012. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44013. * @param maxCapacity defines the maximum capacity per leaf
  44014. * @param maxDepth defines the maximum depth of the octree
  44015. * @returns an octree of AbstractMesh
  44016. */
  44017. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44018. }
  44019. }
  44020. module "babylonjs/Meshes/abstractMesh" {
  44021. interface AbstractMesh {
  44022. /**
  44023. * @hidden
  44024. * Backing Field
  44025. */
  44026. _submeshesOctree: Octree<SubMesh>;
  44027. /**
  44028. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44029. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44030. * @param maxCapacity defines the maximum size of each block (64 by default)
  44031. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44032. * @returns the new octree
  44033. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44034. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44035. */
  44036. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44037. }
  44038. }
  44039. /**
  44040. * Defines the octree scene component responsible to manage any octrees
  44041. * in a given scene.
  44042. */
  44043. export class OctreeSceneComponent {
  44044. /**
  44045. * The component name help to identify the component in the list of scene components.
  44046. */
  44047. readonly name: string;
  44048. /**
  44049. * The scene the component belongs to.
  44050. */
  44051. scene: Scene;
  44052. /**
  44053. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44054. */
  44055. readonly checksIsEnabled: boolean;
  44056. /**
  44057. * Creates a new instance of the component for the given scene
  44058. * @param scene Defines the scene to register the component in
  44059. */
  44060. constructor(scene: Scene);
  44061. /**
  44062. * Registers the component in a given scene
  44063. */
  44064. register(): void;
  44065. /**
  44066. * Return the list of active meshes
  44067. * @returns the list of active meshes
  44068. */
  44069. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44070. /**
  44071. * Return the list of active sub meshes
  44072. * @param mesh The mesh to get the candidates sub meshes from
  44073. * @returns the list of active sub meshes
  44074. */
  44075. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44076. private _tempRay;
  44077. /**
  44078. * Return the list of sub meshes intersecting with a given local ray
  44079. * @param mesh defines the mesh to find the submesh for
  44080. * @param localRay defines the ray in local space
  44081. * @returns the list of intersecting sub meshes
  44082. */
  44083. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44084. /**
  44085. * Return the list of sub meshes colliding with a collider
  44086. * @param mesh defines the mesh to find the submesh for
  44087. * @param collider defines the collider to evaluate the collision against
  44088. * @returns the list of colliding sub meshes
  44089. */
  44090. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44091. /**
  44092. * Rebuilds the elements related to this component in case of
  44093. * context lost for instance.
  44094. */
  44095. rebuild(): void;
  44096. /**
  44097. * Disposes the component and the associated ressources.
  44098. */
  44099. dispose(): void;
  44100. }
  44101. }
  44102. declare module "babylonjs/Culling/Octrees/index" {
  44103. export * from "babylonjs/Culling/Octrees/octree";
  44104. export * from "babylonjs/Culling/Octrees/octreeBlock";
  44105. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  44106. }
  44107. declare module "babylonjs/Culling/index" {
  44108. export * from "babylonjs/Culling/boundingBox";
  44109. export * from "babylonjs/Culling/boundingInfo";
  44110. export * from "babylonjs/Culling/boundingSphere";
  44111. export * from "babylonjs/Culling/Octrees/index";
  44112. export * from "babylonjs/Culling/ray";
  44113. }
  44114. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  44115. import { IDisposable, Scene } from "babylonjs/scene";
  44116. import { Nullable } from "babylonjs/types";
  44117. import { Observable } from "babylonjs/Misc/observable";
  44118. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44119. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  44120. import { Camera } from "babylonjs/Cameras/camera";
  44121. /**
  44122. * Renders a layer on top of an existing scene
  44123. */
  44124. export class UtilityLayerRenderer implements IDisposable {
  44125. /** the original scene that will be rendered on top of */
  44126. originalScene: Scene;
  44127. private _pointerCaptures;
  44128. private _lastPointerEvents;
  44129. private static _DefaultUtilityLayer;
  44130. private static _DefaultKeepDepthUtilityLayer;
  44131. private _sharedGizmoLight;
  44132. private _renderCamera;
  44133. /**
  44134. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44135. * @returns the camera that is used when rendering the utility layer
  44136. */
  44137. getRenderCamera(): Nullable<Camera>;
  44138. /**
  44139. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44140. * @param cam the camera that should be used when rendering the utility layer
  44141. */
  44142. setRenderCamera(cam: Nullable<Camera>): void;
  44143. /**
  44144. * @hidden
  44145. * Light which used by gizmos to get light shading
  44146. */
  44147. _getSharedGizmoLight(): HemisphericLight;
  44148. /**
  44149. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44150. */
  44151. pickUtilitySceneFirst: boolean;
  44152. /**
  44153. * 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)
  44154. */
  44155. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44156. /**
  44157. * 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)
  44158. */
  44159. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44160. /**
  44161. * The scene that is rendered on top of the original scene
  44162. */
  44163. utilityLayerScene: Scene;
  44164. /**
  44165. * If the utility layer should automatically be rendered on top of existing scene
  44166. */
  44167. shouldRender: boolean;
  44168. /**
  44169. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44170. */
  44171. onlyCheckPointerDownEvents: boolean;
  44172. /**
  44173. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44174. */
  44175. processAllEvents: boolean;
  44176. /**
  44177. * Observable raised when the pointer move from the utility layer scene to the main scene
  44178. */
  44179. onPointerOutObservable: Observable<number>;
  44180. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44181. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44182. private _afterRenderObserver;
  44183. private _sceneDisposeObserver;
  44184. private _originalPointerObserver;
  44185. /**
  44186. * Instantiates a UtilityLayerRenderer
  44187. * @param originalScene the original scene that will be rendered on top of
  44188. * @param handleEvents boolean indicating if the utility layer should handle events
  44189. */
  44190. constructor(
  44191. /** the original scene that will be rendered on top of */
  44192. originalScene: Scene, handleEvents?: boolean);
  44193. private _notifyObservers;
  44194. /**
  44195. * Renders the utility layers scene on top of the original scene
  44196. */
  44197. render(): void;
  44198. /**
  44199. * Disposes of the renderer
  44200. */
  44201. dispose(): void;
  44202. private _updateCamera;
  44203. }
  44204. }
  44205. declare module "babylonjs/Gizmos/gizmo" {
  44206. import { Nullable } from "babylonjs/types";
  44207. import { IDisposable } from "babylonjs/scene";
  44208. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44209. import { Mesh } from "babylonjs/Meshes/mesh";
  44210. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44211. /**
  44212. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44213. */
  44214. export class Gizmo implements IDisposable {
  44215. /** The utility layer the gizmo will be added to */
  44216. gizmoLayer: UtilityLayerRenderer;
  44217. /**
  44218. * The root mesh of the gizmo
  44219. */
  44220. _rootMesh: Mesh;
  44221. private _attachedMesh;
  44222. /**
  44223. * Ratio for the scale of the gizmo (Default: 1)
  44224. */
  44225. scaleRatio: number;
  44226. /**
  44227. * If a custom mesh has been set (Default: false)
  44228. */
  44229. protected _customMeshSet: boolean;
  44230. /**
  44231. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44232. * * When set, interactions will be enabled
  44233. */
  44234. attachedMesh: Nullable<AbstractMesh>;
  44235. /**
  44236. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44237. * @param mesh The mesh to replace the default mesh of the gizmo
  44238. */
  44239. setCustomMesh(mesh: Mesh): void;
  44240. /**
  44241. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44242. */
  44243. updateGizmoRotationToMatchAttachedMesh: boolean;
  44244. /**
  44245. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44246. */
  44247. updateGizmoPositionToMatchAttachedMesh: boolean;
  44248. /**
  44249. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44250. */
  44251. updateScale: boolean;
  44252. protected _interactionsEnabled: boolean;
  44253. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44254. private _beforeRenderObserver;
  44255. private _tempVector;
  44256. /**
  44257. * Creates a gizmo
  44258. * @param gizmoLayer The utility layer the gizmo will be added to
  44259. */
  44260. constructor(
  44261. /** The utility layer the gizmo will be added to */
  44262. gizmoLayer?: UtilityLayerRenderer);
  44263. /**
  44264. * Updates the gizmo to match the attached mesh's position/rotation
  44265. */
  44266. protected _update(): void;
  44267. /**
  44268. * Disposes of the gizmo
  44269. */
  44270. dispose(): void;
  44271. }
  44272. }
  44273. declare module "babylonjs/Gizmos/planeDragGizmo" {
  44274. import { Observable } from "babylonjs/Misc/observable";
  44275. import { Nullable } from "babylonjs/types";
  44276. import { Vector3 } from "babylonjs/Maths/math.vector";
  44277. import { Color3 } from "babylonjs/Maths/math.color";
  44278. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44279. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44280. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44281. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44282. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44283. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44284. import { Scene } from "babylonjs/scene";
  44285. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44286. /**
  44287. * Single plane drag gizmo
  44288. */
  44289. export class PlaneDragGizmo extends Gizmo {
  44290. /**
  44291. * Drag behavior responsible for the gizmos dragging interactions
  44292. */
  44293. dragBehavior: PointerDragBehavior;
  44294. private _pointerObserver;
  44295. /**
  44296. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44297. */
  44298. snapDistance: number;
  44299. /**
  44300. * Event that fires each time the gizmo snaps to a new location.
  44301. * * snapDistance is the the change in distance
  44302. */
  44303. onSnapObservable: Observable<{
  44304. snapDistance: number;
  44305. }>;
  44306. private _plane;
  44307. private _coloredMaterial;
  44308. private _hoverMaterial;
  44309. private _isEnabled;
  44310. private _parent;
  44311. /** @hidden */
  44312. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44313. /** @hidden */
  44314. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44315. /**
  44316. * Creates a PlaneDragGizmo
  44317. * @param gizmoLayer The utility layer the gizmo will be added to
  44318. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44319. * @param color The color of the gizmo
  44320. */
  44321. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44322. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44323. /**
  44324. * If the gizmo is enabled
  44325. */
  44326. isEnabled: boolean;
  44327. /**
  44328. * Disposes of the gizmo
  44329. */
  44330. dispose(): void;
  44331. }
  44332. }
  44333. declare module "babylonjs/Gizmos/positionGizmo" {
  44334. import { Observable } from "babylonjs/Misc/observable";
  44335. import { Nullable } from "babylonjs/types";
  44336. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44337. import { Mesh } from "babylonjs/Meshes/mesh";
  44338. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44339. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44340. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  44341. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44342. /**
  44343. * Gizmo that enables dragging a mesh along 3 axis
  44344. */
  44345. export class PositionGizmo extends Gizmo {
  44346. /**
  44347. * Internal gizmo used for interactions on the x axis
  44348. */
  44349. xGizmo: AxisDragGizmo;
  44350. /**
  44351. * Internal gizmo used for interactions on the y axis
  44352. */
  44353. yGizmo: AxisDragGizmo;
  44354. /**
  44355. * Internal gizmo used for interactions on the z axis
  44356. */
  44357. zGizmo: AxisDragGizmo;
  44358. /**
  44359. * Internal gizmo used for interactions on the yz plane
  44360. */
  44361. xPlaneGizmo: PlaneDragGizmo;
  44362. /**
  44363. * Internal gizmo used for interactions on the xz plane
  44364. */
  44365. yPlaneGizmo: PlaneDragGizmo;
  44366. /**
  44367. * Internal gizmo used for interactions on the xy plane
  44368. */
  44369. zPlaneGizmo: PlaneDragGizmo;
  44370. /**
  44371. * private variables
  44372. */
  44373. private _meshAttached;
  44374. private _updateGizmoRotationToMatchAttachedMesh;
  44375. private _snapDistance;
  44376. private _scaleRatio;
  44377. /** Fires an event when any of it's sub gizmos are dragged */
  44378. onDragStartObservable: Observable<unknown>;
  44379. /** Fires an event when any of it's sub gizmos are released from dragging */
  44380. onDragEndObservable: Observable<unknown>;
  44381. /**
  44382. * If set to true, planar drag is enabled
  44383. */
  44384. private _planarGizmoEnabled;
  44385. attachedMesh: Nullable<AbstractMesh>;
  44386. /**
  44387. * Creates a PositionGizmo
  44388. * @param gizmoLayer The utility layer the gizmo will be added to
  44389. */
  44390. constructor(gizmoLayer?: UtilityLayerRenderer);
  44391. /**
  44392. * If the planar drag gizmo is enabled
  44393. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44394. */
  44395. planarGizmoEnabled: boolean;
  44396. updateGizmoRotationToMatchAttachedMesh: boolean;
  44397. /**
  44398. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44399. */
  44400. snapDistance: number;
  44401. /**
  44402. * Ratio for the scale of the gizmo (Default: 1)
  44403. */
  44404. scaleRatio: number;
  44405. /**
  44406. * Disposes of the gizmo
  44407. */
  44408. dispose(): void;
  44409. /**
  44410. * CustomMeshes are not supported by this gizmo
  44411. * @param mesh The mesh to replace the default mesh of the gizmo
  44412. */
  44413. setCustomMesh(mesh: Mesh): void;
  44414. }
  44415. }
  44416. declare module "babylonjs/Gizmos/axisDragGizmo" {
  44417. import { Observable } from "babylonjs/Misc/observable";
  44418. import { Nullable } from "babylonjs/types";
  44419. import { Vector3 } from "babylonjs/Maths/math.vector";
  44420. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44422. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44423. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44424. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44425. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44426. import { Scene } from "babylonjs/scene";
  44427. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44428. import { Color3 } from "babylonjs/Maths/math.color";
  44429. /**
  44430. * Single axis drag gizmo
  44431. */
  44432. export class AxisDragGizmo extends Gizmo {
  44433. /**
  44434. * Drag behavior responsible for the gizmos dragging interactions
  44435. */
  44436. dragBehavior: PointerDragBehavior;
  44437. private _pointerObserver;
  44438. /**
  44439. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44440. */
  44441. snapDistance: number;
  44442. /**
  44443. * Event that fires each time the gizmo snaps to a new location.
  44444. * * snapDistance is the the change in distance
  44445. */
  44446. onSnapObservable: Observable<{
  44447. snapDistance: number;
  44448. }>;
  44449. private _isEnabled;
  44450. private _parent;
  44451. private _arrow;
  44452. private _coloredMaterial;
  44453. private _hoverMaterial;
  44454. /** @hidden */
  44455. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44456. /** @hidden */
  44457. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44458. /**
  44459. * Creates an AxisDragGizmo
  44460. * @param gizmoLayer The utility layer the gizmo will be added to
  44461. * @param dragAxis The axis which the gizmo will be able to drag on
  44462. * @param color The color of the gizmo
  44463. */
  44464. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44465. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44466. /**
  44467. * If the gizmo is enabled
  44468. */
  44469. isEnabled: boolean;
  44470. /**
  44471. * Disposes of the gizmo
  44472. */
  44473. dispose(): void;
  44474. }
  44475. }
  44476. declare module "babylonjs/Debug/axesViewer" {
  44477. import { Vector3 } from "babylonjs/Maths/math.vector";
  44478. import { Nullable } from "babylonjs/types";
  44479. import { Scene } from "babylonjs/scene";
  44480. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44481. /**
  44482. * The Axes viewer will show 3 axes in a specific point in space
  44483. */
  44484. export class AxesViewer {
  44485. private _xAxis;
  44486. private _yAxis;
  44487. private _zAxis;
  44488. private _scaleLinesFactor;
  44489. private _instanced;
  44490. /**
  44491. * Gets the hosting scene
  44492. */
  44493. scene: Scene;
  44494. /**
  44495. * Gets or sets a number used to scale line length
  44496. */
  44497. scaleLines: number;
  44498. /** Gets the node hierarchy used to render x-axis */
  44499. readonly xAxis: TransformNode;
  44500. /** Gets the node hierarchy used to render y-axis */
  44501. readonly yAxis: TransformNode;
  44502. /** Gets the node hierarchy used to render z-axis */
  44503. readonly zAxis: TransformNode;
  44504. /**
  44505. * Creates a new AxesViewer
  44506. * @param scene defines the hosting scene
  44507. * @param scaleLines defines a number used to scale line length (1 by default)
  44508. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44509. * @param xAxis defines the node hierarchy used to render the x-axis
  44510. * @param yAxis defines the node hierarchy used to render the y-axis
  44511. * @param zAxis defines the node hierarchy used to render the z-axis
  44512. */
  44513. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44514. /**
  44515. * Force the viewer to update
  44516. * @param position defines the position of the viewer
  44517. * @param xaxis defines the x axis of the viewer
  44518. * @param yaxis defines the y axis of the viewer
  44519. * @param zaxis defines the z axis of the viewer
  44520. */
  44521. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44522. /**
  44523. * Creates an instance of this axes viewer.
  44524. * @returns a new axes viewer with instanced meshes
  44525. */
  44526. createInstance(): AxesViewer;
  44527. /** Releases resources */
  44528. dispose(): void;
  44529. private static _SetRenderingGroupId;
  44530. }
  44531. }
  44532. declare module "babylonjs/Debug/boneAxesViewer" {
  44533. import { Nullable } from "babylonjs/types";
  44534. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44535. import { Vector3 } from "babylonjs/Maths/math.vector";
  44536. import { Mesh } from "babylonjs/Meshes/mesh";
  44537. import { Bone } from "babylonjs/Bones/bone";
  44538. import { Scene } from "babylonjs/scene";
  44539. /**
  44540. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44541. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44542. */
  44543. export class BoneAxesViewer extends AxesViewer {
  44544. /**
  44545. * Gets or sets the target mesh where to display the axes viewer
  44546. */
  44547. mesh: Nullable<Mesh>;
  44548. /**
  44549. * Gets or sets the target bone where to display the axes viewer
  44550. */
  44551. bone: Nullable<Bone>;
  44552. /** Gets current position */
  44553. pos: Vector3;
  44554. /** Gets direction of X axis */
  44555. xaxis: Vector3;
  44556. /** Gets direction of Y axis */
  44557. yaxis: Vector3;
  44558. /** Gets direction of Z axis */
  44559. zaxis: Vector3;
  44560. /**
  44561. * Creates a new BoneAxesViewer
  44562. * @param scene defines the hosting scene
  44563. * @param bone defines the target bone
  44564. * @param mesh defines the target mesh
  44565. * @param scaleLines defines a scaling factor for line length (1 by default)
  44566. */
  44567. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44568. /**
  44569. * Force the viewer to update
  44570. */
  44571. update(): void;
  44572. /** Releases resources */
  44573. dispose(): void;
  44574. }
  44575. }
  44576. declare module "babylonjs/Debug/debugLayer" {
  44577. import { Scene } from "babylonjs/scene";
  44578. /**
  44579. * Interface used to define scene explorer extensibility option
  44580. */
  44581. export interface IExplorerExtensibilityOption {
  44582. /**
  44583. * Define the option label
  44584. */
  44585. label: string;
  44586. /**
  44587. * Defines the action to execute on click
  44588. */
  44589. action: (entity: any) => void;
  44590. }
  44591. /**
  44592. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44593. */
  44594. export interface IExplorerExtensibilityGroup {
  44595. /**
  44596. * Defines a predicate to test if a given type mut be extended
  44597. */
  44598. predicate: (entity: any) => boolean;
  44599. /**
  44600. * Gets the list of options added to a type
  44601. */
  44602. entries: IExplorerExtensibilityOption[];
  44603. }
  44604. /**
  44605. * Interface used to define the options to use to create the Inspector
  44606. */
  44607. export interface IInspectorOptions {
  44608. /**
  44609. * Display in overlay mode (default: false)
  44610. */
  44611. overlay?: boolean;
  44612. /**
  44613. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44614. */
  44615. globalRoot?: HTMLElement;
  44616. /**
  44617. * Display the Scene explorer
  44618. */
  44619. showExplorer?: boolean;
  44620. /**
  44621. * Display the property inspector
  44622. */
  44623. showInspector?: boolean;
  44624. /**
  44625. * Display in embed mode (both panes on the right)
  44626. */
  44627. embedMode?: boolean;
  44628. /**
  44629. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44630. */
  44631. handleResize?: boolean;
  44632. /**
  44633. * Allow the panes to popup (default: true)
  44634. */
  44635. enablePopup?: boolean;
  44636. /**
  44637. * Allow the panes to be closed by users (default: true)
  44638. */
  44639. enableClose?: boolean;
  44640. /**
  44641. * Optional list of extensibility entries
  44642. */
  44643. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44644. /**
  44645. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44646. */
  44647. inspectorURL?: string;
  44648. }
  44649. module "babylonjs/scene" {
  44650. interface Scene {
  44651. /**
  44652. * @hidden
  44653. * Backing field
  44654. */
  44655. _debugLayer: DebugLayer;
  44656. /**
  44657. * Gets the debug layer (aka Inspector) associated with the scene
  44658. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44659. */
  44660. debugLayer: DebugLayer;
  44661. }
  44662. }
  44663. /**
  44664. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44665. * what is happening in your scene
  44666. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44667. */
  44668. export class DebugLayer {
  44669. /**
  44670. * Define the url to get the inspector script from.
  44671. * By default it uses the babylonjs CDN.
  44672. * @ignoreNaming
  44673. */
  44674. static InspectorURL: string;
  44675. private _scene;
  44676. private BJSINSPECTOR;
  44677. private _onPropertyChangedObservable?;
  44678. /**
  44679. * Observable triggered when a property is changed through the inspector.
  44680. */
  44681. readonly onPropertyChangedObservable: any;
  44682. /**
  44683. * Instantiates a new debug layer.
  44684. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44685. * what is happening in your scene
  44686. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44687. * @param scene Defines the scene to inspect
  44688. */
  44689. constructor(scene: Scene);
  44690. /** Creates the inspector window. */
  44691. private _createInspector;
  44692. /**
  44693. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44694. * @param entity defines the entity to select
  44695. * @param lineContainerTitle defines the specific block to highlight
  44696. */
  44697. select(entity: any, lineContainerTitle?: string): void;
  44698. /** Get the inspector from bundle or global */
  44699. private _getGlobalInspector;
  44700. /**
  44701. * Get if the inspector is visible or not.
  44702. * @returns true if visible otherwise, false
  44703. */
  44704. isVisible(): boolean;
  44705. /**
  44706. * Hide the inspector and close its window.
  44707. */
  44708. hide(): void;
  44709. /**
  44710. * Launch the debugLayer.
  44711. * @param config Define the configuration of the inspector
  44712. * @return a promise fulfilled when the debug layer is visible
  44713. */
  44714. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44715. }
  44716. }
  44717. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  44718. import { Nullable } from "babylonjs/types";
  44719. import { Scene } from "babylonjs/scene";
  44720. import { Vector4 } from "babylonjs/Maths/math.vector";
  44721. import { Color4 } from "babylonjs/Maths/math.color";
  44722. import { Mesh } from "babylonjs/Meshes/mesh";
  44723. /**
  44724. * Class containing static functions to help procedurally build meshes
  44725. */
  44726. export class BoxBuilder {
  44727. /**
  44728. * Creates a box mesh
  44729. * * The parameter `size` sets the size (float) of each box side (default 1)
  44730. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44731. * * 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)
  44732. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44733. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44734. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44735. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44736. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44737. * @param name defines the name of the mesh
  44738. * @param options defines the options used to create the mesh
  44739. * @param scene defines the hosting scene
  44740. * @returns the box mesh
  44741. */
  44742. static CreateBox(name: string, options: {
  44743. size?: number;
  44744. width?: number;
  44745. height?: number;
  44746. depth?: number;
  44747. faceUV?: Vector4[];
  44748. faceColors?: Color4[];
  44749. sideOrientation?: number;
  44750. frontUVs?: Vector4;
  44751. backUVs?: Vector4;
  44752. wrap?: boolean;
  44753. topBaseAt?: number;
  44754. bottomBaseAt?: number;
  44755. updatable?: boolean;
  44756. }, scene?: Nullable<Scene>): Mesh;
  44757. }
  44758. }
  44759. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  44760. import { Vector4 } from "babylonjs/Maths/math.vector";
  44761. import { Mesh } from "babylonjs/Meshes/mesh";
  44762. import { Scene } from "babylonjs/scene";
  44763. import { Nullable } from "babylonjs/types";
  44764. /**
  44765. * Class containing static functions to help procedurally build meshes
  44766. */
  44767. export class SphereBuilder {
  44768. /**
  44769. * Creates a sphere mesh
  44770. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44771. * * 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`)
  44772. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44773. * * 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
  44774. * * 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)
  44775. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44776. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44777. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44778. * @param name defines the name of the mesh
  44779. * @param options defines the options used to create the mesh
  44780. * @param scene defines the hosting scene
  44781. * @returns the sphere mesh
  44782. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44783. */
  44784. static CreateSphere(name: string, options: {
  44785. segments?: number;
  44786. diameter?: number;
  44787. diameterX?: number;
  44788. diameterY?: number;
  44789. diameterZ?: number;
  44790. arc?: number;
  44791. slice?: number;
  44792. sideOrientation?: number;
  44793. frontUVs?: Vector4;
  44794. backUVs?: Vector4;
  44795. updatable?: boolean;
  44796. }, scene?: Nullable<Scene>): Mesh;
  44797. }
  44798. }
  44799. declare module "babylonjs/Debug/physicsViewer" {
  44800. import { Nullable } from "babylonjs/types";
  44801. import { Scene } from "babylonjs/scene";
  44802. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44803. import { Mesh } from "babylonjs/Meshes/mesh";
  44804. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  44805. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  44806. /**
  44807. * Used to show the physics impostor around the specific mesh
  44808. */
  44809. export class PhysicsViewer {
  44810. /** @hidden */
  44811. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  44812. /** @hidden */
  44813. protected _meshes: Array<Nullable<AbstractMesh>>;
  44814. /** @hidden */
  44815. protected _scene: Nullable<Scene>;
  44816. /** @hidden */
  44817. protected _numMeshes: number;
  44818. /** @hidden */
  44819. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  44820. private _renderFunction;
  44821. private _utilityLayer;
  44822. private _debugBoxMesh;
  44823. private _debugSphereMesh;
  44824. private _debugCylinderMesh;
  44825. private _debugMaterial;
  44826. private _debugMeshMeshes;
  44827. /**
  44828. * Creates a new PhysicsViewer
  44829. * @param scene defines the hosting scene
  44830. */
  44831. constructor(scene: Scene);
  44832. /** @hidden */
  44833. protected _updateDebugMeshes(): void;
  44834. /**
  44835. * Renders a specified physic impostor
  44836. * @param impostor defines the impostor to render
  44837. * @param targetMesh defines the mesh represented by the impostor
  44838. * @returns the new debug mesh used to render the impostor
  44839. */
  44840. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  44841. /**
  44842. * Hides a specified physic impostor
  44843. * @param impostor defines the impostor to hide
  44844. */
  44845. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  44846. private _getDebugMaterial;
  44847. private _getDebugBoxMesh;
  44848. private _getDebugSphereMesh;
  44849. private _getDebugCylinderMesh;
  44850. private _getDebugMeshMesh;
  44851. private _getDebugMesh;
  44852. /** Releases all resources */
  44853. dispose(): void;
  44854. }
  44855. }
  44856. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  44857. import { Vector3 } from "babylonjs/Maths/math.vector";
  44858. import { Color4 } from "babylonjs/Maths/math.color";
  44859. import { Nullable } from "babylonjs/types";
  44860. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44861. import { Scene } from "babylonjs/scene";
  44862. /**
  44863. * Class containing static functions to help procedurally build meshes
  44864. */
  44865. export class LinesBuilder {
  44866. /**
  44867. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44868. * * 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
  44869. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44870. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44871. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44872. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44873. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44874. * * 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
  44875. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44876. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44877. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44878. * @param name defines the name of the new line system
  44879. * @param options defines the options used to create the line system
  44880. * @param scene defines the hosting scene
  44881. * @returns a new line system mesh
  44882. */
  44883. static CreateLineSystem(name: string, options: {
  44884. lines: Vector3[][];
  44885. updatable?: boolean;
  44886. instance?: Nullable<LinesMesh>;
  44887. colors?: Nullable<Color4[][]>;
  44888. useVertexAlpha?: boolean;
  44889. }, scene: Nullable<Scene>): LinesMesh;
  44890. /**
  44891. * Creates a line mesh
  44892. * 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
  44893. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44894. * * The parameter `points` is an array successive Vector3
  44895. * * 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
  44896. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44897. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44898. * * When updating an instance, remember that only point positions can change, not the number of points
  44899. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44900. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44901. * @param name defines the name of the new line system
  44902. * @param options defines the options used to create the line system
  44903. * @param scene defines the hosting scene
  44904. * @returns a new line mesh
  44905. */
  44906. static CreateLines(name: string, options: {
  44907. points: Vector3[];
  44908. updatable?: boolean;
  44909. instance?: Nullable<LinesMesh>;
  44910. colors?: Color4[];
  44911. useVertexAlpha?: boolean;
  44912. }, scene?: Nullable<Scene>): LinesMesh;
  44913. /**
  44914. * Creates a dashed line mesh
  44915. * * 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
  44916. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44917. * * The parameter `points` is an array successive Vector3
  44918. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44919. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44920. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44921. * * 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
  44922. * * When updating an instance, remember that only point positions can change, not the number of points
  44923. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44924. * @param name defines the name of the mesh
  44925. * @param options defines the options used to create the mesh
  44926. * @param scene defines the hosting scene
  44927. * @returns the dashed line mesh
  44928. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44929. */
  44930. static CreateDashedLines(name: string, options: {
  44931. points: Vector3[];
  44932. dashSize?: number;
  44933. gapSize?: number;
  44934. dashNb?: number;
  44935. updatable?: boolean;
  44936. instance?: LinesMesh;
  44937. }, scene?: Nullable<Scene>): LinesMesh;
  44938. }
  44939. }
  44940. declare module "babylonjs/Debug/rayHelper" {
  44941. import { Nullable } from "babylonjs/types";
  44942. import { Ray } from "babylonjs/Culling/ray";
  44943. import { Vector3 } from "babylonjs/Maths/math.vector";
  44944. import { Color3 } from "babylonjs/Maths/math.color";
  44945. import { Scene } from "babylonjs/scene";
  44946. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44947. import "babylonjs/Meshes/Builders/linesBuilder";
  44948. /**
  44949. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44950. * in order to better appreciate the issue one might have.
  44951. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44952. */
  44953. export class RayHelper {
  44954. /**
  44955. * Defines the ray we are currently tryin to visualize.
  44956. */
  44957. ray: Nullable<Ray>;
  44958. private _renderPoints;
  44959. private _renderLine;
  44960. private _renderFunction;
  44961. private _scene;
  44962. private _updateToMeshFunction;
  44963. private _attachedToMesh;
  44964. private _meshSpaceDirection;
  44965. private _meshSpaceOrigin;
  44966. /**
  44967. * Helper function to create a colored helper in a scene in one line.
  44968. * @param ray Defines the ray we are currently tryin to visualize
  44969. * @param scene Defines the scene the ray is used in
  44970. * @param color Defines the color we want to see the ray in
  44971. * @returns The newly created ray helper.
  44972. */
  44973. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  44974. /**
  44975. * Instantiate a new ray helper.
  44976. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44977. * in order to better appreciate the issue one might have.
  44978. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44979. * @param ray Defines the ray we are currently tryin to visualize
  44980. */
  44981. constructor(ray: Ray);
  44982. /**
  44983. * Shows the ray we are willing to debug.
  44984. * @param scene Defines the scene the ray needs to be rendered in
  44985. * @param color Defines the color the ray needs to be rendered in
  44986. */
  44987. show(scene: Scene, color?: Color3): void;
  44988. /**
  44989. * Hides the ray we are debugging.
  44990. */
  44991. hide(): void;
  44992. private _render;
  44993. /**
  44994. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  44995. * @param mesh Defines the mesh we want the helper attached to
  44996. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  44997. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  44998. * @param length Defines the length of the ray
  44999. */
  45000. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45001. /**
  45002. * Detach the ray helper from the mesh it has previously been attached to.
  45003. */
  45004. detachFromMesh(): void;
  45005. private _updateToMesh;
  45006. /**
  45007. * Dispose the helper and release its associated resources.
  45008. */
  45009. dispose(): void;
  45010. }
  45011. }
  45012. declare module "babylonjs/Debug/skeletonViewer" {
  45013. import { Color3 } from "babylonjs/Maths/math.color";
  45014. import { Scene } from "babylonjs/scene";
  45015. import { Nullable } from "babylonjs/types";
  45016. import { Skeleton } from "babylonjs/Bones/skeleton";
  45017. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45018. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45019. /**
  45020. * Class used to render a debug view of a given skeleton
  45021. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45022. */
  45023. export class SkeletonViewer {
  45024. /** defines the skeleton to render */
  45025. skeleton: Skeleton;
  45026. /** defines the mesh attached to the skeleton */
  45027. mesh: AbstractMesh;
  45028. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45029. autoUpdateBonesMatrices: boolean;
  45030. /** defines the rendering group id to use with the viewer */
  45031. renderingGroupId: number;
  45032. /** Gets or sets the color used to render the skeleton */
  45033. color: Color3;
  45034. private _scene;
  45035. private _debugLines;
  45036. private _debugMesh;
  45037. private _isEnabled;
  45038. private _renderFunction;
  45039. private _utilityLayer;
  45040. /**
  45041. * Returns the mesh used to render the bones
  45042. */
  45043. readonly debugMesh: Nullable<LinesMesh>;
  45044. /**
  45045. * Creates a new SkeletonViewer
  45046. * @param skeleton defines the skeleton to render
  45047. * @param mesh defines the mesh attached to the skeleton
  45048. * @param scene defines the hosting scene
  45049. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45050. * @param renderingGroupId defines the rendering group id to use with the viewer
  45051. */
  45052. constructor(
  45053. /** defines the skeleton to render */
  45054. skeleton: Skeleton,
  45055. /** defines the mesh attached to the skeleton */
  45056. mesh: AbstractMesh, scene: Scene,
  45057. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45058. autoUpdateBonesMatrices?: boolean,
  45059. /** defines the rendering group id to use with the viewer */
  45060. renderingGroupId?: number);
  45061. /** Gets or sets a boolean indicating if the viewer is enabled */
  45062. isEnabled: boolean;
  45063. private _getBonePosition;
  45064. private _getLinesForBonesWithLength;
  45065. private _getLinesForBonesNoLength;
  45066. /** Update the viewer to sync with current skeleton state */
  45067. update(): void;
  45068. /** Release associated resources */
  45069. dispose(): void;
  45070. }
  45071. }
  45072. declare module "babylonjs/Debug/index" {
  45073. export * from "babylonjs/Debug/axesViewer";
  45074. export * from "babylonjs/Debug/boneAxesViewer";
  45075. export * from "babylonjs/Debug/debugLayer";
  45076. export * from "babylonjs/Debug/physicsViewer";
  45077. export * from "babylonjs/Debug/rayHelper";
  45078. export * from "babylonjs/Debug/skeletonViewer";
  45079. }
  45080. declare module "babylonjs/Engines/nullEngine" {
  45081. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  45082. import { Scene } from "babylonjs/scene";
  45083. import { Engine } from "babylonjs/Engines/engine";
  45084. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45085. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45086. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45087. import { Effect } from "babylonjs/Materials/effect";
  45088. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45089. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45090. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  45091. /**
  45092. * Options to create the null engine
  45093. */
  45094. export class NullEngineOptions {
  45095. /**
  45096. * Render width (Default: 512)
  45097. */
  45098. renderWidth: number;
  45099. /**
  45100. * Render height (Default: 256)
  45101. */
  45102. renderHeight: number;
  45103. /**
  45104. * Texture size (Default: 512)
  45105. */
  45106. textureSize: number;
  45107. /**
  45108. * If delta time between frames should be constant
  45109. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45110. */
  45111. deterministicLockstep: boolean;
  45112. /**
  45113. * Maximum about of steps between frames (Default: 4)
  45114. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45115. */
  45116. lockstepMaxSteps: number;
  45117. }
  45118. /**
  45119. * The null engine class provides support for headless version of babylon.js.
  45120. * This can be used in server side scenario or for testing purposes
  45121. */
  45122. export class NullEngine extends Engine {
  45123. private _options;
  45124. /**
  45125. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45126. */
  45127. isDeterministicLockStep(): boolean;
  45128. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  45129. getLockstepMaxSteps(): number;
  45130. /**
  45131. * Sets hardware scaling, used to save performance if needed
  45132. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  45133. */
  45134. getHardwareScalingLevel(): number;
  45135. constructor(options?: NullEngineOptions);
  45136. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45137. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45138. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45139. getRenderWidth(useScreen?: boolean): number;
  45140. getRenderHeight(useScreen?: boolean): number;
  45141. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45142. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45143. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45144. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45145. bindSamplers(effect: Effect): void;
  45146. enableEffect(effect: Effect): void;
  45147. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45148. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45149. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45150. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45151. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45152. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45153. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45154. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45155. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45156. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45157. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45158. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45159. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45160. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45161. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45162. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45163. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45164. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45165. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45166. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45167. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45168. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45169. bindBuffers(vertexBuffers: {
  45170. [key: string]: VertexBuffer;
  45171. }, indexBuffer: DataBuffer, effect: Effect): void;
  45172. wipeCaches(bruteForce?: boolean): void;
  45173. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45174. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45175. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45176. /** @hidden */
  45177. _createTexture(): WebGLTexture;
  45178. /** @hidden */
  45179. _releaseTexture(texture: InternalTexture): void;
  45180. 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;
  45181. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45182. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45183. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45184. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45185. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45186. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45187. areAllEffectsReady(): boolean;
  45188. /**
  45189. * @hidden
  45190. * Get the current error code of the webGL context
  45191. * @returns the error code
  45192. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  45193. */
  45194. getError(): number;
  45195. /** @hidden */
  45196. _getUnpackAlignement(): number;
  45197. /** @hidden */
  45198. _unpackFlipY(value: boolean): void;
  45199. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  45200. /**
  45201. * Updates a dynamic vertex buffer.
  45202. * @param vertexBuffer the vertex buffer to update
  45203. * @param data the data used to update the vertex buffer
  45204. * @param byteOffset the byte offset of the data (optional)
  45205. * @param byteLength the byte length of the data (optional)
  45206. */
  45207. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  45208. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  45209. /** @hidden */
  45210. _bindTexture(channel: number, texture: InternalTexture): void;
  45211. protected _deleteBuffer(buffer: WebGLBuffer): void;
  45212. releaseEffects(): void;
  45213. displayLoadingUI(): void;
  45214. hideLoadingUI(): void;
  45215. /** @hidden */
  45216. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45217. /** @hidden */
  45218. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45219. /** @hidden */
  45220. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45221. /** @hidden */
  45222. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45223. }
  45224. }
  45225. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  45226. import { Nullable, int } from "babylonjs/types";
  45227. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  45228. /** @hidden */
  45229. export class _OcclusionDataStorage {
  45230. /** @hidden */
  45231. occlusionInternalRetryCounter: number;
  45232. /** @hidden */
  45233. isOcclusionQueryInProgress: boolean;
  45234. /** @hidden */
  45235. isOccluded: boolean;
  45236. /** @hidden */
  45237. occlusionRetryCount: number;
  45238. /** @hidden */
  45239. occlusionType: number;
  45240. /** @hidden */
  45241. occlusionQueryAlgorithmType: number;
  45242. }
  45243. module "babylonjs/Engines/engine" {
  45244. interface Engine {
  45245. /**
  45246. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  45247. * @return the new query
  45248. */
  45249. createQuery(): WebGLQuery;
  45250. /**
  45251. * Delete and release a webGL query
  45252. * @param query defines the query to delete
  45253. * @return the current engine
  45254. */
  45255. deleteQuery(query: WebGLQuery): Engine;
  45256. /**
  45257. * Check if a given query has resolved and got its value
  45258. * @param query defines the query to check
  45259. * @returns true if the query got its value
  45260. */
  45261. isQueryResultAvailable(query: WebGLQuery): boolean;
  45262. /**
  45263. * Gets the value of a given query
  45264. * @param query defines the query to check
  45265. * @returns the value of the query
  45266. */
  45267. getQueryResult(query: WebGLQuery): number;
  45268. /**
  45269. * Initiates an occlusion query
  45270. * @param algorithmType defines the algorithm to use
  45271. * @param query defines the query to use
  45272. * @returns the current engine
  45273. * @see http://doc.babylonjs.com/features/occlusionquery
  45274. */
  45275. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  45276. /**
  45277. * Ends an occlusion query
  45278. * @see http://doc.babylonjs.com/features/occlusionquery
  45279. * @param algorithmType defines the algorithm to use
  45280. * @returns the current engine
  45281. */
  45282. endOcclusionQuery(algorithmType: number): Engine;
  45283. /**
  45284. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  45285. * Please note that only one query can be issued at a time
  45286. * @returns a time token used to track the time span
  45287. */
  45288. startTimeQuery(): Nullable<_TimeToken>;
  45289. /**
  45290. * Ends a time query
  45291. * @param token defines the token used to measure the time span
  45292. * @returns the time spent (in ns)
  45293. */
  45294. endTimeQuery(token: _TimeToken): int;
  45295. /** @hidden */
  45296. _currentNonTimestampToken: Nullable<_TimeToken>;
  45297. /** @hidden */
  45298. _createTimeQuery(): WebGLQuery;
  45299. /** @hidden */
  45300. _deleteTimeQuery(query: WebGLQuery): void;
  45301. /** @hidden */
  45302. _getGlAlgorithmType(algorithmType: number): number;
  45303. /** @hidden */
  45304. _getTimeQueryResult(query: WebGLQuery): any;
  45305. /** @hidden */
  45306. _getTimeQueryAvailability(query: WebGLQuery): any;
  45307. }
  45308. }
  45309. module "babylonjs/Meshes/abstractMesh" {
  45310. interface AbstractMesh {
  45311. /**
  45312. * Backing filed
  45313. * @hidden
  45314. */
  45315. __occlusionDataStorage: _OcclusionDataStorage;
  45316. /**
  45317. * Access property
  45318. * @hidden
  45319. */
  45320. _occlusionDataStorage: _OcclusionDataStorage;
  45321. /**
  45322. * 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.
  45323. * The default value is -1 which means don't break the query and wait till the result
  45324. * @see http://doc.babylonjs.com/features/occlusionquery
  45325. */
  45326. occlusionRetryCount: number;
  45327. /**
  45328. * 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:
  45329. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  45330. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  45331. * * 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.
  45332. * @see http://doc.babylonjs.com/features/occlusionquery
  45333. */
  45334. occlusionType: number;
  45335. /**
  45336. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  45337. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  45338. * * 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.
  45339. * @see http://doc.babylonjs.com/features/occlusionquery
  45340. */
  45341. occlusionQueryAlgorithmType: number;
  45342. /**
  45343. * 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
  45344. * @see http://doc.babylonjs.com/features/occlusionquery
  45345. */
  45346. isOccluded: boolean;
  45347. /**
  45348. * Flag to check the progress status of the query
  45349. * @see http://doc.babylonjs.com/features/occlusionquery
  45350. */
  45351. isOcclusionQueryInProgress: boolean;
  45352. }
  45353. }
  45354. }
  45355. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  45356. import { Nullable } from "babylonjs/types";
  45357. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45358. /** @hidden */
  45359. export var _forceTransformFeedbackToBundle: boolean;
  45360. module "babylonjs/Engines/engine" {
  45361. interface Engine {
  45362. /**
  45363. * Creates a webGL transform feedback object
  45364. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  45365. * @returns the webGL transform feedback object
  45366. */
  45367. createTransformFeedback(): WebGLTransformFeedback;
  45368. /**
  45369. * Delete a webGL transform feedback object
  45370. * @param value defines the webGL transform feedback object to delete
  45371. */
  45372. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  45373. /**
  45374. * Bind a webGL transform feedback object to the webgl context
  45375. * @param value defines the webGL transform feedback object to bind
  45376. */
  45377. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  45378. /**
  45379. * Begins a transform feedback operation
  45380. * @param usePoints defines if points or triangles must be used
  45381. */
  45382. beginTransformFeedback(usePoints: boolean): void;
  45383. /**
  45384. * Ends a transform feedback operation
  45385. */
  45386. endTransformFeedback(): void;
  45387. /**
  45388. * Specify the varyings to use with transform feedback
  45389. * @param program defines the associated webGL program
  45390. * @param value defines the list of strings representing the varying names
  45391. */
  45392. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  45393. /**
  45394. * Bind a webGL buffer for a transform feedback operation
  45395. * @param value defines the webGL buffer to bind
  45396. */
  45397. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  45398. }
  45399. }
  45400. }
  45401. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  45402. import { Scene } from "babylonjs/scene";
  45403. import { Engine } from "babylonjs/Engines/engine";
  45404. import { Texture } from "babylonjs/Materials/Textures/texture";
  45405. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45406. import "babylonjs/Engines/Extensions/engine.multiRender";
  45407. /**
  45408. * Creation options of the multi render target texture.
  45409. */
  45410. export interface IMultiRenderTargetOptions {
  45411. /**
  45412. * Define if the texture needs to create mip maps after render.
  45413. */
  45414. generateMipMaps?: boolean;
  45415. /**
  45416. * Define the types of all the draw buffers we want to create
  45417. */
  45418. types?: number[];
  45419. /**
  45420. * Define the sampling modes of all the draw buffers we want to create
  45421. */
  45422. samplingModes?: number[];
  45423. /**
  45424. * Define if a depth buffer is required
  45425. */
  45426. generateDepthBuffer?: boolean;
  45427. /**
  45428. * Define if a stencil buffer is required
  45429. */
  45430. generateStencilBuffer?: boolean;
  45431. /**
  45432. * Define if a depth texture is required instead of a depth buffer
  45433. */
  45434. generateDepthTexture?: boolean;
  45435. /**
  45436. * Define the number of desired draw buffers
  45437. */
  45438. textureCount?: number;
  45439. /**
  45440. * Define if aspect ratio should be adapted to the texture or stay the scene one
  45441. */
  45442. doNotChangeAspectRatio?: boolean;
  45443. /**
  45444. * Define the default type of the buffers we are creating
  45445. */
  45446. defaultType?: number;
  45447. }
  45448. /**
  45449. * A multi render target, like a render target provides the ability to render to a texture.
  45450. * Unlike the render target, it can render to several draw buffers in one draw.
  45451. * This is specially interesting in deferred rendering or for any effects requiring more than
  45452. * just one color from a single pass.
  45453. */
  45454. export class MultiRenderTarget extends RenderTargetTexture {
  45455. private _internalTextures;
  45456. private _textures;
  45457. private _multiRenderTargetOptions;
  45458. /**
  45459. * Get if draw buffers are currently supported by the used hardware and browser.
  45460. */
  45461. readonly isSupported: boolean;
  45462. /**
  45463. * Get the list of textures generated by the multi render target.
  45464. */
  45465. readonly textures: Texture[];
  45466. /**
  45467. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45468. */
  45469. readonly depthTexture: Texture;
  45470. /**
  45471. * Set the wrapping mode on U of all the textures we are rendering to.
  45472. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45473. */
  45474. wrapU: number;
  45475. /**
  45476. * Set the wrapping mode on V of all the textures we are rendering to.
  45477. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45478. */
  45479. wrapV: number;
  45480. /**
  45481. * Instantiate a new multi render target texture.
  45482. * A multi render target, like a render target provides the ability to render to a texture.
  45483. * Unlike the render target, it can render to several draw buffers in one draw.
  45484. * This is specially interesting in deferred rendering or for any effects requiring more than
  45485. * just one color from a single pass.
  45486. * @param name Define the name of the texture
  45487. * @param size Define the size of the buffers to render to
  45488. * @param count Define the number of target we are rendering into
  45489. * @param scene Define the scene the texture belongs to
  45490. * @param options Define the options used to create the multi render target
  45491. */
  45492. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  45493. /** @hidden */
  45494. _rebuild(): void;
  45495. private _createInternalTextures;
  45496. private _createTextures;
  45497. /**
  45498. * Define the number of samples used if MSAA is enabled.
  45499. */
  45500. samples: number;
  45501. /**
  45502. * Resize all the textures in the multi render target.
  45503. * Be carrefull as it will recreate all the data in the new texture.
  45504. * @param size Define the new size
  45505. */
  45506. resize(size: any): void;
  45507. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  45508. /**
  45509. * Dispose the render targets and their associated resources
  45510. */
  45511. dispose(): void;
  45512. /**
  45513. * Release all the underlying texture used as draw buffers.
  45514. */
  45515. releaseInternalTextures(): void;
  45516. }
  45517. }
  45518. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  45519. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45520. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  45521. import { Nullable } from "babylonjs/types";
  45522. module "babylonjs/Engines/engine" {
  45523. interface Engine {
  45524. /**
  45525. * Unbind a list of render target textures from the webGL context
  45526. * This is used only when drawBuffer extension or webGL2 are active
  45527. * @param textures defines the render target textures to unbind
  45528. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45529. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45530. */
  45531. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  45532. /**
  45533. * Create a multi render target texture
  45534. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  45535. * @param size defines the size of the texture
  45536. * @param options defines the creation options
  45537. * @returns the cube texture as an InternalTexture
  45538. */
  45539. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  45540. /**
  45541. * Update the sample count for a given multiple render target texture
  45542. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  45543. * @param textures defines the textures to update
  45544. * @param samples defines the sample count to set
  45545. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  45546. */
  45547. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  45548. }
  45549. }
  45550. }
  45551. declare module "babylonjs/Engines/Extensions/index" {
  45552. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  45553. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  45554. export * from "babylonjs/Engines/Extensions/engine.multiview";
  45555. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  45556. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  45557. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  45558. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  45559. export * from "babylonjs/Engines/Extensions/engine.webVR";
  45560. }
  45561. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  45562. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45563. /** @hidden */
  45564. export var rgbdEncodePixelShader: {
  45565. name: string;
  45566. shader: string;
  45567. };
  45568. }
  45569. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  45570. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45571. /** @hidden */
  45572. export var rgbdDecodePixelShader: {
  45573. name: string;
  45574. shader: string;
  45575. };
  45576. }
  45577. declare module "babylonjs/Misc/environmentTextureTools" {
  45578. import { Nullable } from "babylonjs/types";
  45579. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  45580. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45581. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  45582. import "babylonjs/Engines/Extensions/engine.renderTarget";
  45583. import "babylonjs/Shaders/rgbdEncode.fragment";
  45584. import "babylonjs/Shaders/rgbdDecode.fragment";
  45585. /**
  45586. * Raw texture data and descriptor sufficient for WebGL texture upload
  45587. */
  45588. export interface EnvironmentTextureInfo {
  45589. /**
  45590. * Version of the environment map
  45591. */
  45592. version: number;
  45593. /**
  45594. * Width of image
  45595. */
  45596. width: number;
  45597. /**
  45598. * Irradiance information stored in the file.
  45599. */
  45600. irradiance: any;
  45601. /**
  45602. * Specular information stored in the file.
  45603. */
  45604. specular: any;
  45605. }
  45606. /**
  45607. * Defines One Image in the file. It requires only the position in the file
  45608. * as well as the length.
  45609. */
  45610. interface BufferImageData {
  45611. /**
  45612. * Length of the image data.
  45613. */
  45614. length: number;
  45615. /**
  45616. * Position of the data from the null terminator delimiting the end of the JSON.
  45617. */
  45618. position: number;
  45619. }
  45620. /**
  45621. * Defines the specular data enclosed in the file.
  45622. * This corresponds to the version 1 of the data.
  45623. */
  45624. export interface EnvironmentTextureSpecularInfoV1 {
  45625. /**
  45626. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  45627. */
  45628. specularDataPosition?: number;
  45629. /**
  45630. * This contains all the images data needed to reconstruct the cubemap.
  45631. */
  45632. mipmaps: Array<BufferImageData>;
  45633. /**
  45634. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  45635. */
  45636. lodGenerationScale: number;
  45637. }
  45638. /**
  45639. * Sets of helpers addressing the serialization and deserialization of environment texture
  45640. * stored in a BabylonJS env file.
  45641. * Those files are usually stored as .env files.
  45642. */
  45643. export class EnvironmentTextureTools {
  45644. /**
  45645. * Magic number identifying the env file.
  45646. */
  45647. private static _MagicBytes;
  45648. /**
  45649. * Gets the environment info from an env file.
  45650. * @param data The array buffer containing the .env bytes.
  45651. * @returns the environment file info (the json header) if successfully parsed.
  45652. */
  45653. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  45654. /**
  45655. * Creates an environment texture from a loaded cube texture.
  45656. * @param texture defines the cube texture to convert in env file
  45657. * @return a promise containing the environment data if succesfull.
  45658. */
  45659. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  45660. /**
  45661. * Creates a JSON representation of the spherical data.
  45662. * @param texture defines the texture containing the polynomials
  45663. * @return the JSON representation of the spherical info
  45664. */
  45665. private static _CreateEnvTextureIrradiance;
  45666. /**
  45667. * Creates the ArrayBufferViews used for initializing environment texture image data.
  45668. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  45669. * @param info parameters that determine what views will be created for accessing the underlying buffer
  45670. * @return the views described by info providing access to the underlying buffer
  45671. */
  45672. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  45673. /**
  45674. * Uploads the texture info contained in the env file to the GPU.
  45675. * @param texture defines the internal texture to upload to
  45676. * @param arrayBuffer defines the buffer cotaining the data to load
  45677. * @param info defines the texture info retrieved through the GetEnvInfo method
  45678. * @returns a promise
  45679. */
  45680. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  45681. /**
  45682. * Uploads the levels of image data to the GPU.
  45683. * @param texture defines the internal texture to upload to
  45684. * @param imageData defines the array buffer views of image data [mipmap][face]
  45685. * @returns a promise
  45686. */
  45687. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  45688. /**
  45689. * Uploads spherical polynomials information to the texture.
  45690. * @param texture defines the texture we are trying to upload the information to
  45691. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  45692. */
  45693. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  45694. /** @hidden */
  45695. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  45696. }
  45697. }
  45698. declare module "babylonjs/Maths/math.vertexFormat" {
  45699. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  45700. /**
  45701. * Contains position and normal vectors for a vertex
  45702. */
  45703. export class PositionNormalVertex {
  45704. /** the position of the vertex (defaut: 0,0,0) */
  45705. position: Vector3;
  45706. /** the normal of the vertex (defaut: 0,1,0) */
  45707. normal: Vector3;
  45708. /**
  45709. * Creates a PositionNormalVertex
  45710. * @param position the position of the vertex (defaut: 0,0,0)
  45711. * @param normal the normal of the vertex (defaut: 0,1,0)
  45712. */
  45713. constructor(
  45714. /** the position of the vertex (defaut: 0,0,0) */
  45715. position?: Vector3,
  45716. /** the normal of the vertex (defaut: 0,1,0) */
  45717. normal?: Vector3);
  45718. /**
  45719. * Clones the PositionNormalVertex
  45720. * @returns the cloned PositionNormalVertex
  45721. */
  45722. clone(): PositionNormalVertex;
  45723. }
  45724. /**
  45725. * Contains position, normal and uv vectors for a vertex
  45726. */
  45727. export class PositionNormalTextureVertex {
  45728. /** the position of the vertex (defaut: 0,0,0) */
  45729. position: Vector3;
  45730. /** the normal of the vertex (defaut: 0,1,0) */
  45731. normal: Vector3;
  45732. /** the uv of the vertex (default: 0,0) */
  45733. uv: Vector2;
  45734. /**
  45735. * Creates a PositionNormalTextureVertex
  45736. * @param position the position of the vertex (defaut: 0,0,0)
  45737. * @param normal the normal of the vertex (defaut: 0,1,0)
  45738. * @param uv the uv of the vertex (default: 0,0)
  45739. */
  45740. constructor(
  45741. /** the position of the vertex (defaut: 0,0,0) */
  45742. position?: Vector3,
  45743. /** the normal of the vertex (defaut: 0,1,0) */
  45744. normal?: Vector3,
  45745. /** the uv of the vertex (default: 0,0) */
  45746. uv?: Vector2);
  45747. /**
  45748. * Clones the PositionNormalTextureVertex
  45749. * @returns the cloned PositionNormalTextureVertex
  45750. */
  45751. clone(): PositionNormalTextureVertex;
  45752. }
  45753. }
  45754. declare module "babylonjs/Maths/math" {
  45755. export * from "babylonjs/Maths/math.axis";
  45756. export * from "babylonjs/Maths/math.color";
  45757. export * from "babylonjs/Maths/math.constants";
  45758. export * from "babylonjs/Maths/math.frustum";
  45759. export * from "babylonjs/Maths/math.path";
  45760. export * from "babylonjs/Maths/math.plane";
  45761. export * from "babylonjs/Maths/math.size";
  45762. export * from "babylonjs/Maths/math.vector";
  45763. export * from "babylonjs/Maths/math.vertexFormat";
  45764. export * from "babylonjs/Maths/math.viewport";
  45765. }
  45766. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  45767. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  45768. /** @hidden */
  45769. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  45770. private _genericAttributeLocation;
  45771. private _varyingLocationCount;
  45772. private _varyingLocationMap;
  45773. private _replacements;
  45774. private _textureCount;
  45775. private _uniforms;
  45776. lineProcessor(line: string): string;
  45777. attributeProcessor(attribute: string): string;
  45778. varyingProcessor(varying: string, isFragment: boolean): string;
  45779. uniformProcessor(uniform: string): string;
  45780. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  45781. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  45782. }
  45783. }
  45784. declare module "babylonjs/Engines/nativeEngine" {
  45785. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  45786. import { Engine } from "babylonjs/Engines/engine";
  45787. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45788. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45789. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45790. import { Effect } from "babylonjs/Materials/effect";
  45791. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45792. import { Color4, Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  45793. import { Scene } from "babylonjs/scene";
  45794. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45795. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45796. /**
  45797. * Container for accessors for natively-stored mesh data buffers.
  45798. */
  45799. class NativeDataBuffer extends DataBuffer {
  45800. /**
  45801. * Accessor value used to identify/retrieve a natively-stored index buffer.
  45802. */
  45803. nativeIndexBuffer?: any;
  45804. /**
  45805. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  45806. */
  45807. nativeVertexBuffer?: any;
  45808. }
  45809. /** @hidden */
  45810. export class NativeEngine extends Engine {
  45811. private readonly _native;
  45812. getHardwareScalingLevel(): number;
  45813. constructor();
  45814. /**
  45815. * Can be used to override the current requestAnimationFrame requester.
  45816. * @hidden
  45817. */
  45818. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  45819. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45820. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  45821. createVertexBuffer(data: DataArray): NativeDataBuffer;
  45822. recordVertexArrayObject(vertexBuffers: {
  45823. [key: string]: VertexBuffer;
  45824. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  45825. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  45826. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  45827. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45828. /**
  45829. * Draw a list of indexed primitives
  45830. * @param fillMode defines the primitive to use
  45831. * @param indexStart defines the starting index
  45832. * @param indexCount defines the number of index to draw
  45833. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45834. */
  45835. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45836. /**
  45837. * Draw a list of unindexed primitives
  45838. * @param fillMode defines the primitive to use
  45839. * @param verticesStart defines the index of first vertex to draw
  45840. * @param verticesCount defines the count of vertices to draw
  45841. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45842. */
  45843. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45844. createPipelineContext(): IPipelineContext;
  45845. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  45846. /** @hidden */
  45847. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  45848. /** @hidden */
  45849. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  45850. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  45851. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  45852. protected _setProgram(program: WebGLProgram): void;
  45853. _releaseEffect(effect: Effect): void;
  45854. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  45855. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  45856. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  45857. bindSamplers(effect: Effect): void;
  45858. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  45859. getRenderWidth(useScreen?: boolean): number;
  45860. getRenderHeight(useScreen?: boolean): number;
  45861. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  45862. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45863. /**
  45864. * Set the z offset to apply to current rendering
  45865. * @param value defines the offset to apply
  45866. */
  45867. setZOffset(value: number): void;
  45868. /**
  45869. * Gets the current value of the zOffset
  45870. * @returns the current zOffset state
  45871. */
  45872. getZOffset(): number;
  45873. /**
  45874. * Enable or disable depth buffering
  45875. * @param enable defines the state to set
  45876. */
  45877. setDepthBuffer(enable: boolean): void;
  45878. /**
  45879. * Gets a boolean indicating if depth writing is enabled
  45880. * @returns the current depth writing state
  45881. */
  45882. getDepthWrite(): boolean;
  45883. /**
  45884. * Enable or disable depth writing
  45885. * @param enable defines the state to set
  45886. */
  45887. setDepthWrite(enable: boolean): void;
  45888. /**
  45889. * Enable or disable color writing
  45890. * @param enable defines the state to set
  45891. */
  45892. setColorWrite(enable: boolean): void;
  45893. /**
  45894. * Gets a boolean indicating if color writing is enabled
  45895. * @returns the current color writing state
  45896. */
  45897. getColorWrite(): boolean;
  45898. /**
  45899. * Sets alpha constants used by some alpha blending modes
  45900. * @param r defines the red component
  45901. * @param g defines the green component
  45902. * @param b defines the blue component
  45903. * @param a defines the alpha component
  45904. */
  45905. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  45906. /**
  45907. * Sets the current alpha mode
  45908. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  45909. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45910. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45911. */
  45912. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45913. /**
  45914. * Gets the current alpha mode
  45915. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45916. * @returns the current alpha mode
  45917. */
  45918. getAlphaMode(): number;
  45919. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45920. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45921. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45922. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45923. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45924. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45925. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45926. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45927. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45928. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45929. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45930. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45931. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45932. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45933. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45934. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45935. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45936. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45937. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45938. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45939. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  45940. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  45941. wipeCaches(bruteForce?: boolean): void;
  45942. _createTexture(): WebGLTexture;
  45943. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  45944. /**
  45945. * Usually called from BABYLON.Texture.ts.
  45946. * Passed information to create a WebGLTexture
  45947. * @param urlArg defines a value which contains one of the following:
  45948. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45949. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45950. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45951. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45952. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  45953. * @param scene needed for loading to the correct scene
  45954. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  45955. * @param onLoad optional callback to be called upon successful completion
  45956. * @param onError optional callback to be called upon failure
  45957. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  45958. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45959. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45960. * @param forcedExtension defines the extension to use to pick the right loader
  45961. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45962. */
  45963. 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;
  45964. /**
  45965. * Creates a cube texture
  45966. * @param rootUrl defines the url where the files to load is located
  45967. * @param scene defines the current scene
  45968. * @param files defines the list of files to load (1 per face)
  45969. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  45970. * @param onLoad defines an optional callback raised when the texture is loaded
  45971. * @param onError defines an optional callback raised if there is an issue to load the texture
  45972. * @param format defines the format of the data
  45973. * @param forcedExtension defines the extension to use to pick the right loader
  45974. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  45975. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  45976. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  45977. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  45978. * @returns the cube texture as an InternalTexture
  45979. */
  45980. 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;
  45981. private _getSamplingFilter;
  45982. private static _GetNativeTextureFormat;
  45983. createRenderTargetTexture(size: number | {
  45984. width: number;
  45985. height: number;
  45986. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45987. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45988. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45989. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45990. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  45991. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  45992. /**
  45993. * Updates a dynamic vertex buffer.
  45994. * @param vertexBuffer the vertex buffer to update
  45995. * @param data the data used to update the vertex buffer
  45996. * @param byteOffset the byte offset of the data (optional)
  45997. * @param byteLength the byte length of the data (optional)
  45998. */
  45999. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  46000. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  46001. private _updateAnisotropicLevel;
  46002. private _getAddressMode;
  46003. /** @hidden */
  46004. _bindTexture(channel: number, texture: InternalTexture): void;
  46005. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  46006. releaseEffects(): void;
  46007. /** @hidden */
  46008. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46009. /** @hidden */
  46010. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46011. /** @hidden */
  46012. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46013. /** @hidden */
  46014. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46015. }
  46016. }
  46017. declare module "babylonjs/Engines/index" {
  46018. export * from "babylonjs/Engines/constants";
  46019. export * from "babylonjs/Engines/engine";
  46020. export * from "babylonjs/Engines/engineStore";
  46021. export * from "babylonjs/Engines/nullEngine";
  46022. export * from "babylonjs/Engines/Extensions/index";
  46023. export * from "babylonjs/Engines/IPipelineContext";
  46024. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  46025. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46026. export * from "babylonjs/Engines/nativeEngine";
  46027. }
  46028. declare module "babylonjs/Events/clipboardEvents" {
  46029. /**
  46030. * Gather the list of clipboard event types as constants.
  46031. */
  46032. export class ClipboardEventTypes {
  46033. /**
  46034. * The clipboard event is fired when a copy command is active (pressed).
  46035. */
  46036. static readonly COPY: number;
  46037. /**
  46038. * The clipboard event is fired when a cut command is active (pressed).
  46039. */
  46040. static readonly CUT: number;
  46041. /**
  46042. * The clipboard event is fired when a paste command is active (pressed).
  46043. */
  46044. static readonly PASTE: number;
  46045. }
  46046. /**
  46047. * This class is used to store clipboard related info for the onClipboardObservable event.
  46048. */
  46049. export class ClipboardInfo {
  46050. /**
  46051. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46052. */
  46053. type: number;
  46054. /**
  46055. * Defines the related dom event
  46056. */
  46057. event: ClipboardEvent;
  46058. /**
  46059. *Creates an instance of ClipboardInfo.
  46060. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  46061. * @param event Defines the related dom event
  46062. */
  46063. constructor(
  46064. /**
  46065. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46066. */
  46067. type: number,
  46068. /**
  46069. * Defines the related dom event
  46070. */
  46071. event: ClipboardEvent);
  46072. /**
  46073. * Get the clipboard event's type from the keycode.
  46074. * @param keyCode Defines the keyCode for the current keyboard event.
  46075. * @return {number}
  46076. */
  46077. static GetTypeFromCharacter(keyCode: number): number;
  46078. }
  46079. }
  46080. declare module "babylonjs/Events/index" {
  46081. export * from "babylonjs/Events/keyboardEvents";
  46082. export * from "babylonjs/Events/pointerEvents";
  46083. export * from "babylonjs/Events/clipboardEvents";
  46084. }
  46085. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  46086. import { Scene } from "babylonjs/scene";
  46087. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46088. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46089. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46090. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46091. /**
  46092. * Google Daydream controller
  46093. */
  46094. export class DaydreamController extends WebVRController {
  46095. /**
  46096. * Base Url for the controller model.
  46097. */
  46098. static MODEL_BASE_URL: string;
  46099. /**
  46100. * File name for the controller model.
  46101. */
  46102. static MODEL_FILENAME: string;
  46103. /**
  46104. * Gamepad Id prefix used to identify Daydream Controller.
  46105. */
  46106. static readonly GAMEPAD_ID_PREFIX: string;
  46107. /**
  46108. * Creates a new DaydreamController from a gamepad
  46109. * @param vrGamepad the gamepad that the controller should be created from
  46110. */
  46111. constructor(vrGamepad: any);
  46112. /**
  46113. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46114. * @param scene scene in which to add meshes
  46115. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46116. */
  46117. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46118. /**
  46119. * Called once for each button that changed state since the last frame
  46120. * @param buttonIdx Which button index changed
  46121. * @param state New state of the button
  46122. * @param changes Which properties on the state changed since last frame
  46123. */
  46124. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46125. }
  46126. }
  46127. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  46128. import { Scene } from "babylonjs/scene";
  46129. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46130. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46131. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46132. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46133. /**
  46134. * Gear VR Controller
  46135. */
  46136. export class GearVRController extends WebVRController {
  46137. /**
  46138. * Base Url for the controller model.
  46139. */
  46140. static MODEL_BASE_URL: string;
  46141. /**
  46142. * File name for the controller model.
  46143. */
  46144. static MODEL_FILENAME: string;
  46145. /**
  46146. * Gamepad Id prefix used to identify this controller.
  46147. */
  46148. static readonly GAMEPAD_ID_PREFIX: string;
  46149. private readonly _buttonIndexToObservableNameMap;
  46150. /**
  46151. * Creates a new GearVRController from a gamepad
  46152. * @param vrGamepad the gamepad that the controller should be created from
  46153. */
  46154. constructor(vrGamepad: any);
  46155. /**
  46156. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46157. * @param scene scene in which to add meshes
  46158. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46159. */
  46160. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46161. /**
  46162. * Called once for each button that changed state since the last frame
  46163. * @param buttonIdx Which button index changed
  46164. * @param state New state of the button
  46165. * @param changes Which properties on the state changed since last frame
  46166. */
  46167. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46168. }
  46169. }
  46170. declare module "babylonjs/Gamepads/Controllers/index" {
  46171. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  46172. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  46173. export * from "babylonjs/Gamepads/Controllers/genericController";
  46174. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  46175. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46176. export * from "babylonjs/Gamepads/Controllers/viveController";
  46177. export * from "babylonjs/Gamepads/Controllers/webVRController";
  46178. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  46179. }
  46180. declare module "babylonjs/Gamepads/index" {
  46181. export * from "babylonjs/Gamepads/Controllers/index";
  46182. export * from "babylonjs/Gamepads/gamepad";
  46183. export * from "babylonjs/Gamepads/gamepadManager";
  46184. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  46185. export * from "babylonjs/Gamepads/xboxGamepad";
  46186. export * from "babylonjs/Gamepads/dualShockGamepad";
  46187. }
  46188. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  46189. import { Scene } from "babylonjs/scene";
  46190. import { Vector4 } from "babylonjs/Maths/math.vector";
  46191. import { Color4 } from "babylonjs/Maths/math.color";
  46192. import { Mesh } from "babylonjs/Meshes/mesh";
  46193. import { Nullable } from "babylonjs/types";
  46194. /**
  46195. * Class containing static functions to help procedurally build meshes
  46196. */
  46197. export class PolyhedronBuilder {
  46198. /**
  46199. * Creates a polyhedron mesh
  46200. * * 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
  46201. * * The parameter `size` (positive float, default 1) sets the polygon size
  46202. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  46203. * * 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`
  46204. * * 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
  46205. * * 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)`)
  46206. * * 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
  46207. * * 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
  46208. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46209. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46210. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46211. * @param name defines the name of the mesh
  46212. * @param options defines the options used to create the mesh
  46213. * @param scene defines the hosting scene
  46214. * @returns the polyhedron mesh
  46215. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  46216. */
  46217. static CreatePolyhedron(name: string, options: {
  46218. type?: number;
  46219. size?: number;
  46220. sizeX?: number;
  46221. sizeY?: number;
  46222. sizeZ?: number;
  46223. custom?: any;
  46224. faceUV?: Vector4[];
  46225. faceColors?: Color4[];
  46226. flat?: boolean;
  46227. updatable?: boolean;
  46228. sideOrientation?: number;
  46229. frontUVs?: Vector4;
  46230. backUVs?: Vector4;
  46231. }, scene?: Nullable<Scene>): Mesh;
  46232. }
  46233. }
  46234. declare module "babylonjs/Gizmos/scaleGizmo" {
  46235. import { Observable } from "babylonjs/Misc/observable";
  46236. import { Nullable } from "babylonjs/types";
  46237. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46238. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46239. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  46240. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46241. /**
  46242. * Gizmo that enables scaling a mesh along 3 axis
  46243. */
  46244. export class ScaleGizmo extends Gizmo {
  46245. /**
  46246. * Internal gizmo used for interactions on the x axis
  46247. */
  46248. xGizmo: AxisScaleGizmo;
  46249. /**
  46250. * Internal gizmo used for interactions on the y axis
  46251. */
  46252. yGizmo: AxisScaleGizmo;
  46253. /**
  46254. * Internal gizmo used for interactions on the z axis
  46255. */
  46256. zGizmo: AxisScaleGizmo;
  46257. /**
  46258. * Internal gizmo used to scale all axis equally
  46259. */
  46260. uniformScaleGizmo: AxisScaleGizmo;
  46261. private _meshAttached;
  46262. private _updateGizmoRotationToMatchAttachedMesh;
  46263. private _snapDistance;
  46264. private _scaleRatio;
  46265. private _uniformScalingMesh;
  46266. private _octahedron;
  46267. /** Fires an event when any of it's sub gizmos are dragged */
  46268. onDragStartObservable: Observable<unknown>;
  46269. /** Fires an event when any of it's sub gizmos are released from dragging */
  46270. onDragEndObservable: Observable<unknown>;
  46271. attachedMesh: Nullable<AbstractMesh>;
  46272. /**
  46273. * Creates a ScaleGizmo
  46274. * @param gizmoLayer The utility layer the gizmo will be added to
  46275. */
  46276. constructor(gizmoLayer?: UtilityLayerRenderer);
  46277. updateGizmoRotationToMatchAttachedMesh: boolean;
  46278. /**
  46279. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46280. */
  46281. snapDistance: number;
  46282. /**
  46283. * Ratio for the scale of the gizmo (Default: 1)
  46284. */
  46285. scaleRatio: number;
  46286. /**
  46287. * Disposes of the gizmo
  46288. */
  46289. dispose(): void;
  46290. }
  46291. }
  46292. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  46293. import { Observable } from "babylonjs/Misc/observable";
  46294. import { Nullable } from "babylonjs/types";
  46295. import { Vector3 } from "babylonjs/Maths/math.vector";
  46296. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46297. import { Mesh } from "babylonjs/Meshes/mesh";
  46298. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46299. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46300. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46301. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  46302. import { Color3 } from "babylonjs/Maths/math.color";
  46303. /**
  46304. * Single axis scale gizmo
  46305. */
  46306. export class AxisScaleGizmo extends Gizmo {
  46307. /**
  46308. * Drag behavior responsible for the gizmos dragging interactions
  46309. */
  46310. dragBehavior: PointerDragBehavior;
  46311. private _pointerObserver;
  46312. /**
  46313. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46314. */
  46315. snapDistance: number;
  46316. /**
  46317. * Event that fires each time the gizmo snaps to a new location.
  46318. * * snapDistance is the the change in distance
  46319. */
  46320. onSnapObservable: Observable<{
  46321. snapDistance: number;
  46322. }>;
  46323. /**
  46324. * If the scaling operation should be done on all axis (default: false)
  46325. */
  46326. uniformScaling: boolean;
  46327. private _isEnabled;
  46328. private _parent;
  46329. private _arrow;
  46330. private _coloredMaterial;
  46331. private _hoverMaterial;
  46332. /**
  46333. * Creates an AxisScaleGizmo
  46334. * @param gizmoLayer The utility layer the gizmo will be added to
  46335. * @param dragAxis The axis which the gizmo will be able to scale on
  46336. * @param color The color of the gizmo
  46337. */
  46338. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  46339. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46340. /**
  46341. * If the gizmo is enabled
  46342. */
  46343. isEnabled: boolean;
  46344. /**
  46345. * Disposes of the gizmo
  46346. */
  46347. dispose(): void;
  46348. /**
  46349. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46350. * @param mesh The mesh to replace the default mesh of the gizmo
  46351. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  46352. */
  46353. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  46354. }
  46355. }
  46356. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  46357. import { Observable } from "babylonjs/Misc/observable";
  46358. import { Nullable } from "babylonjs/types";
  46359. import { Vector3 } from "babylonjs/Maths/math.vector";
  46360. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46361. import { Mesh } from "babylonjs/Meshes/mesh";
  46362. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46363. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46364. import { Color3 } from "babylonjs/Maths/math.color";
  46365. import "babylonjs/Meshes/Builders/boxBuilder";
  46366. /**
  46367. * Bounding box gizmo
  46368. */
  46369. export class BoundingBoxGizmo extends Gizmo {
  46370. private _lineBoundingBox;
  46371. private _rotateSpheresParent;
  46372. private _scaleBoxesParent;
  46373. private _boundingDimensions;
  46374. private _renderObserver;
  46375. private _pointerObserver;
  46376. private _scaleDragSpeed;
  46377. private _tmpQuaternion;
  46378. private _tmpVector;
  46379. private _tmpRotationMatrix;
  46380. /**
  46381. * 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)
  46382. */
  46383. ignoreChildren: boolean;
  46384. /**
  46385. * 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)
  46386. */
  46387. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  46388. /**
  46389. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  46390. */
  46391. rotationSphereSize: number;
  46392. /**
  46393. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  46394. */
  46395. scaleBoxSize: number;
  46396. /**
  46397. * 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)
  46398. */
  46399. fixedDragMeshScreenSize: boolean;
  46400. /**
  46401. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  46402. */
  46403. fixedDragMeshScreenSizeDistanceFactor: number;
  46404. /**
  46405. * Fired when a rotation sphere or scale box is dragged
  46406. */
  46407. onDragStartObservable: Observable<{}>;
  46408. /**
  46409. * Fired when a scale box is dragged
  46410. */
  46411. onScaleBoxDragObservable: Observable<{}>;
  46412. /**
  46413. * Fired when a scale box drag is ended
  46414. */
  46415. onScaleBoxDragEndObservable: Observable<{}>;
  46416. /**
  46417. * Fired when a rotation sphere is dragged
  46418. */
  46419. onRotationSphereDragObservable: Observable<{}>;
  46420. /**
  46421. * Fired when a rotation sphere drag is ended
  46422. */
  46423. onRotationSphereDragEndObservable: Observable<{}>;
  46424. /**
  46425. * 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)
  46426. */
  46427. scalePivot: Nullable<Vector3>;
  46428. /**
  46429. * Mesh used as a pivot to rotate the attached mesh
  46430. */
  46431. private _anchorMesh;
  46432. private _existingMeshScale;
  46433. private _dragMesh;
  46434. private pointerDragBehavior;
  46435. private coloredMaterial;
  46436. private hoverColoredMaterial;
  46437. /**
  46438. * Sets the color of the bounding box gizmo
  46439. * @param color the color to set
  46440. */
  46441. setColor(color: Color3): void;
  46442. /**
  46443. * Creates an BoundingBoxGizmo
  46444. * @param gizmoLayer The utility layer the gizmo will be added to
  46445. * @param color The color of the gizmo
  46446. */
  46447. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  46448. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46449. private _selectNode;
  46450. /**
  46451. * Updates the bounding box information for the Gizmo
  46452. */
  46453. updateBoundingBox(): void;
  46454. private _updateRotationSpheres;
  46455. private _updateScaleBoxes;
  46456. /**
  46457. * Enables rotation on the specified axis and disables rotation on the others
  46458. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  46459. */
  46460. setEnabledRotationAxis(axis: string): void;
  46461. /**
  46462. * Enables/disables scaling
  46463. * @param enable if scaling should be enabled
  46464. */
  46465. setEnabledScaling(enable: boolean): void;
  46466. private _updateDummy;
  46467. /**
  46468. * Enables a pointer drag behavior on the bounding box of the gizmo
  46469. */
  46470. enableDragBehavior(): void;
  46471. /**
  46472. * Disposes of the gizmo
  46473. */
  46474. dispose(): void;
  46475. /**
  46476. * 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)
  46477. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  46478. * @returns the bounding box mesh with the passed in mesh as a child
  46479. */
  46480. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  46481. /**
  46482. * CustomMeshes are not supported by this gizmo
  46483. * @param mesh The mesh to replace the default mesh of the gizmo
  46484. */
  46485. setCustomMesh(mesh: Mesh): void;
  46486. }
  46487. }
  46488. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  46489. import { Observable } from "babylonjs/Misc/observable";
  46490. import { Nullable } from "babylonjs/types";
  46491. import { Vector3 } from "babylonjs/Maths/math.vector";
  46492. import { Color3 } from "babylonjs/Maths/math.color";
  46493. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46494. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46495. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46496. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46497. import "babylonjs/Meshes/Builders/linesBuilder";
  46498. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  46499. /**
  46500. * Single plane rotation gizmo
  46501. */
  46502. export class PlaneRotationGizmo extends Gizmo {
  46503. /**
  46504. * Drag behavior responsible for the gizmos dragging interactions
  46505. */
  46506. dragBehavior: PointerDragBehavior;
  46507. private _pointerObserver;
  46508. /**
  46509. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  46510. */
  46511. snapDistance: number;
  46512. /**
  46513. * Event that fires each time the gizmo snaps to a new location.
  46514. * * snapDistance is the the change in distance
  46515. */
  46516. onSnapObservable: Observable<{
  46517. snapDistance: number;
  46518. }>;
  46519. private _isEnabled;
  46520. private _parent;
  46521. /**
  46522. * Creates a PlaneRotationGizmo
  46523. * @param gizmoLayer The utility layer the gizmo will be added to
  46524. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  46525. * @param color The color of the gizmo
  46526. * @param tessellation Amount of tessellation to be used when creating rotation circles
  46527. * @param useEulerRotation Use and update Euler angle instead of quaternion
  46528. */
  46529. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  46530. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46531. /**
  46532. * If the gizmo is enabled
  46533. */
  46534. isEnabled: boolean;
  46535. /**
  46536. * Disposes of the gizmo
  46537. */
  46538. dispose(): void;
  46539. }
  46540. }
  46541. declare module "babylonjs/Gizmos/rotationGizmo" {
  46542. import { Observable } from "babylonjs/Misc/observable";
  46543. import { Nullable } from "babylonjs/types";
  46544. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46545. import { Mesh } from "babylonjs/Meshes/mesh";
  46546. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46547. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  46548. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46549. /**
  46550. * Gizmo that enables rotating a mesh along 3 axis
  46551. */
  46552. export class RotationGizmo extends Gizmo {
  46553. /**
  46554. * Internal gizmo used for interactions on the x axis
  46555. */
  46556. xGizmo: PlaneRotationGizmo;
  46557. /**
  46558. * Internal gizmo used for interactions on the y axis
  46559. */
  46560. yGizmo: PlaneRotationGizmo;
  46561. /**
  46562. * Internal gizmo used for interactions on the z axis
  46563. */
  46564. zGizmo: PlaneRotationGizmo;
  46565. /** Fires an event when any of it's sub gizmos are dragged */
  46566. onDragStartObservable: Observable<unknown>;
  46567. /** Fires an event when any of it's sub gizmos are released from dragging */
  46568. onDragEndObservable: Observable<unknown>;
  46569. private _meshAttached;
  46570. attachedMesh: Nullable<AbstractMesh>;
  46571. /**
  46572. * Creates a RotationGizmo
  46573. * @param gizmoLayer The utility layer the gizmo will be added to
  46574. * @param tessellation Amount of tessellation to be used when creating rotation circles
  46575. * @param useEulerRotation Use and update Euler angle instead of quaternion
  46576. */
  46577. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  46578. updateGizmoRotationToMatchAttachedMesh: boolean;
  46579. /**
  46580. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46581. */
  46582. snapDistance: number;
  46583. /**
  46584. * Ratio for the scale of the gizmo (Default: 1)
  46585. */
  46586. scaleRatio: number;
  46587. /**
  46588. * Disposes of the gizmo
  46589. */
  46590. dispose(): void;
  46591. /**
  46592. * CustomMeshes are not supported by this gizmo
  46593. * @param mesh The mesh to replace the default mesh of the gizmo
  46594. */
  46595. setCustomMesh(mesh: Mesh): void;
  46596. }
  46597. }
  46598. declare module "babylonjs/Gizmos/gizmoManager" {
  46599. import { Observable } from "babylonjs/Misc/observable";
  46600. import { Nullable } from "babylonjs/types";
  46601. import { Scene, IDisposable } from "babylonjs/scene";
  46602. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46603. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46604. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  46605. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  46606. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  46607. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  46608. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  46609. /**
  46610. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  46611. */
  46612. export class GizmoManager implements IDisposable {
  46613. private scene;
  46614. /**
  46615. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  46616. */
  46617. gizmos: {
  46618. positionGizmo: Nullable<PositionGizmo>;
  46619. rotationGizmo: Nullable<RotationGizmo>;
  46620. scaleGizmo: Nullable<ScaleGizmo>;
  46621. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  46622. };
  46623. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  46624. clearGizmoOnEmptyPointerEvent: boolean;
  46625. /** Fires an event when the manager is attached to a mesh */
  46626. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  46627. private _gizmosEnabled;
  46628. private _pointerObserver;
  46629. private _attachedMesh;
  46630. private _boundingBoxColor;
  46631. private _defaultUtilityLayer;
  46632. private _defaultKeepDepthUtilityLayer;
  46633. /**
  46634. * When bounding box gizmo is enabled, this can be used to track drag/end events
  46635. */
  46636. boundingBoxDragBehavior: SixDofDragBehavior;
  46637. /**
  46638. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  46639. */
  46640. attachableMeshes: Nullable<Array<AbstractMesh>>;
  46641. /**
  46642. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  46643. */
  46644. usePointerToAttachGizmos: boolean;
  46645. /**
  46646. * Utility layer that the bounding box gizmo belongs to
  46647. */
  46648. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  46649. /**
  46650. * Utility layer that all gizmos besides bounding box belong to
  46651. */
  46652. readonly utilityLayer: UtilityLayerRenderer;
  46653. /**
  46654. * Instatiates a gizmo manager
  46655. * @param scene the scene to overlay the gizmos on top of
  46656. */
  46657. constructor(scene: Scene);
  46658. /**
  46659. * Attaches a set of gizmos to the specified mesh
  46660. * @param mesh The mesh the gizmo's should be attached to
  46661. */
  46662. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  46663. /**
  46664. * If the position gizmo is enabled
  46665. */
  46666. positionGizmoEnabled: boolean;
  46667. /**
  46668. * If the rotation gizmo is enabled
  46669. */
  46670. rotationGizmoEnabled: boolean;
  46671. /**
  46672. * If the scale gizmo is enabled
  46673. */
  46674. scaleGizmoEnabled: boolean;
  46675. /**
  46676. * If the boundingBox gizmo is enabled
  46677. */
  46678. boundingBoxGizmoEnabled: boolean;
  46679. /**
  46680. * Disposes of the gizmo manager
  46681. */
  46682. dispose(): void;
  46683. }
  46684. }
  46685. declare module "babylonjs/Lights/directionalLight" {
  46686. import { Camera } from "babylonjs/Cameras/camera";
  46687. import { Scene } from "babylonjs/scene";
  46688. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46689. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46690. import { Light } from "babylonjs/Lights/light";
  46691. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46692. import { Effect } from "babylonjs/Materials/effect";
  46693. /**
  46694. * A directional light is defined by a direction (what a surprise!).
  46695. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  46696. * 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.
  46697. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46698. */
  46699. export class DirectionalLight extends ShadowLight {
  46700. private _shadowFrustumSize;
  46701. /**
  46702. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  46703. */
  46704. /**
  46705. * Specifies a fix frustum size for the shadow generation.
  46706. */
  46707. shadowFrustumSize: number;
  46708. private _shadowOrthoScale;
  46709. /**
  46710. * Gets the shadow projection scale against the optimal computed one.
  46711. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46712. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46713. */
  46714. /**
  46715. * Sets the shadow projection scale against the optimal computed one.
  46716. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46717. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46718. */
  46719. shadowOrthoScale: number;
  46720. /**
  46721. * Automatically compute the projection matrix to best fit (including all the casters)
  46722. * on each frame.
  46723. */
  46724. autoUpdateExtends: boolean;
  46725. private _orthoLeft;
  46726. private _orthoRight;
  46727. private _orthoTop;
  46728. private _orthoBottom;
  46729. /**
  46730. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  46731. * The directional light is emitted from everywhere in the given direction.
  46732. * It can cast shadows.
  46733. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46734. * @param name The friendly name of the light
  46735. * @param direction The direction of the light
  46736. * @param scene The scene the light belongs to
  46737. */
  46738. constructor(name: string, direction: Vector3, scene: Scene);
  46739. /**
  46740. * Returns the string "DirectionalLight".
  46741. * @return The class name
  46742. */
  46743. getClassName(): string;
  46744. /**
  46745. * Returns the integer 1.
  46746. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46747. */
  46748. getTypeID(): number;
  46749. /**
  46750. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  46751. * Returns the DirectionalLight Shadow projection matrix.
  46752. */
  46753. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46754. /**
  46755. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  46756. * Returns the DirectionalLight Shadow projection matrix.
  46757. */
  46758. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  46759. /**
  46760. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  46761. * Returns the DirectionalLight Shadow projection matrix.
  46762. */
  46763. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46764. protected _buildUniformLayout(): void;
  46765. /**
  46766. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  46767. * @param effect The effect to update
  46768. * @param lightIndex The index of the light in the effect to update
  46769. * @returns The directional light
  46770. */
  46771. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  46772. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  46773. /**
  46774. * Gets the minZ used for shadow according to both the scene and the light.
  46775. *
  46776. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46777. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46778. * @param activeCamera The camera we are returning the min for
  46779. * @returns the depth min z
  46780. */
  46781. getDepthMinZ(activeCamera: Camera): number;
  46782. /**
  46783. * Gets the maxZ used for shadow according to both the scene and the light.
  46784. *
  46785. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46786. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46787. * @param activeCamera The camera we are returning the max for
  46788. * @returns the depth max z
  46789. */
  46790. getDepthMaxZ(activeCamera: Camera): number;
  46791. /**
  46792. * Prepares the list of defines specific to the light type.
  46793. * @param defines the list of defines
  46794. * @param lightIndex defines the index of the light for the effect
  46795. */
  46796. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46797. }
  46798. }
  46799. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  46800. import { Mesh } from "babylonjs/Meshes/mesh";
  46801. /**
  46802. * Class containing static functions to help procedurally build meshes
  46803. */
  46804. export class HemisphereBuilder {
  46805. /**
  46806. * Creates a hemisphere mesh
  46807. * @param name defines the name of the mesh
  46808. * @param options defines the options used to create the mesh
  46809. * @param scene defines the hosting scene
  46810. * @returns the hemisphere mesh
  46811. */
  46812. static CreateHemisphere(name: string, options: {
  46813. segments?: number;
  46814. diameter?: number;
  46815. sideOrientation?: number;
  46816. }, scene: any): Mesh;
  46817. }
  46818. }
  46819. declare module "babylonjs/Lights/spotLight" {
  46820. import { Nullable } from "babylonjs/types";
  46821. import { Scene } from "babylonjs/scene";
  46822. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46823. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46824. import { Effect } from "babylonjs/Materials/effect";
  46825. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46826. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46827. /**
  46828. * A spot light is defined by a position, a direction, an angle, and an exponent.
  46829. * These values define a cone of light starting from the position, emitting toward the direction.
  46830. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  46831. * and the exponent defines the speed of the decay of the light with distance (reach).
  46832. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46833. */
  46834. export class SpotLight extends ShadowLight {
  46835. private _angle;
  46836. private _innerAngle;
  46837. private _cosHalfAngle;
  46838. private _lightAngleScale;
  46839. private _lightAngleOffset;
  46840. /**
  46841. * Gets the cone angle of the spot light in Radians.
  46842. */
  46843. /**
  46844. * Sets the cone angle of the spot light in Radians.
  46845. */
  46846. angle: number;
  46847. /**
  46848. * Only used in gltf falloff mode, this defines the angle where
  46849. * the directional falloff will start before cutting at angle which could be seen
  46850. * as outer angle.
  46851. */
  46852. /**
  46853. * Only used in gltf falloff mode, this defines the angle where
  46854. * the directional falloff will start before cutting at angle which could be seen
  46855. * as outer angle.
  46856. */
  46857. innerAngle: number;
  46858. private _shadowAngleScale;
  46859. /**
  46860. * Allows scaling the angle of the light for shadow generation only.
  46861. */
  46862. /**
  46863. * Allows scaling the angle of the light for shadow generation only.
  46864. */
  46865. shadowAngleScale: number;
  46866. /**
  46867. * The light decay speed with the distance from the emission spot.
  46868. */
  46869. exponent: number;
  46870. private _projectionTextureMatrix;
  46871. /**
  46872. * Allows reading the projecton texture
  46873. */
  46874. readonly projectionTextureMatrix: Matrix;
  46875. protected _projectionTextureLightNear: number;
  46876. /**
  46877. * Gets the near clip of the Spotlight for texture projection.
  46878. */
  46879. /**
  46880. * Sets the near clip of the Spotlight for texture projection.
  46881. */
  46882. projectionTextureLightNear: number;
  46883. protected _projectionTextureLightFar: number;
  46884. /**
  46885. * Gets the far clip of the Spotlight for texture projection.
  46886. */
  46887. /**
  46888. * Sets the far clip of the Spotlight for texture projection.
  46889. */
  46890. projectionTextureLightFar: number;
  46891. protected _projectionTextureUpDirection: Vector3;
  46892. /**
  46893. * Gets the Up vector of the Spotlight for texture projection.
  46894. */
  46895. /**
  46896. * Sets the Up vector of the Spotlight for texture projection.
  46897. */
  46898. projectionTextureUpDirection: Vector3;
  46899. private _projectionTexture;
  46900. /**
  46901. * Gets the projection texture of the light.
  46902. */
  46903. /**
  46904. * Sets the projection texture of the light.
  46905. */
  46906. projectionTexture: Nullable<BaseTexture>;
  46907. private _projectionTextureViewLightDirty;
  46908. private _projectionTextureProjectionLightDirty;
  46909. private _projectionTextureDirty;
  46910. private _projectionTextureViewTargetVector;
  46911. private _projectionTextureViewLightMatrix;
  46912. private _projectionTextureProjectionLightMatrix;
  46913. private _projectionTextureScalingMatrix;
  46914. /**
  46915. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  46916. * It can cast shadows.
  46917. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46918. * @param name The light friendly name
  46919. * @param position The position of the spot light in the scene
  46920. * @param direction The direction of the light in the scene
  46921. * @param angle The cone angle of the light in Radians
  46922. * @param exponent The light decay speed with the distance from the emission spot
  46923. * @param scene The scene the lights belongs to
  46924. */
  46925. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  46926. /**
  46927. * Returns the string "SpotLight".
  46928. * @returns the class name
  46929. */
  46930. getClassName(): string;
  46931. /**
  46932. * Returns the integer 2.
  46933. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46934. */
  46935. getTypeID(): number;
  46936. /**
  46937. * Overrides the direction setter to recompute the projection texture view light Matrix.
  46938. */
  46939. protected _setDirection(value: Vector3): void;
  46940. /**
  46941. * Overrides the position setter to recompute the projection texture view light Matrix.
  46942. */
  46943. protected _setPosition(value: Vector3): void;
  46944. /**
  46945. * 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.
  46946. * Returns the SpotLight.
  46947. */
  46948. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46949. protected _computeProjectionTextureViewLightMatrix(): void;
  46950. protected _computeProjectionTextureProjectionLightMatrix(): void;
  46951. /**
  46952. * Main function for light texture projection matrix computing.
  46953. */
  46954. protected _computeProjectionTextureMatrix(): void;
  46955. protected _buildUniformLayout(): void;
  46956. private _computeAngleValues;
  46957. /**
  46958. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  46959. * @param effect The effect to update
  46960. * @param lightIndex The index of the light in the effect to update
  46961. * @returns The spot light
  46962. */
  46963. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  46964. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  46965. /**
  46966. * Disposes the light and the associated resources.
  46967. */
  46968. dispose(): void;
  46969. /**
  46970. * Prepares the list of defines specific to the light type.
  46971. * @param defines the list of defines
  46972. * @param lightIndex defines the index of the light for the effect
  46973. */
  46974. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46975. }
  46976. }
  46977. declare module "babylonjs/Gizmos/lightGizmo" {
  46978. import { Nullable } from "babylonjs/types";
  46979. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46980. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46981. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  46982. import { Light } from "babylonjs/Lights/light";
  46983. /**
  46984. * Gizmo that enables viewing a light
  46985. */
  46986. export class LightGizmo extends Gizmo {
  46987. private _lightMesh;
  46988. private _material;
  46989. private cachedPosition;
  46990. private cachedForward;
  46991. /**
  46992. * Creates a LightGizmo
  46993. * @param gizmoLayer The utility layer the gizmo will be added to
  46994. */
  46995. constructor(gizmoLayer?: UtilityLayerRenderer);
  46996. private _light;
  46997. /**
  46998. * The light that the gizmo is attached to
  46999. */
  47000. light: Nullable<Light>;
  47001. /**
  47002. * Gets the material used to render the light gizmo
  47003. */
  47004. readonly material: StandardMaterial;
  47005. /**
  47006. * @hidden
  47007. * Updates the gizmo to match the attached mesh's position/rotation
  47008. */
  47009. protected _update(): void;
  47010. private static _Scale;
  47011. /**
  47012. * Creates the lines for a light mesh
  47013. */
  47014. private static _createLightLines;
  47015. /**
  47016. * Disposes of the light gizmo
  47017. */
  47018. dispose(): void;
  47019. private static _CreateHemisphericLightMesh;
  47020. private static _CreatePointLightMesh;
  47021. private static _CreateSpotLightMesh;
  47022. private static _CreateDirectionalLightMesh;
  47023. }
  47024. }
  47025. declare module "babylonjs/Gizmos/index" {
  47026. export * from "babylonjs/Gizmos/axisDragGizmo";
  47027. export * from "babylonjs/Gizmos/axisScaleGizmo";
  47028. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  47029. export * from "babylonjs/Gizmos/gizmo";
  47030. export * from "babylonjs/Gizmos/gizmoManager";
  47031. export * from "babylonjs/Gizmos/planeRotationGizmo";
  47032. export * from "babylonjs/Gizmos/positionGizmo";
  47033. export * from "babylonjs/Gizmos/rotationGizmo";
  47034. export * from "babylonjs/Gizmos/scaleGizmo";
  47035. export * from "babylonjs/Gizmos/lightGizmo";
  47036. export * from "babylonjs/Gizmos/planeDragGizmo";
  47037. }
  47038. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  47039. /** @hidden */
  47040. export var backgroundFragmentDeclaration: {
  47041. name: string;
  47042. shader: string;
  47043. };
  47044. }
  47045. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  47046. /** @hidden */
  47047. export var backgroundUboDeclaration: {
  47048. name: string;
  47049. shader: string;
  47050. };
  47051. }
  47052. declare module "babylonjs/Shaders/background.fragment" {
  47053. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  47054. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47055. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47056. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47057. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47058. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47059. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47060. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  47061. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47062. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47063. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47064. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47065. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47066. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47067. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47068. /** @hidden */
  47069. export var backgroundPixelShader: {
  47070. name: string;
  47071. shader: string;
  47072. };
  47073. }
  47074. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  47075. /** @hidden */
  47076. export var backgroundVertexDeclaration: {
  47077. name: string;
  47078. shader: string;
  47079. };
  47080. }
  47081. declare module "babylonjs/Shaders/background.vertex" {
  47082. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  47083. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47084. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47085. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47086. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47087. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47088. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47089. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47090. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47091. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47092. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47093. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47094. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47095. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47096. /** @hidden */
  47097. export var backgroundVertexShader: {
  47098. name: string;
  47099. shader: string;
  47100. };
  47101. }
  47102. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  47103. import { Nullable, int, float } from "babylonjs/types";
  47104. import { Scene } from "babylonjs/scene";
  47105. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47106. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47107. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47108. import { Mesh } from "babylonjs/Meshes/mesh";
  47109. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47110. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47111. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47112. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47113. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  47114. import { Color3 } from "babylonjs/Maths/math.color";
  47115. import "babylonjs/Shaders/background.fragment";
  47116. import "babylonjs/Shaders/background.vertex";
  47117. /**
  47118. * Background material used to create an efficient environement around your scene.
  47119. */
  47120. export class BackgroundMaterial extends PushMaterial {
  47121. /**
  47122. * Standard reflectance value at parallel view angle.
  47123. */
  47124. static StandardReflectance0: number;
  47125. /**
  47126. * Standard reflectance value at grazing angle.
  47127. */
  47128. static StandardReflectance90: number;
  47129. protected _primaryColor: Color3;
  47130. /**
  47131. * Key light Color (multiply against the environement texture)
  47132. */
  47133. primaryColor: Color3;
  47134. protected __perceptualColor: Nullable<Color3>;
  47135. /**
  47136. * Experimental Internal Use Only.
  47137. *
  47138. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  47139. * This acts as a helper to set the primary color to a more "human friendly" value.
  47140. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  47141. * output color as close as possible from the chosen value.
  47142. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  47143. * part of lighting setup.)
  47144. */
  47145. _perceptualColor: Nullable<Color3>;
  47146. protected _primaryColorShadowLevel: float;
  47147. /**
  47148. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  47149. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  47150. */
  47151. primaryColorShadowLevel: float;
  47152. protected _primaryColorHighlightLevel: float;
  47153. /**
  47154. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  47155. * The primary color is used at the level chosen to define what the white area would look.
  47156. */
  47157. primaryColorHighlightLevel: float;
  47158. protected _reflectionTexture: Nullable<BaseTexture>;
  47159. /**
  47160. * Reflection Texture used in the material.
  47161. * Should be author in a specific way for the best result (refer to the documentation).
  47162. */
  47163. reflectionTexture: Nullable<BaseTexture>;
  47164. protected _reflectionBlur: float;
  47165. /**
  47166. * Reflection Texture level of blur.
  47167. *
  47168. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  47169. * texture twice.
  47170. */
  47171. reflectionBlur: float;
  47172. protected _diffuseTexture: Nullable<BaseTexture>;
  47173. /**
  47174. * Diffuse Texture used in the material.
  47175. * Should be author in a specific way for the best result (refer to the documentation).
  47176. */
  47177. diffuseTexture: Nullable<BaseTexture>;
  47178. protected _shadowLights: Nullable<IShadowLight[]>;
  47179. /**
  47180. * Specify the list of lights casting shadow on the material.
  47181. * All scene shadow lights will be included if null.
  47182. */
  47183. shadowLights: Nullable<IShadowLight[]>;
  47184. protected _shadowLevel: float;
  47185. /**
  47186. * Helps adjusting the shadow to a softer level if required.
  47187. * 0 means black shadows and 1 means no shadows.
  47188. */
  47189. shadowLevel: float;
  47190. protected _sceneCenter: Vector3;
  47191. /**
  47192. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  47193. * It is usually zero but might be interesting to modify according to your setup.
  47194. */
  47195. sceneCenter: Vector3;
  47196. protected _opacityFresnel: boolean;
  47197. /**
  47198. * This helps specifying that the material is falling off to the sky box at grazing angle.
  47199. * This helps ensuring a nice transition when the camera goes under the ground.
  47200. */
  47201. opacityFresnel: boolean;
  47202. protected _reflectionFresnel: boolean;
  47203. /**
  47204. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  47205. * This helps adding a mirror texture on the ground.
  47206. */
  47207. reflectionFresnel: boolean;
  47208. protected _reflectionFalloffDistance: number;
  47209. /**
  47210. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  47211. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  47212. */
  47213. reflectionFalloffDistance: number;
  47214. protected _reflectionAmount: number;
  47215. /**
  47216. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  47217. */
  47218. reflectionAmount: number;
  47219. protected _reflectionReflectance0: number;
  47220. /**
  47221. * This specifies the weight of the reflection at grazing angle.
  47222. */
  47223. reflectionReflectance0: number;
  47224. protected _reflectionReflectance90: number;
  47225. /**
  47226. * This specifies the weight of the reflection at a perpendicular point of view.
  47227. */
  47228. reflectionReflectance90: number;
  47229. /**
  47230. * Sets the reflection reflectance fresnel values according to the default standard
  47231. * empirically know to work well :-)
  47232. */
  47233. reflectionStandardFresnelWeight: number;
  47234. protected _useRGBColor: boolean;
  47235. /**
  47236. * Helps to directly use the maps channels instead of their level.
  47237. */
  47238. useRGBColor: boolean;
  47239. protected _enableNoise: boolean;
  47240. /**
  47241. * This helps reducing the banding effect that could occur on the background.
  47242. */
  47243. enableNoise: boolean;
  47244. /**
  47245. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47246. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  47247. * Recommended to be keep at 1.0 except for special cases.
  47248. */
  47249. fovMultiplier: number;
  47250. private _fovMultiplier;
  47251. /**
  47252. * Enable the FOV adjustment feature controlled by fovMultiplier.
  47253. */
  47254. useEquirectangularFOV: boolean;
  47255. private _maxSimultaneousLights;
  47256. /**
  47257. * Number of Simultaneous lights allowed on the material.
  47258. */
  47259. maxSimultaneousLights: int;
  47260. /**
  47261. * Default configuration related to image processing available in the Background Material.
  47262. */
  47263. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47264. /**
  47265. * Keep track of the image processing observer to allow dispose and replace.
  47266. */
  47267. private _imageProcessingObserver;
  47268. /**
  47269. * Attaches a new image processing configuration to the PBR Material.
  47270. * @param configuration (if null the scene configuration will be use)
  47271. */
  47272. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47273. /**
  47274. * Gets the image processing configuration used either in this material.
  47275. */
  47276. /**
  47277. * Sets the Default image processing configuration used either in the this material.
  47278. *
  47279. * If sets to null, the scene one is in use.
  47280. */
  47281. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  47282. /**
  47283. * Gets wether the color curves effect is enabled.
  47284. */
  47285. /**
  47286. * Sets wether the color curves effect is enabled.
  47287. */
  47288. cameraColorCurvesEnabled: boolean;
  47289. /**
  47290. * Gets wether the color grading effect is enabled.
  47291. */
  47292. /**
  47293. * Gets wether the color grading effect is enabled.
  47294. */
  47295. cameraColorGradingEnabled: boolean;
  47296. /**
  47297. * Gets wether tonemapping is enabled or not.
  47298. */
  47299. /**
  47300. * Sets wether tonemapping is enabled or not
  47301. */
  47302. cameraToneMappingEnabled: boolean;
  47303. /**
  47304. * The camera exposure used on this material.
  47305. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47306. * This corresponds to a photographic exposure.
  47307. */
  47308. /**
  47309. * The camera exposure used on this material.
  47310. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47311. * This corresponds to a photographic exposure.
  47312. */
  47313. cameraExposure: float;
  47314. /**
  47315. * Gets The camera contrast used on this material.
  47316. */
  47317. /**
  47318. * Sets The camera contrast used on this material.
  47319. */
  47320. cameraContrast: float;
  47321. /**
  47322. * Gets the Color Grading 2D Lookup Texture.
  47323. */
  47324. /**
  47325. * Sets the Color Grading 2D Lookup Texture.
  47326. */
  47327. cameraColorGradingTexture: Nullable<BaseTexture>;
  47328. /**
  47329. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47330. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47331. * 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;
  47332. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47333. */
  47334. /**
  47335. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47336. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47337. * 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;
  47338. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47339. */
  47340. cameraColorCurves: Nullable<ColorCurves>;
  47341. /**
  47342. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  47343. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  47344. */
  47345. switchToBGR: boolean;
  47346. private _renderTargets;
  47347. private _reflectionControls;
  47348. private _white;
  47349. private _primaryShadowColor;
  47350. private _primaryHighlightColor;
  47351. /**
  47352. * Instantiates a Background Material in the given scene
  47353. * @param name The friendly name of the material
  47354. * @param scene The scene to add the material to
  47355. */
  47356. constructor(name: string, scene: Scene);
  47357. /**
  47358. * Gets a boolean indicating that current material needs to register RTT
  47359. */
  47360. readonly hasRenderTargetTextures: boolean;
  47361. /**
  47362. * The entire material has been created in order to prevent overdraw.
  47363. * @returns false
  47364. */
  47365. needAlphaTesting(): boolean;
  47366. /**
  47367. * The entire material has been created in order to prevent overdraw.
  47368. * @returns true if blending is enable
  47369. */
  47370. needAlphaBlending(): boolean;
  47371. /**
  47372. * Checks wether the material is ready to be rendered for a given mesh.
  47373. * @param mesh The mesh to render
  47374. * @param subMesh The submesh to check against
  47375. * @param useInstances Specify wether or not the material is used with instances
  47376. * @returns true if all the dependencies are ready (Textures, Effects...)
  47377. */
  47378. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47379. /**
  47380. * Compute the primary color according to the chosen perceptual color.
  47381. */
  47382. private _computePrimaryColorFromPerceptualColor;
  47383. /**
  47384. * Compute the highlights and shadow colors according to their chosen levels.
  47385. */
  47386. private _computePrimaryColors;
  47387. /**
  47388. * Build the uniform buffer used in the material.
  47389. */
  47390. buildUniformLayout(): void;
  47391. /**
  47392. * Unbind the material.
  47393. */
  47394. unbind(): void;
  47395. /**
  47396. * Bind only the world matrix to the material.
  47397. * @param world The world matrix to bind.
  47398. */
  47399. bindOnlyWorldMatrix(world: Matrix): void;
  47400. /**
  47401. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  47402. * @param world The world matrix to bind.
  47403. * @param subMesh The submesh to bind for.
  47404. */
  47405. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47406. /**
  47407. * Checks to see if a texture is used in the material.
  47408. * @param texture - Base texture to use.
  47409. * @returns - Boolean specifying if a texture is used in the material.
  47410. */
  47411. hasTexture(texture: BaseTexture): boolean;
  47412. /**
  47413. * Dispose the material.
  47414. * @param forceDisposeEffect Force disposal of the associated effect.
  47415. * @param forceDisposeTextures Force disposal of the associated textures.
  47416. */
  47417. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47418. /**
  47419. * Clones the material.
  47420. * @param name The cloned name.
  47421. * @returns The cloned material.
  47422. */
  47423. clone(name: string): BackgroundMaterial;
  47424. /**
  47425. * Serializes the current material to its JSON representation.
  47426. * @returns The JSON representation.
  47427. */
  47428. serialize(): any;
  47429. /**
  47430. * Gets the class name of the material
  47431. * @returns "BackgroundMaterial"
  47432. */
  47433. getClassName(): string;
  47434. /**
  47435. * Parse a JSON input to create back a background material.
  47436. * @param source The JSON data to parse
  47437. * @param scene The scene to create the parsed material in
  47438. * @param rootUrl The root url of the assets the material depends upon
  47439. * @returns the instantiated BackgroundMaterial.
  47440. */
  47441. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  47442. }
  47443. }
  47444. declare module "babylonjs/Helpers/environmentHelper" {
  47445. import { Observable } from "babylonjs/Misc/observable";
  47446. import { Nullable } from "babylonjs/types";
  47447. import { Scene } from "babylonjs/scene";
  47448. import { Vector3 } from "babylonjs/Maths/math.vector";
  47449. import { Color3 } from "babylonjs/Maths/math.color";
  47450. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47451. import { Mesh } from "babylonjs/Meshes/mesh";
  47452. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47453. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  47454. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47455. import "babylonjs/Meshes/Builders/planeBuilder";
  47456. import "babylonjs/Meshes/Builders/boxBuilder";
  47457. /**
  47458. * Represents the different options available during the creation of
  47459. * a Environment helper.
  47460. *
  47461. * This can control the default ground, skybox and image processing setup of your scene.
  47462. */
  47463. export interface IEnvironmentHelperOptions {
  47464. /**
  47465. * Specifies wether or not to create a ground.
  47466. * True by default.
  47467. */
  47468. createGround: boolean;
  47469. /**
  47470. * Specifies the ground size.
  47471. * 15 by default.
  47472. */
  47473. groundSize: number;
  47474. /**
  47475. * The texture used on the ground for the main color.
  47476. * Comes from the BabylonJS CDN by default.
  47477. *
  47478. * Remarks: Can be either a texture or a url.
  47479. */
  47480. groundTexture: string | BaseTexture;
  47481. /**
  47482. * The color mixed in the ground texture by default.
  47483. * BabylonJS clearColor by default.
  47484. */
  47485. groundColor: Color3;
  47486. /**
  47487. * Specifies the ground opacity.
  47488. * 1 by default.
  47489. */
  47490. groundOpacity: number;
  47491. /**
  47492. * Enables the ground to receive shadows.
  47493. * True by default.
  47494. */
  47495. enableGroundShadow: boolean;
  47496. /**
  47497. * Helps preventing the shadow to be fully black on the ground.
  47498. * 0.5 by default.
  47499. */
  47500. groundShadowLevel: number;
  47501. /**
  47502. * Creates a mirror texture attach to the ground.
  47503. * false by default.
  47504. */
  47505. enableGroundMirror: boolean;
  47506. /**
  47507. * Specifies the ground mirror size ratio.
  47508. * 0.3 by default as the default kernel is 64.
  47509. */
  47510. groundMirrorSizeRatio: number;
  47511. /**
  47512. * Specifies the ground mirror blur kernel size.
  47513. * 64 by default.
  47514. */
  47515. groundMirrorBlurKernel: number;
  47516. /**
  47517. * Specifies the ground mirror visibility amount.
  47518. * 1 by default
  47519. */
  47520. groundMirrorAmount: number;
  47521. /**
  47522. * Specifies the ground mirror reflectance weight.
  47523. * This uses the standard weight of the background material to setup the fresnel effect
  47524. * of the mirror.
  47525. * 1 by default.
  47526. */
  47527. groundMirrorFresnelWeight: number;
  47528. /**
  47529. * Specifies the ground mirror Falloff distance.
  47530. * This can helps reducing the size of the reflection.
  47531. * 0 by Default.
  47532. */
  47533. groundMirrorFallOffDistance: number;
  47534. /**
  47535. * Specifies the ground mirror texture type.
  47536. * Unsigned Int by Default.
  47537. */
  47538. groundMirrorTextureType: number;
  47539. /**
  47540. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  47541. * the shown objects.
  47542. */
  47543. groundYBias: number;
  47544. /**
  47545. * Specifies wether or not to create a skybox.
  47546. * True by default.
  47547. */
  47548. createSkybox: boolean;
  47549. /**
  47550. * Specifies the skybox size.
  47551. * 20 by default.
  47552. */
  47553. skyboxSize: number;
  47554. /**
  47555. * The texture used on the skybox for the main color.
  47556. * Comes from the BabylonJS CDN by default.
  47557. *
  47558. * Remarks: Can be either a texture or a url.
  47559. */
  47560. skyboxTexture: string | BaseTexture;
  47561. /**
  47562. * The color mixed in the skybox texture by default.
  47563. * BabylonJS clearColor by default.
  47564. */
  47565. skyboxColor: Color3;
  47566. /**
  47567. * The background rotation around the Y axis of the scene.
  47568. * This helps aligning the key lights of your scene with the background.
  47569. * 0 by default.
  47570. */
  47571. backgroundYRotation: number;
  47572. /**
  47573. * Compute automatically the size of the elements to best fit with the scene.
  47574. */
  47575. sizeAuto: boolean;
  47576. /**
  47577. * Default position of the rootMesh if autoSize is not true.
  47578. */
  47579. rootPosition: Vector3;
  47580. /**
  47581. * Sets up the image processing in the scene.
  47582. * true by default.
  47583. */
  47584. setupImageProcessing: boolean;
  47585. /**
  47586. * The texture used as your environment texture in the scene.
  47587. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  47588. *
  47589. * Remarks: Can be either a texture or a url.
  47590. */
  47591. environmentTexture: string | BaseTexture;
  47592. /**
  47593. * The value of the exposure to apply to the scene.
  47594. * 0.6 by default if setupImageProcessing is true.
  47595. */
  47596. cameraExposure: number;
  47597. /**
  47598. * The value of the contrast to apply to the scene.
  47599. * 1.6 by default if setupImageProcessing is true.
  47600. */
  47601. cameraContrast: number;
  47602. /**
  47603. * Specifies wether or not tonemapping should be enabled in the scene.
  47604. * true by default if setupImageProcessing is true.
  47605. */
  47606. toneMappingEnabled: boolean;
  47607. }
  47608. /**
  47609. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  47610. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  47611. * It also helps with the default setup of your imageProcessing configuration.
  47612. */
  47613. export class EnvironmentHelper {
  47614. /**
  47615. * Default ground texture URL.
  47616. */
  47617. private static _groundTextureCDNUrl;
  47618. /**
  47619. * Default skybox texture URL.
  47620. */
  47621. private static _skyboxTextureCDNUrl;
  47622. /**
  47623. * Default environment texture URL.
  47624. */
  47625. private static _environmentTextureCDNUrl;
  47626. /**
  47627. * Creates the default options for the helper.
  47628. */
  47629. private static _getDefaultOptions;
  47630. private _rootMesh;
  47631. /**
  47632. * Gets the root mesh created by the helper.
  47633. */
  47634. readonly rootMesh: Mesh;
  47635. private _skybox;
  47636. /**
  47637. * Gets the skybox created by the helper.
  47638. */
  47639. readonly skybox: Nullable<Mesh>;
  47640. private _skyboxTexture;
  47641. /**
  47642. * Gets the skybox texture created by the helper.
  47643. */
  47644. readonly skyboxTexture: Nullable<BaseTexture>;
  47645. private _skyboxMaterial;
  47646. /**
  47647. * Gets the skybox material created by the helper.
  47648. */
  47649. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  47650. private _ground;
  47651. /**
  47652. * Gets the ground mesh created by the helper.
  47653. */
  47654. readonly ground: Nullable<Mesh>;
  47655. private _groundTexture;
  47656. /**
  47657. * Gets the ground texture created by the helper.
  47658. */
  47659. readonly groundTexture: Nullable<BaseTexture>;
  47660. private _groundMirror;
  47661. /**
  47662. * Gets the ground mirror created by the helper.
  47663. */
  47664. readonly groundMirror: Nullable<MirrorTexture>;
  47665. /**
  47666. * Gets the ground mirror render list to helps pushing the meshes
  47667. * you wish in the ground reflection.
  47668. */
  47669. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  47670. private _groundMaterial;
  47671. /**
  47672. * Gets the ground material created by the helper.
  47673. */
  47674. readonly groundMaterial: Nullable<BackgroundMaterial>;
  47675. /**
  47676. * Stores the creation options.
  47677. */
  47678. private readonly _scene;
  47679. private _options;
  47680. /**
  47681. * This observable will be notified with any error during the creation of the environment,
  47682. * mainly texture creation errors.
  47683. */
  47684. onErrorObservable: Observable<{
  47685. message?: string;
  47686. exception?: any;
  47687. }>;
  47688. /**
  47689. * constructor
  47690. * @param options Defines the options we want to customize the helper
  47691. * @param scene The scene to add the material to
  47692. */
  47693. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  47694. /**
  47695. * Updates the background according to the new options
  47696. * @param options
  47697. */
  47698. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  47699. /**
  47700. * Sets the primary color of all the available elements.
  47701. * @param color the main color to affect to the ground and the background
  47702. */
  47703. setMainColor(color: Color3): void;
  47704. /**
  47705. * Setup the image processing according to the specified options.
  47706. */
  47707. private _setupImageProcessing;
  47708. /**
  47709. * Setup the environment texture according to the specified options.
  47710. */
  47711. private _setupEnvironmentTexture;
  47712. /**
  47713. * Setup the background according to the specified options.
  47714. */
  47715. private _setupBackground;
  47716. /**
  47717. * Get the scene sizes according to the setup.
  47718. */
  47719. private _getSceneSize;
  47720. /**
  47721. * Setup the ground according to the specified options.
  47722. */
  47723. private _setupGround;
  47724. /**
  47725. * Setup the ground material according to the specified options.
  47726. */
  47727. private _setupGroundMaterial;
  47728. /**
  47729. * Setup the ground diffuse texture according to the specified options.
  47730. */
  47731. private _setupGroundDiffuseTexture;
  47732. /**
  47733. * Setup the ground mirror texture according to the specified options.
  47734. */
  47735. private _setupGroundMirrorTexture;
  47736. /**
  47737. * Setup the ground to receive the mirror texture.
  47738. */
  47739. private _setupMirrorInGroundMaterial;
  47740. /**
  47741. * Setup the skybox according to the specified options.
  47742. */
  47743. private _setupSkybox;
  47744. /**
  47745. * Setup the skybox material according to the specified options.
  47746. */
  47747. private _setupSkyboxMaterial;
  47748. /**
  47749. * Setup the skybox reflection texture according to the specified options.
  47750. */
  47751. private _setupSkyboxReflectionTexture;
  47752. private _errorHandler;
  47753. /**
  47754. * Dispose all the elements created by the Helper.
  47755. */
  47756. dispose(): void;
  47757. }
  47758. }
  47759. declare module "babylonjs/Helpers/photoDome" {
  47760. import { Observable } from "babylonjs/Misc/observable";
  47761. import { Nullable } from "babylonjs/types";
  47762. import { Scene } from "babylonjs/scene";
  47763. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47764. import { Mesh } from "babylonjs/Meshes/mesh";
  47765. import { Texture } from "babylonjs/Materials/Textures/texture";
  47766. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47767. import "babylonjs/Meshes/Builders/sphereBuilder";
  47768. /**
  47769. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  47770. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  47771. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  47772. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47773. */
  47774. export class PhotoDome extends TransformNode {
  47775. /**
  47776. * Define the image as a Monoscopic panoramic 360 image.
  47777. */
  47778. static readonly MODE_MONOSCOPIC: number;
  47779. /**
  47780. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47781. */
  47782. static readonly MODE_TOPBOTTOM: number;
  47783. /**
  47784. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47785. */
  47786. static readonly MODE_SIDEBYSIDE: number;
  47787. private _useDirectMapping;
  47788. /**
  47789. * The texture being displayed on the sphere
  47790. */
  47791. protected _photoTexture: Texture;
  47792. /**
  47793. * Gets or sets the texture being displayed on the sphere
  47794. */
  47795. photoTexture: Texture;
  47796. /**
  47797. * Observable raised when an error occured while loading the 360 image
  47798. */
  47799. onLoadErrorObservable: Observable<string>;
  47800. /**
  47801. * The skybox material
  47802. */
  47803. protected _material: BackgroundMaterial;
  47804. /**
  47805. * The surface used for the skybox
  47806. */
  47807. protected _mesh: Mesh;
  47808. /**
  47809. * Gets the mesh used for the skybox.
  47810. */
  47811. readonly mesh: Mesh;
  47812. /**
  47813. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47814. * Also see the options.resolution property.
  47815. */
  47816. fovMultiplier: number;
  47817. private _imageMode;
  47818. /**
  47819. * Gets or set the current video mode for the video. It can be:
  47820. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  47821. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47822. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47823. */
  47824. imageMode: number;
  47825. /**
  47826. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  47827. * @param name Element's name, child elements will append suffixes for their own names.
  47828. * @param urlsOfPhoto defines the url of the photo to display
  47829. * @param options defines an object containing optional or exposed sub element properties
  47830. * @param onError defines a callback called when an error occured while loading the texture
  47831. */
  47832. constructor(name: string, urlOfPhoto: string, options: {
  47833. resolution?: number;
  47834. size?: number;
  47835. useDirectMapping?: boolean;
  47836. faceForward?: boolean;
  47837. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  47838. private _onBeforeCameraRenderObserver;
  47839. private _changeImageMode;
  47840. /**
  47841. * Releases resources associated with this node.
  47842. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47843. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47844. */
  47845. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47846. }
  47847. }
  47848. declare module "babylonjs/Misc/rgbdTextureTools" {
  47849. import "babylonjs/Shaders/rgbdDecode.fragment";
  47850. import { Texture } from "babylonjs/Materials/Textures/texture";
  47851. /**
  47852. * Class used to host RGBD texture specific utilities
  47853. */
  47854. export class RGBDTextureTools {
  47855. /**
  47856. * Expand the RGBD Texture from RGBD to Half Float if possible.
  47857. * @param texture the texture to expand.
  47858. */
  47859. static ExpandRGBDTexture(texture: Texture): void;
  47860. }
  47861. }
  47862. declare module "babylonjs/Misc/brdfTextureTools" {
  47863. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47864. import { Scene } from "babylonjs/scene";
  47865. /**
  47866. * Class used to host texture specific utilities
  47867. */
  47868. export class BRDFTextureTools {
  47869. /**
  47870. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  47871. * @param scene defines the hosting scene
  47872. * @returns the environment BRDF texture
  47873. */
  47874. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  47875. private static _environmentBRDFBase64Texture;
  47876. }
  47877. }
  47878. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  47879. import { Nullable } from "babylonjs/types";
  47880. import { Color3 } from "babylonjs/Maths/math.color";
  47881. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47882. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47883. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47884. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47885. import { Engine } from "babylonjs/Engines/engine";
  47886. import { Scene } from "babylonjs/scene";
  47887. /**
  47888. * @hidden
  47889. */
  47890. export interface IMaterialClearCoatDefines {
  47891. CLEARCOAT: boolean;
  47892. CLEARCOAT_DEFAULTIOR: boolean;
  47893. CLEARCOAT_TEXTURE: boolean;
  47894. CLEARCOAT_TEXTUREDIRECTUV: number;
  47895. CLEARCOAT_BUMP: boolean;
  47896. CLEARCOAT_BUMPDIRECTUV: number;
  47897. CLEARCOAT_TINT: boolean;
  47898. CLEARCOAT_TINT_TEXTURE: boolean;
  47899. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47900. /** @hidden */
  47901. _areTexturesDirty: boolean;
  47902. }
  47903. /**
  47904. * Define the code related to the clear coat parameters of the pbr material.
  47905. */
  47906. export class PBRClearCoatConfiguration {
  47907. /**
  47908. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47909. * The default fits with a polyurethane material.
  47910. */
  47911. private static readonly _DefaultIndexOfRefraction;
  47912. private _isEnabled;
  47913. /**
  47914. * Defines if the clear coat is enabled in the material.
  47915. */
  47916. isEnabled: boolean;
  47917. /**
  47918. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  47919. */
  47920. intensity: number;
  47921. /**
  47922. * Defines the clear coat layer roughness.
  47923. */
  47924. roughness: number;
  47925. private _indexOfRefraction;
  47926. /**
  47927. * Defines the index of refraction of the clear coat.
  47928. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47929. * The default fits with a polyurethane material.
  47930. * Changing the default value is more performance intensive.
  47931. */
  47932. indexOfRefraction: number;
  47933. private _texture;
  47934. /**
  47935. * Stores the clear coat values in a texture.
  47936. */
  47937. texture: Nullable<BaseTexture>;
  47938. private _bumpTexture;
  47939. /**
  47940. * Define the clear coat specific bump texture.
  47941. */
  47942. bumpTexture: Nullable<BaseTexture>;
  47943. private _isTintEnabled;
  47944. /**
  47945. * Defines if the clear coat tint is enabled in the material.
  47946. */
  47947. isTintEnabled: boolean;
  47948. /**
  47949. * Defines the clear coat tint of the material.
  47950. * This is only use if tint is enabled
  47951. */
  47952. tintColor: Color3;
  47953. /**
  47954. * Defines the distance at which the tint color should be found in the
  47955. * clear coat media.
  47956. * This is only use if tint is enabled
  47957. */
  47958. tintColorAtDistance: number;
  47959. /**
  47960. * Defines the clear coat layer thickness.
  47961. * This is only use if tint is enabled
  47962. */
  47963. tintThickness: number;
  47964. private _tintTexture;
  47965. /**
  47966. * Stores the clear tint values in a texture.
  47967. * rgb is tint
  47968. * a is a thickness factor
  47969. */
  47970. tintTexture: Nullable<BaseTexture>;
  47971. /** @hidden */
  47972. private _internalMarkAllSubMeshesAsTexturesDirty;
  47973. /** @hidden */
  47974. _markAllSubMeshesAsTexturesDirty(): void;
  47975. /**
  47976. * Instantiate a new istance of clear coat configuration.
  47977. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47978. */
  47979. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47980. /**
  47981. * Gets wehter the submesh is ready to be used or not.
  47982. * @param defines the list of "defines" to update.
  47983. * @param scene defines the scene the material belongs to.
  47984. * @param engine defines the engine the material belongs to.
  47985. * @param disableBumpMap defines wether the material disables bump or not.
  47986. * @returns - boolean indicating that the submesh is ready or not.
  47987. */
  47988. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  47989. /**
  47990. * Checks to see if a texture is used in the material.
  47991. * @param defines the list of "defines" to update.
  47992. * @param scene defines the scene to the material belongs to.
  47993. */
  47994. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  47995. /**
  47996. * Binds the material data.
  47997. * @param uniformBuffer defines the Uniform buffer to fill in.
  47998. * @param scene defines the scene the material belongs to.
  47999. * @param engine defines the engine the material belongs to.
  48000. * @param disableBumpMap defines wether the material disables bump or not.
  48001. * @param isFrozen defines wether the material is frozen or not.
  48002. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48003. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48004. */
  48005. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  48006. /**
  48007. * Checks to see if a texture is used in the material.
  48008. * @param texture - Base texture to use.
  48009. * @returns - Boolean specifying if a texture is used in the material.
  48010. */
  48011. hasTexture(texture: BaseTexture): boolean;
  48012. /**
  48013. * Returns an array of the actively used textures.
  48014. * @param activeTextures Array of BaseTextures
  48015. */
  48016. getActiveTextures(activeTextures: BaseTexture[]): void;
  48017. /**
  48018. * Returns the animatable textures.
  48019. * @param animatables Array of animatable textures.
  48020. */
  48021. getAnimatables(animatables: IAnimatable[]): void;
  48022. /**
  48023. * Disposes the resources of the material.
  48024. * @param forceDisposeTextures - Forces the disposal of all textures.
  48025. */
  48026. dispose(forceDisposeTextures?: boolean): void;
  48027. /**
  48028. * Get the current class name of the texture useful for serialization or dynamic coding.
  48029. * @returns "PBRClearCoatConfiguration"
  48030. */
  48031. getClassName(): string;
  48032. /**
  48033. * Add fallbacks to the effect fallbacks list.
  48034. * @param defines defines the Base texture to use.
  48035. * @param fallbacks defines the current fallback list.
  48036. * @param currentRank defines the current fallback rank.
  48037. * @returns the new fallback rank.
  48038. */
  48039. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48040. /**
  48041. * Add the required uniforms to the current list.
  48042. * @param uniforms defines the current uniform list.
  48043. */
  48044. static AddUniforms(uniforms: string[]): void;
  48045. /**
  48046. * Add the required samplers to the current list.
  48047. * @param samplers defines the current sampler list.
  48048. */
  48049. static AddSamplers(samplers: string[]): void;
  48050. /**
  48051. * Add the required uniforms to the current buffer.
  48052. * @param uniformBuffer defines the current uniform buffer.
  48053. */
  48054. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48055. /**
  48056. * Makes a duplicate of the current configuration into another one.
  48057. * @param clearCoatConfiguration define the config where to copy the info
  48058. */
  48059. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  48060. /**
  48061. * Serializes this clear coat configuration.
  48062. * @returns - An object with the serialized config.
  48063. */
  48064. serialize(): any;
  48065. /**
  48066. * Parses a anisotropy Configuration from a serialized object.
  48067. * @param source - Serialized object.
  48068. * @param scene Defines the scene we are parsing for
  48069. * @param rootUrl Defines the rootUrl to load from
  48070. */
  48071. parse(source: any, scene: Scene, rootUrl: string): void;
  48072. }
  48073. }
  48074. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  48075. import { EffectFallbacks } from "babylonjs/Materials/effect";
  48076. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48077. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48078. import { Vector2 } from "babylonjs/Maths/math.vector";
  48079. import { Scene } from "babylonjs/scene";
  48080. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48081. import { Nullable } from "babylonjs/types";
  48082. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48083. /**
  48084. * @hidden
  48085. */
  48086. export interface IMaterialAnisotropicDefines {
  48087. ANISOTROPIC: boolean;
  48088. ANISOTROPIC_TEXTURE: boolean;
  48089. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48090. MAINUV1: boolean;
  48091. _areTexturesDirty: boolean;
  48092. _needUVs: boolean;
  48093. }
  48094. /**
  48095. * Define the code related to the anisotropic parameters of the pbr material.
  48096. */
  48097. export class PBRAnisotropicConfiguration {
  48098. private _isEnabled;
  48099. /**
  48100. * Defines if the anisotropy is enabled in the material.
  48101. */
  48102. isEnabled: boolean;
  48103. /**
  48104. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  48105. */
  48106. intensity: number;
  48107. /**
  48108. * Defines if the effect is along the tangents, bitangents or in between.
  48109. * By default, the effect is "strectching" the highlights along the tangents.
  48110. */
  48111. direction: Vector2;
  48112. private _texture;
  48113. /**
  48114. * Stores the anisotropy values in a texture.
  48115. * rg is direction (like normal from -1 to 1)
  48116. * b is a intensity
  48117. */
  48118. texture: Nullable<BaseTexture>;
  48119. /** @hidden */
  48120. private _internalMarkAllSubMeshesAsTexturesDirty;
  48121. /** @hidden */
  48122. _markAllSubMeshesAsTexturesDirty(): void;
  48123. /**
  48124. * Instantiate a new istance of anisotropy configuration.
  48125. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48126. */
  48127. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48128. /**
  48129. * Specifies that the submesh is ready to be used.
  48130. * @param defines the list of "defines" to update.
  48131. * @param scene defines the scene the material belongs to.
  48132. * @returns - boolean indicating that the submesh is ready or not.
  48133. */
  48134. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  48135. /**
  48136. * Checks to see if a texture is used in the material.
  48137. * @param defines the list of "defines" to update.
  48138. * @param mesh the mesh we are preparing the defines for.
  48139. * @param scene defines the scene the material belongs to.
  48140. */
  48141. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  48142. /**
  48143. * Binds the material data.
  48144. * @param uniformBuffer defines the Uniform buffer to fill in.
  48145. * @param scene defines the scene the material belongs to.
  48146. * @param isFrozen defines wether the material is frozen or not.
  48147. */
  48148. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48149. /**
  48150. * Checks to see if a texture is used in the material.
  48151. * @param texture - Base texture to use.
  48152. * @returns - Boolean specifying if a texture is used in the material.
  48153. */
  48154. hasTexture(texture: BaseTexture): boolean;
  48155. /**
  48156. * Returns an array of the actively used textures.
  48157. * @param activeTextures Array of BaseTextures
  48158. */
  48159. getActiveTextures(activeTextures: BaseTexture[]): void;
  48160. /**
  48161. * Returns the animatable textures.
  48162. * @param animatables Array of animatable textures.
  48163. */
  48164. getAnimatables(animatables: IAnimatable[]): void;
  48165. /**
  48166. * Disposes the resources of the material.
  48167. * @param forceDisposeTextures - Forces the disposal of all textures.
  48168. */
  48169. dispose(forceDisposeTextures?: boolean): void;
  48170. /**
  48171. * Get the current class name of the texture useful for serialization or dynamic coding.
  48172. * @returns "PBRAnisotropicConfiguration"
  48173. */
  48174. getClassName(): string;
  48175. /**
  48176. * Add fallbacks to the effect fallbacks list.
  48177. * @param defines defines the Base texture to use.
  48178. * @param fallbacks defines the current fallback list.
  48179. * @param currentRank defines the current fallback rank.
  48180. * @returns the new fallback rank.
  48181. */
  48182. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48183. /**
  48184. * Add the required uniforms to the current list.
  48185. * @param uniforms defines the current uniform list.
  48186. */
  48187. static AddUniforms(uniforms: string[]): void;
  48188. /**
  48189. * Add the required uniforms to the current buffer.
  48190. * @param uniformBuffer defines the current uniform buffer.
  48191. */
  48192. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48193. /**
  48194. * Add the required samplers to the current list.
  48195. * @param samplers defines the current sampler list.
  48196. */
  48197. static AddSamplers(samplers: string[]): void;
  48198. /**
  48199. * Makes a duplicate of the current configuration into another one.
  48200. * @param anisotropicConfiguration define the config where to copy the info
  48201. */
  48202. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  48203. /**
  48204. * Serializes this anisotropy configuration.
  48205. * @returns - An object with the serialized config.
  48206. */
  48207. serialize(): any;
  48208. /**
  48209. * Parses a anisotropy Configuration from a serialized object.
  48210. * @param source - Serialized object.
  48211. * @param scene Defines the scene we are parsing for
  48212. * @param rootUrl Defines the rootUrl to load from
  48213. */
  48214. parse(source: any, scene: Scene, rootUrl: string): void;
  48215. }
  48216. }
  48217. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  48218. import { Scene } from "babylonjs/scene";
  48219. /**
  48220. * @hidden
  48221. */
  48222. export interface IMaterialBRDFDefines {
  48223. BRDF_V_HEIGHT_CORRELATED: boolean;
  48224. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48225. SPHERICAL_HARMONICS: boolean;
  48226. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  48227. /** @hidden */
  48228. _areMiscDirty: boolean;
  48229. }
  48230. /**
  48231. * Define the code related to the BRDF parameters of the pbr material.
  48232. */
  48233. export class PBRBRDFConfiguration {
  48234. /**
  48235. * Default value used for the energy conservation.
  48236. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48237. */
  48238. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  48239. /**
  48240. * Default value used for the Smith Visibility Height Correlated mode.
  48241. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48242. */
  48243. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  48244. /**
  48245. * Default value used for the IBL diffuse part.
  48246. * This can help switching back to the polynomials mode globally which is a tiny bit
  48247. * less GPU intensive at the drawback of a lower quality.
  48248. */
  48249. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  48250. /**
  48251. * Default value used for activating energy conservation for the specular workflow.
  48252. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48253. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48254. */
  48255. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  48256. private _useEnergyConservation;
  48257. /**
  48258. * Defines if the material uses energy conservation.
  48259. */
  48260. useEnergyConservation: boolean;
  48261. private _useSmithVisibilityHeightCorrelated;
  48262. /**
  48263. * LEGACY Mode set to false
  48264. * Defines if the material uses height smith correlated visibility term.
  48265. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  48266. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  48267. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  48268. * Not relying on height correlated will also disable energy conservation.
  48269. */
  48270. useSmithVisibilityHeightCorrelated: boolean;
  48271. private _useSphericalHarmonics;
  48272. /**
  48273. * LEGACY Mode set to false
  48274. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  48275. * diffuse part of the IBL.
  48276. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  48277. * to the ground truth.
  48278. */
  48279. useSphericalHarmonics: boolean;
  48280. private _useSpecularGlossinessInputEnergyConservation;
  48281. /**
  48282. * Defines if the material uses energy conservation, when the specular workflow is active.
  48283. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48284. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48285. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  48286. */
  48287. useSpecularGlossinessInputEnergyConservation: boolean;
  48288. /** @hidden */
  48289. private _internalMarkAllSubMeshesAsMiscDirty;
  48290. /** @hidden */
  48291. _markAllSubMeshesAsMiscDirty(): void;
  48292. /**
  48293. * Instantiate a new istance of clear coat configuration.
  48294. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  48295. */
  48296. constructor(markAllSubMeshesAsMiscDirty: () => void);
  48297. /**
  48298. * Checks to see if a texture is used in the material.
  48299. * @param defines the list of "defines" to update.
  48300. */
  48301. prepareDefines(defines: IMaterialBRDFDefines): void;
  48302. /**
  48303. * Get the current class name of the texture useful for serialization or dynamic coding.
  48304. * @returns "PBRClearCoatConfiguration"
  48305. */
  48306. getClassName(): string;
  48307. /**
  48308. * Makes a duplicate of the current configuration into another one.
  48309. * @param brdfConfiguration define the config where to copy the info
  48310. */
  48311. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  48312. /**
  48313. * Serializes this BRDF configuration.
  48314. * @returns - An object with the serialized config.
  48315. */
  48316. serialize(): any;
  48317. /**
  48318. * Parses a anisotropy Configuration from a serialized object.
  48319. * @param source - Serialized object.
  48320. * @param scene Defines the scene we are parsing for
  48321. * @param rootUrl Defines the rootUrl to load from
  48322. */
  48323. parse(source: any, scene: Scene, rootUrl: string): void;
  48324. }
  48325. }
  48326. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  48327. import { EffectFallbacks } from "babylonjs/Materials/effect";
  48328. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48329. import { Color3 } from "babylonjs/Maths/math.color";
  48330. import { Scene } from "babylonjs/scene";
  48331. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48332. import { Nullable } from "babylonjs/types";
  48333. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48334. /**
  48335. * @hidden
  48336. */
  48337. export interface IMaterialSheenDefines {
  48338. SHEEN: boolean;
  48339. SHEEN_TEXTURE: boolean;
  48340. SHEEN_TEXTUREDIRECTUV: number;
  48341. SHEEN_LINKWITHALBEDO: boolean;
  48342. /** @hidden */
  48343. _areTexturesDirty: boolean;
  48344. }
  48345. /**
  48346. * Define the code related to the Sheen parameters of the pbr material.
  48347. */
  48348. export class PBRSheenConfiguration {
  48349. private _isEnabled;
  48350. /**
  48351. * Defines if the material uses sheen.
  48352. */
  48353. isEnabled: boolean;
  48354. private _linkSheenWithAlbedo;
  48355. /**
  48356. * Defines if the sheen is linked to the sheen color.
  48357. */
  48358. linkSheenWithAlbedo: boolean;
  48359. /**
  48360. * Defines the sheen intensity.
  48361. */
  48362. intensity: number;
  48363. /**
  48364. * Defines the sheen color.
  48365. */
  48366. color: Color3;
  48367. private _texture;
  48368. /**
  48369. * Stores the sheen tint values in a texture.
  48370. * rgb is tint
  48371. * a is a intensity
  48372. */
  48373. texture: Nullable<BaseTexture>;
  48374. /** @hidden */
  48375. private _internalMarkAllSubMeshesAsTexturesDirty;
  48376. /** @hidden */
  48377. _markAllSubMeshesAsTexturesDirty(): void;
  48378. /**
  48379. * Instantiate a new istance of clear coat configuration.
  48380. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48381. */
  48382. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48383. /**
  48384. * Specifies that the submesh is ready to be used.
  48385. * @param defines the list of "defines" to update.
  48386. * @param scene defines the scene the material belongs to.
  48387. * @returns - boolean indicating that the submesh is ready or not.
  48388. */
  48389. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  48390. /**
  48391. * Checks to see if a texture is used in the material.
  48392. * @param defines the list of "defines" to update.
  48393. * @param scene defines the scene the material belongs to.
  48394. */
  48395. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  48396. /**
  48397. * Binds the material data.
  48398. * @param uniformBuffer defines the Uniform buffer to fill in.
  48399. * @param scene defines the scene the material belongs to.
  48400. * @param isFrozen defines wether the material is frozen or not.
  48401. */
  48402. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48403. /**
  48404. * Checks to see if a texture is used in the material.
  48405. * @param texture - Base texture to use.
  48406. * @returns - Boolean specifying if a texture is used in the material.
  48407. */
  48408. hasTexture(texture: BaseTexture): boolean;
  48409. /**
  48410. * Returns an array of the actively used textures.
  48411. * @param activeTextures Array of BaseTextures
  48412. */
  48413. getActiveTextures(activeTextures: BaseTexture[]): void;
  48414. /**
  48415. * Returns the animatable textures.
  48416. * @param animatables Array of animatable textures.
  48417. */
  48418. getAnimatables(animatables: IAnimatable[]): void;
  48419. /**
  48420. * Disposes the resources of the material.
  48421. * @param forceDisposeTextures - Forces the disposal of all textures.
  48422. */
  48423. dispose(forceDisposeTextures?: boolean): void;
  48424. /**
  48425. * Get the current class name of the texture useful for serialization or dynamic coding.
  48426. * @returns "PBRSheenConfiguration"
  48427. */
  48428. getClassName(): string;
  48429. /**
  48430. * Add fallbacks to the effect fallbacks list.
  48431. * @param defines defines the Base texture to use.
  48432. * @param fallbacks defines the current fallback list.
  48433. * @param currentRank defines the current fallback rank.
  48434. * @returns the new fallback rank.
  48435. */
  48436. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48437. /**
  48438. * Add the required uniforms to the current list.
  48439. * @param uniforms defines the current uniform list.
  48440. */
  48441. static AddUniforms(uniforms: string[]): void;
  48442. /**
  48443. * Add the required uniforms to the current buffer.
  48444. * @param uniformBuffer defines the current uniform buffer.
  48445. */
  48446. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48447. /**
  48448. * Add the required samplers to the current list.
  48449. * @param samplers defines the current sampler list.
  48450. */
  48451. static AddSamplers(samplers: string[]): void;
  48452. /**
  48453. * Makes a duplicate of the current configuration into another one.
  48454. * @param sheenConfiguration define the config where to copy the info
  48455. */
  48456. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  48457. /**
  48458. * Serializes this BRDF configuration.
  48459. * @returns - An object with the serialized config.
  48460. */
  48461. serialize(): any;
  48462. /**
  48463. * Parses a anisotropy Configuration from a serialized object.
  48464. * @param source - Serialized object.
  48465. * @param scene Defines the scene we are parsing for
  48466. * @param rootUrl Defines the rootUrl to load from
  48467. */
  48468. parse(source: any, scene: Scene, rootUrl: string): void;
  48469. }
  48470. }
  48471. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  48472. import { Nullable } from "babylonjs/types";
  48473. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48474. import { Color3 } from "babylonjs/Maths/math.color";
  48475. import { SmartArray } from "babylonjs/Misc/smartArray";
  48476. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48477. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48478. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  48479. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48480. import { Engine } from "babylonjs/Engines/engine";
  48481. import { Scene } from "babylonjs/scene";
  48482. /**
  48483. * @hidden
  48484. */
  48485. export interface IMaterialSubSurfaceDefines {
  48486. SUBSURFACE: boolean;
  48487. SS_REFRACTION: boolean;
  48488. SS_TRANSLUCENCY: boolean;
  48489. SS_SCATERRING: boolean;
  48490. SS_THICKNESSANDMASK_TEXTURE: boolean;
  48491. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  48492. SS_REFRACTIONMAP_3D: boolean;
  48493. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  48494. SS_LODINREFRACTIONALPHA: boolean;
  48495. SS_GAMMAREFRACTION: boolean;
  48496. SS_RGBDREFRACTION: boolean;
  48497. SS_LINEARSPECULARREFRACTION: boolean;
  48498. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  48499. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  48500. /** @hidden */
  48501. _areTexturesDirty: boolean;
  48502. }
  48503. /**
  48504. * Define the code related to the sub surface parameters of the pbr material.
  48505. */
  48506. export class PBRSubSurfaceConfiguration {
  48507. private _isRefractionEnabled;
  48508. /**
  48509. * Defines if the refraction is enabled in the material.
  48510. */
  48511. isRefractionEnabled: boolean;
  48512. private _isTranslucencyEnabled;
  48513. /**
  48514. * Defines if the translucency is enabled in the material.
  48515. */
  48516. isTranslucencyEnabled: boolean;
  48517. private _isScatteringEnabled;
  48518. /**
  48519. * Defines the refraction intensity of the material.
  48520. * The refraction when enabled replaces the Diffuse part of the material.
  48521. * The intensity helps transitionning between diffuse and refraction.
  48522. */
  48523. refractionIntensity: number;
  48524. /**
  48525. * Defines the translucency intensity of the material.
  48526. * When translucency has been enabled, this defines how much of the "translucency"
  48527. * is addded to the diffuse part of the material.
  48528. */
  48529. translucencyIntensity: number;
  48530. /**
  48531. * Defines the scattering intensity of the material.
  48532. * When scattering has been enabled, this defines how much of the "scattered light"
  48533. * is addded to the diffuse part of the material.
  48534. */
  48535. scatteringIntensity: number;
  48536. private _thicknessTexture;
  48537. /**
  48538. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  48539. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  48540. * 0 would mean minimumThickness
  48541. * 1 would mean maximumThickness
  48542. * The other channels might be use as a mask to vary the different effects intensity.
  48543. */
  48544. thicknessTexture: Nullable<BaseTexture>;
  48545. private _refractionTexture;
  48546. /**
  48547. * Defines the texture to use for refraction.
  48548. */
  48549. refractionTexture: Nullable<BaseTexture>;
  48550. private _indexOfRefraction;
  48551. /**
  48552. * Defines the index of refraction used in the material.
  48553. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  48554. */
  48555. indexOfRefraction: number;
  48556. private _invertRefractionY;
  48557. /**
  48558. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48559. */
  48560. invertRefractionY: boolean;
  48561. private _linkRefractionWithTransparency;
  48562. /**
  48563. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48564. * Materials half opaque for instance using refraction could benefit from this control.
  48565. */
  48566. linkRefractionWithTransparency: boolean;
  48567. /**
  48568. * Defines the minimum thickness stored in the thickness map.
  48569. * If no thickness map is defined, this value will be used to simulate thickness.
  48570. */
  48571. minimumThickness: number;
  48572. /**
  48573. * Defines the maximum thickness stored in the thickness map.
  48574. */
  48575. maximumThickness: number;
  48576. /**
  48577. * Defines the volume tint of the material.
  48578. * This is used for both translucency and scattering.
  48579. */
  48580. tintColor: Color3;
  48581. /**
  48582. * Defines the distance at which the tint color should be found in the media.
  48583. * This is used for refraction only.
  48584. */
  48585. tintColorAtDistance: number;
  48586. /**
  48587. * Defines how far each channel transmit through the media.
  48588. * It is defined as a color to simplify it selection.
  48589. */
  48590. diffusionDistance: Color3;
  48591. private _useMaskFromThicknessTexture;
  48592. /**
  48593. * Stores the intensity of the different subsurface effects in the thickness texture.
  48594. * * the green channel is the translucency intensity.
  48595. * * the blue channel is the scattering intensity.
  48596. * * the alpha channel is the refraction intensity.
  48597. */
  48598. useMaskFromThicknessTexture: boolean;
  48599. /** @hidden */
  48600. private _internalMarkAllSubMeshesAsTexturesDirty;
  48601. /** @hidden */
  48602. _markAllSubMeshesAsTexturesDirty(): void;
  48603. /**
  48604. * Instantiate a new istance of sub surface configuration.
  48605. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48606. */
  48607. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48608. /**
  48609. * Gets wehter the submesh is ready to be used or not.
  48610. * @param defines the list of "defines" to update.
  48611. * @param scene defines the scene the material belongs to.
  48612. * @returns - boolean indicating that the submesh is ready or not.
  48613. */
  48614. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  48615. /**
  48616. * Checks to see if a texture is used in the material.
  48617. * @param defines the list of "defines" to update.
  48618. * @param scene defines the scene to the material belongs to.
  48619. */
  48620. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  48621. /**
  48622. * Binds the material data.
  48623. * @param uniformBuffer defines the Uniform buffer to fill in.
  48624. * @param scene defines the scene the material belongs to.
  48625. * @param engine defines the engine the material belongs to.
  48626. * @param isFrozen defines wether the material is frozen or not.
  48627. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  48628. */
  48629. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  48630. /**
  48631. * Unbinds the material from the mesh.
  48632. * @param activeEffect defines the effect that should be unbound from.
  48633. * @returns true if unbound, otherwise false
  48634. */
  48635. unbind(activeEffect: Effect): boolean;
  48636. /**
  48637. * Returns the texture used for refraction or null if none is used.
  48638. * @param scene defines the scene the material belongs to.
  48639. * @returns - Refraction texture if present. If no refraction texture and refraction
  48640. * is linked with transparency, returns environment texture. Otherwise, returns null.
  48641. */
  48642. private _getRefractionTexture;
  48643. /**
  48644. * Returns true if alpha blending should be disabled.
  48645. */
  48646. readonly disableAlphaBlending: boolean;
  48647. /**
  48648. * Fills the list of render target textures.
  48649. * @param renderTargets the list of render targets to update
  48650. */
  48651. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  48652. /**
  48653. * Checks to see if a texture is used in the material.
  48654. * @param texture - Base texture to use.
  48655. * @returns - Boolean specifying if a texture is used in the material.
  48656. */
  48657. hasTexture(texture: BaseTexture): boolean;
  48658. /**
  48659. * Gets a boolean indicating that current material needs to register RTT
  48660. * @returns true if this uses a render target otherwise false.
  48661. */
  48662. hasRenderTargetTextures(): boolean;
  48663. /**
  48664. * Returns an array of the actively used textures.
  48665. * @param activeTextures Array of BaseTextures
  48666. */
  48667. getActiveTextures(activeTextures: BaseTexture[]): void;
  48668. /**
  48669. * Returns the animatable textures.
  48670. * @param animatables Array of animatable textures.
  48671. */
  48672. getAnimatables(animatables: IAnimatable[]): void;
  48673. /**
  48674. * Disposes the resources of the material.
  48675. * @param forceDisposeTextures - Forces the disposal of all textures.
  48676. */
  48677. dispose(forceDisposeTextures?: boolean): void;
  48678. /**
  48679. * Get the current class name of the texture useful for serialization or dynamic coding.
  48680. * @returns "PBRSubSurfaceConfiguration"
  48681. */
  48682. getClassName(): string;
  48683. /**
  48684. * Add fallbacks to the effect fallbacks list.
  48685. * @param defines defines the Base texture to use.
  48686. * @param fallbacks defines the current fallback list.
  48687. * @param currentRank defines the current fallback rank.
  48688. * @returns the new fallback rank.
  48689. */
  48690. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48691. /**
  48692. * Add the required uniforms to the current list.
  48693. * @param uniforms defines the current uniform list.
  48694. */
  48695. static AddUniforms(uniforms: string[]): void;
  48696. /**
  48697. * Add the required samplers to the current list.
  48698. * @param samplers defines the current sampler list.
  48699. */
  48700. static AddSamplers(samplers: string[]): void;
  48701. /**
  48702. * Add the required uniforms to the current buffer.
  48703. * @param uniformBuffer defines the current uniform buffer.
  48704. */
  48705. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48706. /**
  48707. * Makes a duplicate of the current configuration into another one.
  48708. * @param configuration define the config where to copy the info
  48709. */
  48710. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  48711. /**
  48712. * Serializes this Sub Surface configuration.
  48713. * @returns - An object with the serialized config.
  48714. */
  48715. serialize(): any;
  48716. /**
  48717. * Parses a anisotropy Configuration from a serialized object.
  48718. * @param source - Serialized object.
  48719. * @param scene Defines the scene we are parsing for
  48720. * @param rootUrl Defines the rootUrl to load from
  48721. */
  48722. parse(source: any, scene: Scene, rootUrl: string): void;
  48723. }
  48724. }
  48725. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  48726. /** @hidden */
  48727. export var pbrFragmentDeclaration: {
  48728. name: string;
  48729. shader: string;
  48730. };
  48731. }
  48732. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  48733. /** @hidden */
  48734. export var pbrUboDeclaration: {
  48735. name: string;
  48736. shader: string;
  48737. };
  48738. }
  48739. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  48740. /** @hidden */
  48741. export var pbrFragmentExtraDeclaration: {
  48742. name: string;
  48743. shader: string;
  48744. };
  48745. }
  48746. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  48747. /** @hidden */
  48748. export var pbrFragmentSamplersDeclaration: {
  48749. name: string;
  48750. shader: string;
  48751. };
  48752. }
  48753. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  48754. /** @hidden */
  48755. export var pbrHelperFunctions: {
  48756. name: string;
  48757. shader: string;
  48758. };
  48759. }
  48760. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  48761. /** @hidden */
  48762. export var harmonicsFunctions: {
  48763. name: string;
  48764. shader: string;
  48765. };
  48766. }
  48767. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  48768. /** @hidden */
  48769. export var pbrDirectLightingSetupFunctions: {
  48770. name: string;
  48771. shader: string;
  48772. };
  48773. }
  48774. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  48775. /** @hidden */
  48776. export var pbrDirectLightingFalloffFunctions: {
  48777. name: string;
  48778. shader: string;
  48779. };
  48780. }
  48781. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  48782. /** @hidden */
  48783. export var pbrBRDFFunctions: {
  48784. name: string;
  48785. shader: string;
  48786. };
  48787. }
  48788. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  48789. /** @hidden */
  48790. export var pbrDirectLightingFunctions: {
  48791. name: string;
  48792. shader: string;
  48793. };
  48794. }
  48795. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  48796. /** @hidden */
  48797. export var pbrIBLFunctions: {
  48798. name: string;
  48799. shader: string;
  48800. };
  48801. }
  48802. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  48803. /** @hidden */
  48804. export var pbrDebug: {
  48805. name: string;
  48806. shader: string;
  48807. };
  48808. }
  48809. declare module "babylonjs/Shaders/pbr.fragment" {
  48810. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  48811. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  48812. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  48813. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48814. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48815. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  48816. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  48817. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  48818. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  48819. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  48820. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48821. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  48822. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  48823. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  48824. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  48825. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  48826. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  48827. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  48828. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  48829. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  48830. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  48831. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  48832. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  48833. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  48834. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  48835. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  48836. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  48837. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  48838. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  48839. /** @hidden */
  48840. export var pbrPixelShader: {
  48841. name: string;
  48842. shader: string;
  48843. };
  48844. }
  48845. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  48846. /** @hidden */
  48847. export var pbrVertexDeclaration: {
  48848. name: string;
  48849. shader: string;
  48850. };
  48851. }
  48852. declare module "babylonjs/Shaders/pbr.vertex" {
  48853. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  48854. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  48855. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48856. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48857. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48858. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  48859. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  48860. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  48861. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  48862. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48863. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48864. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  48865. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  48866. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  48867. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  48868. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48869. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48870. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  48871. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  48872. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  48873. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  48874. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  48875. /** @hidden */
  48876. export var pbrVertexShader: {
  48877. name: string;
  48878. shader: string;
  48879. };
  48880. }
  48881. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  48882. import { Nullable } from "babylonjs/types";
  48883. import { Scene } from "babylonjs/scene";
  48884. import { Matrix } from "babylonjs/Maths/math.vector";
  48885. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48886. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48887. import { Mesh } from "babylonjs/Meshes/mesh";
  48888. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  48889. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  48890. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  48891. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  48892. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  48893. import { Color3 } from "babylonjs/Maths/math.color";
  48894. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  48895. import { Material } from "babylonjs/Materials/material";
  48896. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  48897. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  48898. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48899. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48900. import "babylonjs/Shaders/pbr.fragment";
  48901. import "babylonjs/Shaders/pbr.vertex";
  48902. /**
  48903. * Manages the defines for the PBR Material.
  48904. * @hidden
  48905. */
  48906. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  48907. PBR: boolean;
  48908. MAINUV1: boolean;
  48909. MAINUV2: boolean;
  48910. UV1: boolean;
  48911. UV2: boolean;
  48912. ALBEDO: boolean;
  48913. ALBEDODIRECTUV: number;
  48914. VERTEXCOLOR: boolean;
  48915. AMBIENT: boolean;
  48916. AMBIENTDIRECTUV: number;
  48917. AMBIENTINGRAYSCALE: boolean;
  48918. OPACITY: boolean;
  48919. VERTEXALPHA: boolean;
  48920. OPACITYDIRECTUV: number;
  48921. OPACITYRGB: boolean;
  48922. ALPHATEST: boolean;
  48923. DEPTHPREPASS: boolean;
  48924. ALPHABLEND: boolean;
  48925. ALPHAFROMALBEDO: boolean;
  48926. ALPHATESTVALUE: string;
  48927. SPECULAROVERALPHA: boolean;
  48928. RADIANCEOVERALPHA: boolean;
  48929. ALPHAFRESNEL: boolean;
  48930. LINEARALPHAFRESNEL: boolean;
  48931. PREMULTIPLYALPHA: boolean;
  48932. EMISSIVE: boolean;
  48933. EMISSIVEDIRECTUV: number;
  48934. REFLECTIVITY: boolean;
  48935. REFLECTIVITYDIRECTUV: number;
  48936. SPECULARTERM: boolean;
  48937. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  48938. MICROSURFACEAUTOMATIC: boolean;
  48939. LODBASEDMICROSFURACE: boolean;
  48940. MICROSURFACEMAP: boolean;
  48941. MICROSURFACEMAPDIRECTUV: number;
  48942. METALLICWORKFLOW: boolean;
  48943. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  48944. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  48945. METALLNESSSTOREINMETALMAPBLUE: boolean;
  48946. AOSTOREINMETALMAPRED: boolean;
  48947. ENVIRONMENTBRDF: boolean;
  48948. ENVIRONMENTBRDF_RGBD: boolean;
  48949. NORMAL: boolean;
  48950. TANGENT: boolean;
  48951. BUMP: boolean;
  48952. BUMPDIRECTUV: number;
  48953. OBJECTSPACE_NORMALMAP: boolean;
  48954. PARALLAX: boolean;
  48955. PARALLAXOCCLUSION: boolean;
  48956. NORMALXYSCALE: boolean;
  48957. LIGHTMAP: boolean;
  48958. LIGHTMAPDIRECTUV: number;
  48959. USELIGHTMAPASSHADOWMAP: boolean;
  48960. GAMMALIGHTMAP: boolean;
  48961. RGBDLIGHTMAP: boolean;
  48962. REFLECTION: boolean;
  48963. REFLECTIONMAP_3D: boolean;
  48964. REFLECTIONMAP_SPHERICAL: boolean;
  48965. REFLECTIONMAP_PLANAR: boolean;
  48966. REFLECTIONMAP_CUBIC: boolean;
  48967. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  48968. REFLECTIONMAP_PROJECTION: boolean;
  48969. REFLECTIONMAP_SKYBOX: boolean;
  48970. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  48971. REFLECTIONMAP_EXPLICIT: boolean;
  48972. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  48973. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  48974. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  48975. INVERTCUBICMAP: boolean;
  48976. USESPHERICALFROMREFLECTIONMAP: boolean;
  48977. USEIRRADIANCEMAP: boolean;
  48978. SPHERICAL_HARMONICS: boolean;
  48979. USESPHERICALINVERTEX: boolean;
  48980. REFLECTIONMAP_OPPOSITEZ: boolean;
  48981. LODINREFLECTIONALPHA: boolean;
  48982. GAMMAREFLECTION: boolean;
  48983. RGBDREFLECTION: boolean;
  48984. LINEARSPECULARREFLECTION: boolean;
  48985. RADIANCEOCCLUSION: boolean;
  48986. HORIZONOCCLUSION: boolean;
  48987. INSTANCES: boolean;
  48988. NUM_BONE_INFLUENCERS: number;
  48989. BonesPerMesh: number;
  48990. BONETEXTURE: boolean;
  48991. NONUNIFORMSCALING: boolean;
  48992. MORPHTARGETS: boolean;
  48993. MORPHTARGETS_NORMAL: boolean;
  48994. MORPHTARGETS_TANGENT: boolean;
  48995. MORPHTARGETS_UV: boolean;
  48996. NUM_MORPH_INFLUENCERS: number;
  48997. IMAGEPROCESSING: boolean;
  48998. VIGNETTE: boolean;
  48999. VIGNETTEBLENDMODEMULTIPLY: boolean;
  49000. VIGNETTEBLENDMODEOPAQUE: boolean;
  49001. TONEMAPPING: boolean;
  49002. TONEMAPPING_ACES: boolean;
  49003. CONTRAST: boolean;
  49004. COLORCURVES: boolean;
  49005. COLORGRADING: boolean;
  49006. COLORGRADING3D: boolean;
  49007. SAMPLER3DGREENDEPTH: boolean;
  49008. SAMPLER3DBGRMAP: boolean;
  49009. IMAGEPROCESSINGPOSTPROCESS: boolean;
  49010. EXPOSURE: boolean;
  49011. MULTIVIEW: boolean;
  49012. USEPHYSICALLIGHTFALLOFF: boolean;
  49013. USEGLTFLIGHTFALLOFF: boolean;
  49014. TWOSIDEDLIGHTING: boolean;
  49015. SHADOWFLOAT: boolean;
  49016. CLIPPLANE: boolean;
  49017. CLIPPLANE2: boolean;
  49018. CLIPPLANE3: boolean;
  49019. CLIPPLANE4: boolean;
  49020. POINTSIZE: boolean;
  49021. FOG: boolean;
  49022. LOGARITHMICDEPTH: boolean;
  49023. FORCENORMALFORWARD: boolean;
  49024. SPECULARAA: boolean;
  49025. CLEARCOAT: boolean;
  49026. CLEARCOAT_DEFAULTIOR: boolean;
  49027. CLEARCOAT_TEXTURE: boolean;
  49028. CLEARCOAT_TEXTUREDIRECTUV: number;
  49029. CLEARCOAT_BUMP: boolean;
  49030. CLEARCOAT_BUMPDIRECTUV: number;
  49031. CLEARCOAT_TINT: boolean;
  49032. CLEARCOAT_TINT_TEXTURE: boolean;
  49033. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49034. ANISOTROPIC: boolean;
  49035. ANISOTROPIC_TEXTURE: boolean;
  49036. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49037. BRDF_V_HEIGHT_CORRELATED: boolean;
  49038. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49039. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49040. SHEEN: boolean;
  49041. SHEEN_TEXTURE: boolean;
  49042. SHEEN_TEXTUREDIRECTUV: number;
  49043. SHEEN_LINKWITHALBEDO: boolean;
  49044. SUBSURFACE: boolean;
  49045. SS_REFRACTION: boolean;
  49046. SS_TRANSLUCENCY: boolean;
  49047. SS_SCATERRING: boolean;
  49048. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49049. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49050. SS_REFRACTIONMAP_3D: boolean;
  49051. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49052. SS_LODINREFRACTIONALPHA: boolean;
  49053. SS_GAMMAREFRACTION: boolean;
  49054. SS_RGBDREFRACTION: boolean;
  49055. SS_LINEARSPECULARREFRACTION: boolean;
  49056. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49057. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49058. UNLIT: boolean;
  49059. DEBUGMODE: number;
  49060. /**
  49061. * Initializes the PBR Material defines.
  49062. */
  49063. constructor();
  49064. /**
  49065. * Resets the PBR Material defines.
  49066. */
  49067. reset(): void;
  49068. }
  49069. /**
  49070. * The Physically based material base class of BJS.
  49071. *
  49072. * This offers the main features of a standard PBR material.
  49073. * For more information, please refer to the documentation :
  49074. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49075. */
  49076. export abstract class PBRBaseMaterial extends PushMaterial {
  49077. /**
  49078. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49079. */
  49080. static readonly PBRMATERIAL_OPAQUE: number;
  49081. /**
  49082. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49083. */
  49084. static readonly PBRMATERIAL_ALPHATEST: number;
  49085. /**
  49086. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49087. */
  49088. static readonly PBRMATERIAL_ALPHABLEND: number;
  49089. /**
  49090. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49091. * They are also discarded below the alpha cutoff threshold to improve performances.
  49092. */
  49093. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49094. /**
  49095. * Defines the default value of how much AO map is occluding the analytical lights
  49096. * (point spot...).
  49097. */
  49098. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49099. /**
  49100. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  49101. */
  49102. static readonly LIGHTFALLOFF_PHYSICAL: number;
  49103. /**
  49104. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  49105. * to enhance interoperability with other engines.
  49106. */
  49107. static readonly LIGHTFALLOFF_GLTF: number;
  49108. /**
  49109. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  49110. * to enhance interoperability with other materials.
  49111. */
  49112. static readonly LIGHTFALLOFF_STANDARD: number;
  49113. /**
  49114. * Intensity of the direct lights e.g. the four lights available in your scene.
  49115. * This impacts both the direct diffuse and specular highlights.
  49116. */
  49117. protected _directIntensity: number;
  49118. /**
  49119. * Intensity of the emissive part of the material.
  49120. * This helps controlling the emissive effect without modifying the emissive color.
  49121. */
  49122. protected _emissiveIntensity: number;
  49123. /**
  49124. * Intensity of the environment e.g. how much the environment will light the object
  49125. * either through harmonics for rough material or through the refelction for shiny ones.
  49126. */
  49127. protected _environmentIntensity: number;
  49128. /**
  49129. * This is a special control allowing the reduction of the specular highlights coming from the
  49130. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49131. */
  49132. protected _specularIntensity: number;
  49133. /**
  49134. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  49135. */
  49136. private _lightingInfos;
  49137. /**
  49138. * Debug Control allowing disabling the bump map on this material.
  49139. */
  49140. protected _disableBumpMap: boolean;
  49141. /**
  49142. * AKA Diffuse Texture in standard nomenclature.
  49143. */
  49144. protected _albedoTexture: Nullable<BaseTexture>;
  49145. /**
  49146. * AKA Occlusion Texture in other nomenclature.
  49147. */
  49148. protected _ambientTexture: Nullable<BaseTexture>;
  49149. /**
  49150. * AKA Occlusion Texture Intensity in other nomenclature.
  49151. */
  49152. protected _ambientTextureStrength: number;
  49153. /**
  49154. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49155. * 1 means it completely occludes it
  49156. * 0 mean it has no impact
  49157. */
  49158. protected _ambientTextureImpactOnAnalyticalLights: number;
  49159. /**
  49160. * Stores the alpha values in a texture.
  49161. */
  49162. protected _opacityTexture: Nullable<BaseTexture>;
  49163. /**
  49164. * Stores the reflection values in a texture.
  49165. */
  49166. protected _reflectionTexture: Nullable<BaseTexture>;
  49167. /**
  49168. * Stores the emissive values in a texture.
  49169. */
  49170. protected _emissiveTexture: Nullable<BaseTexture>;
  49171. /**
  49172. * AKA Specular texture in other nomenclature.
  49173. */
  49174. protected _reflectivityTexture: Nullable<BaseTexture>;
  49175. /**
  49176. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49177. */
  49178. protected _metallicTexture: Nullable<BaseTexture>;
  49179. /**
  49180. * Specifies the metallic scalar of the metallic/roughness workflow.
  49181. * Can also be used to scale the metalness values of the metallic texture.
  49182. */
  49183. protected _metallic: Nullable<number>;
  49184. /**
  49185. * Specifies the roughness scalar of the metallic/roughness workflow.
  49186. * Can also be used to scale the roughness values of the metallic texture.
  49187. */
  49188. protected _roughness: Nullable<number>;
  49189. /**
  49190. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49191. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49192. */
  49193. protected _microSurfaceTexture: Nullable<BaseTexture>;
  49194. /**
  49195. * Stores surface normal data used to displace a mesh in a texture.
  49196. */
  49197. protected _bumpTexture: Nullable<BaseTexture>;
  49198. /**
  49199. * Stores the pre-calculated light information of a mesh in a texture.
  49200. */
  49201. protected _lightmapTexture: Nullable<BaseTexture>;
  49202. /**
  49203. * The color of a material in ambient lighting.
  49204. */
  49205. protected _ambientColor: Color3;
  49206. /**
  49207. * AKA Diffuse Color in other nomenclature.
  49208. */
  49209. protected _albedoColor: Color3;
  49210. /**
  49211. * AKA Specular Color in other nomenclature.
  49212. */
  49213. protected _reflectivityColor: Color3;
  49214. /**
  49215. * The color applied when light is reflected from a material.
  49216. */
  49217. protected _reflectionColor: Color3;
  49218. /**
  49219. * The color applied when light is emitted from a material.
  49220. */
  49221. protected _emissiveColor: Color3;
  49222. /**
  49223. * AKA Glossiness in other nomenclature.
  49224. */
  49225. protected _microSurface: number;
  49226. /**
  49227. * Specifies that the material will use the light map as a show map.
  49228. */
  49229. protected _useLightmapAsShadowmap: boolean;
  49230. /**
  49231. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49232. * makes the reflect vector face the model (under horizon).
  49233. */
  49234. protected _useHorizonOcclusion: boolean;
  49235. /**
  49236. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49237. * too much the area relying on ambient texture to define their ambient occlusion.
  49238. */
  49239. protected _useRadianceOcclusion: boolean;
  49240. /**
  49241. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49242. */
  49243. protected _useAlphaFromAlbedoTexture: boolean;
  49244. /**
  49245. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  49246. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49247. */
  49248. protected _useSpecularOverAlpha: boolean;
  49249. /**
  49250. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49251. */
  49252. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49253. /**
  49254. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49255. */
  49256. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  49257. /**
  49258. * Specifies if the metallic texture contains the roughness information in its green channel.
  49259. */
  49260. protected _useRoughnessFromMetallicTextureGreen: boolean;
  49261. /**
  49262. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49263. */
  49264. protected _useMetallnessFromMetallicTextureBlue: boolean;
  49265. /**
  49266. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49267. */
  49268. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  49269. /**
  49270. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49271. */
  49272. protected _useAmbientInGrayScale: boolean;
  49273. /**
  49274. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49275. * The material will try to infer what glossiness each pixel should be.
  49276. */
  49277. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  49278. /**
  49279. * Defines the falloff type used in this material.
  49280. * It by default is Physical.
  49281. */
  49282. protected _lightFalloff: number;
  49283. /**
  49284. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49285. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49286. */
  49287. protected _useRadianceOverAlpha: boolean;
  49288. /**
  49289. * Allows using an object space normal map (instead of tangent space).
  49290. */
  49291. protected _useObjectSpaceNormalMap: boolean;
  49292. /**
  49293. * Allows using the bump map in parallax mode.
  49294. */
  49295. protected _useParallax: boolean;
  49296. /**
  49297. * Allows using the bump map in parallax occlusion mode.
  49298. */
  49299. protected _useParallaxOcclusion: boolean;
  49300. /**
  49301. * Controls the scale bias of the parallax mode.
  49302. */
  49303. protected _parallaxScaleBias: number;
  49304. /**
  49305. * If sets to true, disables all the lights affecting the material.
  49306. */
  49307. protected _disableLighting: boolean;
  49308. /**
  49309. * Number of Simultaneous lights allowed on the material.
  49310. */
  49311. protected _maxSimultaneousLights: number;
  49312. /**
  49313. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49314. */
  49315. protected _invertNormalMapX: boolean;
  49316. /**
  49317. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49318. */
  49319. protected _invertNormalMapY: boolean;
  49320. /**
  49321. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49322. */
  49323. protected _twoSidedLighting: boolean;
  49324. /**
  49325. * Defines the alpha limits in alpha test mode.
  49326. */
  49327. protected _alphaCutOff: number;
  49328. /**
  49329. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49330. */
  49331. protected _forceAlphaTest: boolean;
  49332. /**
  49333. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49334. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49335. */
  49336. protected _useAlphaFresnel: boolean;
  49337. /**
  49338. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49339. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49340. */
  49341. protected _useLinearAlphaFresnel: boolean;
  49342. /**
  49343. * The transparency mode of the material.
  49344. */
  49345. protected _transparencyMode: Nullable<number>;
  49346. /**
  49347. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  49348. * from cos thetav and roughness:
  49349. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  49350. */
  49351. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  49352. /**
  49353. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49354. */
  49355. protected _forceIrradianceInFragment: boolean;
  49356. /**
  49357. * Force normal to face away from face.
  49358. */
  49359. protected _forceNormalForward: boolean;
  49360. /**
  49361. * Enables specular anti aliasing in the PBR shader.
  49362. * It will both interacts on the Geometry for analytical and IBL lighting.
  49363. * It also prefilter the roughness map based on the bump values.
  49364. */
  49365. protected _enableSpecularAntiAliasing: boolean;
  49366. /**
  49367. * Default configuration related to image processing available in the PBR Material.
  49368. */
  49369. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49370. /**
  49371. * Keep track of the image processing observer to allow dispose and replace.
  49372. */
  49373. private _imageProcessingObserver;
  49374. /**
  49375. * Attaches a new image processing configuration to the PBR Material.
  49376. * @param configuration
  49377. */
  49378. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49379. /**
  49380. * Stores the available render targets.
  49381. */
  49382. private _renderTargets;
  49383. /**
  49384. * Sets the global ambient color for the material used in lighting calculations.
  49385. */
  49386. private _globalAmbientColor;
  49387. /**
  49388. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  49389. */
  49390. private _useLogarithmicDepth;
  49391. /**
  49392. * If set to true, no lighting calculations will be applied.
  49393. */
  49394. private _unlit;
  49395. private _debugMode;
  49396. /**
  49397. * @hidden
  49398. * This is reserved for the inspector.
  49399. * Defines the material debug mode.
  49400. * It helps seeing only some components of the material while troubleshooting.
  49401. */
  49402. debugMode: number;
  49403. /**
  49404. * @hidden
  49405. * This is reserved for the inspector.
  49406. * Specify from where on screen the debug mode should start.
  49407. * The value goes from -1 (full screen) to 1 (not visible)
  49408. * It helps with side by side comparison against the final render
  49409. * This defaults to -1
  49410. */
  49411. private debugLimit;
  49412. /**
  49413. * @hidden
  49414. * This is reserved for the inspector.
  49415. * As the default viewing range might not be enough (if the ambient is really small for instance)
  49416. * You can use the factor to better multiply the final value.
  49417. */
  49418. private debugFactor;
  49419. /**
  49420. * Defines the clear coat layer parameters for the material.
  49421. */
  49422. readonly clearCoat: PBRClearCoatConfiguration;
  49423. /**
  49424. * Defines the anisotropic parameters for the material.
  49425. */
  49426. readonly anisotropy: PBRAnisotropicConfiguration;
  49427. /**
  49428. * Defines the BRDF parameters for the material.
  49429. */
  49430. readonly brdf: PBRBRDFConfiguration;
  49431. /**
  49432. * Defines the Sheen parameters for the material.
  49433. */
  49434. readonly sheen: PBRSheenConfiguration;
  49435. /**
  49436. * Defines the SubSurface parameters for the material.
  49437. */
  49438. readonly subSurface: PBRSubSurfaceConfiguration;
  49439. /**
  49440. * Custom callback helping to override the default shader used in the material.
  49441. */
  49442. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  49443. protected _rebuildInParallel: boolean;
  49444. /**
  49445. * Instantiates a new PBRMaterial instance.
  49446. *
  49447. * @param name The material name
  49448. * @param scene The scene the material will be use in.
  49449. */
  49450. constructor(name: string, scene: Scene);
  49451. /**
  49452. * Gets a boolean indicating that current material needs to register RTT
  49453. */
  49454. readonly hasRenderTargetTextures: boolean;
  49455. /**
  49456. * Gets the name of the material class.
  49457. */
  49458. getClassName(): string;
  49459. /**
  49460. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49461. */
  49462. /**
  49463. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49464. */
  49465. useLogarithmicDepth: boolean;
  49466. /**
  49467. * Gets the current transparency mode.
  49468. */
  49469. /**
  49470. * Sets the transparency mode of the material.
  49471. *
  49472. * | Value | Type | Description |
  49473. * | ----- | ----------------------------------- | ----------- |
  49474. * | 0 | OPAQUE | |
  49475. * | 1 | ALPHATEST | |
  49476. * | 2 | ALPHABLEND | |
  49477. * | 3 | ALPHATESTANDBLEND | |
  49478. *
  49479. */
  49480. transparencyMode: Nullable<number>;
  49481. /**
  49482. * Returns true if alpha blending should be disabled.
  49483. */
  49484. private readonly _disableAlphaBlending;
  49485. /**
  49486. * Specifies whether or not this material should be rendered in alpha blend mode.
  49487. */
  49488. needAlphaBlending(): boolean;
  49489. /**
  49490. * Specifies if the mesh will require alpha blending.
  49491. * @param mesh - BJS mesh.
  49492. */
  49493. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  49494. /**
  49495. * Specifies whether or not this material should be rendered in alpha test mode.
  49496. */
  49497. needAlphaTesting(): boolean;
  49498. /**
  49499. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  49500. */
  49501. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  49502. /**
  49503. * Gets the texture used for the alpha test.
  49504. */
  49505. getAlphaTestTexture(): Nullable<BaseTexture>;
  49506. /**
  49507. * Specifies that the submesh is ready to be used.
  49508. * @param mesh - BJS mesh.
  49509. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  49510. * @param useInstances - Specifies that instances should be used.
  49511. * @returns - boolean indicating that the submesh is ready or not.
  49512. */
  49513. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49514. /**
  49515. * Specifies if the material uses metallic roughness workflow.
  49516. * @returns boolean specifiying if the material uses metallic roughness workflow.
  49517. */
  49518. isMetallicWorkflow(): boolean;
  49519. private _prepareEffect;
  49520. private _prepareDefines;
  49521. /**
  49522. * Force shader compilation
  49523. */
  49524. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  49525. clipPlane: boolean;
  49526. }>): void;
  49527. /**
  49528. * Initializes the uniform buffer layout for the shader.
  49529. */
  49530. buildUniformLayout(): void;
  49531. /**
  49532. * Unbinds the material from the mesh
  49533. */
  49534. unbind(): void;
  49535. /**
  49536. * Binds the submesh data.
  49537. * @param world - The world matrix.
  49538. * @param mesh - The BJS mesh.
  49539. * @param subMesh - A submesh of the BJS mesh.
  49540. */
  49541. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49542. /**
  49543. * Returns the animatable textures.
  49544. * @returns - Array of animatable textures.
  49545. */
  49546. getAnimatables(): IAnimatable[];
  49547. /**
  49548. * Returns the texture used for reflections.
  49549. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  49550. */
  49551. private _getReflectionTexture;
  49552. /**
  49553. * Returns an array of the actively used textures.
  49554. * @returns - Array of BaseTextures
  49555. */
  49556. getActiveTextures(): BaseTexture[];
  49557. /**
  49558. * Checks to see if a texture is used in the material.
  49559. * @param texture - Base texture to use.
  49560. * @returns - Boolean specifying if a texture is used in the material.
  49561. */
  49562. hasTexture(texture: BaseTexture): boolean;
  49563. /**
  49564. * Disposes the resources of the material.
  49565. * @param forceDisposeEffect - Forces the disposal of effects.
  49566. * @param forceDisposeTextures - Forces the disposal of all textures.
  49567. */
  49568. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49569. }
  49570. }
  49571. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  49572. import { Nullable } from "babylonjs/types";
  49573. import { Scene } from "babylonjs/scene";
  49574. import { Color3 } from "babylonjs/Maths/math.color";
  49575. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  49576. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  49577. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49578. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  49579. /**
  49580. * The Physically based material of BJS.
  49581. *
  49582. * This offers the main features of a standard PBR material.
  49583. * For more information, please refer to the documentation :
  49584. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49585. */
  49586. export class PBRMaterial extends PBRBaseMaterial {
  49587. /**
  49588. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49589. */
  49590. static readonly PBRMATERIAL_OPAQUE: number;
  49591. /**
  49592. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49593. */
  49594. static readonly PBRMATERIAL_ALPHATEST: number;
  49595. /**
  49596. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49597. */
  49598. static readonly PBRMATERIAL_ALPHABLEND: number;
  49599. /**
  49600. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49601. * They are also discarded below the alpha cutoff threshold to improve performances.
  49602. */
  49603. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49604. /**
  49605. * Defines the default value of how much AO map is occluding the analytical lights
  49606. * (point spot...).
  49607. */
  49608. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49609. /**
  49610. * Intensity of the direct lights e.g. the four lights available in your scene.
  49611. * This impacts both the direct diffuse and specular highlights.
  49612. */
  49613. directIntensity: number;
  49614. /**
  49615. * Intensity of the emissive part of the material.
  49616. * This helps controlling the emissive effect without modifying the emissive color.
  49617. */
  49618. emissiveIntensity: number;
  49619. /**
  49620. * Intensity of the environment e.g. how much the environment will light the object
  49621. * either through harmonics for rough material or through the refelction for shiny ones.
  49622. */
  49623. environmentIntensity: number;
  49624. /**
  49625. * This is a special control allowing the reduction of the specular highlights coming from the
  49626. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49627. */
  49628. specularIntensity: number;
  49629. /**
  49630. * Debug Control allowing disabling the bump map on this material.
  49631. */
  49632. disableBumpMap: boolean;
  49633. /**
  49634. * AKA Diffuse Texture in standard nomenclature.
  49635. */
  49636. albedoTexture: BaseTexture;
  49637. /**
  49638. * AKA Occlusion Texture in other nomenclature.
  49639. */
  49640. ambientTexture: BaseTexture;
  49641. /**
  49642. * AKA Occlusion Texture Intensity in other nomenclature.
  49643. */
  49644. ambientTextureStrength: number;
  49645. /**
  49646. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49647. * 1 means it completely occludes it
  49648. * 0 mean it has no impact
  49649. */
  49650. ambientTextureImpactOnAnalyticalLights: number;
  49651. /**
  49652. * Stores the alpha values in a texture.
  49653. */
  49654. opacityTexture: BaseTexture;
  49655. /**
  49656. * Stores the reflection values in a texture.
  49657. */
  49658. reflectionTexture: Nullable<BaseTexture>;
  49659. /**
  49660. * Stores the emissive values in a texture.
  49661. */
  49662. emissiveTexture: BaseTexture;
  49663. /**
  49664. * AKA Specular texture in other nomenclature.
  49665. */
  49666. reflectivityTexture: BaseTexture;
  49667. /**
  49668. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49669. */
  49670. metallicTexture: BaseTexture;
  49671. /**
  49672. * Specifies the metallic scalar of the metallic/roughness workflow.
  49673. * Can also be used to scale the metalness values of the metallic texture.
  49674. */
  49675. metallic: Nullable<number>;
  49676. /**
  49677. * Specifies the roughness scalar of the metallic/roughness workflow.
  49678. * Can also be used to scale the roughness values of the metallic texture.
  49679. */
  49680. roughness: Nullable<number>;
  49681. /**
  49682. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49683. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49684. */
  49685. microSurfaceTexture: BaseTexture;
  49686. /**
  49687. * Stores surface normal data used to displace a mesh in a texture.
  49688. */
  49689. bumpTexture: BaseTexture;
  49690. /**
  49691. * Stores the pre-calculated light information of a mesh in a texture.
  49692. */
  49693. lightmapTexture: BaseTexture;
  49694. /**
  49695. * Stores the refracted light information in a texture.
  49696. */
  49697. refractionTexture: Nullable<BaseTexture>;
  49698. /**
  49699. * The color of a material in ambient lighting.
  49700. */
  49701. ambientColor: Color3;
  49702. /**
  49703. * AKA Diffuse Color in other nomenclature.
  49704. */
  49705. albedoColor: Color3;
  49706. /**
  49707. * AKA Specular Color in other nomenclature.
  49708. */
  49709. reflectivityColor: Color3;
  49710. /**
  49711. * The color reflected from the material.
  49712. */
  49713. reflectionColor: Color3;
  49714. /**
  49715. * The color emitted from the material.
  49716. */
  49717. emissiveColor: Color3;
  49718. /**
  49719. * AKA Glossiness in other nomenclature.
  49720. */
  49721. microSurface: number;
  49722. /**
  49723. * source material index of refraction (IOR)' / 'destination material IOR.
  49724. */
  49725. indexOfRefraction: number;
  49726. /**
  49727. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49728. */
  49729. invertRefractionY: boolean;
  49730. /**
  49731. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49732. * Materials half opaque for instance using refraction could benefit from this control.
  49733. */
  49734. linkRefractionWithTransparency: boolean;
  49735. /**
  49736. * If true, the light map contains occlusion information instead of lighting info.
  49737. */
  49738. useLightmapAsShadowmap: boolean;
  49739. /**
  49740. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49741. */
  49742. useAlphaFromAlbedoTexture: boolean;
  49743. /**
  49744. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49745. */
  49746. forceAlphaTest: boolean;
  49747. /**
  49748. * Defines the alpha limits in alpha test mode.
  49749. */
  49750. alphaCutOff: number;
  49751. /**
  49752. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  49753. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49754. */
  49755. useSpecularOverAlpha: boolean;
  49756. /**
  49757. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49758. */
  49759. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49760. /**
  49761. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49762. */
  49763. useRoughnessFromMetallicTextureAlpha: boolean;
  49764. /**
  49765. * Specifies if the metallic texture contains the roughness information in its green channel.
  49766. */
  49767. useRoughnessFromMetallicTextureGreen: boolean;
  49768. /**
  49769. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49770. */
  49771. useMetallnessFromMetallicTextureBlue: boolean;
  49772. /**
  49773. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49774. */
  49775. useAmbientOcclusionFromMetallicTextureRed: boolean;
  49776. /**
  49777. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49778. */
  49779. useAmbientInGrayScale: boolean;
  49780. /**
  49781. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49782. * The material will try to infer what glossiness each pixel should be.
  49783. */
  49784. useAutoMicroSurfaceFromReflectivityMap: boolean;
  49785. /**
  49786. * BJS is using an harcoded light falloff based on a manually sets up range.
  49787. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49788. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49789. */
  49790. /**
  49791. * BJS is using an harcoded light falloff based on a manually sets up range.
  49792. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49793. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49794. */
  49795. usePhysicalLightFalloff: boolean;
  49796. /**
  49797. * In order to support the falloff compatibility with gltf, a special mode has been added
  49798. * to reproduce the gltf light falloff.
  49799. */
  49800. /**
  49801. * In order to support the falloff compatibility with gltf, a special mode has been added
  49802. * to reproduce the gltf light falloff.
  49803. */
  49804. useGLTFLightFalloff: boolean;
  49805. /**
  49806. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49807. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49808. */
  49809. useRadianceOverAlpha: boolean;
  49810. /**
  49811. * Allows using an object space normal map (instead of tangent space).
  49812. */
  49813. useObjectSpaceNormalMap: boolean;
  49814. /**
  49815. * Allows using the bump map in parallax mode.
  49816. */
  49817. useParallax: boolean;
  49818. /**
  49819. * Allows using the bump map in parallax occlusion mode.
  49820. */
  49821. useParallaxOcclusion: boolean;
  49822. /**
  49823. * Controls the scale bias of the parallax mode.
  49824. */
  49825. parallaxScaleBias: number;
  49826. /**
  49827. * If sets to true, disables all the lights affecting the material.
  49828. */
  49829. disableLighting: boolean;
  49830. /**
  49831. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49832. */
  49833. forceIrradianceInFragment: boolean;
  49834. /**
  49835. * Number of Simultaneous lights allowed on the material.
  49836. */
  49837. maxSimultaneousLights: number;
  49838. /**
  49839. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49840. */
  49841. invertNormalMapX: boolean;
  49842. /**
  49843. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49844. */
  49845. invertNormalMapY: boolean;
  49846. /**
  49847. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49848. */
  49849. twoSidedLighting: boolean;
  49850. /**
  49851. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49852. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49853. */
  49854. useAlphaFresnel: boolean;
  49855. /**
  49856. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49857. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49858. */
  49859. useLinearAlphaFresnel: boolean;
  49860. /**
  49861. * Let user defines the brdf lookup texture used for IBL.
  49862. * A default 8bit version is embedded but you could point at :
  49863. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  49864. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  49865. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  49866. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  49867. */
  49868. environmentBRDFTexture: Nullable<BaseTexture>;
  49869. /**
  49870. * Force normal to face away from face.
  49871. */
  49872. forceNormalForward: boolean;
  49873. /**
  49874. * Enables specular anti aliasing in the PBR shader.
  49875. * It will both interacts on the Geometry for analytical and IBL lighting.
  49876. * It also prefilter the roughness map based on the bump values.
  49877. */
  49878. enableSpecularAntiAliasing: boolean;
  49879. /**
  49880. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49881. * makes the reflect vector face the model (under horizon).
  49882. */
  49883. useHorizonOcclusion: boolean;
  49884. /**
  49885. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49886. * too much the area relying on ambient texture to define their ambient occlusion.
  49887. */
  49888. useRadianceOcclusion: boolean;
  49889. /**
  49890. * If set to true, no lighting calculations will be applied.
  49891. */
  49892. unlit: boolean;
  49893. /**
  49894. * Gets the image processing configuration used either in this material.
  49895. */
  49896. /**
  49897. * Sets the Default image processing configuration used either in the this material.
  49898. *
  49899. * If sets to null, the scene one is in use.
  49900. */
  49901. imageProcessingConfiguration: ImageProcessingConfiguration;
  49902. /**
  49903. * Gets wether the color curves effect is enabled.
  49904. */
  49905. /**
  49906. * Sets wether the color curves effect is enabled.
  49907. */
  49908. cameraColorCurvesEnabled: boolean;
  49909. /**
  49910. * Gets wether the color grading effect is enabled.
  49911. */
  49912. /**
  49913. * Gets wether the color grading effect is enabled.
  49914. */
  49915. cameraColorGradingEnabled: boolean;
  49916. /**
  49917. * Gets wether tonemapping is enabled or not.
  49918. */
  49919. /**
  49920. * Sets wether tonemapping is enabled or not
  49921. */
  49922. cameraToneMappingEnabled: boolean;
  49923. /**
  49924. * The camera exposure used on this material.
  49925. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49926. * This corresponds to a photographic exposure.
  49927. */
  49928. /**
  49929. * The camera exposure used on this material.
  49930. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49931. * This corresponds to a photographic exposure.
  49932. */
  49933. cameraExposure: number;
  49934. /**
  49935. * Gets The camera contrast used on this material.
  49936. */
  49937. /**
  49938. * Sets The camera contrast used on this material.
  49939. */
  49940. cameraContrast: number;
  49941. /**
  49942. * Gets the Color Grading 2D Lookup Texture.
  49943. */
  49944. /**
  49945. * Sets the Color Grading 2D Lookup Texture.
  49946. */
  49947. cameraColorGradingTexture: Nullable<BaseTexture>;
  49948. /**
  49949. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49950. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49951. * 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;
  49952. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49953. */
  49954. /**
  49955. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49956. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49957. * 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;
  49958. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49959. */
  49960. cameraColorCurves: Nullable<ColorCurves>;
  49961. /**
  49962. * Instantiates a new PBRMaterial instance.
  49963. *
  49964. * @param name The material name
  49965. * @param scene The scene the material will be use in.
  49966. */
  49967. constructor(name: string, scene: Scene);
  49968. /**
  49969. * Returns the name of this material class.
  49970. */
  49971. getClassName(): string;
  49972. /**
  49973. * Makes a duplicate of the current material.
  49974. * @param name - name to use for the new material.
  49975. */
  49976. clone(name: string): PBRMaterial;
  49977. /**
  49978. * Serializes this PBR Material.
  49979. * @returns - An object with the serialized material.
  49980. */
  49981. serialize(): any;
  49982. /**
  49983. * Parses a PBR Material from a serialized object.
  49984. * @param source - Serialized object.
  49985. * @param scene - BJS scene instance.
  49986. * @param rootUrl - url for the scene object
  49987. * @returns - PBRMaterial
  49988. */
  49989. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  49990. }
  49991. }
  49992. declare module "babylonjs/Misc/dds" {
  49993. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49994. import { Engine } from "babylonjs/Engines/engine";
  49995. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49996. import { Nullable } from "babylonjs/types";
  49997. import { Scene } from "babylonjs/scene";
  49998. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  49999. /**
  50000. * Direct draw surface info
  50001. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  50002. */
  50003. export interface DDSInfo {
  50004. /**
  50005. * Width of the texture
  50006. */
  50007. width: number;
  50008. /**
  50009. * Width of the texture
  50010. */
  50011. height: number;
  50012. /**
  50013. * Number of Mipmaps for the texture
  50014. * @see https://en.wikipedia.org/wiki/Mipmap
  50015. */
  50016. mipmapCount: number;
  50017. /**
  50018. * If the textures format is a known fourCC format
  50019. * @see https://www.fourcc.org/
  50020. */
  50021. isFourCC: boolean;
  50022. /**
  50023. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  50024. */
  50025. isRGB: boolean;
  50026. /**
  50027. * If the texture is a lumincance format
  50028. */
  50029. isLuminance: boolean;
  50030. /**
  50031. * If this is a cube texture
  50032. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  50033. */
  50034. isCube: boolean;
  50035. /**
  50036. * If the texture is a compressed format eg. FOURCC_DXT1
  50037. */
  50038. isCompressed: boolean;
  50039. /**
  50040. * The dxgiFormat of the texture
  50041. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  50042. */
  50043. dxgiFormat: number;
  50044. /**
  50045. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  50046. */
  50047. textureType: number;
  50048. /**
  50049. * Sphericle polynomial created for the dds texture
  50050. */
  50051. sphericalPolynomial?: SphericalPolynomial;
  50052. }
  50053. /**
  50054. * Class used to provide DDS decompression tools
  50055. */
  50056. export class DDSTools {
  50057. /**
  50058. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  50059. */
  50060. static StoreLODInAlphaChannel: boolean;
  50061. /**
  50062. * Gets DDS information from an array buffer
  50063. * @param arrayBuffer defines the array buffer to read data from
  50064. * @returns the DDS information
  50065. */
  50066. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  50067. private static _FloatView;
  50068. private static _Int32View;
  50069. private static _ToHalfFloat;
  50070. private static _FromHalfFloat;
  50071. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  50072. private static _GetHalfFloatRGBAArrayBuffer;
  50073. private static _GetFloatRGBAArrayBuffer;
  50074. private static _GetFloatAsUIntRGBAArrayBuffer;
  50075. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  50076. private static _GetRGBAArrayBuffer;
  50077. private static _ExtractLongWordOrder;
  50078. private static _GetRGBArrayBuffer;
  50079. private static _GetLuminanceArrayBuffer;
  50080. /**
  50081. * Uploads DDS Levels to a Babylon Texture
  50082. * @hidden
  50083. */
  50084. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  50085. }
  50086. module "babylonjs/Engines/engine" {
  50087. interface Engine {
  50088. /**
  50089. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  50090. * @param rootUrl defines the url where the file to load is located
  50091. * @param scene defines the current scene
  50092. * @param lodScale defines scale to apply to the mip map selection
  50093. * @param lodOffset defines offset to apply to the mip map selection
  50094. * @param onLoad defines an optional callback raised when the texture is loaded
  50095. * @param onError defines an optional callback raised if there is an issue to load the texture
  50096. * @param format defines the format of the data
  50097. * @param forcedExtension defines the extension to use to pick the right loader
  50098. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  50099. * @returns the cube texture as an InternalTexture
  50100. */
  50101. 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;
  50102. }
  50103. }
  50104. }
  50105. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  50106. import { Nullable } from "babylonjs/types";
  50107. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50108. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50109. /**
  50110. * Implementation of the DDS Texture Loader.
  50111. * @hidden
  50112. */
  50113. export class _DDSTextureLoader implements IInternalTextureLoader {
  50114. /**
  50115. * Defines wether the loader supports cascade loading the different faces.
  50116. */
  50117. readonly supportCascades: boolean;
  50118. /**
  50119. * This returns if the loader support the current file information.
  50120. * @param extension defines the file extension of the file being loaded
  50121. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50122. * @param fallback defines the fallback internal texture if any
  50123. * @param isBase64 defines whether the texture is encoded as a base64
  50124. * @param isBuffer defines whether the texture data are stored as a buffer
  50125. * @returns true if the loader can load the specified file
  50126. */
  50127. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50128. /**
  50129. * Transform the url before loading if required.
  50130. * @param rootUrl the url of the texture
  50131. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50132. * @returns the transformed texture
  50133. */
  50134. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50135. /**
  50136. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50137. * @param rootUrl the url of the texture
  50138. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50139. * @returns the fallback texture
  50140. */
  50141. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50142. /**
  50143. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50144. * @param data contains the texture data
  50145. * @param texture defines the BabylonJS internal texture
  50146. * @param createPolynomials will be true if polynomials have been requested
  50147. * @param onLoad defines the callback to trigger once the texture is ready
  50148. * @param onError defines the callback to trigger in case of error
  50149. */
  50150. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50151. /**
  50152. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50153. * @param data contains the texture data
  50154. * @param texture defines the BabylonJS internal texture
  50155. * @param callback defines the method to call once ready to upload
  50156. */
  50157. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50158. }
  50159. }
  50160. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  50161. import { Nullable } from "babylonjs/types";
  50162. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50163. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50164. /**
  50165. * Implementation of the ENV Texture Loader.
  50166. * @hidden
  50167. */
  50168. export class _ENVTextureLoader implements IInternalTextureLoader {
  50169. /**
  50170. * Defines wether the loader supports cascade loading the different faces.
  50171. */
  50172. readonly supportCascades: boolean;
  50173. /**
  50174. * This returns if the loader support the current file information.
  50175. * @param extension defines the file extension of the file being loaded
  50176. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50177. * @param fallback defines the fallback internal texture if any
  50178. * @param isBase64 defines whether the texture is encoded as a base64
  50179. * @param isBuffer defines whether the texture data are stored as a buffer
  50180. * @returns true if the loader can load the specified file
  50181. */
  50182. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50183. /**
  50184. * Transform the url before loading if required.
  50185. * @param rootUrl the url of the texture
  50186. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50187. * @returns the transformed texture
  50188. */
  50189. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50190. /**
  50191. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50192. * @param rootUrl the url of the texture
  50193. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50194. * @returns the fallback texture
  50195. */
  50196. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50197. /**
  50198. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50199. * @param data contains the texture data
  50200. * @param texture defines the BabylonJS internal texture
  50201. * @param createPolynomials will be true if polynomials have been requested
  50202. * @param onLoad defines the callback to trigger once the texture is ready
  50203. * @param onError defines the callback to trigger in case of error
  50204. */
  50205. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50206. /**
  50207. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50208. * @param data contains the texture data
  50209. * @param texture defines the BabylonJS internal texture
  50210. * @param callback defines the method to call once ready to upload
  50211. */
  50212. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50213. }
  50214. }
  50215. declare module "babylonjs/Misc/khronosTextureContainer" {
  50216. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50217. /**
  50218. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  50219. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  50220. */
  50221. export class KhronosTextureContainer {
  50222. /** contents of the KTX container file */
  50223. arrayBuffer: any;
  50224. private static HEADER_LEN;
  50225. private static COMPRESSED_2D;
  50226. private static COMPRESSED_3D;
  50227. private static TEX_2D;
  50228. private static TEX_3D;
  50229. /**
  50230. * Gets the openGL type
  50231. */
  50232. glType: number;
  50233. /**
  50234. * Gets the openGL type size
  50235. */
  50236. glTypeSize: number;
  50237. /**
  50238. * Gets the openGL format
  50239. */
  50240. glFormat: number;
  50241. /**
  50242. * Gets the openGL internal format
  50243. */
  50244. glInternalFormat: number;
  50245. /**
  50246. * Gets the base internal format
  50247. */
  50248. glBaseInternalFormat: number;
  50249. /**
  50250. * Gets image width in pixel
  50251. */
  50252. pixelWidth: number;
  50253. /**
  50254. * Gets image height in pixel
  50255. */
  50256. pixelHeight: number;
  50257. /**
  50258. * Gets image depth in pixels
  50259. */
  50260. pixelDepth: number;
  50261. /**
  50262. * Gets the number of array elements
  50263. */
  50264. numberOfArrayElements: number;
  50265. /**
  50266. * Gets the number of faces
  50267. */
  50268. numberOfFaces: number;
  50269. /**
  50270. * Gets the number of mipmap levels
  50271. */
  50272. numberOfMipmapLevels: number;
  50273. /**
  50274. * Gets the bytes of key value data
  50275. */
  50276. bytesOfKeyValueData: number;
  50277. /**
  50278. * Gets the load type
  50279. */
  50280. loadType: number;
  50281. /**
  50282. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  50283. */
  50284. isInvalid: boolean;
  50285. /**
  50286. * Creates a new KhronosTextureContainer
  50287. * @param arrayBuffer contents of the KTX container file
  50288. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  50289. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  50290. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  50291. */
  50292. constructor(
  50293. /** contents of the KTX container file */
  50294. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  50295. /**
  50296. * Uploads KTX content to a Babylon Texture.
  50297. * It is assumed that the texture has already been created & is currently bound
  50298. * @hidden
  50299. */
  50300. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  50301. private _upload2DCompressedLevels;
  50302. }
  50303. }
  50304. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  50305. import { Nullable } from "babylonjs/types";
  50306. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50307. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50308. /**
  50309. * Implementation of the KTX Texture Loader.
  50310. * @hidden
  50311. */
  50312. export class _KTXTextureLoader implements IInternalTextureLoader {
  50313. /**
  50314. * Defines wether the loader supports cascade loading the different faces.
  50315. */
  50316. readonly supportCascades: boolean;
  50317. /**
  50318. * This returns if the loader support the current file information.
  50319. * @param extension defines the file extension of the file being loaded
  50320. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50321. * @param fallback defines the fallback internal texture if any
  50322. * @param isBase64 defines whether the texture is encoded as a base64
  50323. * @param isBuffer defines whether the texture data are stored as a buffer
  50324. * @returns true if the loader can load the specified file
  50325. */
  50326. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50327. /**
  50328. * Transform the url before loading if required.
  50329. * @param rootUrl the url of the texture
  50330. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50331. * @returns the transformed texture
  50332. */
  50333. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50334. /**
  50335. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50336. * @param rootUrl the url of the texture
  50337. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50338. * @returns the fallback texture
  50339. */
  50340. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50341. /**
  50342. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50343. * @param data contains the texture data
  50344. * @param texture defines the BabylonJS internal texture
  50345. * @param createPolynomials will be true if polynomials have been requested
  50346. * @param onLoad defines the callback to trigger once the texture is ready
  50347. * @param onError defines the callback to trigger in case of error
  50348. */
  50349. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50350. /**
  50351. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50352. * @param data contains the texture data
  50353. * @param texture defines the BabylonJS internal texture
  50354. * @param callback defines the method to call once ready to upload
  50355. */
  50356. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  50357. }
  50358. }
  50359. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  50360. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  50361. import { Scene } from "babylonjs/scene";
  50362. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  50363. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  50364. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  50365. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  50366. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  50367. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  50368. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50369. /**
  50370. * Options for the default xr helper
  50371. */
  50372. export class WebXRDefaultExperienceOptions {
  50373. /**
  50374. * Floor meshes that should be used for teleporting
  50375. */
  50376. floorMeshes: Array<AbstractMesh>;
  50377. }
  50378. /**
  50379. * Default experience which provides a similar setup to the previous webVRExperience
  50380. */
  50381. export class WebXRDefaultExperience {
  50382. /**
  50383. * Base experience
  50384. */
  50385. baseExperience: WebXRExperienceHelper;
  50386. /**
  50387. * Input experience extension
  50388. */
  50389. input: WebXRInput;
  50390. /**
  50391. * Loads the controller models
  50392. */
  50393. controllerModelLoader: WebXRControllerModelLoader;
  50394. /**
  50395. * Enables laser pointer and selection
  50396. */
  50397. pointerSelection: WebXRControllerPointerSelection;
  50398. /**
  50399. * Enables teleportation
  50400. */
  50401. teleportation: WebXRControllerTeleportation;
  50402. /**
  50403. * Enables ui for enetering/exiting xr
  50404. */
  50405. enterExitUI: WebXREnterExitUI;
  50406. /**
  50407. * Default output canvas xr should render to
  50408. */
  50409. outputCanvas: WebXRManagedOutputCanvas;
  50410. /**
  50411. * Creates the default xr experience
  50412. * @param scene scene
  50413. * @param options options for basic configuration
  50414. * @returns resulting WebXRDefaultExperience
  50415. */
  50416. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50417. private constructor();
  50418. /**
  50419. * DIsposes of the experience helper
  50420. */
  50421. dispose(): void;
  50422. }
  50423. }
  50424. declare module "babylonjs/Helpers/sceneHelpers" {
  50425. import { Nullable } from "babylonjs/types";
  50426. import { Mesh } from "babylonjs/Meshes/mesh";
  50427. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50428. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  50429. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  50430. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  50431. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  50432. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  50433. import "babylonjs/Meshes/Builders/boxBuilder";
  50434. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  50435. /** @hidden */
  50436. export var _forceSceneHelpersToBundle: boolean;
  50437. module "babylonjs/scene" {
  50438. interface Scene {
  50439. /**
  50440. * Creates a default light for the scene.
  50441. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  50442. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  50443. */
  50444. createDefaultLight(replace?: boolean): void;
  50445. /**
  50446. * Creates a default camera for the scene.
  50447. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  50448. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50449. * @param replace has default false, when true replaces the active camera in the scene
  50450. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  50451. */
  50452. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50453. /**
  50454. * Creates a default camera and a default light.
  50455. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  50456. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50457. * @param replace has the default false, when true replaces the active camera/light in the scene
  50458. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  50459. */
  50460. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50461. /**
  50462. * Creates a new sky box
  50463. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  50464. * @param environmentTexture defines the texture to use as environment texture
  50465. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  50466. * @param scale defines the overall scale of the skybox
  50467. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  50468. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  50469. * @returns a new mesh holding the sky box
  50470. */
  50471. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  50472. /**
  50473. * Creates a new environment
  50474. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  50475. * @param options defines the options you can use to configure the environment
  50476. * @returns the new EnvironmentHelper
  50477. */
  50478. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  50479. /**
  50480. * Creates a new VREXperienceHelper
  50481. * @see http://doc.babylonjs.com/how_to/webvr_helper
  50482. * @param webVROptions defines the options used to create the new VREXperienceHelper
  50483. * @returns a new VREXperienceHelper
  50484. */
  50485. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  50486. /**
  50487. * Creates a new WebXRDefaultExperience
  50488. * @see http://doc.babylonjs.com/how_to/webxr
  50489. * @param options experience options
  50490. * @returns a promise for a new WebXRDefaultExperience
  50491. */
  50492. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50493. }
  50494. }
  50495. }
  50496. declare module "babylonjs/Helpers/videoDome" {
  50497. import { Scene } from "babylonjs/scene";
  50498. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50499. import { Mesh } from "babylonjs/Meshes/mesh";
  50500. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  50501. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  50502. import "babylonjs/Meshes/Builders/sphereBuilder";
  50503. /**
  50504. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  50505. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  50506. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  50507. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50508. */
  50509. export class VideoDome extends TransformNode {
  50510. /**
  50511. * Define the video source as a Monoscopic panoramic 360 video.
  50512. */
  50513. static readonly MODE_MONOSCOPIC: number;
  50514. /**
  50515. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50516. */
  50517. static readonly MODE_TOPBOTTOM: number;
  50518. /**
  50519. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50520. */
  50521. static readonly MODE_SIDEBYSIDE: number;
  50522. private _halfDome;
  50523. private _useDirectMapping;
  50524. /**
  50525. * The video texture being displayed on the sphere
  50526. */
  50527. protected _videoTexture: VideoTexture;
  50528. /**
  50529. * Gets the video texture being displayed on the sphere
  50530. */
  50531. readonly videoTexture: VideoTexture;
  50532. /**
  50533. * The skybox material
  50534. */
  50535. protected _material: BackgroundMaterial;
  50536. /**
  50537. * The surface used for the skybox
  50538. */
  50539. protected _mesh: Mesh;
  50540. /**
  50541. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  50542. */
  50543. private _halfDomeMask;
  50544. /**
  50545. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50546. * Also see the options.resolution property.
  50547. */
  50548. fovMultiplier: number;
  50549. private _videoMode;
  50550. /**
  50551. * Gets or set the current video mode for the video. It can be:
  50552. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  50553. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50554. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50555. */
  50556. videoMode: number;
  50557. /**
  50558. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  50559. *
  50560. */
  50561. /**
  50562. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  50563. */
  50564. halfDome: boolean;
  50565. /**
  50566. * Oberserver used in Stereoscopic VR Mode.
  50567. */
  50568. private _onBeforeCameraRenderObserver;
  50569. /**
  50570. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  50571. * @param name Element's name, child elements will append suffixes for their own names.
  50572. * @param urlsOrVideo defines the url(s) or the video element to use
  50573. * @param options An object containing optional or exposed sub element properties
  50574. */
  50575. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  50576. resolution?: number;
  50577. clickToPlay?: boolean;
  50578. autoPlay?: boolean;
  50579. loop?: boolean;
  50580. size?: number;
  50581. poster?: string;
  50582. faceForward?: boolean;
  50583. useDirectMapping?: boolean;
  50584. halfDomeMode?: boolean;
  50585. }, scene: Scene);
  50586. private _changeVideoMode;
  50587. /**
  50588. * Releases resources associated with this node.
  50589. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50590. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50591. */
  50592. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50593. }
  50594. }
  50595. declare module "babylonjs/Helpers/index" {
  50596. export * from "babylonjs/Helpers/environmentHelper";
  50597. export * from "babylonjs/Helpers/photoDome";
  50598. export * from "babylonjs/Helpers/sceneHelpers";
  50599. export * from "babylonjs/Helpers/videoDome";
  50600. }
  50601. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  50602. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  50603. import { IDisposable } from "babylonjs/scene";
  50604. import { Engine } from "babylonjs/Engines/engine";
  50605. /**
  50606. * This class can be used to get instrumentation data from a Babylon engine
  50607. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50608. */
  50609. export class EngineInstrumentation implements IDisposable {
  50610. /**
  50611. * Define the instrumented engine.
  50612. */
  50613. engine: Engine;
  50614. private _captureGPUFrameTime;
  50615. private _gpuFrameTimeToken;
  50616. private _gpuFrameTime;
  50617. private _captureShaderCompilationTime;
  50618. private _shaderCompilationTime;
  50619. private _onBeginFrameObserver;
  50620. private _onEndFrameObserver;
  50621. private _onBeforeShaderCompilationObserver;
  50622. private _onAfterShaderCompilationObserver;
  50623. /**
  50624. * Gets the perf counter used for GPU frame time
  50625. */
  50626. readonly gpuFrameTimeCounter: PerfCounter;
  50627. /**
  50628. * Gets the GPU frame time capture status
  50629. */
  50630. /**
  50631. * Enable or disable the GPU frame time capture
  50632. */
  50633. captureGPUFrameTime: boolean;
  50634. /**
  50635. * Gets the perf counter used for shader compilation time
  50636. */
  50637. readonly shaderCompilationTimeCounter: PerfCounter;
  50638. /**
  50639. * Gets the shader compilation time capture status
  50640. */
  50641. /**
  50642. * Enable or disable the shader compilation time capture
  50643. */
  50644. captureShaderCompilationTime: boolean;
  50645. /**
  50646. * Instantiates a new engine instrumentation.
  50647. * This class can be used to get instrumentation data from a Babylon engine
  50648. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50649. * @param engine Defines the engine to instrument
  50650. */
  50651. constructor(
  50652. /**
  50653. * Define the instrumented engine.
  50654. */
  50655. engine: Engine);
  50656. /**
  50657. * Dispose and release associated resources.
  50658. */
  50659. dispose(): void;
  50660. }
  50661. }
  50662. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  50663. import { Scene, IDisposable } from "babylonjs/scene";
  50664. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  50665. /**
  50666. * This class can be used to get instrumentation data from a Babylon engine
  50667. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50668. */
  50669. export class SceneInstrumentation implements IDisposable {
  50670. /**
  50671. * Defines the scene to instrument
  50672. */
  50673. scene: Scene;
  50674. private _captureActiveMeshesEvaluationTime;
  50675. private _activeMeshesEvaluationTime;
  50676. private _captureRenderTargetsRenderTime;
  50677. private _renderTargetsRenderTime;
  50678. private _captureFrameTime;
  50679. private _frameTime;
  50680. private _captureRenderTime;
  50681. private _renderTime;
  50682. private _captureInterFrameTime;
  50683. private _interFrameTime;
  50684. private _captureParticlesRenderTime;
  50685. private _particlesRenderTime;
  50686. private _captureSpritesRenderTime;
  50687. private _spritesRenderTime;
  50688. private _capturePhysicsTime;
  50689. private _physicsTime;
  50690. private _captureAnimationsTime;
  50691. private _animationsTime;
  50692. private _captureCameraRenderTime;
  50693. private _cameraRenderTime;
  50694. private _onBeforeActiveMeshesEvaluationObserver;
  50695. private _onAfterActiveMeshesEvaluationObserver;
  50696. private _onBeforeRenderTargetsRenderObserver;
  50697. private _onAfterRenderTargetsRenderObserver;
  50698. private _onAfterRenderObserver;
  50699. private _onBeforeDrawPhaseObserver;
  50700. private _onAfterDrawPhaseObserver;
  50701. private _onBeforeAnimationsObserver;
  50702. private _onBeforeParticlesRenderingObserver;
  50703. private _onAfterParticlesRenderingObserver;
  50704. private _onBeforeSpritesRenderingObserver;
  50705. private _onAfterSpritesRenderingObserver;
  50706. private _onBeforePhysicsObserver;
  50707. private _onAfterPhysicsObserver;
  50708. private _onAfterAnimationsObserver;
  50709. private _onBeforeCameraRenderObserver;
  50710. private _onAfterCameraRenderObserver;
  50711. /**
  50712. * Gets the perf counter used for active meshes evaluation time
  50713. */
  50714. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  50715. /**
  50716. * Gets the active meshes evaluation time capture status
  50717. */
  50718. /**
  50719. * Enable or disable the active meshes evaluation time capture
  50720. */
  50721. captureActiveMeshesEvaluationTime: boolean;
  50722. /**
  50723. * Gets the perf counter used for render targets render time
  50724. */
  50725. readonly renderTargetsRenderTimeCounter: PerfCounter;
  50726. /**
  50727. * Gets the render targets render time capture status
  50728. */
  50729. /**
  50730. * Enable or disable the render targets render time capture
  50731. */
  50732. captureRenderTargetsRenderTime: boolean;
  50733. /**
  50734. * Gets the perf counter used for particles render time
  50735. */
  50736. readonly particlesRenderTimeCounter: PerfCounter;
  50737. /**
  50738. * Gets the particles render time capture status
  50739. */
  50740. /**
  50741. * Enable or disable the particles render time capture
  50742. */
  50743. captureParticlesRenderTime: boolean;
  50744. /**
  50745. * Gets the perf counter used for sprites render time
  50746. */
  50747. readonly spritesRenderTimeCounter: PerfCounter;
  50748. /**
  50749. * Gets the sprites render time capture status
  50750. */
  50751. /**
  50752. * Enable or disable the sprites render time capture
  50753. */
  50754. captureSpritesRenderTime: boolean;
  50755. /**
  50756. * Gets the perf counter used for physics time
  50757. */
  50758. readonly physicsTimeCounter: PerfCounter;
  50759. /**
  50760. * Gets the physics time capture status
  50761. */
  50762. /**
  50763. * Enable or disable the physics time capture
  50764. */
  50765. capturePhysicsTime: boolean;
  50766. /**
  50767. * Gets the perf counter used for animations time
  50768. */
  50769. readonly animationsTimeCounter: PerfCounter;
  50770. /**
  50771. * Gets the animations time capture status
  50772. */
  50773. /**
  50774. * Enable or disable the animations time capture
  50775. */
  50776. captureAnimationsTime: boolean;
  50777. /**
  50778. * Gets the perf counter used for frame time capture
  50779. */
  50780. readonly frameTimeCounter: PerfCounter;
  50781. /**
  50782. * Gets the frame time capture status
  50783. */
  50784. /**
  50785. * Enable or disable the frame time capture
  50786. */
  50787. captureFrameTime: boolean;
  50788. /**
  50789. * Gets the perf counter used for inter-frames time capture
  50790. */
  50791. readonly interFrameTimeCounter: PerfCounter;
  50792. /**
  50793. * Gets the inter-frames time capture status
  50794. */
  50795. /**
  50796. * Enable or disable the inter-frames time capture
  50797. */
  50798. captureInterFrameTime: boolean;
  50799. /**
  50800. * Gets the perf counter used for render time capture
  50801. */
  50802. readonly renderTimeCounter: PerfCounter;
  50803. /**
  50804. * Gets the render time capture status
  50805. */
  50806. /**
  50807. * Enable or disable the render time capture
  50808. */
  50809. captureRenderTime: boolean;
  50810. /**
  50811. * Gets the perf counter used for camera render time capture
  50812. */
  50813. readonly cameraRenderTimeCounter: PerfCounter;
  50814. /**
  50815. * Gets the camera render time capture status
  50816. */
  50817. /**
  50818. * Enable or disable the camera render time capture
  50819. */
  50820. captureCameraRenderTime: boolean;
  50821. /**
  50822. * Gets the perf counter used for draw calls
  50823. */
  50824. readonly drawCallsCounter: PerfCounter;
  50825. /**
  50826. * Instantiates a new scene instrumentation.
  50827. * This class can be used to get instrumentation data from a Babylon engine
  50828. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50829. * @param scene Defines the scene to instrument
  50830. */
  50831. constructor(
  50832. /**
  50833. * Defines the scene to instrument
  50834. */
  50835. scene: Scene);
  50836. /**
  50837. * Dispose and release associated resources.
  50838. */
  50839. dispose(): void;
  50840. }
  50841. }
  50842. declare module "babylonjs/Instrumentation/index" {
  50843. export * from "babylonjs/Instrumentation/engineInstrumentation";
  50844. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  50845. export * from "babylonjs/Instrumentation/timeToken";
  50846. }
  50847. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  50848. /** @hidden */
  50849. export var glowMapGenerationPixelShader: {
  50850. name: string;
  50851. shader: string;
  50852. };
  50853. }
  50854. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  50855. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50856. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  50857. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  50858. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50859. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  50860. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50861. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50862. /** @hidden */
  50863. export var glowMapGenerationVertexShader: {
  50864. name: string;
  50865. shader: string;
  50866. };
  50867. }
  50868. declare module "babylonjs/Layers/effectLayer" {
  50869. import { Observable } from "babylonjs/Misc/observable";
  50870. import { Nullable } from "babylonjs/types";
  50871. import { Camera } from "babylonjs/Cameras/camera";
  50872. import { Scene } from "babylonjs/scene";
  50873. import { ISize } from "babylonjs/Maths/math.size";
  50874. import { Color4 } from "babylonjs/Maths/math.color";
  50875. import { Engine } from "babylonjs/Engines/engine";
  50876. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50877. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50878. import { Mesh } from "babylonjs/Meshes/mesh";
  50879. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  50880. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50881. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50882. import { Effect } from "babylonjs/Materials/effect";
  50883. import { Material } from "babylonjs/Materials/material";
  50884. import "babylonjs/Shaders/glowMapGeneration.fragment";
  50885. import "babylonjs/Shaders/glowMapGeneration.vertex";
  50886. /**
  50887. * Effect layer options. This helps customizing the behaviour
  50888. * of the effect layer.
  50889. */
  50890. export interface IEffectLayerOptions {
  50891. /**
  50892. * Multiplication factor apply to the canvas size to compute the render target size
  50893. * used to generated the objects (the smaller the faster).
  50894. */
  50895. mainTextureRatio: number;
  50896. /**
  50897. * Enforces a fixed size texture to ensure effect stability across devices.
  50898. */
  50899. mainTextureFixedSize?: number;
  50900. /**
  50901. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  50902. */
  50903. alphaBlendingMode: number;
  50904. /**
  50905. * The camera attached to the layer.
  50906. */
  50907. camera: Nullable<Camera>;
  50908. /**
  50909. * The rendering group to draw the layer in.
  50910. */
  50911. renderingGroupId: number;
  50912. }
  50913. /**
  50914. * The effect layer Helps adding post process effect blended with the main pass.
  50915. *
  50916. * This can be for instance use to generate glow or higlight effects on the scene.
  50917. *
  50918. * The effect layer class can not be used directly and is intented to inherited from to be
  50919. * customized per effects.
  50920. */
  50921. export abstract class EffectLayer {
  50922. private _vertexBuffers;
  50923. private _indexBuffer;
  50924. private _cachedDefines;
  50925. private _effectLayerMapGenerationEffect;
  50926. private _effectLayerOptions;
  50927. private _mergeEffect;
  50928. protected _scene: Scene;
  50929. protected _engine: Engine;
  50930. protected _maxSize: number;
  50931. protected _mainTextureDesiredSize: ISize;
  50932. protected _mainTexture: RenderTargetTexture;
  50933. protected _shouldRender: boolean;
  50934. protected _postProcesses: PostProcess[];
  50935. protected _textures: BaseTexture[];
  50936. protected _emissiveTextureAndColor: {
  50937. texture: Nullable<BaseTexture>;
  50938. color: Color4;
  50939. };
  50940. /**
  50941. * The name of the layer
  50942. */
  50943. name: string;
  50944. /**
  50945. * The clear color of the texture used to generate the glow map.
  50946. */
  50947. neutralColor: Color4;
  50948. /**
  50949. * Specifies wether the highlight layer is enabled or not.
  50950. */
  50951. isEnabled: boolean;
  50952. /**
  50953. * Gets the camera attached to the layer.
  50954. */
  50955. readonly camera: Nullable<Camera>;
  50956. /**
  50957. * Gets the rendering group id the layer should render in.
  50958. */
  50959. renderingGroupId: number;
  50960. /**
  50961. * An event triggered when the effect layer has been disposed.
  50962. */
  50963. onDisposeObservable: Observable<EffectLayer>;
  50964. /**
  50965. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  50966. */
  50967. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  50968. /**
  50969. * An event triggered when the generated texture is being merged in the scene.
  50970. */
  50971. onBeforeComposeObservable: Observable<EffectLayer>;
  50972. /**
  50973. * An event triggered when the generated texture has been merged in the scene.
  50974. */
  50975. onAfterComposeObservable: Observable<EffectLayer>;
  50976. /**
  50977. * An event triggered when the efffect layer changes its size.
  50978. */
  50979. onSizeChangedObservable: Observable<EffectLayer>;
  50980. /** @hidden */
  50981. static _SceneComponentInitialization: (scene: Scene) => void;
  50982. /**
  50983. * Instantiates a new effect Layer and references it in the scene.
  50984. * @param name The name of the layer
  50985. * @param scene The scene to use the layer in
  50986. */
  50987. constructor(
  50988. /** The Friendly of the effect in the scene */
  50989. name: string, scene: Scene);
  50990. /**
  50991. * Get the effect name of the layer.
  50992. * @return The effect name
  50993. */
  50994. abstract getEffectName(): string;
  50995. /**
  50996. * Checks for the readiness of the element composing the layer.
  50997. * @param subMesh the mesh to check for
  50998. * @param useInstances specify wether or not to use instances to render the mesh
  50999. * @return true if ready otherwise, false
  51000. */
  51001. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51002. /**
  51003. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51004. * @returns true if the effect requires stencil during the main canvas render pass.
  51005. */
  51006. abstract needStencil(): boolean;
  51007. /**
  51008. * Create the merge effect. This is the shader use to blit the information back
  51009. * to the main canvas at the end of the scene rendering.
  51010. * @returns The effect containing the shader used to merge the effect on the main canvas
  51011. */
  51012. protected abstract _createMergeEffect(): Effect;
  51013. /**
  51014. * Creates the render target textures and post processes used in the effect layer.
  51015. */
  51016. protected abstract _createTextureAndPostProcesses(): void;
  51017. /**
  51018. * Implementation specific of rendering the generating effect on the main canvas.
  51019. * @param effect The effect used to render through
  51020. */
  51021. protected abstract _internalRender(effect: Effect): void;
  51022. /**
  51023. * Sets the required values for both the emissive texture and and the main color.
  51024. */
  51025. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51026. /**
  51027. * Free any resources and references associated to a mesh.
  51028. * Internal use
  51029. * @param mesh The mesh to free.
  51030. */
  51031. abstract _disposeMesh(mesh: Mesh): void;
  51032. /**
  51033. * Serializes this layer (Glow or Highlight for example)
  51034. * @returns a serialized layer object
  51035. */
  51036. abstract serialize?(): any;
  51037. /**
  51038. * Initializes the effect layer with the required options.
  51039. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  51040. */
  51041. protected _init(options: Partial<IEffectLayerOptions>): void;
  51042. /**
  51043. * Generates the index buffer of the full screen quad blending to the main canvas.
  51044. */
  51045. private _generateIndexBuffer;
  51046. /**
  51047. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  51048. */
  51049. private _generateVertexBuffer;
  51050. /**
  51051. * Sets the main texture desired size which is the closest power of two
  51052. * of the engine canvas size.
  51053. */
  51054. private _setMainTextureSize;
  51055. /**
  51056. * Creates the main texture for the effect layer.
  51057. */
  51058. protected _createMainTexture(): void;
  51059. /**
  51060. * Adds specific effects defines.
  51061. * @param defines The defines to add specifics to.
  51062. */
  51063. protected _addCustomEffectDefines(defines: string[]): void;
  51064. /**
  51065. * Checks for the readiness of the element composing the layer.
  51066. * @param subMesh the mesh to check for
  51067. * @param useInstances specify wether or not to use instances to render the mesh
  51068. * @param emissiveTexture the associated emissive texture used to generate the glow
  51069. * @return true if ready otherwise, false
  51070. */
  51071. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  51072. /**
  51073. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  51074. */
  51075. render(): void;
  51076. /**
  51077. * Determine if a given mesh will be used in the current effect.
  51078. * @param mesh mesh to test
  51079. * @returns true if the mesh will be used
  51080. */
  51081. hasMesh(mesh: AbstractMesh): boolean;
  51082. /**
  51083. * Returns true if the layer contains information to display, otherwise false.
  51084. * @returns true if the glow layer should be rendered
  51085. */
  51086. shouldRender(): boolean;
  51087. /**
  51088. * Returns true if the mesh should render, otherwise false.
  51089. * @param mesh The mesh to render
  51090. * @returns true if it should render otherwise false
  51091. */
  51092. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  51093. /**
  51094. * Returns true if the mesh can be rendered, otherwise false.
  51095. * @param mesh The mesh to render
  51096. * @param material The material used on the mesh
  51097. * @returns true if it can be rendered otherwise false
  51098. */
  51099. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51100. /**
  51101. * Returns true if the mesh should render, otherwise false.
  51102. * @param mesh The mesh to render
  51103. * @returns true if it should render otherwise false
  51104. */
  51105. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  51106. /**
  51107. * Renders the submesh passed in parameter to the generation map.
  51108. */
  51109. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  51110. /**
  51111. * Rebuild the required buffers.
  51112. * @hidden Internal use only.
  51113. */
  51114. _rebuild(): void;
  51115. /**
  51116. * Dispose only the render target textures and post process.
  51117. */
  51118. private _disposeTextureAndPostProcesses;
  51119. /**
  51120. * Dispose the highlight layer and free resources.
  51121. */
  51122. dispose(): void;
  51123. /**
  51124. * Gets the class name of the effect layer
  51125. * @returns the string with the class name of the effect layer
  51126. */
  51127. getClassName(): string;
  51128. /**
  51129. * Creates an effect layer from parsed effect layer data
  51130. * @param parsedEffectLayer defines effect layer data
  51131. * @param scene defines the current scene
  51132. * @param rootUrl defines the root URL containing the effect layer information
  51133. * @returns a parsed effect Layer
  51134. */
  51135. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  51136. }
  51137. }
  51138. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  51139. import { Scene } from "babylonjs/scene";
  51140. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51141. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51142. import { AbstractScene } from "babylonjs/abstractScene";
  51143. module "babylonjs/abstractScene" {
  51144. interface AbstractScene {
  51145. /**
  51146. * The list of effect layers (highlights/glow) added to the scene
  51147. * @see http://doc.babylonjs.com/how_to/highlight_layer
  51148. * @see http://doc.babylonjs.com/how_to/glow_layer
  51149. */
  51150. effectLayers: Array<EffectLayer>;
  51151. /**
  51152. * Removes the given effect layer from this scene.
  51153. * @param toRemove defines the effect layer to remove
  51154. * @returns the index of the removed effect layer
  51155. */
  51156. removeEffectLayer(toRemove: EffectLayer): number;
  51157. /**
  51158. * Adds the given effect layer to this scene
  51159. * @param newEffectLayer defines the effect layer to add
  51160. */
  51161. addEffectLayer(newEffectLayer: EffectLayer): void;
  51162. }
  51163. }
  51164. /**
  51165. * Defines the layer scene component responsible to manage any effect layers
  51166. * in a given scene.
  51167. */
  51168. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  51169. /**
  51170. * The component name helpfull to identify the component in the list of scene components.
  51171. */
  51172. readonly name: string;
  51173. /**
  51174. * The scene the component belongs to.
  51175. */
  51176. scene: Scene;
  51177. private _engine;
  51178. private _renderEffects;
  51179. private _needStencil;
  51180. private _previousStencilState;
  51181. /**
  51182. * Creates a new instance of the component for the given scene
  51183. * @param scene Defines the scene to register the component in
  51184. */
  51185. constructor(scene: Scene);
  51186. /**
  51187. * Registers the component in a given scene
  51188. */
  51189. register(): void;
  51190. /**
  51191. * Rebuilds the elements related to this component in case of
  51192. * context lost for instance.
  51193. */
  51194. rebuild(): void;
  51195. /**
  51196. * Serializes the component data to the specified json object
  51197. * @param serializationObject The object to serialize to
  51198. */
  51199. serialize(serializationObject: any): void;
  51200. /**
  51201. * Adds all the elements from the container to the scene
  51202. * @param container the container holding the elements
  51203. */
  51204. addFromContainer(container: AbstractScene): void;
  51205. /**
  51206. * Removes all the elements in the container from the scene
  51207. * @param container contains the elements to remove
  51208. * @param dispose if the removed element should be disposed (default: false)
  51209. */
  51210. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51211. /**
  51212. * Disposes the component and the associated ressources.
  51213. */
  51214. dispose(): void;
  51215. private _isReadyForMesh;
  51216. private _renderMainTexture;
  51217. private _setStencil;
  51218. private _setStencilBack;
  51219. private _draw;
  51220. private _drawCamera;
  51221. private _drawRenderingGroup;
  51222. }
  51223. }
  51224. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  51225. /** @hidden */
  51226. export var glowMapMergePixelShader: {
  51227. name: string;
  51228. shader: string;
  51229. };
  51230. }
  51231. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  51232. /** @hidden */
  51233. export var glowMapMergeVertexShader: {
  51234. name: string;
  51235. shader: string;
  51236. };
  51237. }
  51238. declare module "babylonjs/Layers/glowLayer" {
  51239. import { Nullable } from "babylonjs/types";
  51240. import { Camera } from "babylonjs/Cameras/camera";
  51241. import { Scene } from "babylonjs/scene";
  51242. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51243. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51244. import { Mesh } from "babylonjs/Meshes/mesh";
  51245. import { Texture } from "babylonjs/Materials/Textures/texture";
  51246. import { Effect } from "babylonjs/Materials/effect";
  51247. import { Material } from "babylonjs/Materials/material";
  51248. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51249. import { Color4 } from "babylonjs/Maths/math.color";
  51250. import "babylonjs/Shaders/glowMapMerge.fragment";
  51251. import "babylonjs/Shaders/glowMapMerge.vertex";
  51252. import "babylonjs/Layers/effectLayerSceneComponent";
  51253. module "babylonjs/abstractScene" {
  51254. interface AbstractScene {
  51255. /**
  51256. * Return a the first highlight layer of the scene with a given name.
  51257. * @param name The name of the highlight layer to look for.
  51258. * @return The highlight layer if found otherwise null.
  51259. */
  51260. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  51261. }
  51262. }
  51263. /**
  51264. * Glow layer options. This helps customizing the behaviour
  51265. * of the glow layer.
  51266. */
  51267. export interface IGlowLayerOptions {
  51268. /**
  51269. * Multiplication factor apply to the canvas size to compute the render target size
  51270. * used to generated the glowing objects (the smaller the faster).
  51271. */
  51272. mainTextureRatio: number;
  51273. /**
  51274. * Enforces a fixed size texture to ensure resize independant blur.
  51275. */
  51276. mainTextureFixedSize?: number;
  51277. /**
  51278. * How big is the kernel of the blur texture.
  51279. */
  51280. blurKernelSize: number;
  51281. /**
  51282. * The camera attached to the layer.
  51283. */
  51284. camera: Nullable<Camera>;
  51285. /**
  51286. * Enable MSAA by chosing the number of samples.
  51287. */
  51288. mainTextureSamples?: number;
  51289. /**
  51290. * The rendering group to draw the layer in.
  51291. */
  51292. renderingGroupId: number;
  51293. }
  51294. /**
  51295. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  51296. *
  51297. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  51298. * glowy meshes to your scene.
  51299. *
  51300. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  51301. */
  51302. export class GlowLayer extends EffectLayer {
  51303. /**
  51304. * Effect Name of the layer.
  51305. */
  51306. static readonly EffectName: string;
  51307. /**
  51308. * The default blur kernel size used for the glow.
  51309. */
  51310. static DefaultBlurKernelSize: number;
  51311. /**
  51312. * The default texture size ratio used for the glow.
  51313. */
  51314. static DefaultTextureRatio: number;
  51315. /**
  51316. * Sets the kernel size of the blur.
  51317. */
  51318. /**
  51319. * Gets the kernel size of the blur.
  51320. */
  51321. blurKernelSize: number;
  51322. /**
  51323. * Sets the glow intensity.
  51324. */
  51325. /**
  51326. * Gets the glow intensity.
  51327. */
  51328. intensity: number;
  51329. private _options;
  51330. private _intensity;
  51331. private _horizontalBlurPostprocess1;
  51332. private _verticalBlurPostprocess1;
  51333. private _horizontalBlurPostprocess2;
  51334. private _verticalBlurPostprocess2;
  51335. private _blurTexture1;
  51336. private _blurTexture2;
  51337. private _postProcesses1;
  51338. private _postProcesses2;
  51339. private _includedOnlyMeshes;
  51340. private _excludedMeshes;
  51341. /**
  51342. * Callback used to let the user override the color selection on a per mesh basis
  51343. */
  51344. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  51345. /**
  51346. * Callback used to let the user override the texture selection on a per mesh basis
  51347. */
  51348. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  51349. /**
  51350. * Instantiates a new glow Layer and references it to the scene.
  51351. * @param name The name of the layer
  51352. * @param scene The scene to use the layer in
  51353. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  51354. */
  51355. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  51356. /**
  51357. * Get the effect name of the layer.
  51358. * @return The effect name
  51359. */
  51360. getEffectName(): string;
  51361. /**
  51362. * Create the merge effect. This is the shader use to blit the information back
  51363. * to the main canvas at the end of the scene rendering.
  51364. */
  51365. protected _createMergeEffect(): Effect;
  51366. /**
  51367. * Creates the render target textures and post processes used in the glow layer.
  51368. */
  51369. protected _createTextureAndPostProcesses(): void;
  51370. /**
  51371. * Checks for the readiness of the element composing the layer.
  51372. * @param subMesh the mesh to check for
  51373. * @param useInstances specify wether or not to use instances to render the mesh
  51374. * @param emissiveTexture the associated emissive texture used to generate the glow
  51375. * @return true if ready otherwise, false
  51376. */
  51377. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51378. /**
  51379. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51380. */
  51381. needStencil(): boolean;
  51382. /**
  51383. * Returns true if the mesh can be rendered, otherwise false.
  51384. * @param mesh The mesh to render
  51385. * @param material The material used on the mesh
  51386. * @returns true if it can be rendered otherwise false
  51387. */
  51388. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51389. /**
  51390. * Implementation specific of rendering the generating effect on the main canvas.
  51391. * @param effect The effect used to render through
  51392. */
  51393. protected _internalRender(effect: Effect): void;
  51394. /**
  51395. * Sets the required values for both the emissive texture and and the main color.
  51396. */
  51397. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51398. /**
  51399. * Returns true if the mesh should render, otherwise false.
  51400. * @param mesh The mesh to render
  51401. * @returns true if it should render otherwise false
  51402. */
  51403. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51404. /**
  51405. * Adds specific effects defines.
  51406. * @param defines The defines to add specifics to.
  51407. */
  51408. protected _addCustomEffectDefines(defines: string[]): void;
  51409. /**
  51410. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  51411. * @param mesh The mesh to exclude from the glow layer
  51412. */
  51413. addExcludedMesh(mesh: Mesh): void;
  51414. /**
  51415. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  51416. * @param mesh The mesh to remove
  51417. */
  51418. removeExcludedMesh(mesh: Mesh): void;
  51419. /**
  51420. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  51421. * @param mesh The mesh to include in the glow layer
  51422. */
  51423. addIncludedOnlyMesh(mesh: Mesh): void;
  51424. /**
  51425. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  51426. * @param mesh The mesh to remove
  51427. */
  51428. removeIncludedOnlyMesh(mesh: Mesh): void;
  51429. /**
  51430. * Determine if a given mesh will be used in the glow layer
  51431. * @param mesh The mesh to test
  51432. * @returns true if the mesh will be highlighted by the current glow layer
  51433. */
  51434. hasMesh(mesh: AbstractMesh): boolean;
  51435. /**
  51436. * Free any resources and references associated to a mesh.
  51437. * Internal use
  51438. * @param mesh The mesh to free.
  51439. * @hidden
  51440. */
  51441. _disposeMesh(mesh: Mesh): void;
  51442. /**
  51443. * Gets the class name of the effect layer
  51444. * @returns the string with the class name of the effect layer
  51445. */
  51446. getClassName(): string;
  51447. /**
  51448. * Serializes this glow layer
  51449. * @returns a serialized glow layer object
  51450. */
  51451. serialize(): any;
  51452. /**
  51453. * Creates a Glow Layer from parsed glow layer data
  51454. * @param parsedGlowLayer defines glow layer data
  51455. * @param scene defines the current scene
  51456. * @param rootUrl defines the root URL containing the glow layer information
  51457. * @returns a parsed Glow Layer
  51458. */
  51459. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  51460. }
  51461. }
  51462. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  51463. /** @hidden */
  51464. export var glowBlurPostProcessPixelShader: {
  51465. name: string;
  51466. shader: string;
  51467. };
  51468. }
  51469. declare module "babylonjs/Layers/highlightLayer" {
  51470. import { Observable } from "babylonjs/Misc/observable";
  51471. import { Nullable } from "babylonjs/types";
  51472. import { Camera } from "babylonjs/Cameras/camera";
  51473. import { Scene } from "babylonjs/scene";
  51474. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51475. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51476. import { Mesh } from "babylonjs/Meshes/mesh";
  51477. import { Effect } from "babylonjs/Materials/effect";
  51478. import { Material } from "babylonjs/Materials/material";
  51479. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51480. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  51481. import "babylonjs/Shaders/glowMapMerge.fragment";
  51482. import "babylonjs/Shaders/glowMapMerge.vertex";
  51483. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  51484. module "babylonjs/abstractScene" {
  51485. interface AbstractScene {
  51486. /**
  51487. * Return a the first highlight layer of the scene with a given name.
  51488. * @param name The name of the highlight layer to look for.
  51489. * @return The highlight layer if found otherwise null.
  51490. */
  51491. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  51492. }
  51493. }
  51494. /**
  51495. * Highlight layer options. This helps customizing the behaviour
  51496. * of the highlight layer.
  51497. */
  51498. export interface IHighlightLayerOptions {
  51499. /**
  51500. * Multiplication factor apply to the canvas size to compute the render target size
  51501. * used to generated the glowing objects (the smaller the faster).
  51502. */
  51503. mainTextureRatio: number;
  51504. /**
  51505. * Enforces a fixed size texture to ensure resize independant blur.
  51506. */
  51507. mainTextureFixedSize?: number;
  51508. /**
  51509. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  51510. * of the picture to blur (the smaller the faster).
  51511. */
  51512. blurTextureSizeRatio: number;
  51513. /**
  51514. * How big in texel of the blur texture is the vertical blur.
  51515. */
  51516. blurVerticalSize: number;
  51517. /**
  51518. * How big in texel of the blur texture is the horizontal blur.
  51519. */
  51520. blurHorizontalSize: number;
  51521. /**
  51522. * Alpha blending mode used to apply the blur. Default is combine.
  51523. */
  51524. alphaBlendingMode: number;
  51525. /**
  51526. * The camera attached to the layer.
  51527. */
  51528. camera: Nullable<Camera>;
  51529. /**
  51530. * Should we display highlight as a solid stroke?
  51531. */
  51532. isStroke?: boolean;
  51533. /**
  51534. * The rendering group to draw the layer in.
  51535. */
  51536. renderingGroupId: number;
  51537. }
  51538. /**
  51539. * The highlight layer Helps adding a glow effect around a mesh.
  51540. *
  51541. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  51542. * glowy meshes to your scene.
  51543. *
  51544. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  51545. */
  51546. export class HighlightLayer extends EffectLayer {
  51547. name: string;
  51548. /**
  51549. * Effect Name of the highlight layer.
  51550. */
  51551. static readonly EffectName: string;
  51552. /**
  51553. * The neutral color used during the preparation of the glow effect.
  51554. * This is black by default as the blend operation is a blend operation.
  51555. */
  51556. static NeutralColor: Color4;
  51557. /**
  51558. * Stencil value used for glowing meshes.
  51559. */
  51560. static GlowingMeshStencilReference: number;
  51561. /**
  51562. * Stencil value used for the other meshes in the scene.
  51563. */
  51564. static NormalMeshStencilReference: number;
  51565. /**
  51566. * Specifies whether or not the inner glow is ACTIVE in the layer.
  51567. */
  51568. innerGlow: boolean;
  51569. /**
  51570. * Specifies whether or not the outer glow is ACTIVE in the layer.
  51571. */
  51572. outerGlow: boolean;
  51573. /**
  51574. * Specifies the horizontal size of the blur.
  51575. */
  51576. /**
  51577. * Gets the horizontal size of the blur.
  51578. */
  51579. blurHorizontalSize: number;
  51580. /**
  51581. * Specifies the vertical size of the blur.
  51582. */
  51583. /**
  51584. * Gets the vertical size of the blur.
  51585. */
  51586. blurVerticalSize: number;
  51587. /**
  51588. * An event triggered when the highlight layer is being blurred.
  51589. */
  51590. onBeforeBlurObservable: Observable<HighlightLayer>;
  51591. /**
  51592. * An event triggered when the highlight layer has been blurred.
  51593. */
  51594. onAfterBlurObservable: Observable<HighlightLayer>;
  51595. private _instanceGlowingMeshStencilReference;
  51596. private _options;
  51597. private _downSamplePostprocess;
  51598. private _horizontalBlurPostprocess;
  51599. private _verticalBlurPostprocess;
  51600. private _blurTexture;
  51601. private _meshes;
  51602. private _excludedMeshes;
  51603. /**
  51604. * Instantiates a new highlight Layer and references it to the scene..
  51605. * @param name The name of the layer
  51606. * @param scene The scene to use the layer in
  51607. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  51608. */
  51609. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  51610. /**
  51611. * Get the effect name of the layer.
  51612. * @return The effect name
  51613. */
  51614. getEffectName(): string;
  51615. /**
  51616. * Create the merge effect. This is the shader use to blit the information back
  51617. * to the main canvas at the end of the scene rendering.
  51618. */
  51619. protected _createMergeEffect(): Effect;
  51620. /**
  51621. * Creates the render target textures and post processes used in the highlight layer.
  51622. */
  51623. protected _createTextureAndPostProcesses(): void;
  51624. /**
  51625. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51626. */
  51627. needStencil(): boolean;
  51628. /**
  51629. * Checks for the readiness of the element composing the layer.
  51630. * @param subMesh the mesh to check for
  51631. * @param useInstances specify wether or not to use instances to render the mesh
  51632. * @param emissiveTexture the associated emissive texture used to generate the glow
  51633. * @return true if ready otherwise, false
  51634. */
  51635. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51636. /**
  51637. * Implementation specific of rendering the generating effect on the main canvas.
  51638. * @param effect The effect used to render through
  51639. */
  51640. protected _internalRender(effect: Effect): void;
  51641. /**
  51642. * Returns true if the layer contains information to display, otherwise false.
  51643. */
  51644. shouldRender(): boolean;
  51645. /**
  51646. * Returns true if the mesh should render, otherwise false.
  51647. * @param mesh The mesh to render
  51648. * @returns true if it should render otherwise false
  51649. */
  51650. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51651. /**
  51652. * Sets the required values for both the emissive texture and and the main color.
  51653. */
  51654. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51655. /**
  51656. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  51657. * @param mesh The mesh to exclude from the highlight layer
  51658. */
  51659. addExcludedMesh(mesh: Mesh): void;
  51660. /**
  51661. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  51662. * @param mesh The mesh to highlight
  51663. */
  51664. removeExcludedMesh(mesh: Mesh): void;
  51665. /**
  51666. * Determine if a given mesh will be highlighted by the current HighlightLayer
  51667. * @param mesh mesh to test
  51668. * @returns true if the mesh will be highlighted by the current HighlightLayer
  51669. */
  51670. hasMesh(mesh: AbstractMesh): boolean;
  51671. /**
  51672. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  51673. * @param mesh The mesh to highlight
  51674. * @param color The color of the highlight
  51675. * @param glowEmissiveOnly Extract the glow from the emissive texture
  51676. */
  51677. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  51678. /**
  51679. * Remove a mesh from the highlight layer in order to make it stop glowing.
  51680. * @param mesh The mesh to highlight
  51681. */
  51682. removeMesh(mesh: Mesh): void;
  51683. /**
  51684. * Force the stencil to the normal expected value for none glowing parts
  51685. */
  51686. private _defaultStencilReference;
  51687. /**
  51688. * Free any resources and references associated to a mesh.
  51689. * Internal use
  51690. * @param mesh The mesh to free.
  51691. * @hidden
  51692. */
  51693. _disposeMesh(mesh: Mesh): void;
  51694. /**
  51695. * Dispose the highlight layer and free resources.
  51696. */
  51697. dispose(): void;
  51698. /**
  51699. * Gets the class name of the effect layer
  51700. * @returns the string with the class name of the effect layer
  51701. */
  51702. getClassName(): string;
  51703. /**
  51704. * Serializes this Highlight layer
  51705. * @returns a serialized Highlight layer object
  51706. */
  51707. serialize(): any;
  51708. /**
  51709. * Creates a Highlight layer from parsed Highlight layer data
  51710. * @param parsedHightlightLayer defines the Highlight layer data
  51711. * @param scene defines the current scene
  51712. * @param rootUrl defines the root URL containing the Highlight layer information
  51713. * @returns a parsed Highlight layer
  51714. */
  51715. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  51716. }
  51717. }
  51718. declare module "babylonjs/Layers/layerSceneComponent" {
  51719. import { Scene } from "babylonjs/scene";
  51720. import { ISceneComponent } from "babylonjs/sceneComponent";
  51721. import { Layer } from "babylonjs/Layers/layer";
  51722. import { AbstractScene } from "babylonjs/abstractScene";
  51723. module "babylonjs/abstractScene" {
  51724. interface AbstractScene {
  51725. /**
  51726. * The list of layers (background and foreground) of the scene
  51727. */
  51728. layers: Array<Layer>;
  51729. }
  51730. }
  51731. /**
  51732. * Defines the layer scene component responsible to manage any layers
  51733. * in a given scene.
  51734. */
  51735. export class LayerSceneComponent implements ISceneComponent {
  51736. /**
  51737. * The component name helpfull to identify the component in the list of scene components.
  51738. */
  51739. readonly name: string;
  51740. /**
  51741. * The scene the component belongs to.
  51742. */
  51743. scene: Scene;
  51744. private _engine;
  51745. /**
  51746. * Creates a new instance of the component for the given scene
  51747. * @param scene Defines the scene to register the component in
  51748. */
  51749. constructor(scene: Scene);
  51750. /**
  51751. * Registers the component in a given scene
  51752. */
  51753. register(): void;
  51754. /**
  51755. * Rebuilds the elements related to this component in case of
  51756. * context lost for instance.
  51757. */
  51758. rebuild(): void;
  51759. /**
  51760. * Disposes the component and the associated ressources.
  51761. */
  51762. dispose(): void;
  51763. private _draw;
  51764. private _drawCameraPredicate;
  51765. private _drawCameraBackground;
  51766. private _drawCameraForeground;
  51767. private _drawRenderTargetPredicate;
  51768. private _drawRenderTargetBackground;
  51769. private _drawRenderTargetForeground;
  51770. /**
  51771. * Adds all the elements from the container to the scene
  51772. * @param container the container holding the elements
  51773. */
  51774. addFromContainer(container: AbstractScene): void;
  51775. /**
  51776. * Removes all the elements in the container from the scene
  51777. * @param container contains the elements to remove
  51778. * @param dispose if the removed element should be disposed (default: false)
  51779. */
  51780. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51781. }
  51782. }
  51783. declare module "babylonjs/Shaders/layer.fragment" {
  51784. /** @hidden */
  51785. export var layerPixelShader: {
  51786. name: string;
  51787. shader: string;
  51788. };
  51789. }
  51790. declare module "babylonjs/Shaders/layer.vertex" {
  51791. /** @hidden */
  51792. export var layerVertexShader: {
  51793. name: string;
  51794. shader: string;
  51795. };
  51796. }
  51797. declare module "babylonjs/Layers/layer" {
  51798. import { Observable } from "babylonjs/Misc/observable";
  51799. import { Nullable } from "babylonjs/types";
  51800. import { Scene } from "babylonjs/scene";
  51801. import { Vector2 } from "babylonjs/Maths/math.vector";
  51802. import { Color4 } from "babylonjs/Maths/math.color";
  51803. import { Texture } from "babylonjs/Materials/Textures/texture";
  51804. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51805. import "babylonjs/Shaders/layer.fragment";
  51806. import "babylonjs/Shaders/layer.vertex";
  51807. /**
  51808. * This represents a full screen 2d layer.
  51809. * This can be useful to display a picture in the background of your scene for instance.
  51810. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51811. */
  51812. export class Layer {
  51813. /**
  51814. * Define the name of the layer.
  51815. */
  51816. name: string;
  51817. /**
  51818. * Define the texture the layer should display.
  51819. */
  51820. texture: Nullable<Texture>;
  51821. /**
  51822. * Is the layer in background or foreground.
  51823. */
  51824. isBackground: boolean;
  51825. /**
  51826. * Define the color of the layer (instead of texture).
  51827. */
  51828. color: Color4;
  51829. /**
  51830. * Define the scale of the layer in order to zoom in out of the texture.
  51831. */
  51832. scale: Vector2;
  51833. /**
  51834. * Define an offset for the layer in order to shift the texture.
  51835. */
  51836. offset: Vector2;
  51837. /**
  51838. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  51839. */
  51840. alphaBlendingMode: number;
  51841. /**
  51842. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  51843. * Alpha test will not mix with the background color in case of transparency.
  51844. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  51845. */
  51846. alphaTest: boolean;
  51847. /**
  51848. * Define a mask to restrict the layer to only some of the scene cameras.
  51849. */
  51850. layerMask: number;
  51851. /**
  51852. * Define the list of render target the layer is visible into.
  51853. */
  51854. renderTargetTextures: RenderTargetTexture[];
  51855. /**
  51856. * Define if the layer is only used in renderTarget or if it also
  51857. * renders in the main frame buffer of the canvas.
  51858. */
  51859. renderOnlyInRenderTargetTextures: boolean;
  51860. private _scene;
  51861. private _vertexBuffers;
  51862. private _indexBuffer;
  51863. private _effect;
  51864. private _alphaTestEffect;
  51865. /**
  51866. * An event triggered when the layer is disposed.
  51867. */
  51868. onDisposeObservable: Observable<Layer>;
  51869. private _onDisposeObserver;
  51870. /**
  51871. * Back compatibility with callback before the onDisposeObservable existed.
  51872. * The set callback will be triggered when the layer has been disposed.
  51873. */
  51874. onDispose: () => void;
  51875. /**
  51876. * An event triggered before rendering the scene
  51877. */
  51878. onBeforeRenderObservable: Observable<Layer>;
  51879. private _onBeforeRenderObserver;
  51880. /**
  51881. * Back compatibility with callback before the onBeforeRenderObservable existed.
  51882. * The set callback will be triggered just before rendering the layer.
  51883. */
  51884. onBeforeRender: () => void;
  51885. /**
  51886. * An event triggered after rendering the scene
  51887. */
  51888. onAfterRenderObservable: Observable<Layer>;
  51889. private _onAfterRenderObserver;
  51890. /**
  51891. * Back compatibility with callback before the onAfterRenderObservable existed.
  51892. * The set callback will be triggered just after rendering the layer.
  51893. */
  51894. onAfterRender: () => void;
  51895. /**
  51896. * Instantiates a new layer.
  51897. * This represents a full screen 2d layer.
  51898. * This can be useful to display a picture in the background of your scene for instance.
  51899. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51900. * @param name Define the name of the layer in the scene
  51901. * @param imgUrl Define the url of the texture to display in the layer
  51902. * @param scene Define the scene the layer belongs to
  51903. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  51904. * @param color Defines a color for the layer
  51905. */
  51906. constructor(
  51907. /**
  51908. * Define the name of the layer.
  51909. */
  51910. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  51911. private _createIndexBuffer;
  51912. /** @hidden */
  51913. _rebuild(): void;
  51914. /**
  51915. * Renders the layer in the scene.
  51916. */
  51917. render(): void;
  51918. /**
  51919. * Disposes and releases the associated ressources.
  51920. */
  51921. dispose(): void;
  51922. }
  51923. }
  51924. declare module "babylonjs/Layers/index" {
  51925. export * from "babylonjs/Layers/effectLayer";
  51926. export * from "babylonjs/Layers/effectLayerSceneComponent";
  51927. export * from "babylonjs/Layers/glowLayer";
  51928. export * from "babylonjs/Layers/highlightLayer";
  51929. export * from "babylonjs/Layers/layer";
  51930. export * from "babylonjs/Layers/layerSceneComponent";
  51931. }
  51932. declare module "babylonjs/Shaders/lensFlare.fragment" {
  51933. /** @hidden */
  51934. export var lensFlarePixelShader: {
  51935. name: string;
  51936. shader: string;
  51937. };
  51938. }
  51939. declare module "babylonjs/Shaders/lensFlare.vertex" {
  51940. /** @hidden */
  51941. export var lensFlareVertexShader: {
  51942. name: string;
  51943. shader: string;
  51944. };
  51945. }
  51946. declare module "babylonjs/LensFlares/lensFlareSystem" {
  51947. import { Scene } from "babylonjs/scene";
  51948. import { Vector3 } from "babylonjs/Maths/math.vector";
  51949. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51950. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  51951. import "babylonjs/Shaders/lensFlare.fragment";
  51952. import "babylonjs/Shaders/lensFlare.vertex";
  51953. import { Viewport } from "babylonjs/Maths/math.viewport";
  51954. /**
  51955. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51956. * It is usually composed of several `lensFlare`.
  51957. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51958. */
  51959. export class LensFlareSystem {
  51960. /**
  51961. * Define the name of the lens flare system
  51962. */
  51963. name: string;
  51964. /**
  51965. * List of lens flares used in this system.
  51966. */
  51967. lensFlares: LensFlare[];
  51968. /**
  51969. * Define a limit from the border the lens flare can be visible.
  51970. */
  51971. borderLimit: number;
  51972. /**
  51973. * Define a viewport border we do not want to see the lens flare in.
  51974. */
  51975. viewportBorder: number;
  51976. /**
  51977. * Define a predicate which could limit the list of meshes able to occlude the effect.
  51978. */
  51979. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51980. /**
  51981. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  51982. */
  51983. layerMask: number;
  51984. /**
  51985. * Define the id of the lens flare system in the scene.
  51986. * (equal to name by default)
  51987. */
  51988. id: string;
  51989. private _scene;
  51990. private _emitter;
  51991. private _vertexBuffers;
  51992. private _indexBuffer;
  51993. private _effect;
  51994. private _positionX;
  51995. private _positionY;
  51996. private _isEnabled;
  51997. /** @hidden */
  51998. static _SceneComponentInitialization: (scene: Scene) => void;
  51999. /**
  52000. * Instantiates a lens flare system.
  52001. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52002. * It is usually composed of several `lensFlare`.
  52003. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52004. * @param name Define the name of the lens flare system in the scene
  52005. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  52006. * @param scene Define the scene the lens flare system belongs to
  52007. */
  52008. constructor(
  52009. /**
  52010. * Define the name of the lens flare system
  52011. */
  52012. name: string, emitter: any, scene: Scene);
  52013. /**
  52014. * Define if the lens flare system is enabled.
  52015. */
  52016. isEnabled: boolean;
  52017. /**
  52018. * Get the scene the effects belongs to.
  52019. * @returns the scene holding the lens flare system
  52020. */
  52021. getScene(): Scene;
  52022. /**
  52023. * Get the emitter of the lens flare system.
  52024. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52025. * @returns the emitter of the lens flare system
  52026. */
  52027. getEmitter(): any;
  52028. /**
  52029. * Set the emitter of the lens flare system.
  52030. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52031. * @param newEmitter Define the new emitter of the system
  52032. */
  52033. setEmitter(newEmitter: any): void;
  52034. /**
  52035. * Get the lens flare system emitter position.
  52036. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  52037. * @returns the position
  52038. */
  52039. getEmitterPosition(): Vector3;
  52040. /**
  52041. * @hidden
  52042. */
  52043. computeEffectivePosition(globalViewport: Viewport): boolean;
  52044. /** @hidden */
  52045. _isVisible(): boolean;
  52046. /**
  52047. * @hidden
  52048. */
  52049. render(): boolean;
  52050. /**
  52051. * Dispose and release the lens flare with its associated resources.
  52052. */
  52053. dispose(): void;
  52054. /**
  52055. * Parse a lens flare system from a JSON repressentation
  52056. * @param parsedLensFlareSystem Define the JSON to parse
  52057. * @param scene Define the scene the parsed system should be instantiated in
  52058. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  52059. * @returns the parsed system
  52060. */
  52061. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  52062. /**
  52063. * Serialize the current Lens Flare System into a JSON representation.
  52064. * @returns the serialized JSON
  52065. */
  52066. serialize(): any;
  52067. }
  52068. }
  52069. declare module "babylonjs/LensFlares/lensFlare" {
  52070. import { Nullable } from "babylonjs/types";
  52071. import { Color3 } from "babylonjs/Maths/math.color";
  52072. import { Texture } from "babylonjs/Materials/Textures/texture";
  52073. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52074. /**
  52075. * This represents one of the lens effect in a `lensFlareSystem`.
  52076. * It controls one of the indiviual texture used in the effect.
  52077. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52078. */
  52079. export class LensFlare {
  52080. /**
  52081. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52082. */
  52083. size: number;
  52084. /**
  52085. * 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.
  52086. */
  52087. position: number;
  52088. /**
  52089. * Define the lens color.
  52090. */
  52091. color: Color3;
  52092. /**
  52093. * Define the lens texture.
  52094. */
  52095. texture: Nullable<Texture>;
  52096. /**
  52097. * Define the alpha mode to render this particular lens.
  52098. */
  52099. alphaMode: number;
  52100. private _system;
  52101. /**
  52102. * Creates a new Lens Flare.
  52103. * This represents one of the lens effect in a `lensFlareSystem`.
  52104. * It controls one of the indiviual texture used in the effect.
  52105. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52106. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  52107. * @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.
  52108. * @param color Define the lens color
  52109. * @param imgUrl Define the lens texture url
  52110. * @param system Define the `lensFlareSystem` this flare is part of
  52111. * @returns The newly created Lens Flare
  52112. */
  52113. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  52114. /**
  52115. * Instantiates a new Lens Flare.
  52116. * This represents one of the lens effect in a `lensFlareSystem`.
  52117. * It controls one of the indiviual texture used in the effect.
  52118. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52119. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  52120. * @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.
  52121. * @param color Define the lens color
  52122. * @param imgUrl Define the lens texture url
  52123. * @param system Define the `lensFlareSystem` this flare is part of
  52124. */
  52125. constructor(
  52126. /**
  52127. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52128. */
  52129. size: number,
  52130. /**
  52131. * 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.
  52132. */
  52133. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  52134. /**
  52135. * Dispose and release the lens flare with its associated resources.
  52136. */
  52137. dispose(): void;
  52138. }
  52139. }
  52140. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  52141. import { Nullable } from "babylonjs/types";
  52142. import { Scene } from "babylonjs/scene";
  52143. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52144. import { AbstractScene } from "babylonjs/abstractScene";
  52145. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52146. module "babylonjs/abstractScene" {
  52147. interface AbstractScene {
  52148. /**
  52149. * The list of lens flare system added to the scene
  52150. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52151. */
  52152. lensFlareSystems: Array<LensFlareSystem>;
  52153. /**
  52154. * Removes the given lens flare system from this scene.
  52155. * @param toRemove The lens flare system to remove
  52156. * @returns The index of the removed lens flare system
  52157. */
  52158. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  52159. /**
  52160. * Adds the given lens flare system to this scene
  52161. * @param newLensFlareSystem The lens flare system to add
  52162. */
  52163. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  52164. /**
  52165. * Gets a lens flare system using its name
  52166. * @param name defines the name to look for
  52167. * @returns the lens flare system or null if not found
  52168. */
  52169. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  52170. /**
  52171. * Gets a lens flare system using its id
  52172. * @param id defines the id to look for
  52173. * @returns the lens flare system or null if not found
  52174. */
  52175. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  52176. }
  52177. }
  52178. /**
  52179. * Defines the lens flare scene component responsible to manage any lens flares
  52180. * in a given scene.
  52181. */
  52182. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  52183. /**
  52184. * The component name helpfull to identify the component in the list of scene components.
  52185. */
  52186. readonly name: string;
  52187. /**
  52188. * The scene the component belongs to.
  52189. */
  52190. scene: Scene;
  52191. /**
  52192. * Creates a new instance of the component for the given scene
  52193. * @param scene Defines the scene to register the component in
  52194. */
  52195. constructor(scene: Scene);
  52196. /**
  52197. * Registers the component in a given scene
  52198. */
  52199. register(): void;
  52200. /**
  52201. * Rebuilds the elements related to this component in case of
  52202. * context lost for instance.
  52203. */
  52204. rebuild(): void;
  52205. /**
  52206. * Adds all the elements from the container to the scene
  52207. * @param container the container holding the elements
  52208. */
  52209. addFromContainer(container: AbstractScene): void;
  52210. /**
  52211. * Removes all the elements in the container from the scene
  52212. * @param container contains the elements to remove
  52213. * @param dispose if the removed element should be disposed (default: false)
  52214. */
  52215. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52216. /**
  52217. * Serializes the component data to the specified json object
  52218. * @param serializationObject The object to serialize to
  52219. */
  52220. serialize(serializationObject: any): void;
  52221. /**
  52222. * Disposes the component and the associated ressources.
  52223. */
  52224. dispose(): void;
  52225. private _draw;
  52226. }
  52227. }
  52228. declare module "babylonjs/LensFlares/index" {
  52229. export * from "babylonjs/LensFlares/lensFlare";
  52230. export * from "babylonjs/LensFlares/lensFlareSystem";
  52231. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  52232. }
  52233. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  52234. import { Scene } from "babylonjs/scene";
  52235. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52236. import { AbstractScene } from "babylonjs/abstractScene";
  52237. /**
  52238. * Defines the shadow generator component responsible to manage any shadow generators
  52239. * in a given scene.
  52240. */
  52241. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  52242. /**
  52243. * The component name helpfull to identify the component in the list of scene components.
  52244. */
  52245. readonly name: string;
  52246. /**
  52247. * The scene the component belongs to.
  52248. */
  52249. scene: Scene;
  52250. /**
  52251. * Creates a new instance of the component for the given scene
  52252. * @param scene Defines the scene to register the component in
  52253. */
  52254. constructor(scene: Scene);
  52255. /**
  52256. * Registers the component in a given scene
  52257. */
  52258. register(): void;
  52259. /**
  52260. * Rebuilds the elements related to this component in case of
  52261. * context lost for instance.
  52262. */
  52263. rebuild(): void;
  52264. /**
  52265. * Serializes the component data to the specified json object
  52266. * @param serializationObject The object to serialize to
  52267. */
  52268. serialize(serializationObject: any): void;
  52269. /**
  52270. * Adds all the elements from the container to the scene
  52271. * @param container the container holding the elements
  52272. */
  52273. addFromContainer(container: AbstractScene): void;
  52274. /**
  52275. * Removes all the elements in the container from the scene
  52276. * @param container contains the elements to remove
  52277. * @param dispose if the removed element should be disposed (default: false)
  52278. */
  52279. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52280. /**
  52281. * Rebuilds the elements related to this component in case of
  52282. * context lost for instance.
  52283. */
  52284. dispose(): void;
  52285. private _gatherRenderTargets;
  52286. }
  52287. }
  52288. declare module "babylonjs/Lights/Shadows/index" {
  52289. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  52290. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  52291. }
  52292. declare module "babylonjs/Lights/pointLight" {
  52293. import { Scene } from "babylonjs/scene";
  52294. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52295. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52296. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  52297. import { Effect } from "babylonjs/Materials/effect";
  52298. /**
  52299. * A point light is a light defined by an unique point in world space.
  52300. * The light is emitted in every direction from this point.
  52301. * A good example of a point light is a standard light bulb.
  52302. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52303. */
  52304. export class PointLight extends ShadowLight {
  52305. private _shadowAngle;
  52306. /**
  52307. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52308. * This specifies what angle the shadow will use to be created.
  52309. *
  52310. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52311. */
  52312. /**
  52313. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52314. * This specifies what angle the shadow will use to be created.
  52315. *
  52316. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52317. */
  52318. shadowAngle: number;
  52319. /**
  52320. * Gets the direction if it has been set.
  52321. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52322. */
  52323. /**
  52324. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52325. */
  52326. direction: Vector3;
  52327. /**
  52328. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  52329. * A PointLight emits the light in every direction.
  52330. * It can cast shadows.
  52331. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  52332. * ```javascript
  52333. * var pointLight = new PointLight("pl", camera.position, scene);
  52334. * ```
  52335. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52336. * @param name The light friendly name
  52337. * @param position The position of the point light in the scene
  52338. * @param scene The scene the lights belongs to
  52339. */
  52340. constructor(name: string, position: Vector3, scene: Scene);
  52341. /**
  52342. * Returns the string "PointLight"
  52343. * @returns the class name
  52344. */
  52345. getClassName(): string;
  52346. /**
  52347. * Returns the integer 0.
  52348. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52349. */
  52350. getTypeID(): number;
  52351. /**
  52352. * Specifies wether or not the shadowmap should be a cube texture.
  52353. * @returns true if the shadowmap needs to be a cube texture.
  52354. */
  52355. needCube(): boolean;
  52356. /**
  52357. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  52358. * @param faceIndex The index of the face we are computed the direction to generate shadow
  52359. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  52360. */
  52361. getShadowDirection(faceIndex?: number): Vector3;
  52362. /**
  52363. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  52364. * - fov = PI / 2
  52365. * - aspect ratio : 1.0
  52366. * - z-near and far equal to the active camera minZ and maxZ.
  52367. * Returns the PointLight.
  52368. */
  52369. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52370. protected _buildUniformLayout(): void;
  52371. /**
  52372. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  52373. * @param effect The effect to update
  52374. * @param lightIndex The index of the light in the effect to update
  52375. * @returns The point light
  52376. */
  52377. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  52378. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52379. /**
  52380. * Prepares the list of defines specific to the light type.
  52381. * @param defines the list of defines
  52382. * @param lightIndex defines the index of the light for the effect
  52383. */
  52384. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52385. }
  52386. }
  52387. declare module "babylonjs/Lights/index" {
  52388. export * from "babylonjs/Lights/light";
  52389. export * from "babylonjs/Lights/shadowLight";
  52390. export * from "babylonjs/Lights/Shadows/index";
  52391. export * from "babylonjs/Lights/directionalLight";
  52392. export * from "babylonjs/Lights/hemisphericLight";
  52393. export * from "babylonjs/Lights/pointLight";
  52394. export * from "babylonjs/Lights/spotLight";
  52395. }
  52396. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  52397. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  52398. /**
  52399. * Header information of HDR texture files.
  52400. */
  52401. export interface HDRInfo {
  52402. /**
  52403. * The height of the texture in pixels.
  52404. */
  52405. height: number;
  52406. /**
  52407. * The width of the texture in pixels.
  52408. */
  52409. width: number;
  52410. /**
  52411. * The index of the beginning of the data in the binary file.
  52412. */
  52413. dataPosition: number;
  52414. }
  52415. /**
  52416. * This groups tools to convert HDR texture to native colors array.
  52417. */
  52418. export class HDRTools {
  52419. private static Ldexp;
  52420. private static Rgbe2float;
  52421. private static readStringLine;
  52422. /**
  52423. * Reads header information from an RGBE texture stored in a native array.
  52424. * More information on this format are available here:
  52425. * https://en.wikipedia.org/wiki/RGBE_image_format
  52426. *
  52427. * @param uint8array The binary file stored in native array.
  52428. * @return The header information.
  52429. */
  52430. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  52431. /**
  52432. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  52433. * This RGBE texture needs to store the information as a panorama.
  52434. *
  52435. * More information on this format are available here:
  52436. * https://en.wikipedia.org/wiki/RGBE_image_format
  52437. *
  52438. * @param buffer The binary file stored in an array buffer.
  52439. * @param size The expected size of the extracted cubemap.
  52440. * @return The Cube Map information.
  52441. */
  52442. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  52443. /**
  52444. * Returns the pixels data extracted from an RGBE texture.
  52445. * This pixels will be stored left to right up to down in the R G B order in one array.
  52446. *
  52447. * More information on this format are available here:
  52448. * https://en.wikipedia.org/wiki/RGBE_image_format
  52449. *
  52450. * @param uint8array The binary file stored in an array buffer.
  52451. * @param hdrInfo The header information of the file.
  52452. * @return The pixels data in RGB right to left up to down order.
  52453. */
  52454. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  52455. private static RGBE_ReadPixels_RLE;
  52456. }
  52457. }
  52458. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  52459. import { Nullable } from "babylonjs/types";
  52460. import { Scene } from "babylonjs/scene";
  52461. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52462. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52463. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52464. /**
  52465. * This represents a texture coming from an HDR input.
  52466. *
  52467. * The only supported format is currently panorama picture stored in RGBE format.
  52468. * Example of such files can be found on HDRLib: http://hdrlib.com/
  52469. */
  52470. export class HDRCubeTexture extends BaseTexture {
  52471. private static _facesMapping;
  52472. private _generateHarmonics;
  52473. private _noMipmap;
  52474. private _textureMatrix;
  52475. private _size;
  52476. private _onLoad;
  52477. private _onError;
  52478. /**
  52479. * The texture URL.
  52480. */
  52481. url: string;
  52482. /**
  52483. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  52484. */
  52485. coordinatesMode: number;
  52486. protected _isBlocking: boolean;
  52487. /**
  52488. * Sets wether or not the texture is blocking during loading.
  52489. */
  52490. /**
  52491. * Gets wether or not the texture is blocking during loading.
  52492. */
  52493. isBlocking: boolean;
  52494. protected _rotationY: number;
  52495. /**
  52496. * Sets texture matrix rotation angle around Y axis in radians.
  52497. */
  52498. /**
  52499. * Gets texture matrix rotation angle around Y axis radians.
  52500. */
  52501. rotationY: number;
  52502. /**
  52503. * Gets or sets the center of the bounding box associated with the cube texture
  52504. * It must define where the camera used to render the texture was set
  52505. */
  52506. boundingBoxPosition: Vector3;
  52507. private _boundingBoxSize;
  52508. /**
  52509. * Gets or sets the size of the bounding box associated with the cube texture
  52510. * When defined, the cubemap will switch to local mode
  52511. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  52512. * @example https://www.babylonjs-playground.com/#RNASML
  52513. */
  52514. boundingBoxSize: Vector3;
  52515. /**
  52516. * Instantiates an HDRTexture from the following parameters.
  52517. *
  52518. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  52519. * @param scene The scene the texture will be used in
  52520. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52521. * @param noMipmap Forces to not generate the mipmap if true
  52522. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  52523. * @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)
  52524. * @param reserved Reserved flag for internal use.
  52525. */
  52526. 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>);
  52527. /**
  52528. * Get the current class name of the texture useful for serialization or dynamic coding.
  52529. * @returns "HDRCubeTexture"
  52530. */
  52531. getClassName(): string;
  52532. /**
  52533. * Occurs when the file is raw .hdr file.
  52534. */
  52535. private loadTexture;
  52536. clone(): HDRCubeTexture;
  52537. delayLoad(): void;
  52538. /**
  52539. * Get the texture reflection matrix used to rotate/transform the reflection.
  52540. * @returns the reflection matrix
  52541. */
  52542. getReflectionTextureMatrix(): Matrix;
  52543. /**
  52544. * Set the texture reflection matrix used to rotate/transform the reflection.
  52545. * @param value Define the reflection matrix to set
  52546. */
  52547. setReflectionTextureMatrix(value: Matrix): void;
  52548. /**
  52549. * Parses a JSON representation of an HDR Texture in order to create the texture
  52550. * @param parsedTexture Define the JSON representation
  52551. * @param scene Define the scene the texture should be created in
  52552. * @param rootUrl Define the root url in case we need to load relative dependencies
  52553. * @returns the newly created texture after parsing
  52554. */
  52555. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  52556. serialize(): any;
  52557. }
  52558. }
  52559. declare module "babylonjs/Physics/physicsEngine" {
  52560. import { Nullable } from "babylonjs/types";
  52561. import { Vector3 } from "babylonjs/Maths/math.vector";
  52562. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  52563. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  52564. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  52565. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52566. /**
  52567. * Class used to control physics engine
  52568. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  52569. */
  52570. export class PhysicsEngine implements IPhysicsEngine {
  52571. private _physicsPlugin;
  52572. /**
  52573. * Global value used to control the smallest number supported by the simulation
  52574. */
  52575. static Epsilon: number;
  52576. private _impostors;
  52577. private _joints;
  52578. /**
  52579. * Gets the gravity vector used by the simulation
  52580. */
  52581. gravity: Vector3;
  52582. /**
  52583. * Factory used to create the default physics plugin.
  52584. * @returns The default physics plugin
  52585. */
  52586. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  52587. /**
  52588. * Creates a new Physics Engine
  52589. * @param gravity defines the gravity vector used by the simulation
  52590. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  52591. */
  52592. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  52593. /**
  52594. * Sets the gravity vector used by the simulation
  52595. * @param gravity defines the gravity vector to use
  52596. */
  52597. setGravity(gravity: Vector3): void;
  52598. /**
  52599. * Set the time step of the physics engine.
  52600. * Default is 1/60.
  52601. * To slow it down, enter 1/600 for example.
  52602. * To speed it up, 1/30
  52603. * @param newTimeStep defines the new timestep to apply to this world.
  52604. */
  52605. setTimeStep(newTimeStep?: number): void;
  52606. /**
  52607. * Get the time step of the physics engine.
  52608. * @returns the current time step
  52609. */
  52610. getTimeStep(): number;
  52611. /**
  52612. * Release all resources
  52613. */
  52614. dispose(): void;
  52615. /**
  52616. * Gets the name of the current physics plugin
  52617. * @returns the name of the plugin
  52618. */
  52619. getPhysicsPluginName(): string;
  52620. /**
  52621. * Adding a new impostor for the impostor tracking.
  52622. * This will be done by the impostor itself.
  52623. * @param impostor the impostor to add
  52624. */
  52625. addImpostor(impostor: PhysicsImpostor): void;
  52626. /**
  52627. * Remove an impostor from the engine.
  52628. * This impostor and its mesh will not longer be updated by the physics engine.
  52629. * @param impostor the impostor to remove
  52630. */
  52631. removeImpostor(impostor: PhysicsImpostor): void;
  52632. /**
  52633. * Add a joint to the physics engine
  52634. * @param mainImpostor defines the main impostor to which the joint is added.
  52635. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  52636. * @param joint defines the joint that will connect both impostors.
  52637. */
  52638. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52639. /**
  52640. * Removes a joint from the simulation
  52641. * @param mainImpostor defines the impostor used with the joint
  52642. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  52643. * @param joint defines the joint to remove
  52644. */
  52645. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52646. /**
  52647. * Called by the scene. No need to call it.
  52648. * @param delta defines the timespam between frames
  52649. */
  52650. _step(delta: number): void;
  52651. /**
  52652. * Gets the current plugin used to run the simulation
  52653. * @returns current plugin
  52654. */
  52655. getPhysicsPlugin(): IPhysicsEnginePlugin;
  52656. /**
  52657. * Gets the list of physic impostors
  52658. * @returns an array of PhysicsImpostor
  52659. */
  52660. getImpostors(): Array<PhysicsImpostor>;
  52661. /**
  52662. * Gets the impostor for a physics enabled object
  52663. * @param object defines the object impersonated by the impostor
  52664. * @returns the PhysicsImpostor or null if not found
  52665. */
  52666. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  52667. /**
  52668. * Gets the impostor for a physics body object
  52669. * @param body defines physics body used by the impostor
  52670. * @returns the PhysicsImpostor or null if not found
  52671. */
  52672. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  52673. /**
  52674. * Does a raycast in the physics world
  52675. * @param from when should the ray start?
  52676. * @param to when should the ray end?
  52677. * @returns PhysicsRaycastResult
  52678. */
  52679. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52680. }
  52681. }
  52682. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  52683. import { Nullable } from "babylonjs/types";
  52684. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  52685. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52686. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52687. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52688. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52689. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52690. /** @hidden */
  52691. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  52692. private _useDeltaForWorldStep;
  52693. world: any;
  52694. name: string;
  52695. private _physicsMaterials;
  52696. private _fixedTimeStep;
  52697. private _cannonRaycastResult;
  52698. private _raycastResult;
  52699. private _physicsBodysToRemoveAfterStep;
  52700. BJSCANNON: any;
  52701. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  52702. setGravity(gravity: Vector3): void;
  52703. setTimeStep(timeStep: number): void;
  52704. getTimeStep(): number;
  52705. executeStep(delta: number): void;
  52706. private _removeMarkedPhysicsBodiesFromWorld;
  52707. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52708. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52709. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52710. private _processChildMeshes;
  52711. removePhysicsBody(impostor: PhysicsImpostor): void;
  52712. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52713. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52714. private _addMaterial;
  52715. private _checkWithEpsilon;
  52716. private _createShape;
  52717. private _createHeightmap;
  52718. private _minus90X;
  52719. private _plus90X;
  52720. private _tmpPosition;
  52721. private _tmpDeltaPosition;
  52722. private _tmpUnityRotation;
  52723. private _updatePhysicsBodyTransformation;
  52724. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52725. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52726. isSupported(): boolean;
  52727. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52728. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52729. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52730. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52731. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52732. getBodyMass(impostor: PhysicsImpostor): number;
  52733. getBodyFriction(impostor: PhysicsImpostor): number;
  52734. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52735. getBodyRestitution(impostor: PhysicsImpostor): number;
  52736. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52737. sleepBody(impostor: PhysicsImpostor): void;
  52738. wakeUpBody(impostor: PhysicsImpostor): void;
  52739. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  52740. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52741. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52742. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52743. getRadius(impostor: PhysicsImpostor): number;
  52744. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52745. dispose(): void;
  52746. private _extendNamespace;
  52747. /**
  52748. * Does a raycast in the physics world
  52749. * @param from when should the ray start?
  52750. * @param to when should the ray end?
  52751. * @returns PhysicsRaycastResult
  52752. */
  52753. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52754. }
  52755. }
  52756. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  52757. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52758. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52759. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52760. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52761. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  52762. import { Nullable } from "babylonjs/types";
  52763. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52764. /** @hidden */
  52765. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  52766. world: any;
  52767. name: string;
  52768. BJSOIMO: any;
  52769. private _raycastResult;
  52770. constructor(iterations?: number, oimoInjection?: any);
  52771. setGravity(gravity: Vector3): void;
  52772. setTimeStep(timeStep: number): void;
  52773. getTimeStep(): number;
  52774. private _tmpImpostorsArray;
  52775. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52776. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52777. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52778. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52779. private _tmpPositionVector;
  52780. removePhysicsBody(impostor: PhysicsImpostor): void;
  52781. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52782. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52783. isSupported(): boolean;
  52784. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52785. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52786. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52787. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52788. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52789. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52790. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52791. getBodyMass(impostor: PhysicsImpostor): number;
  52792. getBodyFriction(impostor: PhysicsImpostor): number;
  52793. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52794. getBodyRestitution(impostor: PhysicsImpostor): number;
  52795. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52796. sleepBody(impostor: PhysicsImpostor): void;
  52797. wakeUpBody(impostor: PhysicsImpostor): void;
  52798. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52799. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  52800. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  52801. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52802. getRadius(impostor: PhysicsImpostor): number;
  52803. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52804. dispose(): void;
  52805. /**
  52806. * Does a raycast in the physics world
  52807. * @param from when should the ray start?
  52808. * @param to when should the ray end?
  52809. * @returns PhysicsRaycastResult
  52810. */
  52811. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52812. }
  52813. }
  52814. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  52815. import { Nullable } from "babylonjs/types";
  52816. import { Scene } from "babylonjs/scene";
  52817. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  52818. import { Color4 } from "babylonjs/Maths/math.color";
  52819. import { Mesh } from "babylonjs/Meshes/mesh";
  52820. /**
  52821. * Class containing static functions to help procedurally build meshes
  52822. */
  52823. export class RibbonBuilder {
  52824. /**
  52825. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52826. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52827. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52828. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52829. * * 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
  52830. * * 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
  52831. * * 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
  52832. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52833. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52834. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52835. * * 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
  52836. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52837. * * 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
  52838. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52839. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52840. * @param name defines the name of the mesh
  52841. * @param options defines the options used to create the mesh
  52842. * @param scene defines the hosting scene
  52843. * @returns the ribbon mesh
  52844. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52845. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52846. */
  52847. static CreateRibbon(name: string, options: {
  52848. pathArray: Vector3[][];
  52849. closeArray?: boolean;
  52850. closePath?: boolean;
  52851. offset?: number;
  52852. updatable?: boolean;
  52853. sideOrientation?: number;
  52854. frontUVs?: Vector4;
  52855. backUVs?: Vector4;
  52856. instance?: Mesh;
  52857. invertUV?: boolean;
  52858. uvs?: Vector2[];
  52859. colors?: Color4[];
  52860. }, scene?: Nullable<Scene>): Mesh;
  52861. }
  52862. }
  52863. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  52864. import { Nullable } from "babylonjs/types";
  52865. import { Scene } from "babylonjs/scene";
  52866. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  52867. import { Mesh } from "babylonjs/Meshes/mesh";
  52868. /**
  52869. * Class containing static functions to help procedurally build meshes
  52870. */
  52871. export class ShapeBuilder {
  52872. /**
  52873. * 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.
  52874. * * 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.
  52875. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52876. * * 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.
  52877. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52878. * * 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
  52879. * * 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
  52880. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52881. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52882. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52883. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52884. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52885. * @param name defines the name of the mesh
  52886. * @param options defines the options used to create the mesh
  52887. * @param scene defines the hosting scene
  52888. * @returns the extruded shape mesh
  52889. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52890. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52891. */
  52892. static ExtrudeShape(name: string, options: {
  52893. shape: Vector3[];
  52894. path: Vector3[];
  52895. scale?: number;
  52896. rotation?: number;
  52897. cap?: number;
  52898. updatable?: boolean;
  52899. sideOrientation?: number;
  52900. frontUVs?: Vector4;
  52901. backUVs?: Vector4;
  52902. instance?: Mesh;
  52903. invertUV?: boolean;
  52904. }, scene?: Nullable<Scene>): Mesh;
  52905. /**
  52906. * Creates an custom extruded shape mesh.
  52907. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52908. * * 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.
  52909. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52910. * * 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
  52911. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52912. * * 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
  52913. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52914. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52915. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52916. * * 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
  52917. * * 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
  52918. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52919. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52920. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52921. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52922. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52923. * @param name defines the name of the mesh
  52924. * @param options defines the options used to create the mesh
  52925. * @param scene defines the hosting scene
  52926. * @returns the custom extruded shape mesh
  52927. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52928. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52929. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52930. */
  52931. static ExtrudeShapeCustom(name: string, options: {
  52932. shape: Vector3[];
  52933. path: Vector3[];
  52934. scaleFunction?: any;
  52935. rotationFunction?: any;
  52936. ribbonCloseArray?: boolean;
  52937. ribbonClosePath?: boolean;
  52938. cap?: number;
  52939. updatable?: boolean;
  52940. sideOrientation?: number;
  52941. frontUVs?: Vector4;
  52942. backUVs?: Vector4;
  52943. instance?: Mesh;
  52944. invertUV?: boolean;
  52945. }, scene?: Nullable<Scene>): Mesh;
  52946. private static _ExtrudeShapeGeneric;
  52947. }
  52948. }
  52949. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  52950. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  52951. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52952. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52953. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52954. import { Nullable } from "babylonjs/types";
  52955. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52956. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52957. /**
  52958. * AmmoJS Physics plugin
  52959. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52960. * @see https://github.com/kripken/ammo.js/
  52961. */
  52962. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  52963. private _useDeltaForWorldStep;
  52964. /**
  52965. * Reference to the Ammo library
  52966. */
  52967. bjsAMMO: any;
  52968. /**
  52969. * Created ammoJS world which physics bodies are added to
  52970. */
  52971. world: any;
  52972. /**
  52973. * Name of the plugin
  52974. */
  52975. name: string;
  52976. private _timeStep;
  52977. private _fixedTimeStep;
  52978. private _maxSteps;
  52979. private _tmpQuaternion;
  52980. private _tmpAmmoTransform;
  52981. private _tmpAmmoQuaternion;
  52982. private _tmpAmmoConcreteContactResultCallback;
  52983. private _collisionConfiguration;
  52984. private _dispatcher;
  52985. private _overlappingPairCache;
  52986. private _solver;
  52987. private _softBodySolver;
  52988. private _tmpAmmoVectorA;
  52989. private _tmpAmmoVectorB;
  52990. private _tmpAmmoVectorC;
  52991. private _tmpAmmoVectorD;
  52992. private _tmpContactCallbackResult;
  52993. private _tmpAmmoVectorRCA;
  52994. private _tmpAmmoVectorRCB;
  52995. private _raycastResult;
  52996. private static readonly DISABLE_COLLISION_FLAG;
  52997. private static readonly KINEMATIC_FLAG;
  52998. private static readonly DISABLE_DEACTIVATION_FLAG;
  52999. /**
  53000. * Initializes the ammoJS plugin
  53001. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  53002. * @param ammoInjection can be used to inject your own ammo reference
  53003. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  53004. */
  53005. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  53006. /**
  53007. * Sets the gravity of the physics world (m/(s^2))
  53008. * @param gravity Gravity to set
  53009. */
  53010. setGravity(gravity: Vector3): void;
  53011. /**
  53012. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  53013. * @param timeStep timestep to use in seconds
  53014. */
  53015. setTimeStep(timeStep: number): void;
  53016. /**
  53017. * 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)
  53018. * @param fixedTimeStep fixedTimeStep to use in seconds
  53019. */
  53020. setFixedTimeStep(fixedTimeStep: number): void;
  53021. /**
  53022. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  53023. * @param maxSteps the maximum number of steps by the physics engine per frame
  53024. */
  53025. setMaxSteps(maxSteps: number): void;
  53026. /**
  53027. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  53028. * @returns the current timestep in seconds
  53029. */
  53030. getTimeStep(): number;
  53031. private _isImpostorInContact;
  53032. private _isImpostorPairInContact;
  53033. private _stepSimulation;
  53034. /**
  53035. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  53036. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  53037. * After the step the babylon meshes are set to the position of the physics imposters
  53038. * @param delta amount of time to step forward
  53039. * @param impostors array of imposters to update before/after the step
  53040. */
  53041. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53042. /**
  53043. * Update babylon mesh to match physics world object
  53044. * @param impostor imposter to match
  53045. */
  53046. private _afterSoftStep;
  53047. /**
  53048. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53049. * @param impostor imposter to match
  53050. */
  53051. private _ropeStep;
  53052. /**
  53053. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53054. * @param impostor imposter to match
  53055. */
  53056. private _softbodyOrClothStep;
  53057. private _tmpVector;
  53058. private _tmpMatrix;
  53059. /**
  53060. * Applies an impulse on the imposter
  53061. * @param impostor imposter to apply impulse to
  53062. * @param force amount of force to be applied to the imposter
  53063. * @param contactPoint the location to apply the impulse on the imposter
  53064. */
  53065. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53066. /**
  53067. * Applies a force on the imposter
  53068. * @param impostor imposter to apply force
  53069. * @param force amount of force to be applied to the imposter
  53070. * @param contactPoint the location to apply the force on the imposter
  53071. */
  53072. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53073. /**
  53074. * Creates a physics body using the plugin
  53075. * @param impostor the imposter to create the physics body on
  53076. */
  53077. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53078. /**
  53079. * Removes the physics body from the imposter and disposes of the body's memory
  53080. * @param impostor imposter to remove the physics body from
  53081. */
  53082. removePhysicsBody(impostor: PhysicsImpostor): void;
  53083. /**
  53084. * Generates a joint
  53085. * @param impostorJoint the imposter joint to create the joint with
  53086. */
  53087. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53088. /**
  53089. * Removes a joint
  53090. * @param impostorJoint the imposter joint to remove the joint from
  53091. */
  53092. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53093. private _addMeshVerts;
  53094. /**
  53095. * Initialise the soft body vertices to match its object's (mesh) vertices
  53096. * Softbody vertices (nodes) are in world space and to match this
  53097. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  53098. * @param impostor to create the softbody for
  53099. */
  53100. private _softVertexData;
  53101. /**
  53102. * Create an impostor's soft body
  53103. * @param impostor to create the softbody for
  53104. */
  53105. private _createSoftbody;
  53106. /**
  53107. * Create cloth for an impostor
  53108. * @param impostor to create the softbody for
  53109. */
  53110. private _createCloth;
  53111. /**
  53112. * Create rope for an impostor
  53113. * @param impostor to create the softbody for
  53114. */
  53115. private _createRope;
  53116. private _addHullVerts;
  53117. private _createShape;
  53118. /**
  53119. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  53120. * @param impostor imposter containing the physics body and babylon object
  53121. */
  53122. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53123. /**
  53124. * Sets the babylon object's position/rotation from the physics body's position/rotation
  53125. * @param impostor imposter containing the physics body and babylon object
  53126. * @param newPosition new position
  53127. * @param newRotation new rotation
  53128. */
  53129. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53130. /**
  53131. * If this plugin is supported
  53132. * @returns true if its supported
  53133. */
  53134. isSupported(): boolean;
  53135. /**
  53136. * Sets the linear velocity of the physics body
  53137. * @param impostor imposter to set the velocity on
  53138. * @param velocity velocity to set
  53139. */
  53140. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53141. /**
  53142. * Sets the angular velocity of the physics body
  53143. * @param impostor imposter to set the velocity on
  53144. * @param velocity velocity to set
  53145. */
  53146. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53147. /**
  53148. * gets the linear velocity
  53149. * @param impostor imposter to get linear velocity from
  53150. * @returns linear velocity
  53151. */
  53152. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53153. /**
  53154. * gets the angular velocity
  53155. * @param impostor imposter to get angular velocity from
  53156. * @returns angular velocity
  53157. */
  53158. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53159. /**
  53160. * Sets the mass of physics body
  53161. * @param impostor imposter to set the mass on
  53162. * @param mass mass to set
  53163. */
  53164. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53165. /**
  53166. * Gets the mass of the physics body
  53167. * @param impostor imposter to get the mass from
  53168. * @returns mass
  53169. */
  53170. getBodyMass(impostor: PhysicsImpostor): number;
  53171. /**
  53172. * Gets friction of the impostor
  53173. * @param impostor impostor to get friction from
  53174. * @returns friction value
  53175. */
  53176. getBodyFriction(impostor: PhysicsImpostor): number;
  53177. /**
  53178. * Sets friction of the impostor
  53179. * @param impostor impostor to set friction on
  53180. * @param friction friction value
  53181. */
  53182. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53183. /**
  53184. * Gets restitution of the impostor
  53185. * @param impostor impostor to get restitution from
  53186. * @returns restitution value
  53187. */
  53188. getBodyRestitution(impostor: PhysicsImpostor): number;
  53189. /**
  53190. * Sets resitution of the impostor
  53191. * @param impostor impostor to set resitution on
  53192. * @param restitution resitution value
  53193. */
  53194. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53195. /**
  53196. * Gets pressure inside the impostor
  53197. * @param impostor impostor to get pressure from
  53198. * @returns pressure value
  53199. */
  53200. getBodyPressure(impostor: PhysicsImpostor): number;
  53201. /**
  53202. * Sets pressure inside a soft body impostor
  53203. * Cloth and rope must remain 0 pressure
  53204. * @param impostor impostor to set pressure on
  53205. * @param pressure pressure value
  53206. */
  53207. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  53208. /**
  53209. * Gets stiffness of the impostor
  53210. * @param impostor impostor to get stiffness from
  53211. * @returns pressure value
  53212. */
  53213. getBodyStiffness(impostor: PhysicsImpostor): number;
  53214. /**
  53215. * Sets stiffness of the impostor
  53216. * @param impostor impostor to set stiffness on
  53217. * @param stiffness stiffness value from 0 to 1
  53218. */
  53219. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  53220. /**
  53221. * Gets velocityIterations of the impostor
  53222. * @param impostor impostor to get velocity iterations from
  53223. * @returns velocityIterations value
  53224. */
  53225. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  53226. /**
  53227. * Sets velocityIterations of the impostor
  53228. * @param impostor impostor to set velocity iterations on
  53229. * @param velocityIterations velocityIterations value
  53230. */
  53231. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  53232. /**
  53233. * Gets positionIterations of the impostor
  53234. * @param impostor impostor to get position iterations from
  53235. * @returns positionIterations value
  53236. */
  53237. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  53238. /**
  53239. * Sets positionIterations of the impostor
  53240. * @param impostor impostor to set position on
  53241. * @param positionIterations positionIterations value
  53242. */
  53243. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  53244. /**
  53245. * Append an anchor to a cloth object
  53246. * @param impostor is the cloth impostor to add anchor to
  53247. * @param otherImpostor is the rigid impostor to anchor to
  53248. * @param width ratio across width from 0 to 1
  53249. * @param height ratio up height from 0 to 1
  53250. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  53251. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53252. */
  53253. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53254. /**
  53255. * Append an hook to a rope object
  53256. * @param impostor is the rope impostor to add hook to
  53257. * @param otherImpostor is the rigid impostor to hook to
  53258. * @param length ratio along the rope from 0 to 1
  53259. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  53260. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53261. */
  53262. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53263. /**
  53264. * Sleeps the physics body and stops it from being active
  53265. * @param impostor impostor to sleep
  53266. */
  53267. sleepBody(impostor: PhysicsImpostor): void;
  53268. /**
  53269. * Activates the physics body
  53270. * @param impostor impostor to activate
  53271. */
  53272. wakeUpBody(impostor: PhysicsImpostor): void;
  53273. /**
  53274. * Updates the distance parameters of the joint
  53275. * @param joint joint to update
  53276. * @param maxDistance maximum distance of the joint
  53277. * @param minDistance minimum distance of the joint
  53278. */
  53279. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53280. /**
  53281. * Sets a motor on the joint
  53282. * @param joint joint to set motor on
  53283. * @param speed speed of the motor
  53284. * @param maxForce maximum force of the motor
  53285. * @param motorIndex index of the motor
  53286. */
  53287. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53288. /**
  53289. * Sets the motors limit
  53290. * @param joint joint to set limit on
  53291. * @param upperLimit upper limit
  53292. * @param lowerLimit lower limit
  53293. */
  53294. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53295. /**
  53296. * Syncs the position and rotation of a mesh with the impostor
  53297. * @param mesh mesh to sync
  53298. * @param impostor impostor to update the mesh with
  53299. */
  53300. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53301. /**
  53302. * Gets the radius of the impostor
  53303. * @param impostor impostor to get radius from
  53304. * @returns the radius
  53305. */
  53306. getRadius(impostor: PhysicsImpostor): number;
  53307. /**
  53308. * Gets the box size of the impostor
  53309. * @param impostor impostor to get box size from
  53310. * @param result the resulting box size
  53311. */
  53312. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53313. /**
  53314. * Disposes of the impostor
  53315. */
  53316. dispose(): void;
  53317. /**
  53318. * Does a raycast in the physics world
  53319. * @param from when should the ray start?
  53320. * @param to when should the ray end?
  53321. * @returns PhysicsRaycastResult
  53322. */
  53323. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53324. }
  53325. }
  53326. declare module "babylonjs/Probes/reflectionProbe" {
  53327. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53328. import { Vector3 } from "babylonjs/Maths/math.vector";
  53329. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53330. import { Nullable } from "babylonjs/types";
  53331. import { Scene } from "babylonjs/scene";
  53332. module "babylonjs/abstractScene" {
  53333. interface AbstractScene {
  53334. /**
  53335. * The list of reflection probes added to the scene
  53336. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53337. */
  53338. reflectionProbes: Array<ReflectionProbe>;
  53339. /**
  53340. * Removes the given reflection probe from this scene.
  53341. * @param toRemove The reflection probe to remove
  53342. * @returns The index of the removed reflection probe
  53343. */
  53344. removeReflectionProbe(toRemove: ReflectionProbe): number;
  53345. /**
  53346. * Adds the given reflection probe to this scene.
  53347. * @param newReflectionProbe The reflection probe to add
  53348. */
  53349. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  53350. }
  53351. }
  53352. /**
  53353. * Class used to generate realtime reflection / refraction cube textures
  53354. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53355. */
  53356. export class ReflectionProbe {
  53357. /** defines the name of the probe */
  53358. name: string;
  53359. private _scene;
  53360. private _renderTargetTexture;
  53361. private _projectionMatrix;
  53362. private _viewMatrix;
  53363. private _target;
  53364. private _add;
  53365. private _attachedMesh;
  53366. private _invertYAxis;
  53367. /** Gets or sets probe position (center of the cube map) */
  53368. position: Vector3;
  53369. /**
  53370. * Creates a new reflection probe
  53371. * @param name defines the name of the probe
  53372. * @param size defines the texture resolution (for each face)
  53373. * @param scene defines the hosting scene
  53374. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  53375. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  53376. */
  53377. constructor(
  53378. /** defines the name of the probe */
  53379. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  53380. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  53381. samples: number;
  53382. /** Gets or sets the refresh rate to use (on every frame by default) */
  53383. refreshRate: number;
  53384. /**
  53385. * Gets the hosting scene
  53386. * @returns a Scene
  53387. */
  53388. getScene(): Scene;
  53389. /** Gets the internal CubeTexture used to render to */
  53390. readonly cubeTexture: RenderTargetTexture;
  53391. /** Gets the list of meshes to render */
  53392. readonly renderList: Nullable<AbstractMesh[]>;
  53393. /**
  53394. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  53395. * @param mesh defines the mesh to attach to
  53396. */
  53397. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53398. /**
  53399. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  53400. * @param renderingGroupId The rendering group id corresponding to its index
  53401. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  53402. */
  53403. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  53404. /**
  53405. * Clean all associated resources
  53406. */
  53407. dispose(): void;
  53408. /**
  53409. * Converts the reflection probe information to a readable string for debug purpose.
  53410. * @param fullDetails Supports for multiple levels of logging within scene loading
  53411. * @returns the human readable reflection probe info
  53412. */
  53413. toString(fullDetails?: boolean): string;
  53414. /**
  53415. * Get the class name of the relfection probe.
  53416. * @returns "ReflectionProbe"
  53417. */
  53418. getClassName(): string;
  53419. /**
  53420. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  53421. * @returns The JSON representation of the texture
  53422. */
  53423. serialize(): any;
  53424. /**
  53425. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  53426. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  53427. * @param scene Define the scene the parsed reflection probe should be instantiated in
  53428. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  53429. * @returns The parsed reflection probe if successful
  53430. */
  53431. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  53432. }
  53433. }
  53434. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  53435. /** @hidden */
  53436. export var _BabylonLoaderRegistered: boolean;
  53437. }
  53438. declare module "babylonjs/Loading/Plugins/index" {
  53439. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  53440. }
  53441. declare module "babylonjs/Loading/index" {
  53442. export * from "babylonjs/Loading/loadingScreen";
  53443. export * from "babylonjs/Loading/Plugins/index";
  53444. export * from "babylonjs/Loading/sceneLoader";
  53445. export * from "babylonjs/Loading/sceneLoaderFlags";
  53446. }
  53447. declare module "babylonjs/Materials/Background/index" {
  53448. export * from "babylonjs/Materials/Background/backgroundMaterial";
  53449. }
  53450. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  53451. import { Scene } from "babylonjs/scene";
  53452. import { Color3 } from "babylonjs/Maths/math.color";
  53453. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53454. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53455. /**
  53456. * The Physically based simple base material of BJS.
  53457. *
  53458. * This enables better naming and convention enforcements on top of the pbrMaterial.
  53459. * It is used as the base class for both the specGloss and metalRough conventions.
  53460. */
  53461. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  53462. /**
  53463. * Number of Simultaneous lights allowed on the material.
  53464. */
  53465. maxSimultaneousLights: number;
  53466. /**
  53467. * If sets to true, disables all the lights affecting the material.
  53468. */
  53469. disableLighting: boolean;
  53470. /**
  53471. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  53472. */
  53473. environmentTexture: BaseTexture;
  53474. /**
  53475. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53476. */
  53477. invertNormalMapX: boolean;
  53478. /**
  53479. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53480. */
  53481. invertNormalMapY: boolean;
  53482. /**
  53483. * Normal map used in the model.
  53484. */
  53485. normalTexture: BaseTexture;
  53486. /**
  53487. * Emissivie color used to self-illuminate the model.
  53488. */
  53489. emissiveColor: Color3;
  53490. /**
  53491. * Emissivie texture used to self-illuminate the model.
  53492. */
  53493. emissiveTexture: BaseTexture;
  53494. /**
  53495. * Occlusion Channel Strenght.
  53496. */
  53497. occlusionStrength: number;
  53498. /**
  53499. * Occlusion Texture of the material (adding extra occlusion effects).
  53500. */
  53501. occlusionTexture: BaseTexture;
  53502. /**
  53503. * Defines the alpha limits in alpha test mode.
  53504. */
  53505. alphaCutOff: number;
  53506. /**
  53507. * Gets the current double sided mode.
  53508. */
  53509. /**
  53510. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53511. */
  53512. doubleSided: boolean;
  53513. /**
  53514. * Stores the pre-calculated light information of a mesh in a texture.
  53515. */
  53516. lightmapTexture: BaseTexture;
  53517. /**
  53518. * If true, the light map contains occlusion information instead of lighting info.
  53519. */
  53520. useLightmapAsShadowmap: boolean;
  53521. /**
  53522. * Instantiates a new PBRMaterial instance.
  53523. *
  53524. * @param name The material name
  53525. * @param scene The scene the material will be use in.
  53526. */
  53527. constructor(name: string, scene: Scene);
  53528. getClassName(): string;
  53529. }
  53530. }
  53531. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  53532. import { Scene } from "babylonjs/scene";
  53533. import { Color3 } from "babylonjs/Maths/math.color";
  53534. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53535. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53536. /**
  53537. * The PBR material of BJS following the metal roughness convention.
  53538. *
  53539. * This fits to the PBR convention in the GLTF definition:
  53540. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  53541. */
  53542. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  53543. /**
  53544. * The base color has two different interpretations depending on the value of metalness.
  53545. * When the material is a metal, the base color is the specific measured reflectance value
  53546. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  53547. * of the material.
  53548. */
  53549. baseColor: Color3;
  53550. /**
  53551. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  53552. * well as opacity information in the alpha channel.
  53553. */
  53554. baseTexture: BaseTexture;
  53555. /**
  53556. * Specifies the metallic scalar value of the material.
  53557. * Can also be used to scale the metalness values of the metallic texture.
  53558. */
  53559. metallic: number;
  53560. /**
  53561. * Specifies the roughness scalar value of the material.
  53562. * Can also be used to scale the roughness values of the metallic texture.
  53563. */
  53564. roughness: number;
  53565. /**
  53566. * Texture containing both the metallic value in the B channel and the
  53567. * roughness value in the G channel to keep better precision.
  53568. */
  53569. metallicRoughnessTexture: BaseTexture;
  53570. /**
  53571. * Instantiates a new PBRMetalRoughnessMaterial instance.
  53572. *
  53573. * @param name The material name
  53574. * @param scene The scene the material will be use in.
  53575. */
  53576. constructor(name: string, scene: Scene);
  53577. /**
  53578. * Return the currrent class name of the material.
  53579. */
  53580. getClassName(): string;
  53581. /**
  53582. * Makes a duplicate of the current material.
  53583. * @param name - name to use for the new material.
  53584. */
  53585. clone(name: string): PBRMetallicRoughnessMaterial;
  53586. /**
  53587. * Serialize the material to a parsable JSON object.
  53588. */
  53589. serialize(): any;
  53590. /**
  53591. * Parses a JSON object correponding to the serialize function.
  53592. */
  53593. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  53594. }
  53595. }
  53596. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  53597. import { Scene } from "babylonjs/scene";
  53598. import { Color3 } from "babylonjs/Maths/math.color";
  53599. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53600. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53601. /**
  53602. * The PBR material of BJS following the specular glossiness convention.
  53603. *
  53604. * This fits to the PBR convention in the GLTF definition:
  53605. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  53606. */
  53607. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  53608. /**
  53609. * Specifies the diffuse color of the material.
  53610. */
  53611. diffuseColor: Color3;
  53612. /**
  53613. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  53614. * channel.
  53615. */
  53616. diffuseTexture: BaseTexture;
  53617. /**
  53618. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  53619. */
  53620. specularColor: Color3;
  53621. /**
  53622. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  53623. */
  53624. glossiness: number;
  53625. /**
  53626. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  53627. */
  53628. specularGlossinessTexture: BaseTexture;
  53629. /**
  53630. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  53631. *
  53632. * @param name The material name
  53633. * @param scene The scene the material will be use in.
  53634. */
  53635. constructor(name: string, scene: Scene);
  53636. /**
  53637. * Return the currrent class name of the material.
  53638. */
  53639. getClassName(): string;
  53640. /**
  53641. * Makes a duplicate of the current material.
  53642. * @param name - name to use for the new material.
  53643. */
  53644. clone(name: string): PBRSpecularGlossinessMaterial;
  53645. /**
  53646. * Serialize the material to a parsable JSON object.
  53647. */
  53648. serialize(): any;
  53649. /**
  53650. * Parses a JSON object correponding to the serialize function.
  53651. */
  53652. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  53653. }
  53654. }
  53655. declare module "babylonjs/Materials/PBR/index" {
  53656. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53657. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53658. export * from "babylonjs/Materials/PBR/pbrMaterial";
  53659. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  53660. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  53661. }
  53662. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  53663. import { Nullable } from "babylonjs/types";
  53664. import { Scene } from "babylonjs/scene";
  53665. import { Matrix } from "babylonjs/Maths/math.vector";
  53666. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53667. /**
  53668. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  53669. * It can help converting any input color in a desired output one. This can then be used to create effects
  53670. * from sepia, black and white to sixties or futuristic rendering...
  53671. *
  53672. * The only supported format is currently 3dl.
  53673. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  53674. */
  53675. export class ColorGradingTexture extends BaseTexture {
  53676. /**
  53677. * The current texture matrix. (will always be identity in color grading texture)
  53678. */
  53679. private _textureMatrix;
  53680. /**
  53681. * The texture URL.
  53682. */
  53683. url: string;
  53684. /**
  53685. * Empty line regex stored for GC.
  53686. */
  53687. private static _noneEmptyLineRegex;
  53688. private _engine;
  53689. /**
  53690. * Instantiates a ColorGradingTexture from the following parameters.
  53691. *
  53692. * @param url The location of the color gradind data (currently only supporting 3dl)
  53693. * @param scene The scene the texture will be used in
  53694. */
  53695. constructor(url: string, scene: Scene);
  53696. /**
  53697. * Returns the texture matrix used in most of the material.
  53698. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  53699. */
  53700. getTextureMatrix(): Matrix;
  53701. /**
  53702. * Occurs when the file being loaded is a .3dl LUT file.
  53703. */
  53704. private load3dlTexture;
  53705. /**
  53706. * Starts the loading process of the texture.
  53707. */
  53708. private loadTexture;
  53709. /**
  53710. * Clones the color gradind texture.
  53711. */
  53712. clone(): ColorGradingTexture;
  53713. /**
  53714. * Called during delayed load for textures.
  53715. */
  53716. delayLoad(): void;
  53717. /**
  53718. * Parses a color grading texture serialized by Babylon.
  53719. * @param parsedTexture The texture information being parsedTexture
  53720. * @param scene The scene to load the texture in
  53721. * @param rootUrl The root url of the data assets to load
  53722. * @return A color gradind texture
  53723. */
  53724. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  53725. /**
  53726. * Serializes the LUT texture to json format.
  53727. */
  53728. serialize(): any;
  53729. }
  53730. }
  53731. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  53732. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53733. import { Scene } from "babylonjs/scene";
  53734. import { Nullable } from "babylonjs/types";
  53735. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53736. /**
  53737. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  53738. */
  53739. export class EquiRectangularCubeTexture extends BaseTexture {
  53740. /** The six faces of the cube. */
  53741. private static _FacesMapping;
  53742. private _noMipmap;
  53743. private _onLoad;
  53744. private _onError;
  53745. /** The size of the cubemap. */
  53746. private _size;
  53747. /** The buffer of the image. */
  53748. private _buffer;
  53749. /** The width of the input image. */
  53750. private _width;
  53751. /** The height of the input image. */
  53752. private _height;
  53753. /** The URL to the image. */
  53754. url: string;
  53755. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  53756. coordinatesMode: number;
  53757. /**
  53758. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  53759. * @param url The location of the image
  53760. * @param scene The scene the texture will be used in
  53761. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53762. * @param noMipmap Forces to not generate the mipmap if true
  53763. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  53764. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  53765. * @param onLoad — defines a callback called when texture is loaded
  53766. * @param onError — defines a callback called if there is an error
  53767. */
  53768. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  53769. /**
  53770. * Load the image data, by putting the image on a canvas and extracting its buffer.
  53771. */
  53772. private loadImage;
  53773. /**
  53774. * Convert the image buffer into a cubemap and create a CubeTexture.
  53775. */
  53776. private loadTexture;
  53777. /**
  53778. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  53779. * @param buffer The ArrayBuffer that should be converted.
  53780. * @returns The buffer as Float32Array.
  53781. */
  53782. private getFloat32ArrayFromArrayBuffer;
  53783. /**
  53784. * Get the current class name of the texture useful for serialization or dynamic coding.
  53785. * @returns "EquiRectangularCubeTexture"
  53786. */
  53787. getClassName(): string;
  53788. /**
  53789. * Create a clone of the current EquiRectangularCubeTexture and return it.
  53790. * @returns A clone of the current EquiRectangularCubeTexture.
  53791. */
  53792. clone(): EquiRectangularCubeTexture;
  53793. }
  53794. }
  53795. declare module "babylonjs/Misc/tga" {
  53796. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53797. /**
  53798. * Based on jsTGALoader - Javascript loader for TGA file
  53799. * By Vincent Thibault
  53800. * @see http://blog.robrowser.com/javascript-tga-loader.html
  53801. */
  53802. export class TGATools {
  53803. private static _TYPE_INDEXED;
  53804. private static _TYPE_RGB;
  53805. private static _TYPE_GREY;
  53806. private static _TYPE_RLE_INDEXED;
  53807. private static _TYPE_RLE_RGB;
  53808. private static _TYPE_RLE_GREY;
  53809. private static _ORIGIN_MASK;
  53810. private static _ORIGIN_SHIFT;
  53811. private static _ORIGIN_BL;
  53812. private static _ORIGIN_BR;
  53813. private static _ORIGIN_UL;
  53814. private static _ORIGIN_UR;
  53815. /**
  53816. * Gets the header of a TGA file
  53817. * @param data defines the TGA data
  53818. * @returns the header
  53819. */
  53820. static GetTGAHeader(data: Uint8Array): any;
  53821. /**
  53822. * Uploads TGA content to a Babylon Texture
  53823. * @hidden
  53824. */
  53825. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  53826. /** @hidden */
  53827. 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;
  53828. /** @hidden */
  53829. 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;
  53830. /** @hidden */
  53831. 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;
  53832. /** @hidden */
  53833. 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;
  53834. /** @hidden */
  53835. 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;
  53836. /** @hidden */
  53837. 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;
  53838. }
  53839. }
  53840. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  53841. import { Nullable } from "babylonjs/types";
  53842. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53843. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53844. /**
  53845. * Implementation of the TGA Texture Loader.
  53846. * @hidden
  53847. */
  53848. export class _TGATextureLoader implements IInternalTextureLoader {
  53849. /**
  53850. * Defines wether the loader supports cascade loading the different faces.
  53851. */
  53852. readonly supportCascades: boolean;
  53853. /**
  53854. * This returns if the loader support the current file information.
  53855. * @param extension defines the file extension of the file being loaded
  53856. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53857. * @param fallback defines the fallback internal texture if any
  53858. * @param isBase64 defines whether the texture is encoded as a base64
  53859. * @param isBuffer defines whether the texture data are stored as a buffer
  53860. * @returns true if the loader can load the specified file
  53861. */
  53862. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53863. /**
  53864. * Transform the url before loading if required.
  53865. * @param rootUrl the url of the texture
  53866. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53867. * @returns the transformed texture
  53868. */
  53869. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53870. /**
  53871. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53872. * @param rootUrl the url of the texture
  53873. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53874. * @returns the fallback texture
  53875. */
  53876. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53877. /**
  53878. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53879. * @param data contains the texture data
  53880. * @param texture defines the BabylonJS internal texture
  53881. * @param createPolynomials will be true if polynomials have been requested
  53882. * @param onLoad defines the callback to trigger once the texture is ready
  53883. * @param onError defines the callback to trigger in case of error
  53884. */
  53885. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53886. /**
  53887. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53888. * @param data contains the texture data
  53889. * @param texture defines the BabylonJS internal texture
  53890. * @param callback defines the method to call once ready to upload
  53891. */
  53892. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53893. }
  53894. }
  53895. declare module "babylonjs/Misc/basis" {
  53896. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53897. /**
  53898. * Info about the .basis files
  53899. */
  53900. class BasisFileInfo {
  53901. /**
  53902. * If the file has alpha
  53903. */
  53904. hasAlpha: boolean;
  53905. /**
  53906. * Info about each image of the basis file
  53907. */
  53908. images: Array<{
  53909. levels: Array<{
  53910. width: number;
  53911. height: number;
  53912. transcodedPixels: ArrayBufferView;
  53913. }>;
  53914. }>;
  53915. }
  53916. /**
  53917. * Result of transcoding a basis file
  53918. */
  53919. class TranscodeResult {
  53920. /**
  53921. * Info about the .basis file
  53922. */
  53923. fileInfo: BasisFileInfo;
  53924. /**
  53925. * Format to use when loading the file
  53926. */
  53927. format: number;
  53928. }
  53929. /**
  53930. * Configuration options for the Basis transcoder
  53931. */
  53932. export class BasisTranscodeConfiguration {
  53933. /**
  53934. * Supported compression formats used to determine the supported output format of the transcoder
  53935. */
  53936. supportedCompressionFormats?: {
  53937. /**
  53938. * etc1 compression format
  53939. */
  53940. etc1?: boolean;
  53941. /**
  53942. * s3tc compression format
  53943. */
  53944. s3tc?: boolean;
  53945. /**
  53946. * pvrtc compression format
  53947. */
  53948. pvrtc?: boolean;
  53949. /**
  53950. * etc2 compression format
  53951. */
  53952. etc2?: boolean;
  53953. };
  53954. /**
  53955. * If mipmap levels should be loaded for transcoded images (Default: true)
  53956. */
  53957. loadMipmapLevels?: boolean;
  53958. /**
  53959. * Index of a single image to load (Default: all images)
  53960. */
  53961. loadSingleImage?: number;
  53962. }
  53963. /**
  53964. * Used to load .Basis files
  53965. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  53966. */
  53967. export class BasisTools {
  53968. private static _IgnoreSupportedFormats;
  53969. /**
  53970. * URL to use when loading the basis transcoder
  53971. */
  53972. static JSModuleURL: string;
  53973. /**
  53974. * URL to use when loading the wasm module for the transcoder
  53975. */
  53976. static WasmModuleURL: string;
  53977. /**
  53978. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  53979. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  53980. * @returns internal format corresponding to the Basis format
  53981. */
  53982. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  53983. private static _WorkerPromise;
  53984. private static _Worker;
  53985. private static _actionId;
  53986. private static _CreateWorkerAsync;
  53987. /**
  53988. * Transcodes a loaded image file to compressed pixel data
  53989. * @param imageData image data to transcode
  53990. * @param config configuration options for the transcoding
  53991. * @returns a promise resulting in the transcoded image
  53992. */
  53993. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  53994. /**
  53995. * Loads a texture from the transcode result
  53996. * @param texture texture load to
  53997. * @param transcodeResult the result of transcoding the basis file to load from
  53998. */
  53999. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  54000. }
  54001. }
  54002. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  54003. import { Nullable } from "babylonjs/types";
  54004. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54005. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54006. /**
  54007. * Loader for .basis file format
  54008. */
  54009. export class _BasisTextureLoader implements IInternalTextureLoader {
  54010. /**
  54011. * Defines whether the loader supports cascade loading the different faces.
  54012. */
  54013. readonly supportCascades: boolean;
  54014. /**
  54015. * This returns if the loader support the current file information.
  54016. * @param extension defines the file extension of the file being loaded
  54017. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54018. * @param fallback defines the fallback internal texture if any
  54019. * @param isBase64 defines whether the texture is encoded as a base64
  54020. * @param isBuffer defines whether the texture data are stored as a buffer
  54021. * @returns true if the loader can load the specified file
  54022. */
  54023. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54024. /**
  54025. * Transform the url before loading if required.
  54026. * @param rootUrl the url of the texture
  54027. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54028. * @returns the transformed texture
  54029. */
  54030. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54031. /**
  54032. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54033. * @param rootUrl the url of the texture
  54034. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54035. * @returns the fallback texture
  54036. */
  54037. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54038. /**
  54039. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  54040. * @param data contains the texture data
  54041. * @param texture defines the BabylonJS internal texture
  54042. * @param createPolynomials will be true if polynomials have been requested
  54043. * @param onLoad defines the callback to trigger once the texture is ready
  54044. * @param onError defines the callback to trigger in case of error
  54045. */
  54046. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54047. /**
  54048. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54049. * @param data contains the texture data
  54050. * @param texture defines the BabylonJS internal texture
  54051. * @param callback defines the method to call once ready to upload
  54052. */
  54053. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54054. }
  54055. }
  54056. declare module "babylonjs/Materials/Textures/Loaders/index" {
  54057. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54058. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54059. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54060. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  54061. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  54062. }
  54063. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  54064. import { Scene } from "babylonjs/scene";
  54065. import { Texture } from "babylonjs/Materials/Textures/texture";
  54066. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54067. /**
  54068. * 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.
  54069. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54070. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54071. */
  54072. export class CustomProceduralTexture extends ProceduralTexture {
  54073. private _animate;
  54074. private _time;
  54075. private _config;
  54076. private _texturePath;
  54077. /**
  54078. * Instantiates a new Custom Procedural Texture.
  54079. * 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.
  54080. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54081. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54082. * @param name Define the name of the texture
  54083. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  54084. * @param size Define the size of the texture to create
  54085. * @param scene Define the scene the texture belongs to
  54086. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  54087. * @param generateMipMaps Define if the texture should creates mip maps or not
  54088. */
  54089. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54090. private _loadJson;
  54091. /**
  54092. * Is the texture ready to be used ? (rendered at least once)
  54093. * @returns true if ready, otherwise, false.
  54094. */
  54095. isReady(): boolean;
  54096. /**
  54097. * Render the texture to its associated render target.
  54098. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  54099. */
  54100. render(useCameraPostProcess?: boolean): void;
  54101. /**
  54102. * Update the list of dependant textures samplers in the shader.
  54103. */
  54104. updateTextures(): void;
  54105. /**
  54106. * Update the uniform values of the procedural texture in the shader.
  54107. */
  54108. updateShaderUniforms(): void;
  54109. /**
  54110. * Define if the texture animates or not.
  54111. */
  54112. animate: boolean;
  54113. }
  54114. }
  54115. declare module "babylonjs/Shaders/noise.fragment" {
  54116. /** @hidden */
  54117. export var noisePixelShader: {
  54118. name: string;
  54119. shader: string;
  54120. };
  54121. }
  54122. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  54123. import { Nullable } from "babylonjs/types";
  54124. import { Scene } from "babylonjs/scene";
  54125. import { Texture } from "babylonjs/Materials/Textures/texture";
  54126. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54127. import "babylonjs/Shaders/noise.fragment";
  54128. /**
  54129. * Class used to generate noise procedural textures
  54130. */
  54131. export class NoiseProceduralTexture extends ProceduralTexture {
  54132. private _time;
  54133. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  54134. brightness: number;
  54135. /** Defines the number of octaves to process */
  54136. octaves: number;
  54137. /** Defines the level of persistence (0.8 by default) */
  54138. persistence: number;
  54139. /** Gets or sets animation speed factor (default is 1) */
  54140. animationSpeedFactor: number;
  54141. /**
  54142. * Creates a new NoiseProceduralTexture
  54143. * @param name defines the name fo the texture
  54144. * @param size defines the size of the texture (default is 256)
  54145. * @param scene defines the hosting scene
  54146. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  54147. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  54148. */
  54149. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54150. private _updateShaderUniforms;
  54151. protected _getDefines(): string;
  54152. /** Generate the current state of the procedural texture */
  54153. render(useCameraPostProcess?: boolean): void;
  54154. /**
  54155. * Serializes this noise procedural texture
  54156. * @returns a serialized noise procedural texture object
  54157. */
  54158. serialize(): any;
  54159. /**
  54160. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  54161. * @param parsedTexture defines parsed texture data
  54162. * @param scene defines the current scene
  54163. * @param rootUrl defines the root URL containing noise procedural texture information
  54164. * @returns a parsed NoiseProceduralTexture
  54165. */
  54166. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  54167. }
  54168. }
  54169. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  54170. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  54171. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  54172. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54173. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  54174. }
  54175. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  54176. import { Nullable } from "babylonjs/types";
  54177. import { Scene } from "babylonjs/scene";
  54178. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54179. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54180. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  54181. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54182. /**
  54183. * Raw cube texture where the raw buffers are passed in
  54184. */
  54185. export class RawCubeTexture extends CubeTexture {
  54186. /**
  54187. * Creates a cube texture where the raw buffers are passed in.
  54188. * @param scene defines the scene the texture is attached to
  54189. * @param data defines the array of data to use to create each face
  54190. * @param size defines the size of the textures
  54191. * @param format defines the format of the data
  54192. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  54193. * @param generateMipMaps defines if the engine should generate the mip levels
  54194. * @param invertY defines if data must be stored with Y axis inverted
  54195. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  54196. * @param compression defines the compression used (null by default)
  54197. */
  54198. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  54199. /**
  54200. * Updates the raw cube texture.
  54201. * @param data defines the data to store
  54202. * @param format defines the data format
  54203. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54204. * @param invertY defines if data must be stored with Y axis inverted
  54205. * @param compression defines the compression used (null by default)
  54206. * @param level defines which level of the texture to update
  54207. */
  54208. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  54209. /**
  54210. * Updates a raw cube texture with RGBD encoded data.
  54211. * @param data defines the array of data [mipmap][face] to use to create each face
  54212. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  54213. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54214. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54215. * @returns a promsie that resolves when the operation is complete
  54216. */
  54217. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  54218. /**
  54219. * Clones the raw cube texture.
  54220. * @return a new cube texture
  54221. */
  54222. clone(): CubeTexture;
  54223. /** @hidden */
  54224. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54225. }
  54226. }
  54227. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  54228. import { Scene } from "babylonjs/scene";
  54229. import { Texture } from "babylonjs/Materials/Textures/texture";
  54230. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54231. /**
  54232. * Class used to store 3D textures containing user data
  54233. */
  54234. export class RawTexture3D extends Texture {
  54235. /** Gets or sets the texture format to use */
  54236. format: number;
  54237. private _engine;
  54238. /**
  54239. * Create a new RawTexture3D
  54240. * @param data defines the data of the texture
  54241. * @param width defines the width of the texture
  54242. * @param height defines the height of the texture
  54243. * @param depth defines the depth of the texture
  54244. * @param format defines the texture format to use
  54245. * @param scene defines the hosting scene
  54246. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  54247. * @param invertY defines if texture must be stored with Y axis inverted
  54248. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54249. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  54250. */
  54251. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  54252. /** Gets or sets the texture format to use */
  54253. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  54254. /**
  54255. * Update the texture with new data
  54256. * @param data defines the data to store in the texture
  54257. */
  54258. update(data: ArrayBufferView): void;
  54259. }
  54260. }
  54261. declare module "babylonjs/Materials/Textures/refractionTexture" {
  54262. import { Scene } from "babylonjs/scene";
  54263. import { Plane } from "babylonjs/Maths/math.plane";
  54264. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54265. /**
  54266. * Creates a refraction texture used by refraction channel of the standard material.
  54267. * It is like a mirror but to see through a material.
  54268. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54269. */
  54270. export class RefractionTexture extends RenderTargetTexture {
  54271. /**
  54272. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  54273. * 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.
  54274. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54275. */
  54276. refractionPlane: Plane;
  54277. /**
  54278. * Define how deep under the surface we should see.
  54279. */
  54280. depth: number;
  54281. /**
  54282. * Creates a refraction texture used by refraction channel of the standard material.
  54283. * It is like a mirror but to see through a material.
  54284. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54285. * @param name Define the texture name
  54286. * @param size Define the size of the underlying texture
  54287. * @param scene Define the scene the refraction belongs to
  54288. * @param generateMipMaps Define if we need to generate mips level for the refraction
  54289. */
  54290. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  54291. /**
  54292. * Clone the refraction texture.
  54293. * @returns the cloned texture
  54294. */
  54295. clone(): RefractionTexture;
  54296. /**
  54297. * Serialize the texture to a JSON representation you could use in Parse later on
  54298. * @returns the serialized JSON representation
  54299. */
  54300. serialize(): any;
  54301. }
  54302. }
  54303. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  54304. import { Nullable } from "babylonjs/types";
  54305. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54306. import { Matrix } from "babylonjs/Maths/math.vector";
  54307. import { Engine } from "babylonjs/Engines/engine";
  54308. import { Scene } from "babylonjs/scene";
  54309. /**
  54310. * Defines the options related to the creation of an HtmlElementTexture
  54311. */
  54312. export interface IHtmlElementTextureOptions {
  54313. /**
  54314. * Defines wether mip maps should be created or not.
  54315. */
  54316. generateMipMaps?: boolean;
  54317. /**
  54318. * Defines the sampling mode of the texture.
  54319. */
  54320. samplingMode?: number;
  54321. /**
  54322. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  54323. */
  54324. engine: Nullable<Engine>;
  54325. /**
  54326. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  54327. */
  54328. scene: Nullable<Scene>;
  54329. }
  54330. /**
  54331. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  54332. * To be as efficient as possible depending on your constraints nothing aside the first upload
  54333. * is automatically managed.
  54334. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  54335. * in your application.
  54336. *
  54337. * As the update is not automatic, you need to call them manually.
  54338. */
  54339. export class HtmlElementTexture extends BaseTexture {
  54340. /**
  54341. * The texture URL.
  54342. */
  54343. element: HTMLVideoElement | HTMLCanvasElement;
  54344. private static readonly DefaultOptions;
  54345. private _textureMatrix;
  54346. private _engine;
  54347. private _isVideo;
  54348. private _generateMipMaps;
  54349. private _samplingMode;
  54350. /**
  54351. * Instantiates a HtmlElementTexture from the following parameters.
  54352. *
  54353. * @param name Defines the name of the texture
  54354. * @param element Defines the video or canvas the texture is filled with
  54355. * @param options Defines the other none mandatory texture creation options
  54356. */
  54357. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  54358. private _createInternalTexture;
  54359. /**
  54360. * Returns the texture matrix used in most of the material.
  54361. */
  54362. getTextureMatrix(): Matrix;
  54363. /**
  54364. * Updates the content of the texture.
  54365. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  54366. */
  54367. update(invertY?: Nullable<boolean>): void;
  54368. }
  54369. }
  54370. declare module "babylonjs/Materials/Textures/index" {
  54371. export * from "babylonjs/Materials/Textures/baseTexture";
  54372. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  54373. export * from "babylonjs/Materials/Textures/cubeTexture";
  54374. export * from "babylonjs/Materials/Textures/dynamicTexture";
  54375. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  54376. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  54377. export * from "babylonjs/Materials/Textures/internalTexture";
  54378. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  54379. export * from "babylonjs/Materials/Textures/Loaders/index";
  54380. export * from "babylonjs/Materials/Textures/mirrorTexture";
  54381. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  54382. export * from "babylonjs/Materials/Textures/Procedurals/index";
  54383. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  54384. export * from "babylonjs/Materials/Textures/rawTexture";
  54385. export * from "babylonjs/Materials/Textures/rawTexture3D";
  54386. export * from "babylonjs/Materials/Textures/refractionTexture";
  54387. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  54388. export * from "babylonjs/Materials/Textures/texture";
  54389. export * from "babylonjs/Materials/Textures/videoTexture";
  54390. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  54391. }
  54392. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  54393. /**
  54394. * Enum used to define the target of a block
  54395. */
  54396. export enum NodeMaterialBlockTargets {
  54397. /** Vertex shader */
  54398. Vertex = 1,
  54399. /** Fragment shader */
  54400. Fragment = 2,
  54401. /** Neutral */
  54402. Neutral = 4,
  54403. /** Vertex and Fragment */
  54404. VertexAndFragment = 3
  54405. }
  54406. }
  54407. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  54408. /**
  54409. * Defines the kind of connection point for node based material
  54410. */
  54411. export enum NodeMaterialBlockConnectionPointTypes {
  54412. /** Float */
  54413. Float = 1,
  54414. /** Int */
  54415. Int = 2,
  54416. /** Vector2 */
  54417. Vector2 = 4,
  54418. /** Vector3 */
  54419. Vector3 = 8,
  54420. /** Vector4 */
  54421. Vector4 = 16,
  54422. /** Color3 */
  54423. Color3 = 32,
  54424. /** Color4 */
  54425. Color4 = 64,
  54426. /** Matrix */
  54427. Matrix = 128,
  54428. /** Detect type based on connection */
  54429. AutoDetect = 1024,
  54430. /** Output type that will be defined by input type */
  54431. BasedOnInput = 2048
  54432. }
  54433. }
  54434. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  54435. /**
  54436. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  54437. */
  54438. export enum NodeMaterialBlockConnectionPointMode {
  54439. /** Value is an uniform */
  54440. Uniform = 0,
  54441. /** Value is a mesh attribute */
  54442. Attribute = 1,
  54443. /** Value is a varying between vertex and fragment shaders */
  54444. Varying = 2,
  54445. /** Mode is undefined */
  54446. Undefined = 3
  54447. }
  54448. }
  54449. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  54450. /**
  54451. * Enum used to define system values e.g. values automatically provided by the system
  54452. */
  54453. export enum NodeMaterialSystemValues {
  54454. /** World */
  54455. World = 1,
  54456. /** View */
  54457. View = 2,
  54458. /** Projection */
  54459. Projection = 3,
  54460. /** ViewProjection */
  54461. ViewProjection = 4,
  54462. /** WorldView */
  54463. WorldView = 5,
  54464. /** WorldViewProjection */
  54465. WorldViewProjection = 6,
  54466. /** CameraPosition */
  54467. CameraPosition = 7,
  54468. /** Fog Color */
  54469. FogColor = 8
  54470. }
  54471. }
  54472. declare module "babylonjs/Materials/Node/Enums/index" {
  54473. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  54474. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  54475. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  54476. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  54477. }
  54478. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  54479. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54480. /**
  54481. * Root class for all node material optimizers
  54482. */
  54483. export class NodeMaterialOptimizer {
  54484. /**
  54485. * Function used to optimize a NodeMaterial graph
  54486. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  54487. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  54488. */
  54489. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  54490. }
  54491. }
  54492. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  54493. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54494. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54495. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54496. import { Scene } from "babylonjs/scene";
  54497. /**
  54498. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  54499. */
  54500. export class TransformBlock extends NodeMaterialBlock {
  54501. /**
  54502. * Defines the value to use to complement W value to transform it to a Vector4
  54503. */
  54504. complementW: number;
  54505. /**
  54506. * Defines the value to use to complement z value to transform it to a Vector4
  54507. */
  54508. complementZ: number;
  54509. /**
  54510. * Creates a new TransformBlock
  54511. * @param name defines the block name
  54512. */
  54513. constructor(name: string);
  54514. /**
  54515. * Gets the current class name
  54516. * @returns the class name
  54517. */
  54518. getClassName(): string;
  54519. /**
  54520. * Gets the vector input
  54521. */
  54522. readonly vector: NodeMaterialConnectionPoint;
  54523. /**
  54524. * Gets the output component
  54525. */
  54526. readonly output: NodeMaterialConnectionPoint;
  54527. /**
  54528. * Gets the matrix transform input
  54529. */
  54530. readonly transform: NodeMaterialConnectionPoint;
  54531. protected _buildBlock(state: NodeMaterialBuildState): this;
  54532. serialize(): any;
  54533. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54534. protected _dumpPropertiesCode(): string;
  54535. }
  54536. }
  54537. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  54538. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54539. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54540. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54541. /**
  54542. * Block used to output the vertex position
  54543. */
  54544. export class VertexOutputBlock extends NodeMaterialBlock {
  54545. /**
  54546. * Creates a new VertexOutputBlock
  54547. * @param name defines the block name
  54548. */
  54549. constructor(name: string);
  54550. /**
  54551. * Gets the current class name
  54552. * @returns the class name
  54553. */
  54554. getClassName(): string;
  54555. /**
  54556. * Gets the vector input component
  54557. */
  54558. readonly vector: NodeMaterialConnectionPoint;
  54559. protected _buildBlock(state: NodeMaterialBuildState): this;
  54560. }
  54561. }
  54562. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  54563. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54564. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54565. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54566. /**
  54567. * Block used to output the final color
  54568. */
  54569. export class FragmentOutputBlock extends NodeMaterialBlock {
  54570. /**
  54571. * Create a new FragmentOutputBlock
  54572. * @param name defines the block name
  54573. */
  54574. constructor(name: string);
  54575. /**
  54576. * Gets the current class name
  54577. * @returns the class name
  54578. */
  54579. getClassName(): string;
  54580. /**
  54581. * Gets the rgba input component
  54582. */
  54583. readonly rgba: NodeMaterialConnectionPoint;
  54584. /**
  54585. * Gets the rgb input component
  54586. */
  54587. readonly rgb: NodeMaterialConnectionPoint;
  54588. /**
  54589. * Gets the a input component
  54590. */
  54591. readonly a: NodeMaterialConnectionPoint;
  54592. protected _buildBlock(state: NodeMaterialBuildState): this;
  54593. }
  54594. }
  54595. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  54596. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54597. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54598. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54599. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54600. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54601. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54602. import { Effect } from "babylonjs/Materials/effect";
  54603. import { Mesh } from "babylonjs/Meshes/mesh";
  54604. import { Nullable } from "babylonjs/types";
  54605. import { Scene } from "babylonjs/scene";
  54606. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  54607. /**
  54608. * Block used to read a reflection texture from a sampler
  54609. */
  54610. export class ReflectionTextureBlock extends NodeMaterialBlock {
  54611. private _define3DName;
  54612. private _defineCubicName;
  54613. private _defineExplicitName;
  54614. private _defineProjectionName;
  54615. private _defineLocalCubicName;
  54616. private _defineSphericalName;
  54617. private _definePlanarName;
  54618. private _defineEquirectangularName;
  54619. private _defineMirroredEquirectangularFixedName;
  54620. private _defineEquirectangularFixedName;
  54621. private _defineSkyboxName;
  54622. private _cubeSamplerName;
  54623. private _2DSamplerName;
  54624. private _positionUVWName;
  54625. private _directionWName;
  54626. private _reflectionCoordsName;
  54627. private _reflection2DCoordsName;
  54628. private _reflectionColorName;
  54629. private _reflectionMatrixName;
  54630. /**
  54631. * Gets or sets the texture associated with the node
  54632. */
  54633. texture: Nullable<BaseTexture>;
  54634. /**
  54635. * Create a new TextureBlock
  54636. * @param name defines the block name
  54637. */
  54638. constructor(name: string);
  54639. /**
  54640. * Gets the current class name
  54641. * @returns the class name
  54642. */
  54643. getClassName(): string;
  54644. /**
  54645. * Gets the world position input component
  54646. */
  54647. readonly position: NodeMaterialConnectionPoint;
  54648. /**
  54649. * Gets the world position input component
  54650. */
  54651. readonly worldPosition: NodeMaterialConnectionPoint;
  54652. /**
  54653. * Gets the world normal input component
  54654. */
  54655. readonly worldNormal: NodeMaterialConnectionPoint;
  54656. /**
  54657. * Gets the world input component
  54658. */
  54659. readonly world: NodeMaterialConnectionPoint;
  54660. /**
  54661. * Gets the camera (or eye) position component
  54662. */
  54663. readonly cameraPosition: NodeMaterialConnectionPoint;
  54664. /**
  54665. * Gets the view input component
  54666. */
  54667. readonly view: NodeMaterialConnectionPoint;
  54668. /**
  54669. * Gets the rgb output component
  54670. */
  54671. readonly rgb: NodeMaterialConnectionPoint;
  54672. /**
  54673. * Gets the r output component
  54674. */
  54675. readonly r: NodeMaterialConnectionPoint;
  54676. /**
  54677. * Gets the g output component
  54678. */
  54679. readonly g: NodeMaterialConnectionPoint;
  54680. /**
  54681. * Gets the b output component
  54682. */
  54683. readonly b: NodeMaterialConnectionPoint;
  54684. autoConfigure(material: NodeMaterial): void;
  54685. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54686. isReady(): boolean;
  54687. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54688. private _injectVertexCode;
  54689. private _writeOutput;
  54690. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54691. serialize(): any;
  54692. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54693. }
  54694. }
  54695. declare module "babylonjs/Materials/Node/nodeMaterial" {
  54696. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54697. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  54698. import { Scene } from "babylonjs/scene";
  54699. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54700. import { Matrix } from "babylonjs/Maths/math.vector";
  54701. import { Mesh } from "babylonjs/Meshes/mesh";
  54702. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54703. import { Observable } from "babylonjs/Misc/observable";
  54704. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54705. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  54706. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  54707. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  54708. import { Nullable } from "babylonjs/types";
  54709. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  54710. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  54711. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  54712. /**
  54713. * Interface used to configure the node material editor
  54714. */
  54715. export interface INodeMaterialEditorOptions {
  54716. /** Define the URl to load node editor script */
  54717. editorURL?: string;
  54718. }
  54719. /** @hidden */
  54720. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  54721. /** BONES */
  54722. NUM_BONE_INFLUENCERS: number;
  54723. BonesPerMesh: number;
  54724. BONETEXTURE: boolean;
  54725. /** MORPH TARGETS */
  54726. MORPHTARGETS: boolean;
  54727. MORPHTARGETS_NORMAL: boolean;
  54728. MORPHTARGETS_TANGENT: boolean;
  54729. MORPHTARGETS_UV: boolean;
  54730. NUM_MORPH_INFLUENCERS: number;
  54731. /** IMAGE PROCESSING */
  54732. IMAGEPROCESSING: boolean;
  54733. VIGNETTE: boolean;
  54734. VIGNETTEBLENDMODEMULTIPLY: boolean;
  54735. VIGNETTEBLENDMODEOPAQUE: boolean;
  54736. TONEMAPPING: boolean;
  54737. TONEMAPPING_ACES: boolean;
  54738. CONTRAST: boolean;
  54739. EXPOSURE: boolean;
  54740. COLORCURVES: boolean;
  54741. COLORGRADING: boolean;
  54742. COLORGRADING3D: boolean;
  54743. SAMPLER3DGREENDEPTH: boolean;
  54744. SAMPLER3DBGRMAP: boolean;
  54745. IMAGEPROCESSINGPOSTPROCESS: boolean;
  54746. /** MISC. */
  54747. BUMPDIRECTUV: number;
  54748. constructor();
  54749. setValue(name: string, value: boolean): void;
  54750. }
  54751. /**
  54752. * Class used to configure NodeMaterial
  54753. */
  54754. export interface INodeMaterialOptions {
  54755. /**
  54756. * Defines if blocks should emit comments
  54757. */
  54758. emitComments: boolean;
  54759. }
  54760. /**
  54761. * Class used to create a node based material built by assembling shader blocks
  54762. */
  54763. export class NodeMaterial extends PushMaterial {
  54764. private static _BuildIdGenerator;
  54765. private _options;
  54766. private _vertexCompilationState;
  54767. private _fragmentCompilationState;
  54768. private _sharedData;
  54769. private _buildId;
  54770. private _buildWasSuccessful;
  54771. private _cachedWorldViewMatrix;
  54772. private _cachedWorldViewProjectionMatrix;
  54773. private _optimizers;
  54774. private _animationFrame;
  54775. /** Define the URl to load node editor script */
  54776. static EditorURL: string;
  54777. private BJSNODEMATERIALEDITOR;
  54778. /** Get the inspector from bundle or global */
  54779. private _getGlobalNodeMaterialEditor;
  54780. /**
  54781. * 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)
  54782. */
  54783. ignoreAlpha: boolean;
  54784. /**
  54785. * Defines the maximum number of lights that can be used in the material
  54786. */
  54787. maxSimultaneousLights: number;
  54788. /**
  54789. * Observable raised when the material is built
  54790. */
  54791. onBuildObservable: Observable<NodeMaterial>;
  54792. /**
  54793. * Gets or sets the root nodes of the material vertex shader
  54794. */
  54795. _vertexOutputNodes: NodeMaterialBlock[];
  54796. /**
  54797. * Gets or sets the root nodes of the material fragment (pixel) shader
  54798. */
  54799. _fragmentOutputNodes: NodeMaterialBlock[];
  54800. /** Gets or sets options to control the node material overall behavior */
  54801. options: INodeMaterialOptions;
  54802. /**
  54803. * Default configuration related to image processing available in the standard Material.
  54804. */
  54805. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54806. /**
  54807. * Gets the image processing configuration used either in this material.
  54808. */
  54809. /**
  54810. * Sets the Default image processing configuration used either in the this material.
  54811. *
  54812. * If sets to null, the scene one is in use.
  54813. */
  54814. imageProcessingConfiguration: ImageProcessingConfiguration;
  54815. /**
  54816. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  54817. */
  54818. attachedBlocks: NodeMaterialBlock[];
  54819. /**
  54820. * Create a new node based material
  54821. * @param name defines the material name
  54822. * @param scene defines the hosting scene
  54823. * @param options defines creation option
  54824. */
  54825. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  54826. /**
  54827. * Gets the current class name of the material e.g. "NodeMaterial"
  54828. * @returns the class name
  54829. */
  54830. getClassName(): string;
  54831. /**
  54832. * Keep track of the image processing observer to allow dispose and replace.
  54833. */
  54834. private _imageProcessingObserver;
  54835. /**
  54836. * Attaches a new image processing configuration to the Standard Material.
  54837. * @param configuration
  54838. */
  54839. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54840. /**
  54841. * Get a block by its name
  54842. * @param name defines the name of the block to retrieve
  54843. * @returns the required block or null if not found
  54844. */
  54845. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  54846. /**
  54847. * Get a block by its name
  54848. * @param predicate defines the predicate used to find the good candidate
  54849. * @returns the required block or null if not found
  54850. */
  54851. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  54852. /**
  54853. * Get an input block by its name
  54854. * @param predicate defines the predicate used to find the good candidate
  54855. * @returns the required input block or null if not found
  54856. */
  54857. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  54858. /**
  54859. * Gets the list of input blocks attached to this material
  54860. * @returns an array of InputBlocks
  54861. */
  54862. getInputBlocks(): InputBlock[];
  54863. /**
  54864. * Adds a new optimizer to the list of optimizers
  54865. * @param optimizer defines the optimizers to add
  54866. * @returns the current material
  54867. */
  54868. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54869. /**
  54870. * Remove an optimizer from the list of optimizers
  54871. * @param optimizer defines the optimizers to remove
  54872. * @returns the current material
  54873. */
  54874. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54875. /**
  54876. * Add a new block to the list of output nodes
  54877. * @param node defines the node to add
  54878. * @returns the current material
  54879. */
  54880. addOutputNode(node: NodeMaterialBlock): this;
  54881. /**
  54882. * Remove a block from the list of root nodes
  54883. * @param node defines the node to remove
  54884. * @returns the current material
  54885. */
  54886. removeOutputNode(node: NodeMaterialBlock): this;
  54887. private _addVertexOutputNode;
  54888. private _removeVertexOutputNode;
  54889. private _addFragmentOutputNode;
  54890. private _removeFragmentOutputNode;
  54891. /**
  54892. * Specifies if the material will require alpha blending
  54893. * @returns a boolean specifying if alpha blending is needed
  54894. */
  54895. needAlphaBlending(): boolean;
  54896. /**
  54897. * Specifies if this material should be rendered in alpha test mode
  54898. * @returns a boolean specifying if an alpha test is needed.
  54899. */
  54900. needAlphaTesting(): boolean;
  54901. private _initializeBlock;
  54902. private _resetDualBlocks;
  54903. /**
  54904. * Build the material and generates the inner effect
  54905. * @param verbose defines if the build should log activity
  54906. */
  54907. build(verbose?: boolean): void;
  54908. /**
  54909. * Runs an otpimization phase to try to improve the shader code
  54910. */
  54911. optimize(): void;
  54912. private _prepareDefinesForAttributes;
  54913. /**
  54914. * Get if the submesh is ready to be used and all its information available.
  54915. * Child classes can use it to update shaders
  54916. * @param mesh defines the mesh to check
  54917. * @param subMesh defines which submesh to check
  54918. * @param useInstances specifies that instances should be used
  54919. * @returns a boolean indicating that the submesh is ready or not
  54920. */
  54921. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54922. /**
  54923. * Get a string representing the shaders built by the current node graph
  54924. */
  54925. readonly compiledShaders: string;
  54926. /**
  54927. * Binds the world matrix to the material
  54928. * @param world defines the world transformation matrix
  54929. */
  54930. bindOnlyWorldMatrix(world: Matrix): void;
  54931. /**
  54932. * Binds the submesh to this material by preparing the effect and shader to draw
  54933. * @param world defines the world transformation matrix
  54934. * @param mesh defines the mesh containing the submesh
  54935. * @param subMesh defines the submesh to bind the material to
  54936. */
  54937. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54938. /**
  54939. * Gets the active textures from the material
  54940. * @returns an array of textures
  54941. */
  54942. getActiveTextures(): BaseTexture[];
  54943. /**
  54944. * Gets the list of texture blocks
  54945. * @returns an array of texture blocks
  54946. */
  54947. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  54948. /**
  54949. * Specifies if the material uses a texture
  54950. * @param texture defines the texture to check against the material
  54951. * @returns a boolean specifying if the material uses the texture
  54952. */
  54953. hasTexture(texture: BaseTexture): boolean;
  54954. /**
  54955. * Disposes the material
  54956. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  54957. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  54958. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  54959. */
  54960. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  54961. /** Creates the node editor window. */
  54962. private _createNodeEditor;
  54963. /**
  54964. * Launch the node material editor
  54965. * @param config Define the configuration of the editor
  54966. * @return a promise fulfilled when the node editor is visible
  54967. */
  54968. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  54969. /**
  54970. * Clear the current material
  54971. */
  54972. clear(): void;
  54973. /**
  54974. * Clear the current material and set it to a default state
  54975. */
  54976. setToDefault(): void;
  54977. /**
  54978. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  54979. * @param url defines the url to load from
  54980. * @returns a promise that will fullfil when the material is fully loaded
  54981. */
  54982. loadAsync(url: string): Promise<unknown>;
  54983. private _gatherBlocks;
  54984. /**
  54985. * Generate a string containing the code declaration required to create an equivalent of this material
  54986. * @returns a string
  54987. */
  54988. generateCode(): string;
  54989. /**
  54990. * Serializes this material in a JSON representation
  54991. * @returns the serialized material object
  54992. */
  54993. serialize(): any;
  54994. private _restoreConnections;
  54995. /**
  54996. * Clear the current graph and load a new one from a serialization object
  54997. * @param source defines the JSON representation of the material
  54998. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54999. */
  55000. loadFromSerialization(source: any, rootUrl?: string): void;
  55001. /**
  55002. * Creates a node material from parsed material data
  55003. * @param source defines the JSON representation of the material
  55004. * @param scene defines the hosting scene
  55005. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55006. * @returns a new node material
  55007. */
  55008. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  55009. /**
  55010. * Creates a new node material set to default basic configuration
  55011. * @param name defines the name of the material
  55012. * @param scene defines the hosting scene
  55013. * @returns a new NodeMaterial
  55014. */
  55015. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  55016. }
  55017. }
  55018. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  55019. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55020. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55021. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55022. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55023. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55024. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55025. import { Effect } from "babylonjs/Materials/effect";
  55026. import { Mesh } from "babylonjs/Meshes/mesh";
  55027. import { Nullable } from "babylonjs/types";
  55028. import { Texture } from "babylonjs/Materials/Textures/texture";
  55029. import { Scene } from "babylonjs/scene";
  55030. /**
  55031. * Block used to read a texture from a sampler
  55032. */
  55033. export class TextureBlock extends NodeMaterialBlock {
  55034. private _defineName;
  55035. private _samplerName;
  55036. private _transformedUVName;
  55037. private _textureTransformName;
  55038. private _textureInfoName;
  55039. private _mainUVName;
  55040. private _mainUVDefineName;
  55041. /**
  55042. * Gets or sets the texture associated with the node
  55043. */
  55044. texture: Nullable<Texture>;
  55045. /**
  55046. * Create a new TextureBlock
  55047. * @param name defines the block name
  55048. */
  55049. constructor(name: string);
  55050. /**
  55051. * Gets the current class name
  55052. * @returns the class name
  55053. */
  55054. getClassName(): string;
  55055. /**
  55056. * Gets the uv input component
  55057. */
  55058. readonly uv: NodeMaterialConnectionPoint;
  55059. /**
  55060. * Gets the rgba output component
  55061. */
  55062. readonly rgba: NodeMaterialConnectionPoint;
  55063. /**
  55064. * Gets the rgb output component
  55065. */
  55066. readonly rgb: NodeMaterialConnectionPoint;
  55067. /**
  55068. * Gets the r output component
  55069. */
  55070. readonly r: NodeMaterialConnectionPoint;
  55071. /**
  55072. * Gets the g output component
  55073. */
  55074. readonly g: NodeMaterialConnectionPoint;
  55075. /**
  55076. * Gets the b output component
  55077. */
  55078. readonly b: NodeMaterialConnectionPoint;
  55079. /**
  55080. * Gets the a output component
  55081. */
  55082. readonly a: NodeMaterialConnectionPoint;
  55083. readonly target: NodeMaterialBlockTargets;
  55084. autoConfigure(material: NodeMaterial): void;
  55085. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55086. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55087. isReady(): boolean;
  55088. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55089. private readonly _isMixed;
  55090. private _injectVertexCode;
  55091. private _writeOutput;
  55092. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55093. protected _dumpPropertiesCode(): string;
  55094. serialize(): any;
  55095. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55096. }
  55097. }
  55098. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  55099. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55100. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55101. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55102. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55103. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55104. import { Scene } from "babylonjs/scene";
  55105. /**
  55106. * Class used to store shared data between 2 NodeMaterialBuildState
  55107. */
  55108. export class NodeMaterialBuildStateSharedData {
  55109. /**
  55110. * Gets the list of emitted varyings
  55111. */
  55112. temps: string[];
  55113. /**
  55114. * Gets the list of emitted varyings
  55115. */
  55116. varyings: string[];
  55117. /**
  55118. * Gets the varying declaration string
  55119. */
  55120. varyingDeclaration: string;
  55121. /**
  55122. * Input blocks
  55123. */
  55124. inputBlocks: InputBlock[];
  55125. /**
  55126. * Input blocks
  55127. */
  55128. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  55129. /**
  55130. * Bindable blocks (Blocks that need to set data to the effect)
  55131. */
  55132. bindableBlocks: NodeMaterialBlock[];
  55133. /**
  55134. * List of blocks that can provide a compilation fallback
  55135. */
  55136. blocksWithFallbacks: NodeMaterialBlock[];
  55137. /**
  55138. * List of blocks that can provide a define update
  55139. */
  55140. blocksWithDefines: NodeMaterialBlock[];
  55141. /**
  55142. * List of blocks that can provide a repeatable content
  55143. */
  55144. repeatableContentBlocks: NodeMaterialBlock[];
  55145. /**
  55146. * List of blocks that can provide a dynamic list of uniforms
  55147. */
  55148. dynamicUniformBlocks: NodeMaterialBlock[];
  55149. /**
  55150. * List of blocks that can block the isReady function for the material
  55151. */
  55152. blockingBlocks: NodeMaterialBlock[];
  55153. /**
  55154. * Gets the list of animated inputs
  55155. */
  55156. animatedInputs: InputBlock[];
  55157. /**
  55158. * Build Id used to avoid multiple recompilations
  55159. */
  55160. buildId: number;
  55161. /** List of emitted variables */
  55162. variableNames: {
  55163. [key: string]: number;
  55164. };
  55165. /** List of emitted defines */
  55166. defineNames: {
  55167. [key: string]: number;
  55168. };
  55169. /** Should emit comments? */
  55170. emitComments: boolean;
  55171. /** Emit build activity */
  55172. verbose: boolean;
  55173. /** Gets or sets the hosting scene */
  55174. scene: Scene;
  55175. /**
  55176. * Gets the compilation hints emitted at compilation time
  55177. */
  55178. hints: {
  55179. needWorldViewMatrix: boolean;
  55180. needWorldViewProjectionMatrix: boolean;
  55181. needAlphaBlending: boolean;
  55182. needAlphaTesting: boolean;
  55183. };
  55184. /**
  55185. * List of compilation checks
  55186. */
  55187. checks: {
  55188. emitVertex: boolean;
  55189. emitFragment: boolean;
  55190. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  55191. };
  55192. /** Creates a new shared data */
  55193. constructor();
  55194. /**
  55195. * Emits console errors and exceptions if there is a failing check
  55196. */
  55197. emitErrors(): void;
  55198. }
  55199. }
  55200. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  55201. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55202. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55203. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  55204. /**
  55205. * Class used to store node based material build state
  55206. */
  55207. export class NodeMaterialBuildState {
  55208. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  55209. supportUniformBuffers: boolean;
  55210. /**
  55211. * Gets the list of emitted attributes
  55212. */
  55213. attributes: string[];
  55214. /**
  55215. * Gets the list of emitted uniforms
  55216. */
  55217. uniforms: string[];
  55218. /**
  55219. * Gets the list of emitted constants
  55220. */
  55221. constants: string[];
  55222. /**
  55223. * Gets the list of emitted uniform buffers
  55224. */
  55225. uniformBuffers: string[];
  55226. /**
  55227. * Gets the list of emitted samplers
  55228. */
  55229. samplers: string[];
  55230. /**
  55231. * Gets the list of emitted functions
  55232. */
  55233. functions: {
  55234. [key: string]: string;
  55235. };
  55236. /**
  55237. * Gets the list of emitted extensions
  55238. */
  55239. extensions: {
  55240. [key: string]: string;
  55241. };
  55242. /**
  55243. * Gets the target of the compilation state
  55244. */
  55245. target: NodeMaterialBlockTargets;
  55246. /**
  55247. * Gets the list of emitted counters
  55248. */
  55249. counters: {
  55250. [key: string]: number;
  55251. };
  55252. /**
  55253. * Shared data between multiple NodeMaterialBuildState instances
  55254. */
  55255. sharedData: NodeMaterialBuildStateSharedData;
  55256. /** @hidden */
  55257. _vertexState: NodeMaterialBuildState;
  55258. /** @hidden */
  55259. _attributeDeclaration: string;
  55260. /** @hidden */
  55261. _uniformDeclaration: string;
  55262. /** @hidden */
  55263. _constantDeclaration: string;
  55264. /** @hidden */
  55265. _samplerDeclaration: string;
  55266. /** @hidden */
  55267. _varyingTransfer: string;
  55268. private _repeatableContentAnchorIndex;
  55269. /** @hidden */
  55270. _builtCompilationString: string;
  55271. /**
  55272. * Gets the emitted compilation strings
  55273. */
  55274. compilationString: string;
  55275. /**
  55276. * Finalize the compilation strings
  55277. * @param state defines the current compilation state
  55278. */
  55279. finalize(state: NodeMaterialBuildState): void;
  55280. /** @hidden */
  55281. readonly _repeatableContentAnchor: string;
  55282. /** @hidden */
  55283. _getFreeVariableName(prefix: string): string;
  55284. /** @hidden */
  55285. _getFreeDefineName(prefix: string): string;
  55286. /** @hidden */
  55287. _excludeVariableName(name: string): void;
  55288. /** @hidden */
  55289. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  55290. /** @hidden */
  55291. _emitExtension(name: string, extension: string): void;
  55292. /** @hidden */
  55293. _emitFunction(name: string, code: string, comments: string): void;
  55294. /** @hidden */
  55295. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  55296. replaceStrings?: {
  55297. search: RegExp;
  55298. replace: string;
  55299. }[];
  55300. repeatKey?: string;
  55301. }): string;
  55302. /** @hidden */
  55303. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  55304. repeatKey?: string;
  55305. removeAttributes?: boolean;
  55306. removeUniforms?: boolean;
  55307. removeVaryings?: boolean;
  55308. removeIfDef?: boolean;
  55309. replaceStrings?: {
  55310. search: RegExp;
  55311. replace: string;
  55312. }[];
  55313. }, storeKey?: string): void;
  55314. /** @hidden */
  55315. _registerTempVariable(name: string): boolean;
  55316. /** @hidden */
  55317. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  55318. /** @hidden */
  55319. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  55320. }
  55321. }
  55322. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  55323. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55324. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55325. import { Nullable } from "babylonjs/types";
  55326. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55327. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55328. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  55329. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55330. import { Mesh } from "babylonjs/Meshes/mesh";
  55331. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55332. import { Scene } from "babylonjs/scene";
  55333. /**
  55334. * Defines a block that can be used inside a node based material
  55335. */
  55336. export class NodeMaterialBlock {
  55337. private _buildId;
  55338. private _buildTarget;
  55339. private _target;
  55340. private _isFinalMerger;
  55341. private _isInput;
  55342. /** @hidden */
  55343. _codeVariableName: string;
  55344. /** @hidden */
  55345. _inputs: NodeMaterialConnectionPoint[];
  55346. /** @hidden */
  55347. _outputs: NodeMaterialConnectionPoint[];
  55348. /** @hidden */
  55349. _preparationId: number;
  55350. /**
  55351. * Gets or sets the name of the block
  55352. */
  55353. name: string;
  55354. /**
  55355. * Gets or sets the unique id of the node
  55356. */
  55357. uniqueId: number;
  55358. /**
  55359. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  55360. */
  55361. readonly isFinalMerger: boolean;
  55362. /**
  55363. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  55364. */
  55365. readonly isInput: boolean;
  55366. /**
  55367. * Gets or sets the build Id
  55368. */
  55369. buildId: number;
  55370. /**
  55371. * Gets or sets the target of the block
  55372. */
  55373. target: NodeMaterialBlockTargets;
  55374. /**
  55375. * Gets the list of input points
  55376. */
  55377. readonly inputs: NodeMaterialConnectionPoint[];
  55378. /** Gets the list of output points */
  55379. readonly outputs: NodeMaterialConnectionPoint[];
  55380. /**
  55381. * Find an input by its name
  55382. * @param name defines the name of the input to look for
  55383. * @returns the input or null if not found
  55384. */
  55385. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55386. /**
  55387. * Find an output by its name
  55388. * @param name defines the name of the outputto look for
  55389. * @returns the output or null if not found
  55390. */
  55391. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55392. /**
  55393. * Creates a new NodeMaterialBlock
  55394. * @param name defines the block name
  55395. * @param target defines the target of that block (Vertex by default)
  55396. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  55397. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  55398. */
  55399. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  55400. /**
  55401. * Initialize the block and prepare the context for build
  55402. * @param state defines the state that will be used for the build
  55403. */
  55404. initialize(state: NodeMaterialBuildState): void;
  55405. /**
  55406. * Bind data to effect. Will only be called for blocks with isBindable === true
  55407. * @param effect defines the effect to bind data to
  55408. * @param nodeMaterial defines the hosting NodeMaterial
  55409. * @param mesh defines the mesh that will be rendered
  55410. */
  55411. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55412. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  55413. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  55414. protected _writeFloat(value: number): string;
  55415. /**
  55416. * Gets the current class name e.g. "NodeMaterialBlock"
  55417. * @returns the class name
  55418. */
  55419. getClassName(): string;
  55420. /**
  55421. * Register a new input. Must be called inside a block constructor
  55422. * @param name defines the connection point name
  55423. * @param type defines the connection point type
  55424. * @param isOptional defines a boolean indicating that this input can be omitted
  55425. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55426. * @returns the current block
  55427. */
  55428. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  55429. /**
  55430. * Register a new output. Must be called inside a block constructor
  55431. * @param name defines the connection point name
  55432. * @param type defines the connection point type
  55433. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55434. * @returns the current block
  55435. */
  55436. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  55437. /**
  55438. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  55439. * @param forOutput defines an optional connection point to check compatibility with
  55440. * @returns the first available input or null
  55441. */
  55442. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  55443. /**
  55444. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  55445. * @param forBlock defines an optional block to check compatibility with
  55446. * @returns the first available input or null
  55447. */
  55448. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  55449. /**
  55450. * Gets the sibling of the given output
  55451. * @param current defines the current output
  55452. * @returns the next output in the list or null
  55453. */
  55454. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  55455. /**
  55456. * Connect current block with another block
  55457. * @param other defines the block to connect with
  55458. * @param options define the various options to help pick the right connections
  55459. * @returns the current block
  55460. */
  55461. connectTo(other: NodeMaterialBlock, options?: {
  55462. input?: string;
  55463. output?: string;
  55464. outputSwizzle?: string;
  55465. }): this | undefined;
  55466. protected _buildBlock(state: NodeMaterialBuildState): void;
  55467. /**
  55468. * Add uniforms, samplers and uniform buffers at compilation time
  55469. * @param state defines the state to update
  55470. * @param nodeMaterial defines the node material requesting the update
  55471. * @param defines defines the material defines to update
  55472. */
  55473. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55474. /**
  55475. * Add potential fallbacks if shader compilation fails
  55476. * @param mesh defines the mesh to be rendered
  55477. * @param fallbacks defines the current prioritized list of fallbacks
  55478. */
  55479. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55480. /**
  55481. * Initialize defines for shader compilation
  55482. * @param mesh defines the mesh to be rendered
  55483. * @param nodeMaterial defines the node material requesting the update
  55484. * @param defines defines the material defines to update
  55485. * @param useInstances specifies that instances should be used
  55486. */
  55487. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55488. /**
  55489. * Update defines for shader compilation
  55490. * @param mesh defines the mesh to be rendered
  55491. * @param nodeMaterial defines the node material requesting the update
  55492. * @param defines defines the material defines to update
  55493. * @param useInstances specifies that instances should be used
  55494. */
  55495. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55496. /**
  55497. * Lets the block try to connect some inputs automatically
  55498. * @param material defines the hosting NodeMaterial
  55499. */
  55500. autoConfigure(material: NodeMaterial): void;
  55501. /**
  55502. * Function called when a block is declared as repeatable content generator
  55503. * @param vertexShaderState defines the current compilation state for the vertex shader
  55504. * @param fragmentShaderState defines the current compilation state for the fragment shader
  55505. * @param mesh defines the mesh to be rendered
  55506. * @param defines defines the material defines to update
  55507. */
  55508. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  55509. /**
  55510. * Checks if the block is ready
  55511. * @param mesh defines the mesh to be rendered
  55512. * @param nodeMaterial defines the node material requesting the update
  55513. * @param defines defines the material defines to update
  55514. * @param useInstances specifies that instances should be used
  55515. * @returns true if the block is ready
  55516. */
  55517. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  55518. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  55519. private _processBuild;
  55520. /**
  55521. * Compile the current node and generate the shader code
  55522. * @param state defines the current compilation state (uniforms, samplers, current string)
  55523. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  55524. * @returns true if already built
  55525. */
  55526. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  55527. protected _inputRename(name: string): string;
  55528. protected _outputRename(name: string): string;
  55529. protected _dumpPropertiesCode(): string;
  55530. /** @hidden */
  55531. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  55532. /**
  55533. * Clone the current block to a new identical block
  55534. * @param scene defines the hosting scene
  55535. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55536. * @returns a copy of the current block
  55537. */
  55538. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  55539. /**
  55540. * Serializes this block in a JSON representation
  55541. * @returns the serialized block object
  55542. */
  55543. serialize(): any;
  55544. /** @hidden */
  55545. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55546. }
  55547. }
  55548. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  55549. /**
  55550. * Enum defining the type of animations supported by InputBlock
  55551. */
  55552. export enum AnimatedInputBlockTypes {
  55553. /** No animation */
  55554. None = 0,
  55555. /** Time based animation. Will only work for floats */
  55556. Time = 1
  55557. }
  55558. }
  55559. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  55560. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55561. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55562. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  55563. import { Nullable } from "babylonjs/types";
  55564. import { Effect } from "babylonjs/Materials/effect";
  55565. import { Matrix } from "babylonjs/Maths/math.vector";
  55566. import { Scene } from "babylonjs/scene";
  55567. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55568. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55569. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55570. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  55571. /**
  55572. * Block used to expose an input value
  55573. */
  55574. export class InputBlock extends NodeMaterialBlock {
  55575. private _mode;
  55576. private _associatedVariableName;
  55577. private _storedValue;
  55578. private _valueCallback;
  55579. private _type;
  55580. private _animationType;
  55581. /** Gets or set a value used to limit the range of float values */
  55582. min: number;
  55583. /** Gets or set a value used to limit the range of float values */
  55584. max: number;
  55585. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  55586. matrixMode: number;
  55587. /** @hidden */
  55588. _systemValue: Nullable<NodeMaterialSystemValues>;
  55589. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  55590. visibleInInspector: boolean;
  55591. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  55592. isConstant: boolean;
  55593. /**
  55594. * Gets or sets the connection point type (default is float)
  55595. */
  55596. readonly type: NodeMaterialBlockConnectionPointTypes;
  55597. /**
  55598. * Creates a new InputBlock
  55599. * @param name defines the block name
  55600. * @param target defines the target of that block (Vertex by default)
  55601. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  55602. */
  55603. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  55604. /**
  55605. * Gets the output component
  55606. */
  55607. readonly output: NodeMaterialConnectionPoint;
  55608. /**
  55609. * Set the source of this connection point to a vertex attribute
  55610. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  55611. * @returns the current connection point
  55612. */
  55613. setAsAttribute(attributeName?: string): InputBlock;
  55614. /**
  55615. * Set the source of this connection point to a system value
  55616. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  55617. * @returns the current connection point
  55618. */
  55619. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  55620. /**
  55621. * Gets or sets the value of that point.
  55622. * Please note that this value will be ignored if valueCallback is defined
  55623. */
  55624. value: any;
  55625. /**
  55626. * Gets or sets a callback used to get the value of that point.
  55627. * Please note that setting this value will force the connection point to ignore the value property
  55628. */
  55629. valueCallback: () => any;
  55630. /**
  55631. * Gets or sets the associated variable name in the shader
  55632. */
  55633. associatedVariableName: string;
  55634. /** Gets or sets the type of animation applied to the input */
  55635. animationType: AnimatedInputBlockTypes;
  55636. /**
  55637. * Gets a boolean indicating that this connection point not defined yet
  55638. */
  55639. readonly isUndefined: boolean;
  55640. /**
  55641. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  55642. * In this case the connection point name must be the name of the uniform to use.
  55643. * Can only be set on inputs
  55644. */
  55645. isUniform: boolean;
  55646. /**
  55647. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  55648. * In this case the connection point name must be the name of the attribute to use
  55649. * Can only be set on inputs
  55650. */
  55651. isAttribute: boolean;
  55652. /**
  55653. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  55654. * Can only be set on exit points
  55655. */
  55656. isVarying: boolean;
  55657. /**
  55658. * Gets a boolean indicating that the current connection point is a system value
  55659. */
  55660. readonly isSystemValue: boolean;
  55661. /**
  55662. * Gets or sets the current well known value or null if not defined as a system value
  55663. */
  55664. systemValue: Nullable<NodeMaterialSystemValues>;
  55665. /**
  55666. * Gets the current class name
  55667. * @returns the class name
  55668. */
  55669. getClassName(): string;
  55670. /**
  55671. * Animate the input if animationType !== None
  55672. * @param scene defines the rendering scene
  55673. */
  55674. animate(scene: Scene): void;
  55675. private _emitDefine;
  55676. initialize(state: NodeMaterialBuildState): void;
  55677. /**
  55678. * Set the input block to its default value (based on its type)
  55679. */
  55680. setDefaultValue(): void;
  55681. private _emitConstant;
  55682. private _emit;
  55683. /** @hidden */
  55684. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  55685. /** @hidden */
  55686. _transmit(effect: Effect, scene: Scene): void;
  55687. protected _buildBlock(state: NodeMaterialBuildState): void;
  55688. protected _dumpPropertiesCode(): string;
  55689. serialize(): any;
  55690. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55691. }
  55692. }
  55693. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  55694. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55695. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55696. import { Nullable } from "babylonjs/types";
  55697. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55698. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55699. /**
  55700. * Defines a connection point for a block
  55701. */
  55702. export class NodeMaterialConnectionPoint {
  55703. /** @hidden */
  55704. _ownerBlock: NodeMaterialBlock;
  55705. /** @hidden */
  55706. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55707. private _endpoints;
  55708. private _associatedVariableName;
  55709. /** @hidden */
  55710. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  55711. /** @hidden */
  55712. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  55713. private _type;
  55714. /** @hidden */
  55715. _enforceAssociatedVariableName: boolean;
  55716. /**
  55717. * Gets or sets the additional types supported by this connection point
  55718. */
  55719. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  55720. /**
  55721. * Gets or sets the additional types excluded by this connection point
  55722. */
  55723. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  55724. /**
  55725. * Gets or sets the associated variable name in the shader
  55726. */
  55727. associatedVariableName: string;
  55728. /**
  55729. * Gets or sets the connection point type (default is float)
  55730. */
  55731. type: NodeMaterialBlockConnectionPointTypes;
  55732. /**
  55733. * Gets or sets the connection point name
  55734. */
  55735. name: string;
  55736. /**
  55737. * Gets or sets a boolean indicating that this connection point can be omitted
  55738. */
  55739. isOptional: boolean;
  55740. /**
  55741. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  55742. */
  55743. define: string;
  55744. /** Gets or sets the target of that connection point */
  55745. target: NodeMaterialBlockTargets;
  55746. /**
  55747. * Gets a boolean indicating that the current point is connected
  55748. */
  55749. readonly isConnected: boolean;
  55750. /**
  55751. * Gets a boolean indicating that the current point is connected to an input block
  55752. */
  55753. readonly isConnectedToInputBlock: boolean;
  55754. /**
  55755. * Gets a the connected input block (if any)
  55756. */
  55757. readonly connectInputBlock: Nullable<InputBlock>;
  55758. /** Get the other side of the connection (if any) */
  55759. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55760. /** Get the block that owns this connection point */
  55761. readonly ownerBlock: NodeMaterialBlock;
  55762. /** Get the block connected on the other side of this connection (if any) */
  55763. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  55764. /** Get the block connected on the endpoints of this connection (if any) */
  55765. readonly connectedBlocks: Array<NodeMaterialBlock>;
  55766. /** Gets the list of connected endpoints */
  55767. readonly endpoints: NodeMaterialConnectionPoint[];
  55768. /** Gets a boolean indicating if that output point is connected to at least one input */
  55769. readonly hasEndpoints: boolean;
  55770. /**
  55771. * Creates a new connection point
  55772. * @param name defines the connection point name
  55773. * @param ownerBlock defines the block hosting this connection point
  55774. */
  55775. constructor(name: string, ownerBlock: NodeMaterialBlock);
  55776. /**
  55777. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  55778. * @returns the class name
  55779. */
  55780. getClassName(): string;
  55781. /**
  55782. * Gets an boolean indicating if the current point can be connected to another point
  55783. * @param connectionPoint defines the other connection point
  55784. * @returns true if the connection is possible
  55785. */
  55786. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  55787. /**
  55788. * Connect this point to another connection point
  55789. * @param connectionPoint defines the other connection point
  55790. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  55791. * @returns the current connection point
  55792. */
  55793. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  55794. /**
  55795. * Disconnect this point from one of his endpoint
  55796. * @param endpoint defines the other connection point
  55797. * @returns the current connection point
  55798. */
  55799. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  55800. /**
  55801. * Serializes this point in a JSON representation
  55802. * @returns the serialized point object
  55803. */
  55804. serialize(): any;
  55805. }
  55806. }
  55807. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  55808. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55809. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55810. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55811. import { Mesh } from "babylonjs/Meshes/mesh";
  55812. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  55813. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55814. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55815. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55816. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55817. /**
  55818. * Block used to add support for vertex skinning (bones)
  55819. */
  55820. export class BonesBlock extends NodeMaterialBlock {
  55821. /**
  55822. * Creates a new BonesBlock
  55823. * @param name defines the block name
  55824. */
  55825. constructor(name: string);
  55826. /**
  55827. * Initialize the block and prepare the context for build
  55828. * @param state defines the state that will be used for the build
  55829. */
  55830. initialize(state: NodeMaterialBuildState): void;
  55831. /**
  55832. * Gets the current class name
  55833. * @returns the class name
  55834. */
  55835. getClassName(): string;
  55836. /**
  55837. * Gets the matrix indices input component
  55838. */
  55839. readonly matricesIndices: NodeMaterialConnectionPoint;
  55840. /**
  55841. * Gets the matrix weights input component
  55842. */
  55843. readonly matricesWeights: NodeMaterialConnectionPoint;
  55844. /**
  55845. * Gets the extra matrix indices input component
  55846. */
  55847. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  55848. /**
  55849. * Gets the extra matrix weights input component
  55850. */
  55851. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  55852. /**
  55853. * Gets the world input component
  55854. */
  55855. readonly world: NodeMaterialConnectionPoint;
  55856. /**
  55857. * Gets the output component
  55858. */
  55859. readonly output: NodeMaterialConnectionPoint;
  55860. autoConfigure(material: NodeMaterial): void;
  55861. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55862. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55863. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55864. protected _buildBlock(state: NodeMaterialBuildState): this;
  55865. }
  55866. }
  55867. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  55868. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55869. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55870. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55871. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55872. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55873. /**
  55874. * Block used to add support for instances
  55875. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  55876. */
  55877. export class InstancesBlock extends NodeMaterialBlock {
  55878. /**
  55879. * Creates a new InstancesBlock
  55880. * @param name defines the block name
  55881. */
  55882. constructor(name: string);
  55883. /**
  55884. * Gets the current class name
  55885. * @returns the class name
  55886. */
  55887. getClassName(): string;
  55888. /**
  55889. * Gets the first world row input component
  55890. */
  55891. readonly world0: NodeMaterialConnectionPoint;
  55892. /**
  55893. * Gets the second world row input component
  55894. */
  55895. readonly world1: NodeMaterialConnectionPoint;
  55896. /**
  55897. * Gets the third world row input component
  55898. */
  55899. readonly world2: NodeMaterialConnectionPoint;
  55900. /**
  55901. * Gets the forth world row input component
  55902. */
  55903. readonly world3: NodeMaterialConnectionPoint;
  55904. /**
  55905. * Gets the world input component
  55906. */
  55907. readonly world: NodeMaterialConnectionPoint;
  55908. /**
  55909. * Gets the output component
  55910. */
  55911. readonly output: NodeMaterialConnectionPoint;
  55912. autoConfigure(material: NodeMaterial): void;
  55913. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55914. protected _buildBlock(state: NodeMaterialBuildState): this;
  55915. }
  55916. }
  55917. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  55918. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55919. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55920. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55921. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55922. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55923. import { Effect } from "babylonjs/Materials/effect";
  55924. import { Mesh } from "babylonjs/Meshes/mesh";
  55925. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  55926. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  55927. /**
  55928. * Block used to add morph targets support to vertex shader
  55929. */
  55930. export class MorphTargetsBlock extends NodeMaterialBlock {
  55931. private _repeatableContentAnchor;
  55932. private _repeatebleContentGenerated;
  55933. /**
  55934. * Create a new MorphTargetsBlock
  55935. * @param name defines the block name
  55936. */
  55937. constructor(name: string);
  55938. /**
  55939. * Gets the current class name
  55940. * @returns the class name
  55941. */
  55942. getClassName(): string;
  55943. /**
  55944. * Gets the position input component
  55945. */
  55946. readonly position: NodeMaterialConnectionPoint;
  55947. /**
  55948. * Gets the normal input component
  55949. */
  55950. readonly normal: NodeMaterialConnectionPoint;
  55951. /**
  55952. * Gets the tangent input component
  55953. */
  55954. readonly tangent: NodeMaterialConnectionPoint;
  55955. /**
  55956. * Gets the tangent input component
  55957. */
  55958. readonly uv: NodeMaterialConnectionPoint;
  55959. /**
  55960. * Gets the position output component
  55961. */
  55962. readonly positionOutput: NodeMaterialConnectionPoint;
  55963. /**
  55964. * Gets the normal output component
  55965. */
  55966. readonly normalOutput: NodeMaterialConnectionPoint;
  55967. /**
  55968. * Gets the tangent output component
  55969. */
  55970. readonly tangentOutput: NodeMaterialConnectionPoint;
  55971. /**
  55972. * Gets the tangent output component
  55973. */
  55974. readonly uvOutput: NodeMaterialConnectionPoint;
  55975. initialize(state: NodeMaterialBuildState): void;
  55976. autoConfigure(material: NodeMaterial): void;
  55977. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55978. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55979. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  55980. protected _buildBlock(state: NodeMaterialBuildState): this;
  55981. }
  55982. }
  55983. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  55984. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55985. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55986. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55987. import { Nullable } from "babylonjs/types";
  55988. import { Scene } from "babylonjs/scene";
  55989. import { Effect } from "babylonjs/Materials/effect";
  55990. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55991. import { Mesh } from "babylonjs/Meshes/mesh";
  55992. import { Light } from "babylonjs/Lights/light";
  55993. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55994. /**
  55995. * Block used to get data information from a light
  55996. */
  55997. export class LightInformationBlock extends NodeMaterialBlock {
  55998. private _lightDataUniformName;
  55999. private _lightColorUniformName;
  56000. private _lightTypeDefineName;
  56001. /**
  56002. * Gets or sets the light associated with this block
  56003. */
  56004. light: Nullable<Light>;
  56005. /**
  56006. * Creates a new LightInformationBlock
  56007. * @param name defines the block name
  56008. */
  56009. constructor(name: string);
  56010. /**
  56011. * Gets the current class name
  56012. * @returns the class name
  56013. */
  56014. getClassName(): string;
  56015. /**
  56016. * Gets the world position input component
  56017. */
  56018. readonly worldPosition: NodeMaterialConnectionPoint;
  56019. /**
  56020. * Gets the direction output component
  56021. */
  56022. readonly direction: NodeMaterialConnectionPoint;
  56023. /**
  56024. * Gets the direction output component
  56025. */
  56026. readonly color: NodeMaterialConnectionPoint;
  56027. /**
  56028. * Gets the direction output component
  56029. */
  56030. readonly intensity: NodeMaterialConnectionPoint;
  56031. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56032. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56033. protected _buildBlock(state: NodeMaterialBuildState): this;
  56034. serialize(): any;
  56035. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56036. }
  56037. }
  56038. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  56039. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  56040. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  56041. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  56042. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  56043. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  56044. }
  56045. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  56046. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56047. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56048. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56049. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56050. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56051. import { Effect } from "babylonjs/Materials/effect";
  56052. import { Mesh } from "babylonjs/Meshes/mesh";
  56053. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56054. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56055. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56056. /**
  56057. * Block used to add image processing support to fragment shader
  56058. */
  56059. export class ImageProcessingBlock extends NodeMaterialBlock {
  56060. /**
  56061. * Create a new ImageProcessingBlock
  56062. * @param name defines the block name
  56063. */
  56064. constructor(name: string);
  56065. /**
  56066. * Gets the current class name
  56067. * @returns the class name
  56068. */
  56069. getClassName(): string;
  56070. /**
  56071. * Gets the color input component
  56072. */
  56073. readonly color: NodeMaterialConnectionPoint;
  56074. /**
  56075. * Gets the output component
  56076. */
  56077. readonly output: NodeMaterialConnectionPoint;
  56078. /**
  56079. * Initialize the block and prepare the context for build
  56080. * @param state defines the state that will be used for the build
  56081. */
  56082. initialize(state: NodeMaterialBuildState): void;
  56083. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  56084. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56085. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56086. protected _buildBlock(state: NodeMaterialBuildState): this;
  56087. }
  56088. }
  56089. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  56090. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56091. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56092. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56093. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56094. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56095. import { Effect } from "babylonjs/Materials/effect";
  56096. import { Mesh } from "babylonjs/Meshes/mesh";
  56097. import { Scene } from "babylonjs/scene";
  56098. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  56099. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  56100. /**
  56101. * Block used to pertub normals based on a normal map
  56102. */
  56103. export class PerturbNormalBlock extends NodeMaterialBlock {
  56104. private _tangentSpaceParameterName;
  56105. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  56106. invertX: boolean;
  56107. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  56108. invertY: boolean;
  56109. /**
  56110. * Create a new PerturbNormalBlock
  56111. * @param name defines the block name
  56112. */
  56113. constructor(name: string);
  56114. /**
  56115. * Gets the current class name
  56116. * @returns the class name
  56117. */
  56118. getClassName(): string;
  56119. /**
  56120. * Gets the world position input component
  56121. */
  56122. readonly worldPosition: NodeMaterialConnectionPoint;
  56123. /**
  56124. * Gets the world normal input component
  56125. */
  56126. readonly worldNormal: NodeMaterialConnectionPoint;
  56127. /**
  56128. * Gets the uv input component
  56129. */
  56130. readonly uv: NodeMaterialConnectionPoint;
  56131. /**
  56132. * Gets the normal map color input component
  56133. */
  56134. readonly normalMapColor: NodeMaterialConnectionPoint;
  56135. /**
  56136. * Gets the strength input component
  56137. */
  56138. readonly strength: NodeMaterialConnectionPoint;
  56139. /**
  56140. * Gets the output component
  56141. */
  56142. readonly output: NodeMaterialConnectionPoint;
  56143. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56144. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56145. autoConfigure(material: NodeMaterial): void;
  56146. protected _buildBlock(state: NodeMaterialBuildState): this;
  56147. protected _dumpPropertiesCode(): string;
  56148. serialize(): any;
  56149. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56150. }
  56151. }
  56152. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  56153. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56154. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56155. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56156. /**
  56157. * Block used to discard a pixel if a value is smaller than a cutoff
  56158. */
  56159. export class DiscardBlock extends NodeMaterialBlock {
  56160. /**
  56161. * Create a new DiscardBlock
  56162. * @param name defines the block name
  56163. */
  56164. constructor(name: string);
  56165. /**
  56166. * Gets the current class name
  56167. * @returns the class name
  56168. */
  56169. getClassName(): string;
  56170. /**
  56171. * Gets the color input component
  56172. */
  56173. readonly value: NodeMaterialConnectionPoint;
  56174. /**
  56175. * Gets the cutoff input component
  56176. */
  56177. readonly cutoff: NodeMaterialConnectionPoint;
  56178. protected _buildBlock(state: NodeMaterialBuildState): this;
  56179. }
  56180. }
  56181. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  56182. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  56183. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  56184. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  56185. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  56186. }
  56187. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  56188. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56189. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56190. import { Mesh } from "babylonjs/Meshes/mesh";
  56191. import { Effect } from "babylonjs/Materials/effect";
  56192. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56193. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56194. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56195. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56196. /**
  56197. * Block used to add support for scene fog
  56198. */
  56199. export class FogBlock extends NodeMaterialBlock {
  56200. private _fogDistanceName;
  56201. private _fogParameters;
  56202. /**
  56203. * Create a new FogBlock
  56204. * @param name defines the block name
  56205. */
  56206. constructor(name: string);
  56207. /**
  56208. * Gets the current class name
  56209. * @returns the class name
  56210. */
  56211. getClassName(): string;
  56212. /**
  56213. * Gets the world position input component
  56214. */
  56215. readonly worldPosition: NodeMaterialConnectionPoint;
  56216. /**
  56217. * Gets the view input component
  56218. */
  56219. readonly view: NodeMaterialConnectionPoint;
  56220. /**
  56221. * Gets the color input component
  56222. */
  56223. readonly input: NodeMaterialConnectionPoint;
  56224. /**
  56225. * Gets the fog color input component
  56226. */
  56227. readonly fogColor: NodeMaterialConnectionPoint;
  56228. /**
  56229. * Gets the output component
  56230. */
  56231. readonly output: NodeMaterialConnectionPoint;
  56232. autoConfigure(material: NodeMaterial): void;
  56233. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56234. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56235. protected _buildBlock(state: NodeMaterialBuildState): this;
  56236. }
  56237. }
  56238. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  56239. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56240. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56241. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56242. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56243. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56244. import { Effect } from "babylonjs/Materials/effect";
  56245. import { Mesh } from "babylonjs/Meshes/mesh";
  56246. import { Light } from "babylonjs/Lights/light";
  56247. import { Nullable } from "babylonjs/types";
  56248. import { Scene } from "babylonjs/scene";
  56249. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56250. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56251. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56252. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56253. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  56254. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56255. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56256. /**
  56257. * Block used to add light in the fragment shader
  56258. */
  56259. export class LightBlock extends NodeMaterialBlock {
  56260. private _lightId;
  56261. /**
  56262. * Gets or sets the light associated with this block
  56263. */
  56264. light: Nullable<Light>;
  56265. /**
  56266. * Create a new LightBlock
  56267. * @param name defines the block name
  56268. */
  56269. constructor(name: string);
  56270. /**
  56271. * Gets the current class name
  56272. * @returns the class name
  56273. */
  56274. getClassName(): string;
  56275. /**
  56276. * Gets the world position input component
  56277. */
  56278. readonly worldPosition: NodeMaterialConnectionPoint;
  56279. /**
  56280. * Gets the world normal input component
  56281. */
  56282. readonly worldNormal: NodeMaterialConnectionPoint;
  56283. /**
  56284. * Gets the camera (or eye) position component
  56285. */
  56286. readonly cameraPosition: NodeMaterialConnectionPoint;
  56287. /**
  56288. * Gets the diffuse output component
  56289. */
  56290. readonly diffuseOutput: NodeMaterialConnectionPoint;
  56291. /**
  56292. * Gets the specular output component
  56293. */
  56294. readonly specularOutput: NodeMaterialConnectionPoint;
  56295. autoConfigure(material: NodeMaterial): void;
  56296. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56297. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56298. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56299. private _injectVertexCode;
  56300. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56301. serialize(): any;
  56302. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56303. }
  56304. }
  56305. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  56306. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  56307. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  56308. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56309. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56310. }
  56311. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  56312. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56313. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56314. }
  56315. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  56316. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56317. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56318. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56319. /**
  56320. * Block used to multiply 2 values
  56321. */
  56322. export class MultiplyBlock extends NodeMaterialBlock {
  56323. /**
  56324. * Creates a new MultiplyBlock
  56325. * @param name defines the block name
  56326. */
  56327. constructor(name: string);
  56328. /**
  56329. * Gets the current class name
  56330. * @returns the class name
  56331. */
  56332. getClassName(): string;
  56333. /**
  56334. * Gets the left operand input component
  56335. */
  56336. readonly left: NodeMaterialConnectionPoint;
  56337. /**
  56338. * Gets the right operand input component
  56339. */
  56340. readonly right: NodeMaterialConnectionPoint;
  56341. /**
  56342. * Gets the output component
  56343. */
  56344. readonly output: NodeMaterialConnectionPoint;
  56345. protected _buildBlock(state: NodeMaterialBuildState): this;
  56346. }
  56347. }
  56348. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  56349. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56350. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56351. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56352. /**
  56353. * Block used to add 2 vectors
  56354. */
  56355. export class AddBlock extends NodeMaterialBlock {
  56356. /**
  56357. * Creates a new AddBlock
  56358. * @param name defines the block name
  56359. */
  56360. constructor(name: string);
  56361. /**
  56362. * Gets the current class name
  56363. * @returns the class name
  56364. */
  56365. getClassName(): string;
  56366. /**
  56367. * Gets the left operand input component
  56368. */
  56369. readonly left: NodeMaterialConnectionPoint;
  56370. /**
  56371. * Gets the right operand input component
  56372. */
  56373. readonly right: NodeMaterialConnectionPoint;
  56374. /**
  56375. * Gets the output component
  56376. */
  56377. readonly output: NodeMaterialConnectionPoint;
  56378. protected _buildBlock(state: NodeMaterialBuildState): this;
  56379. }
  56380. }
  56381. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  56382. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56383. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56384. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56385. /**
  56386. * Block used to scale a vector by a float
  56387. */
  56388. export class ScaleBlock extends NodeMaterialBlock {
  56389. /**
  56390. * Creates a new ScaleBlock
  56391. * @param name defines the block name
  56392. */
  56393. constructor(name: string);
  56394. /**
  56395. * Gets the current class name
  56396. * @returns the class name
  56397. */
  56398. getClassName(): string;
  56399. /**
  56400. * Gets the input component
  56401. */
  56402. readonly input: NodeMaterialConnectionPoint;
  56403. /**
  56404. * Gets the factor input component
  56405. */
  56406. readonly factor: NodeMaterialConnectionPoint;
  56407. /**
  56408. * Gets the output component
  56409. */
  56410. readonly output: NodeMaterialConnectionPoint;
  56411. protected _buildBlock(state: NodeMaterialBuildState): this;
  56412. }
  56413. }
  56414. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  56415. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56416. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56417. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56418. import { Scene } from "babylonjs/scene";
  56419. /**
  56420. * Block used to clamp a float
  56421. */
  56422. export class ClampBlock extends NodeMaterialBlock {
  56423. /** Gets or sets the minimum range */
  56424. minimum: number;
  56425. /** Gets or sets the maximum range */
  56426. maximum: number;
  56427. /**
  56428. * Creates a new ClampBlock
  56429. * @param name defines the block name
  56430. */
  56431. constructor(name: string);
  56432. /**
  56433. * Gets the current class name
  56434. * @returns the class name
  56435. */
  56436. getClassName(): string;
  56437. /**
  56438. * Gets the value input component
  56439. */
  56440. readonly value: NodeMaterialConnectionPoint;
  56441. /**
  56442. * Gets the output component
  56443. */
  56444. readonly output: NodeMaterialConnectionPoint;
  56445. protected _buildBlock(state: NodeMaterialBuildState): this;
  56446. protected _dumpPropertiesCode(): string;
  56447. serialize(): any;
  56448. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56449. }
  56450. }
  56451. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  56452. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56453. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56454. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56455. /**
  56456. * Block used to apply a cross product between 2 vectors
  56457. */
  56458. export class CrossBlock extends NodeMaterialBlock {
  56459. /**
  56460. * Creates a new CrossBlock
  56461. * @param name defines the block name
  56462. */
  56463. constructor(name: string);
  56464. /**
  56465. * Gets the current class name
  56466. * @returns the class name
  56467. */
  56468. getClassName(): string;
  56469. /**
  56470. * Gets the left operand input component
  56471. */
  56472. readonly left: NodeMaterialConnectionPoint;
  56473. /**
  56474. * Gets the right operand input component
  56475. */
  56476. readonly right: NodeMaterialConnectionPoint;
  56477. /**
  56478. * Gets the output component
  56479. */
  56480. readonly output: NodeMaterialConnectionPoint;
  56481. protected _buildBlock(state: NodeMaterialBuildState): this;
  56482. }
  56483. }
  56484. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  56485. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56486. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56487. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56488. /**
  56489. * Block used to apply a dot product between 2 vectors
  56490. */
  56491. export class DotBlock extends NodeMaterialBlock {
  56492. /**
  56493. * Creates a new DotBlock
  56494. * @param name defines the block name
  56495. */
  56496. constructor(name: string);
  56497. /**
  56498. * Gets the current class name
  56499. * @returns the class name
  56500. */
  56501. getClassName(): string;
  56502. /**
  56503. * Gets the left operand input component
  56504. */
  56505. readonly left: NodeMaterialConnectionPoint;
  56506. /**
  56507. * Gets the right operand input component
  56508. */
  56509. readonly right: NodeMaterialConnectionPoint;
  56510. /**
  56511. * Gets the output component
  56512. */
  56513. readonly output: NodeMaterialConnectionPoint;
  56514. protected _buildBlock(state: NodeMaterialBuildState): this;
  56515. }
  56516. }
  56517. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  56518. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56519. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56520. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56521. import { Vector2 } from "babylonjs/Maths/math.vector";
  56522. import { Scene } from "babylonjs/scene";
  56523. /**
  56524. * Block used to remap a float from a range to a new one
  56525. */
  56526. export class RemapBlock extends NodeMaterialBlock {
  56527. /**
  56528. * Gets or sets the source range
  56529. */
  56530. sourceRange: Vector2;
  56531. /**
  56532. * Gets or sets the target range
  56533. */
  56534. targetRange: Vector2;
  56535. /**
  56536. * Creates a new RemapBlock
  56537. * @param name defines the block name
  56538. */
  56539. constructor(name: string);
  56540. /**
  56541. * Gets the current class name
  56542. * @returns the class name
  56543. */
  56544. getClassName(): string;
  56545. /**
  56546. * Gets the input component
  56547. */
  56548. readonly input: NodeMaterialConnectionPoint;
  56549. /**
  56550. * Gets the source min input component
  56551. */
  56552. readonly sourceMin: NodeMaterialConnectionPoint;
  56553. /**
  56554. * Gets the source max input component
  56555. */
  56556. readonly sourceMax: NodeMaterialConnectionPoint;
  56557. /**
  56558. * Gets the target min input component
  56559. */
  56560. readonly targetMin: NodeMaterialConnectionPoint;
  56561. /**
  56562. * Gets the target max input component
  56563. */
  56564. readonly targetMax: NodeMaterialConnectionPoint;
  56565. /**
  56566. * Gets the output component
  56567. */
  56568. readonly output: NodeMaterialConnectionPoint;
  56569. protected _buildBlock(state: NodeMaterialBuildState): this;
  56570. protected _dumpPropertiesCode(): string;
  56571. serialize(): any;
  56572. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56573. }
  56574. }
  56575. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  56576. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56577. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56578. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56579. /**
  56580. * Block used to normalize a vector
  56581. */
  56582. export class NormalizeBlock extends NodeMaterialBlock {
  56583. /**
  56584. * Creates a new NormalizeBlock
  56585. * @param name defines the block name
  56586. */
  56587. constructor(name: string);
  56588. /**
  56589. * Gets the current class name
  56590. * @returns the class name
  56591. */
  56592. getClassName(): string;
  56593. /**
  56594. * Gets the input component
  56595. */
  56596. readonly input: NodeMaterialConnectionPoint;
  56597. /**
  56598. * Gets the output component
  56599. */
  56600. readonly output: NodeMaterialConnectionPoint;
  56601. protected _buildBlock(state: NodeMaterialBuildState): this;
  56602. }
  56603. }
  56604. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  56605. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56606. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56607. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56608. import { Scene } from "babylonjs/scene";
  56609. /**
  56610. * Operations supported by the Trigonometry block
  56611. */
  56612. export enum TrigonometryBlockOperations {
  56613. /** Cos */
  56614. Cos = 0,
  56615. /** Sin */
  56616. Sin = 1,
  56617. /** Abs */
  56618. Abs = 2,
  56619. /** Exp */
  56620. Exp = 3,
  56621. /** Exp2 */
  56622. Exp2 = 4,
  56623. /** Round */
  56624. Round = 5,
  56625. /** Floor */
  56626. Floor = 6,
  56627. /** Ceiling */
  56628. Ceiling = 7,
  56629. /** Square root */
  56630. Sqrt = 8
  56631. }
  56632. /**
  56633. * Block used to apply trigonometry operation to floats
  56634. */
  56635. export class TrigonometryBlock extends NodeMaterialBlock {
  56636. /**
  56637. * Gets or sets the operation applied by the block
  56638. */
  56639. operation: TrigonometryBlockOperations;
  56640. /**
  56641. * Creates a new TrigonometryBlock
  56642. * @param name defines the block name
  56643. */
  56644. constructor(name: string);
  56645. /**
  56646. * Gets the current class name
  56647. * @returns the class name
  56648. */
  56649. getClassName(): string;
  56650. /**
  56651. * Gets the input component
  56652. */
  56653. readonly input: NodeMaterialConnectionPoint;
  56654. /**
  56655. * Gets the output component
  56656. */
  56657. readonly output: NodeMaterialConnectionPoint;
  56658. protected _buildBlock(state: NodeMaterialBuildState): this;
  56659. serialize(): any;
  56660. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56661. }
  56662. }
  56663. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  56664. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56665. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56666. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56667. /**
  56668. * Block used to create a Color3/4 out of individual inputs (one for each component)
  56669. */
  56670. export class ColorMergerBlock extends NodeMaterialBlock {
  56671. /**
  56672. * Create a new ColorMergerBlock
  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 r component (input)
  56683. */
  56684. readonly r: NodeMaterialConnectionPoint;
  56685. /**
  56686. * Gets the g component (input)
  56687. */
  56688. readonly g: NodeMaterialConnectionPoint;
  56689. /**
  56690. * Gets the b component (input)
  56691. */
  56692. readonly b: NodeMaterialConnectionPoint;
  56693. /**
  56694. * Gets the a component (input)
  56695. */
  56696. readonly a: NodeMaterialConnectionPoint;
  56697. /**
  56698. * Gets the rgba component (output)
  56699. */
  56700. readonly rgba: NodeMaterialConnectionPoint;
  56701. /**
  56702. * Gets the rgb component (output)
  56703. */
  56704. readonly rgb: NodeMaterialConnectionPoint;
  56705. protected _buildBlock(state: NodeMaterialBuildState): this;
  56706. }
  56707. }
  56708. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  56709. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56710. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56711. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56712. /**
  56713. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  56714. */
  56715. export class VectorMergerBlock extends NodeMaterialBlock {
  56716. /**
  56717. * Create a new VectorMergerBlock
  56718. * @param name defines the block name
  56719. */
  56720. constructor(name: string);
  56721. /**
  56722. * Gets the current class name
  56723. * @returns the class name
  56724. */
  56725. getClassName(): string;
  56726. /**
  56727. * Gets the x component (input)
  56728. */
  56729. readonly x: NodeMaterialConnectionPoint;
  56730. /**
  56731. * Gets the y component (input)
  56732. */
  56733. readonly y: NodeMaterialConnectionPoint;
  56734. /**
  56735. * Gets the z component (input)
  56736. */
  56737. readonly z: NodeMaterialConnectionPoint;
  56738. /**
  56739. * Gets the w component (input)
  56740. */
  56741. readonly w: NodeMaterialConnectionPoint;
  56742. /**
  56743. * Gets the xyzw component (output)
  56744. */
  56745. readonly xyzw: NodeMaterialConnectionPoint;
  56746. /**
  56747. * Gets the xyz component (output)
  56748. */
  56749. readonly xyz: NodeMaterialConnectionPoint;
  56750. /**
  56751. * Gets the xy component (output)
  56752. */
  56753. readonly xy: NodeMaterialConnectionPoint;
  56754. protected _buildBlock(state: NodeMaterialBuildState): this;
  56755. }
  56756. }
  56757. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  56758. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56759. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56760. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56761. /**
  56762. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  56763. */
  56764. export class ColorSplitterBlock extends NodeMaterialBlock {
  56765. /**
  56766. * Create a new ColorSplitterBlock
  56767. * @param name defines the block name
  56768. */
  56769. constructor(name: string);
  56770. /**
  56771. * Gets the current class name
  56772. * @returns the class name
  56773. */
  56774. getClassName(): string;
  56775. /**
  56776. * Gets the rgba component (input)
  56777. */
  56778. readonly rgba: NodeMaterialConnectionPoint;
  56779. /**
  56780. * Gets the rgb component (input)
  56781. */
  56782. readonly rgbIn: NodeMaterialConnectionPoint;
  56783. /**
  56784. * Gets the rgb component (output)
  56785. */
  56786. readonly rgbOut: NodeMaterialConnectionPoint;
  56787. /**
  56788. * Gets the r component (output)
  56789. */
  56790. readonly r: NodeMaterialConnectionPoint;
  56791. /**
  56792. * Gets the g component (output)
  56793. */
  56794. readonly g: NodeMaterialConnectionPoint;
  56795. /**
  56796. * Gets the b component (output)
  56797. */
  56798. readonly b: NodeMaterialConnectionPoint;
  56799. /**
  56800. * Gets the a component (output)
  56801. */
  56802. readonly a: NodeMaterialConnectionPoint;
  56803. protected _inputRename(name: string): string;
  56804. protected _outputRename(name: string): string;
  56805. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56806. }
  56807. }
  56808. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  56809. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56810. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56811. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56812. /**
  56813. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  56814. */
  56815. export class VectorSplitterBlock extends NodeMaterialBlock {
  56816. /**
  56817. * Create a new VectorSplitterBlock
  56818. * @param name defines the block name
  56819. */
  56820. constructor(name: string);
  56821. /**
  56822. * Gets the current class name
  56823. * @returns the class name
  56824. */
  56825. getClassName(): string;
  56826. /**
  56827. * Gets the xyzw component (input)
  56828. */
  56829. readonly xyzw: NodeMaterialConnectionPoint;
  56830. /**
  56831. * Gets the xyz component (input)
  56832. */
  56833. readonly xyzIn: NodeMaterialConnectionPoint;
  56834. /**
  56835. * Gets the xy component (input)
  56836. */
  56837. readonly xyIn: NodeMaterialConnectionPoint;
  56838. /**
  56839. * Gets the xyz component (output)
  56840. */
  56841. readonly xyzOut: NodeMaterialConnectionPoint;
  56842. /**
  56843. * Gets the xy component (output)
  56844. */
  56845. readonly xyOut: NodeMaterialConnectionPoint;
  56846. /**
  56847. * Gets the x component (output)
  56848. */
  56849. readonly x: NodeMaterialConnectionPoint;
  56850. /**
  56851. * Gets the y component (output)
  56852. */
  56853. readonly y: NodeMaterialConnectionPoint;
  56854. /**
  56855. * Gets the z component (output)
  56856. */
  56857. readonly z: NodeMaterialConnectionPoint;
  56858. /**
  56859. * Gets the w component (output)
  56860. */
  56861. readonly w: NodeMaterialConnectionPoint;
  56862. protected _inputRename(name: string): string;
  56863. protected _outputRename(name: string): string;
  56864. protected _buildBlock(state: NodeMaterialBuildState): this;
  56865. }
  56866. }
  56867. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  56868. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56869. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56870. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56871. /**
  56872. * Block used to lerp 2 values
  56873. */
  56874. export class LerpBlock extends NodeMaterialBlock {
  56875. /**
  56876. * Creates a new LerpBlock
  56877. * @param name defines the block name
  56878. */
  56879. constructor(name: string);
  56880. /**
  56881. * Gets the current class name
  56882. * @returns the class name
  56883. */
  56884. getClassName(): string;
  56885. /**
  56886. * Gets the left operand input component
  56887. */
  56888. readonly left: NodeMaterialConnectionPoint;
  56889. /**
  56890. * Gets the right operand input component
  56891. */
  56892. readonly right: NodeMaterialConnectionPoint;
  56893. /**
  56894. * Gets the gradient operand input component
  56895. */
  56896. readonly gradient: NodeMaterialConnectionPoint;
  56897. /**
  56898. * Gets the output component
  56899. */
  56900. readonly output: NodeMaterialConnectionPoint;
  56901. protected _buildBlock(state: NodeMaterialBuildState): this;
  56902. }
  56903. }
  56904. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  56905. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56906. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56907. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56908. /**
  56909. * Block used to divide 2 vectors
  56910. */
  56911. export class DivideBlock extends NodeMaterialBlock {
  56912. /**
  56913. * Creates a new DivideBlock
  56914. * @param name defines the block name
  56915. */
  56916. constructor(name: string);
  56917. /**
  56918. * Gets the current class name
  56919. * @returns the class name
  56920. */
  56921. getClassName(): string;
  56922. /**
  56923. * Gets the left operand input component
  56924. */
  56925. readonly left: NodeMaterialConnectionPoint;
  56926. /**
  56927. * Gets the right operand input component
  56928. */
  56929. readonly right: NodeMaterialConnectionPoint;
  56930. /**
  56931. * Gets the output component
  56932. */
  56933. readonly output: NodeMaterialConnectionPoint;
  56934. protected _buildBlock(state: NodeMaterialBuildState): this;
  56935. }
  56936. }
  56937. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  56938. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56939. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56940. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56941. /**
  56942. * Block used to subtract 2 vectors
  56943. */
  56944. export class SubtractBlock extends NodeMaterialBlock {
  56945. /**
  56946. * Creates a new SubtractBlock
  56947. * @param name defines the block name
  56948. */
  56949. constructor(name: string);
  56950. /**
  56951. * Gets the current class name
  56952. * @returns the class name
  56953. */
  56954. getClassName(): string;
  56955. /**
  56956. * Gets the left operand input component
  56957. */
  56958. readonly left: NodeMaterialConnectionPoint;
  56959. /**
  56960. * Gets the right operand input component
  56961. */
  56962. readonly right: NodeMaterialConnectionPoint;
  56963. /**
  56964. * Gets the output component
  56965. */
  56966. readonly output: NodeMaterialConnectionPoint;
  56967. protected _buildBlock(state: NodeMaterialBuildState): this;
  56968. }
  56969. }
  56970. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  56971. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56972. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56973. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56974. /**
  56975. * Block used to step a value
  56976. */
  56977. export class StepBlock extends NodeMaterialBlock {
  56978. /**
  56979. * Creates a new AddBlock
  56980. * @param name defines the block name
  56981. */
  56982. constructor(name: string);
  56983. /**
  56984. * Gets the current class name
  56985. * @returns the class name
  56986. */
  56987. getClassName(): string;
  56988. /**
  56989. * Gets the value operand input component
  56990. */
  56991. readonly value: NodeMaterialConnectionPoint;
  56992. /**
  56993. * Gets the edge operand input component
  56994. */
  56995. readonly edge: NodeMaterialConnectionPoint;
  56996. /**
  56997. * Gets the output component
  56998. */
  56999. readonly output: NodeMaterialConnectionPoint;
  57000. protected _buildBlock(state: NodeMaterialBuildState): this;
  57001. }
  57002. }
  57003. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  57004. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57005. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57006. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57007. /**
  57008. * Block used to get the opposite (1 - x) of a value
  57009. */
  57010. export class OneMinusBlock extends NodeMaterialBlock {
  57011. /**
  57012. * Creates a new OneMinusBlock
  57013. * @param name defines the block name
  57014. */
  57015. constructor(name: string);
  57016. /**
  57017. * Gets the current class name
  57018. * @returns the class name
  57019. */
  57020. getClassName(): string;
  57021. /**
  57022. * Gets the input component
  57023. */
  57024. readonly input: NodeMaterialConnectionPoint;
  57025. /**
  57026. * Gets the output component
  57027. */
  57028. readonly output: NodeMaterialConnectionPoint;
  57029. protected _buildBlock(state: NodeMaterialBuildState): this;
  57030. }
  57031. }
  57032. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  57033. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57034. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57035. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57036. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57037. /**
  57038. * Block used to get the view direction
  57039. */
  57040. export class ViewDirectionBlock extends NodeMaterialBlock {
  57041. /**
  57042. * Creates a new ViewDirectionBlock
  57043. * @param name defines the block name
  57044. */
  57045. constructor(name: string);
  57046. /**
  57047. * Gets the current class name
  57048. * @returns the class name
  57049. */
  57050. getClassName(): string;
  57051. /**
  57052. * Gets the world position component
  57053. */
  57054. readonly worldPosition: NodeMaterialConnectionPoint;
  57055. /**
  57056. * Gets the camera position component
  57057. */
  57058. readonly cameraPosition: NodeMaterialConnectionPoint;
  57059. /**
  57060. * Gets the output component
  57061. */
  57062. readonly output: NodeMaterialConnectionPoint;
  57063. autoConfigure(material: NodeMaterial): void;
  57064. protected _buildBlock(state: NodeMaterialBuildState): this;
  57065. }
  57066. }
  57067. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  57068. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57069. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57070. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57071. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57072. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  57073. /**
  57074. * Block used to compute fresnel value
  57075. */
  57076. export class FresnelBlock extends NodeMaterialBlock {
  57077. /**
  57078. * Create a new FresnelBlock
  57079. * @param name defines the block name
  57080. */
  57081. constructor(name: string);
  57082. /**
  57083. * Gets the current class name
  57084. * @returns the class name
  57085. */
  57086. getClassName(): string;
  57087. /**
  57088. * Gets the world normal input component
  57089. */
  57090. readonly worldNormal: NodeMaterialConnectionPoint;
  57091. /**
  57092. * Gets the view direction input component
  57093. */
  57094. readonly viewDirection: NodeMaterialConnectionPoint;
  57095. /**
  57096. * Gets the bias input component
  57097. */
  57098. readonly bias: NodeMaterialConnectionPoint;
  57099. /**
  57100. * Gets the camera (or eye) position component
  57101. */
  57102. readonly power: NodeMaterialConnectionPoint;
  57103. /**
  57104. * Gets the fresnel output component
  57105. */
  57106. readonly fresnel: NodeMaterialConnectionPoint;
  57107. autoConfigure(material: NodeMaterial): void;
  57108. protected _buildBlock(state: NodeMaterialBuildState): this;
  57109. }
  57110. }
  57111. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  57112. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57113. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57114. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57115. /**
  57116. * Block used to get the max of 2 values
  57117. */
  57118. export class MaxBlock extends NodeMaterialBlock {
  57119. /**
  57120. * Creates a new MaxBlock
  57121. * @param name defines the block name
  57122. */
  57123. constructor(name: string);
  57124. /**
  57125. * Gets the current class name
  57126. * @returns the class name
  57127. */
  57128. getClassName(): string;
  57129. /**
  57130. * Gets the left operand input component
  57131. */
  57132. readonly left: NodeMaterialConnectionPoint;
  57133. /**
  57134. * Gets the right operand input component
  57135. */
  57136. readonly right: NodeMaterialConnectionPoint;
  57137. /**
  57138. * Gets the output component
  57139. */
  57140. readonly output: NodeMaterialConnectionPoint;
  57141. protected _buildBlock(state: NodeMaterialBuildState): this;
  57142. }
  57143. }
  57144. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  57145. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57146. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57147. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57148. /**
  57149. * Block used to get the min of 2 values
  57150. */
  57151. export class MinBlock extends NodeMaterialBlock {
  57152. /**
  57153. * Creates a new MinBlock
  57154. * @param name defines the block name
  57155. */
  57156. constructor(name: string);
  57157. /**
  57158. * Gets the current class name
  57159. * @returns the class name
  57160. */
  57161. getClassName(): string;
  57162. /**
  57163. * Gets the left operand input component
  57164. */
  57165. readonly left: NodeMaterialConnectionPoint;
  57166. /**
  57167. * Gets the right operand input component
  57168. */
  57169. readonly right: NodeMaterialConnectionPoint;
  57170. /**
  57171. * Gets the output component
  57172. */
  57173. readonly output: NodeMaterialConnectionPoint;
  57174. protected _buildBlock(state: NodeMaterialBuildState): this;
  57175. }
  57176. }
  57177. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  57178. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57179. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57180. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57181. /**
  57182. * Block used to get the distance between 2 values
  57183. */
  57184. export class DistanceBlock extends NodeMaterialBlock {
  57185. /**
  57186. * Creates a new DistanceBlock
  57187. * @param name defines the block name
  57188. */
  57189. constructor(name: string);
  57190. /**
  57191. * Gets the current class name
  57192. * @returns the class name
  57193. */
  57194. getClassName(): string;
  57195. /**
  57196. * Gets the left operand input component
  57197. */
  57198. readonly left: NodeMaterialConnectionPoint;
  57199. /**
  57200. * Gets the right operand input component
  57201. */
  57202. readonly right: NodeMaterialConnectionPoint;
  57203. /**
  57204. * Gets the output component
  57205. */
  57206. readonly output: NodeMaterialConnectionPoint;
  57207. protected _buildBlock(state: NodeMaterialBuildState): this;
  57208. }
  57209. }
  57210. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  57211. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57212. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57213. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57214. /**
  57215. * Block used to get the length of a vector
  57216. */
  57217. export class LengthBlock extends NodeMaterialBlock {
  57218. /**
  57219. * Creates a new LengthBlock
  57220. * @param name defines the block name
  57221. */
  57222. constructor(name: string);
  57223. /**
  57224. * Gets the current class name
  57225. * @returns the class name
  57226. */
  57227. getClassName(): string;
  57228. /**
  57229. * Gets the value input component
  57230. */
  57231. readonly value: NodeMaterialConnectionPoint;
  57232. /**
  57233. * Gets the output component
  57234. */
  57235. readonly output: NodeMaterialConnectionPoint;
  57236. protected _buildBlock(state: NodeMaterialBuildState): this;
  57237. }
  57238. }
  57239. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  57240. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57241. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57242. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57243. /**
  57244. * Block used to get negative version of a value (i.e. x * -1)
  57245. */
  57246. export class NegateBlock extends NodeMaterialBlock {
  57247. /**
  57248. * Creates a new NegateBlock
  57249. * @param name defines the block name
  57250. */
  57251. constructor(name: string);
  57252. /**
  57253. * Gets the current class name
  57254. * @returns the class name
  57255. */
  57256. getClassName(): string;
  57257. /**
  57258. * Gets the value input component
  57259. */
  57260. readonly value: NodeMaterialConnectionPoint;
  57261. /**
  57262. * Gets the output component
  57263. */
  57264. readonly output: NodeMaterialConnectionPoint;
  57265. protected _buildBlock(state: NodeMaterialBuildState): this;
  57266. }
  57267. }
  57268. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  57269. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57270. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57271. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57272. /**
  57273. * Block used to get the value of the first parameter raised to the power of the second
  57274. */
  57275. export class PowBlock extends NodeMaterialBlock {
  57276. /**
  57277. * Creates a new PowBlock
  57278. * @param name defines the block name
  57279. */
  57280. constructor(name: string);
  57281. /**
  57282. * Gets the current class name
  57283. * @returns the class name
  57284. */
  57285. getClassName(): string;
  57286. /**
  57287. * Gets the value operand input component
  57288. */
  57289. readonly value: NodeMaterialConnectionPoint;
  57290. /**
  57291. * Gets the power operand input component
  57292. */
  57293. readonly power: NodeMaterialConnectionPoint;
  57294. /**
  57295. * Gets the output component
  57296. */
  57297. readonly output: NodeMaterialConnectionPoint;
  57298. protected _buildBlock(state: NodeMaterialBuildState): this;
  57299. }
  57300. }
  57301. declare module "babylonjs/Materials/Node/Blocks/index" {
  57302. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  57303. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  57304. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  57305. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  57306. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  57307. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  57308. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  57309. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  57310. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  57311. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  57312. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  57313. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  57314. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  57315. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  57316. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  57317. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  57318. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  57319. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  57320. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  57321. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  57322. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  57323. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  57324. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  57325. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  57326. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  57327. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  57328. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  57329. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  57330. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  57331. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  57332. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  57333. }
  57334. declare module "babylonjs/Materials/Node/Optimizers/index" {
  57335. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  57336. }
  57337. declare module "babylonjs/Materials/Node/index" {
  57338. export * from "babylonjs/Materials/Node/Enums/index";
  57339. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57340. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  57341. export * from "babylonjs/Materials/Node/nodeMaterial";
  57342. export * from "babylonjs/Materials/Node/Blocks/index";
  57343. export * from "babylonjs/Materials/Node/Optimizers/index";
  57344. }
  57345. declare module "babylonjs/Materials/effectRenderer" {
  57346. import { Nullable } from "babylonjs/types";
  57347. import { Texture } from "babylonjs/Materials/Textures/texture";
  57348. import { Engine } from "babylonjs/Engines/engine";
  57349. import { Viewport } from "babylonjs/Maths/math.viewport";
  57350. import { Observable } from "babylonjs/Misc/observable";
  57351. import { Effect } from "babylonjs/Materials/effect";
  57352. import "babylonjs/Shaders/postprocess.vertex";
  57353. /**
  57354. * Effect Render Options
  57355. */
  57356. export interface IEffectRendererOptions {
  57357. /**
  57358. * Defines the vertices positions.
  57359. */
  57360. positions?: number[];
  57361. /**
  57362. * Defines the indices.
  57363. */
  57364. indices?: number[];
  57365. }
  57366. /**
  57367. * Helper class to render one or more effects
  57368. */
  57369. export class EffectRenderer {
  57370. private engine;
  57371. private static _DefaultOptions;
  57372. private _vertexBuffers;
  57373. private _indexBuffer;
  57374. private _ringBufferIndex;
  57375. private _ringScreenBuffer;
  57376. private _fullscreenViewport;
  57377. private _getNextFrameBuffer;
  57378. /**
  57379. * Creates an effect renderer
  57380. * @param engine the engine to use for rendering
  57381. * @param options defines the options of the effect renderer
  57382. */
  57383. constructor(engine: Engine, options?: IEffectRendererOptions);
  57384. /**
  57385. * Sets the current viewport in normalized coordinates 0-1
  57386. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  57387. */
  57388. setViewport(viewport?: Viewport): void;
  57389. /**
  57390. * Binds the embedded attributes buffer to the effect.
  57391. * @param effect Defines the effect to bind the attributes for
  57392. */
  57393. bindBuffers(effect: Effect): void;
  57394. /**
  57395. * Sets the current effect wrapper to use during draw.
  57396. * The effect needs to be ready before calling this api.
  57397. * This also sets the default full screen position attribute.
  57398. * @param effectWrapper Defines the effect to draw with
  57399. */
  57400. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  57401. /**
  57402. * Draws a full screen quad.
  57403. */
  57404. draw(): void;
  57405. /**
  57406. * renders one or more effects to a specified texture
  57407. * @param effectWrappers list of effects to renderer
  57408. * @param outputTexture texture to draw to, if null it will render to the screen
  57409. */
  57410. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  57411. /**
  57412. * Disposes of the effect renderer
  57413. */
  57414. dispose(): void;
  57415. }
  57416. /**
  57417. * Options to create an EffectWrapper
  57418. */
  57419. interface EffectWrapperCreationOptions {
  57420. /**
  57421. * Engine to use to create the effect
  57422. */
  57423. engine: Engine;
  57424. /**
  57425. * Fragment shader for the effect
  57426. */
  57427. fragmentShader: string;
  57428. /**
  57429. * Vertex shader for the effect
  57430. */
  57431. vertexShader?: string;
  57432. /**
  57433. * Attributes to use in the shader
  57434. */
  57435. attributeNames?: Array<string>;
  57436. /**
  57437. * Uniforms to use in the shader
  57438. */
  57439. uniformNames?: Array<string>;
  57440. /**
  57441. * Texture sampler names to use in the shader
  57442. */
  57443. samplerNames?: Array<string>;
  57444. /**
  57445. * The friendly name of the effect displayed in Spector.
  57446. */
  57447. name?: string;
  57448. }
  57449. /**
  57450. * Wraps an effect to be used for rendering
  57451. */
  57452. export class EffectWrapper {
  57453. /**
  57454. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  57455. */
  57456. onApplyObservable: Observable<{}>;
  57457. /**
  57458. * The underlying effect
  57459. */
  57460. effect: Effect;
  57461. /**
  57462. * Creates an effect to be renderer
  57463. * @param creationOptions options to create the effect
  57464. */
  57465. constructor(creationOptions: EffectWrapperCreationOptions);
  57466. /**
  57467. * Disposes of the effect wrapper
  57468. */
  57469. dispose(): void;
  57470. }
  57471. }
  57472. declare module "babylonjs/Materials/index" {
  57473. export * from "babylonjs/Materials/Background/index";
  57474. export * from "babylonjs/Materials/colorCurves";
  57475. export * from "babylonjs/Materials/effect";
  57476. export * from "babylonjs/Materials/fresnelParameters";
  57477. export * from "babylonjs/Materials/imageProcessingConfiguration";
  57478. export * from "babylonjs/Materials/material";
  57479. export * from "babylonjs/Materials/materialDefines";
  57480. export * from "babylonjs/Materials/materialHelper";
  57481. export * from "babylonjs/Materials/multiMaterial";
  57482. export * from "babylonjs/Materials/PBR/index";
  57483. export * from "babylonjs/Materials/pushMaterial";
  57484. export * from "babylonjs/Materials/shaderMaterial";
  57485. export * from "babylonjs/Materials/standardMaterial";
  57486. export * from "babylonjs/Materials/Textures/index";
  57487. export * from "babylonjs/Materials/uniformBuffer";
  57488. export * from "babylonjs/Materials/materialFlags";
  57489. export * from "babylonjs/Materials/Node/index";
  57490. export * from "babylonjs/Materials/effectRenderer";
  57491. }
  57492. declare module "babylonjs/Maths/index" {
  57493. export * from "babylonjs/Maths/math.scalar";
  57494. export * from "babylonjs/Maths/math";
  57495. export * from "babylonjs/Maths/sphericalPolynomial";
  57496. }
  57497. declare module "babylonjs/Misc/workerPool" {
  57498. import { IDisposable } from "babylonjs/scene";
  57499. /**
  57500. * Helper class to push actions to a pool of workers.
  57501. */
  57502. export class WorkerPool implements IDisposable {
  57503. private _workerInfos;
  57504. private _pendingActions;
  57505. /**
  57506. * Constructor
  57507. * @param workers Array of workers to use for actions
  57508. */
  57509. constructor(workers: Array<Worker>);
  57510. /**
  57511. * Terminates all workers and clears any pending actions.
  57512. */
  57513. dispose(): void;
  57514. /**
  57515. * Pushes an action to the worker pool. If all the workers are active, the action will be
  57516. * pended until a worker has completed its action.
  57517. * @param action The action to perform. Call onComplete when the action is complete.
  57518. */
  57519. push(action: (worker: Worker, onComplete: () => void) => void): void;
  57520. private _execute;
  57521. }
  57522. }
  57523. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  57524. import { IDisposable } from "babylonjs/scene";
  57525. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  57526. /**
  57527. * Configuration for Draco compression
  57528. */
  57529. export interface IDracoCompressionConfiguration {
  57530. /**
  57531. * Configuration for the decoder.
  57532. */
  57533. decoder: {
  57534. /**
  57535. * The url to the WebAssembly module.
  57536. */
  57537. wasmUrl?: string;
  57538. /**
  57539. * The url to the WebAssembly binary.
  57540. */
  57541. wasmBinaryUrl?: string;
  57542. /**
  57543. * The url to the fallback JavaScript module.
  57544. */
  57545. fallbackUrl?: string;
  57546. };
  57547. }
  57548. /**
  57549. * Draco compression (https://google.github.io/draco/)
  57550. *
  57551. * This class wraps the Draco module.
  57552. *
  57553. * **Encoder**
  57554. *
  57555. * The encoder is not currently implemented.
  57556. *
  57557. * **Decoder**
  57558. *
  57559. * 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.
  57560. *
  57561. * To update the configuration, use the following code:
  57562. * ```javascript
  57563. * DracoCompression.Configuration = {
  57564. * decoder: {
  57565. * wasmUrl: "<url to the WebAssembly library>",
  57566. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  57567. * fallbackUrl: "<url to the fallback JavaScript library>",
  57568. * }
  57569. * };
  57570. * ```
  57571. *
  57572. * 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.
  57573. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  57574. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  57575. *
  57576. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  57577. * ```javascript
  57578. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  57579. * ```
  57580. *
  57581. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  57582. */
  57583. export class DracoCompression implements IDisposable {
  57584. private _workerPoolPromise?;
  57585. private _decoderModulePromise?;
  57586. /**
  57587. * The configuration. Defaults to the following urls:
  57588. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  57589. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  57590. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  57591. */
  57592. static Configuration: IDracoCompressionConfiguration;
  57593. /**
  57594. * Returns true if the decoder configuration is available.
  57595. */
  57596. static readonly DecoderAvailable: boolean;
  57597. /**
  57598. * Default number of workers to create when creating the draco compression object.
  57599. */
  57600. static DefaultNumWorkers: number;
  57601. private static GetDefaultNumWorkers;
  57602. private static _Default;
  57603. /**
  57604. * Default instance for the draco compression object.
  57605. */
  57606. static readonly Default: DracoCompression;
  57607. /**
  57608. * Constructor
  57609. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  57610. */
  57611. constructor(numWorkers?: number);
  57612. /**
  57613. * Stop all async operations and release resources.
  57614. */
  57615. dispose(): void;
  57616. /**
  57617. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  57618. * @returns a promise that resolves when ready
  57619. */
  57620. whenReadyAsync(): Promise<void>;
  57621. /**
  57622. * Decode Draco compressed mesh data to vertex data.
  57623. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  57624. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  57625. * @returns A promise that resolves with the decoded vertex data
  57626. */
  57627. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  57628. [kind: string]: number;
  57629. }): Promise<VertexData>;
  57630. }
  57631. }
  57632. declare module "babylonjs/Meshes/Compression/index" {
  57633. export * from "babylonjs/Meshes/Compression/dracoCompression";
  57634. }
  57635. declare module "babylonjs/Meshes/csg" {
  57636. import { Nullable } from "babylonjs/types";
  57637. import { Scene } from "babylonjs/scene";
  57638. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57639. import { Mesh } from "babylonjs/Meshes/mesh";
  57640. import { Material } from "babylonjs/Materials/material";
  57641. /**
  57642. * Class for building Constructive Solid Geometry
  57643. */
  57644. export class CSG {
  57645. private polygons;
  57646. /**
  57647. * The world matrix
  57648. */
  57649. matrix: Matrix;
  57650. /**
  57651. * Stores the position
  57652. */
  57653. position: Vector3;
  57654. /**
  57655. * Stores the rotation
  57656. */
  57657. rotation: Vector3;
  57658. /**
  57659. * Stores the rotation quaternion
  57660. */
  57661. rotationQuaternion: Nullable<Quaternion>;
  57662. /**
  57663. * Stores the scaling vector
  57664. */
  57665. scaling: Vector3;
  57666. /**
  57667. * Convert the Mesh to CSG
  57668. * @param mesh The Mesh to convert to CSG
  57669. * @returns A new CSG from the Mesh
  57670. */
  57671. static FromMesh(mesh: Mesh): CSG;
  57672. /**
  57673. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  57674. * @param polygons Polygons used to construct a CSG solid
  57675. */
  57676. private static FromPolygons;
  57677. /**
  57678. * Clones, or makes a deep copy, of the CSG
  57679. * @returns A new CSG
  57680. */
  57681. clone(): CSG;
  57682. /**
  57683. * Unions this CSG with another CSG
  57684. * @param csg The CSG to union against this CSG
  57685. * @returns The unioned CSG
  57686. */
  57687. union(csg: CSG): CSG;
  57688. /**
  57689. * Unions this CSG with another CSG in place
  57690. * @param csg The CSG to union against this CSG
  57691. */
  57692. unionInPlace(csg: CSG): void;
  57693. /**
  57694. * Subtracts this CSG with another CSG
  57695. * @param csg The CSG to subtract against this CSG
  57696. * @returns A new CSG
  57697. */
  57698. subtract(csg: CSG): CSG;
  57699. /**
  57700. * Subtracts this CSG with another CSG in place
  57701. * @param csg The CSG to subtact against this CSG
  57702. */
  57703. subtractInPlace(csg: CSG): void;
  57704. /**
  57705. * Intersect this CSG with another CSG
  57706. * @param csg The CSG to intersect against this CSG
  57707. * @returns A new CSG
  57708. */
  57709. intersect(csg: CSG): CSG;
  57710. /**
  57711. * Intersects this CSG with another CSG in place
  57712. * @param csg The CSG to intersect against this CSG
  57713. */
  57714. intersectInPlace(csg: CSG): void;
  57715. /**
  57716. * Return a new CSG solid with solid and empty space switched. This solid is
  57717. * not modified.
  57718. * @returns A new CSG solid with solid and empty space switched
  57719. */
  57720. inverse(): CSG;
  57721. /**
  57722. * Inverses the CSG in place
  57723. */
  57724. inverseInPlace(): void;
  57725. /**
  57726. * This is used to keep meshes transformations so they can be restored
  57727. * when we build back a Babylon Mesh
  57728. * NB : All CSG operations are performed in world coordinates
  57729. * @param csg The CSG to copy the transform attributes from
  57730. * @returns This CSG
  57731. */
  57732. copyTransformAttributes(csg: CSG): CSG;
  57733. /**
  57734. * Build Raw mesh from CSG
  57735. * Coordinates here are in world space
  57736. * @param name The name of the mesh geometry
  57737. * @param scene The Scene
  57738. * @param keepSubMeshes Specifies if the submeshes should be kept
  57739. * @returns A new Mesh
  57740. */
  57741. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  57742. /**
  57743. * Build Mesh from CSG taking material and transforms into account
  57744. * @param name The name of the Mesh
  57745. * @param material The material of the Mesh
  57746. * @param scene The Scene
  57747. * @param keepSubMeshes Specifies if submeshes should be kept
  57748. * @returns The new Mesh
  57749. */
  57750. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  57751. }
  57752. }
  57753. declare module "babylonjs/Meshes/trailMesh" {
  57754. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57755. import { Mesh } from "babylonjs/Meshes/mesh";
  57756. import { Scene } from "babylonjs/scene";
  57757. /**
  57758. * Class used to create a trail following a mesh
  57759. */
  57760. export class TrailMesh extends Mesh {
  57761. private _generator;
  57762. private _autoStart;
  57763. private _running;
  57764. private _diameter;
  57765. private _length;
  57766. private _sectionPolygonPointsCount;
  57767. private _sectionVectors;
  57768. private _sectionNormalVectors;
  57769. private _beforeRenderObserver;
  57770. /**
  57771. * @constructor
  57772. * @param name The value used by scene.getMeshByName() to do a lookup.
  57773. * @param generator The mesh to generate a trail.
  57774. * @param scene The scene to add this mesh to.
  57775. * @param diameter Diameter of trailing mesh. Default is 1.
  57776. * @param length Length of trailing mesh. Default is 60.
  57777. * @param autoStart Automatically start trailing mesh. Default true.
  57778. */
  57779. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  57780. /**
  57781. * "TrailMesh"
  57782. * @returns "TrailMesh"
  57783. */
  57784. getClassName(): string;
  57785. private _createMesh;
  57786. /**
  57787. * Start trailing mesh.
  57788. */
  57789. start(): void;
  57790. /**
  57791. * Stop trailing mesh.
  57792. */
  57793. stop(): void;
  57794. /**
  57795. * Update trailing mesh geometry.
  57796. */
  57797. update(): void;
  57798. /**
  57799. * Returns a new TrailMesh object.
  57800. * @param name is a string, the name given to the new mesh
  57801. * @param newGenerator use new generator object for cloned trail mesh
  57802. * @returns a new mesh
  57803. */
  57804. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  57805. /**
  57806. * Serializes this trail mesh
  57807. * @param serializationObject object to write serialization to
  57808. */
  57809. serialize(serializationObject: any): void;
  57810. /**
  57811. * Parses a serialized trail mesh
  57812. * @param parsedMesh the serialized mesh
  57813. * @param scene the scene to create the trail mesh in
  57814. * @returns the created trail mesh
  57815. */
  57816. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  57817. }
  57818. }
  57819. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  57820. import { Nullable } from "babylonjs/types";
  57821. import { Scene } from "babylonjs/scene";
  57822. import { Vector4 } from "babylonjs/Maths/math.vector";
  57823. import { Color4 } from "babylonjs/Maths/math.color";
  57824. import { Mesh } from "babylonjs/Meshes/mesh";
  57825. /**
  57826. * Class containing static functions to help procedurally build meshes
  57827. */
  57828. export class TiledBoxBuilder {
  57829. /**
  57830. * Creates a box mesh
  57831. * 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)
  57832. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57833. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57834. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57835. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57836. * @param name defines the name of the mesh
  57837. * @param options defines the options used to create the mesh
  57838. * @param scene defines the hosting scene
  57839. * @returns the box mesh
  57840. */
  57841. static CreateTiledBox(name: string, options: {
  57842. pattern?: number;
  57843. width?: number;
  57844. height?: number;
  57845. depth?: number;
  57846. tileSize?: number;
  57847. tileWidth?: number;
  57848. tileHeight?: number;
  57849. alignHorizontal?: number;
  57850. alignVertical?: number;
  57851. faceUV?: Vector4[];
  57852. faceColors?: Color4[];
  57853. sideOrientation?: number;
  57854. updatable?: boolean;
  57855. }, scene?: Nullable<Scene>): Mesh;
  57856. }
  57857. }
  57858. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  57859. import { Vector4 } from "babylonjs/Maths/math.vector";
  57860. import { Mesh } from "babylonjs/Meshes/mesh";
  57861. /**
  57862. * Class containing static functions to help procedurally build meshes
  57863. */
  57864. export class TorusKnotBuilder {
  57865. /**
  57866. * Creates a torus knot mesh
  57867. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  57868. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  57869. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  57870. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  57871. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57872. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57873. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57874. * @param name defines the name of the mesh
  57875. * @param options defines the options used to create the mesh
  57876. * @param scene defines the hosting scene
  57877. * @returns the torus knot mesh
  57878. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  57879. */
  57880. static CreateTorusKnot(name: string, options: {
  57881. radius?: number;
  57882. tube?: number;
  57883. radialSegments?: number;
  57884. tubularSegments?: number;
  57885. p?: number;
  57886. q?: number;
  57887. updatable?: boolean;
  57888. sideOrientation?: number;
  57889. frontUVs?: Vector4;
  57890. backUVs?: Vector4;
  57891. }, scene: any): Mesh;
  57892. }
  57893. }
  57894. declare module "babylonjs/Meshes/polygonMesh" {
  57895. import { Scene } from "babylonjs/scene";
  57896. import { Vector2 } from "babylonjs/Maths/math.vector";
  57897. import { Mesh } from "babylonjs/Meshes/mesh";
  57898. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  57899. import { Path2 } from "babylonjs/Maths/math.path";
  57900. /**
  57901. * Polygon
  57902. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  57903. */
  57904. export class Polygon {
  57905. /**
  57906. * Creates a rectangle
  57907. * @param xmin bottom X coord
  57908. * @param ymin bottom Y coord
  57909. * @param xmax top X coord
  57910. * @param ymax top Y coord
  57911. * @returns points that make the resulting rectation
  57912. */
  57913. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  57914. /**
  57915. * Creates a circle
  57916. * @param radius radius of circle
  57917. * @param cx scale in x
  57918. * @param cy scale in y
  57919. * @param numberOfSides number of sides that make up the circle
  57920. * @returns points that make the resulting circle
  57921. */
  57922. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  57923. /**
  57924. * Creates a polygon from input string
  57925. * @param input Input polygon data
  57926. * @returns the parsed points
  57927. */
  57928. static Parse(input: string): Vector2[];
  57929. /**
  57930. * Starts building a polygon from x and y coordinates
  57931. * @param x x coordinate
  57932. * @param y y coordinate
  57933. * @returns the started path2
  57934. */
  57935. static StartingAt(x: number, y: number): Path2;
  57936. }
  57937. /**
  57938. * Builds a polygon
  57939. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  57940. */
  57941. export class PolygonMeshBuilder {
  57942. private _points;
  57943. private _outlinepoints;
  57944. private _holes;
  57945. private _name;
  57946. private _scene;
  57947. private _epoints;
  57948. private _eholes;
  57949. private _addToepoint;
  57950. /**
  57951. * Babylon reference to the earcut plugin.
  57952. */
  57953. bjsEarcut: any;
  57954. /**
  57955. * Creates a PolygonMeshBuilder
  57956. * @param name name of the builder
  57957. * @param contours Path of the polygon
  57958. * @param scene scene to add to when creating the mesh
  57959. * @param earcutInjection can be used to inject your own earcut reference
  57960. */
  57961. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  57962. /**
  57963. * Adds a whole within the polygon
  57964. * @param hole Array of points defining the hole
  57965. * @returns this
  57966. */
  57967. addHole(hole: Vector2[]): PolygonMeshBuilder;
  57968. /**
  57969. * Creates the polygon
  57970. * @param updatable If the mesh should be updatable
  57971. * @param depth The depth of the mesh created
  57972. * @returns the created mesh
  57973. */
  57974. build(updatable?: boolean, depth?: number): Mesh;
  57975. /**
  57976. * Creates the polygon
  57977. * @param depth The depth of the mesh created
  57978. * @returns the created VertexData
  57979. */
  57980. buildVertexData(depth?: number): VertexData;
  57981. /**
  57982. * Adds a side to the polygon
  57983. * @param positions points that make the polygon
  57984. * @param normals normals of the polygon
  57985. * @param uvs uvs of the polygon
  57986. * @param indices indices of the polygon
  57987. * @param bounds bounds of the polygon
  57988. * @param points points of the polygon
  57989. * @param depth depth of the polygon
  57990. * @param flip flip of the polygon
  57991. */
  57992. private addSide;
  57993. }
  57994. }
  57995. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  57996. import { Scene } from "babylonjs/scene";
  57997. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57998. import { Color4 } from "babylonjs/Maths/math.color";
  57999. import { Mesh } from "babylonjs/Meshes/mesh";
  58000. import { Nullable } from "babylonjs/types";
  58001. /**
  58002. * Class containing static functions to help procedurally build meshes
  58003. */
  58004. export class PolygonBuilder {
  58005. /**
  58006. * Creates a polygon mesh
  58007. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  58008. * * 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
  58009. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58010. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58011. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  58012. * * Remember you can only change the shape positions, not their number when updating a polygon
  58013. * @param name defines the name of the mesh
  58014. * @param options defines the options used to create the mesh
  58015. * @param scene defines the hosting scene
  58016. * @param earcutInjection can be used to inject your own earcut reference
  58017. * @returns the polygon mesh
  58018. */
  58019. static CreatePolygon(name: string, options: {
  58020. shape: Vector3[];
  58021. holes?: Vector3[][];
  58022. depth?: number;
  58023. faceUV?: Vector4[];
  58024. faceColors?: Color4[];
  58025. updatable?: boolean;
  58026. sideOrientation?: number;
  58027. frontUVs?: Vector4;
  58028. backUVs?: Vector4;
  58029. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58030. /**
  58031. * Creates an extruded polygon mesh, with depth in the Y direction.
  58032. * * 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)
  58033. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58034. * @param name defines the name of the mesh
  58035. * @param options defines the options used to create the mesh
  58036. * @param scene defines the hosting scene
  58037. * @param earcutInjection can be used to inject your own earcut reference
  58038. * @returns the polygon mesh
  58039. */
  58040. static ExtrudePolygon(name: string, options: {
  58041. shape: Vector3[];
  58042. holes?: Vector3[][];
  58043. depth?: number;
  58044. faceUV?: Vector4[];
  58045. faceColors?: Color4[];
  58046. updatable?: boolean;
  58047. sideOrientation?: number;
  58048. frontUVs?: Vector4;
  58049. backUVs?: Vector4;
  58050. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58051. }
  58052. }
  58053. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  58054. import { Scene } from "babylonjs/scene";
  58055. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58056. import { Mesh } from "babylonjs/Meshes/mesh";
  58057. import { Nullable } from "babylonjs/types";
  58058. /**
  58059. * Class containing static functions to help procedurally build meshes
  58060. */
  58061. export class LatheBuilder {
  58062. /**
  58063. * Creates lathe mesh.
  58064. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  58065. * * 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
  58066. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  58067. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  58068. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  58069. * * 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
  58070. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  58071. * * 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
  58072. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58073. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58074. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58076. * @param name defines the name of the mesh
  58077. * @param options defines the options used to create the mesh
  58078. * @param scene defines the hosting scene
  58079. * @returns the lathe mesh
  58080. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  58081. */
  58082. static CreateLathe(name: string, options: {
  58083. shape: Vector3[];
  58084. radius?: number;
  58085. tessellation?: number;
  58086. clip?: number;
  58087. arc?: number;
  58088. closed?: boolean;
  58089. updatable?: boolean;
  58090. sideOrientation?: number;
  58091. frontUVs?: Vector4;
  58092. backUVs?: Vector4;
  58093. cap?: number;
  58094. invertUV?: boolean;
  58095. }, scene?: Nullable<Scene>): Mesh;
  58096. }
  58097. }
  58098. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  58099. import { Nullable } from "babylonjs/types";
  58100. import { Scene } from "babylonjs/scene";
  58101. import { Vector4 } from "babylonjs/Maths/math.vector";
  58102. import { Mesh } from "babylonjs/Meshes/mesh";
  58103. /**
  58104. * Class containing static functions to help procedurally build meshes
  58105. */
  58106. export class TiledPlaneBuilder {
  58107. /**
  58108. * Creates a tiled plane mesh
  58109. * * The parameter `pattern` will, depending on value, do nothing or
  58110. * * * flip (reflect about central vertical) alternate tiles across and up
  58111. * * * flip every tile on alternate rows
  58112. * * * rotate (180 degs) alternate tiles across and up
  58113. * * * rotate every tile on alternate rows
  58114. * * * flip and rotate alternate tiles across and up
  58115. * * * flip and rotate every tile on alternate rows
  58116. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  58117. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  58118. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58119. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58120. * * 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)
  58121. * * 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)
  58122. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  58123. * @param name defines the name of the mesh
  58124. * @param options defines the options used to create the mesh
  58125. * @param scene defines the hosting scene
  58126. * @returns the box mesh
  58127. */
  58128. static CreateTiledPlane(name: string, options: {
  58129. pattern?: number;
  58130. tileSize?: number;
  58131. tileWidth?: number;
  58132. tileHeight?: number;
  58133. size?: number;
  58134. width?: number;
  58135. height?: number;
  58136. alignHorizontal?: number;
  58137. alignVertical?: number;
  58138. sideOrientation?: number;
  58139. frontUVs?: Vector4;
  58140. backUVs?: Vector4;
  58141. updatable?: boolean;
  58142. }, scene?: Nullable<Scene>): Mesh;
  58143. }
  58144. }
  58145. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  58146. import { Nullable } from "babylonjs/types";
  58147. import { Scene } from "babylonjs/scene";
  58148. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58149. import { Mesh } from "babylonjs/Meshes/mesh";
  58150. /**
  58151. * Class containing static functions to help procedurally build meshes
  58152. */
  58153. export class TubeBuilder {
  58154. /**
  58155. * Creates a tube mesh.
  58156. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58157. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  58158. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  58159. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  58160. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  58161. * * 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)
  58162. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  58163. * * 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
  58164. * * 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
  58165. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58166. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58167. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58168. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58169. * @param name defines the name of the mesh
  58170. * @param options defines the options used to create the mesh
  58171. * @param scene defines the hosting scene
  58172. * @returns the tube mesh
  58173. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58174. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  58175. */
  58176. static CreateTube(name: string, options: {
  58177. path: Vector3[];
  58178. radius?: number;
  58179. tessellation?: number;
  58180. radiusFunction?: {
  58181. (i: number, distance: number): number;
  58182. };
  58183. cap?: number;
  58184. arc?: number;
  58185. updatable?: boolean;
  58186. sideOrientation?: number;
  58187. frontUVs?: Vector4;
  58188. backUVs?: Vector4;
  58189. instance?: Mesh;
  58190. invertUV?: boolean;
  58191. }, scene?: Nullable<Scene>): Mesh;
  58192. }
  58193. }
  58194. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  58195. import { Scene } from "babylonjs/scene";
  58196. import { Vector4 } from "babylonjs/Maths/math.vector";
  58197. import { Mesh } from "babylonjs/Meshes/mesh";
  58198. import { Nullable } from "babylonjs/types";
  58199. /**
  58200. * Class containing static functions to help procedurally build meshes
  58201. */
  58202. export class IcoSphereBuilder {
  58203. /**
  58204. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  58205. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  58206. * * 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`)
  58207. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  58208. * * 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
  58209. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58210. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58211. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58212. * @param name defines the name of the mesh
  58213. * @param options defines the options used to create the mesh
  58214. * @param scene defines the hosting scene
  58215. * @returns the icosahedron mesh
  58216. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  58217. */
  58218. static CreateIcoSphere(name: string, options: {
  58219. radius?: number;
  58220. radiusX?: number;
  58221. radiusY?: number;
  58222. radiusZ?: number;
  58223. flat?: boolean;
  58224. subdivisions?: number;
  58225. sideOrientation?: number;
  58226. frontUVs?: Vector4;
  58227. backUVs?: Vector4;
  58228. updatable?: boolean;
  58229. }, scene?: Nullable<Scene>): Mesh;
  58230. }
  58231. }
  58232. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  58233. import { Vector3 } from "babylonjs/Maths/math.vector";
  58234. import { Mesh } from "babylonjs/Meshes/mesh";
  58235. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58236. /**
  58237. * Class containing static functions to help procedurally build meshes
  58238. */
  58239. export class DecalBuilder {
  58240. /**
  58241. * Creates a decal mesh.
  58242. * 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
  58243. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  58244. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  58245. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  58246. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  58247. * @param name defines the name of the mesh
  58248. * @param sourceMesh defines the mesh where the decal must be applied
  58249. * @param options defines the options used to create the mesh
  58250. * @param scene defines the hosting scene
  58251. * @returns the decal mesh
  58252. * @see https://doc.babylonjs.com/how_to/decals
  58253. */
  58254. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  58255. position?: Vector3;
  58256. normal?: Vector3;
  58257. size?: Vector3;
  58258. angle?: number;
  58259. }): Mesh;
  58260. }
  58261. }
  58262. declare module "babylonjs/Meshes/meshBuilder" {
  58263. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  58264. import { Nullable } from "babylonjs/types";
  58265. import { Scene } from "babylonjs/scene";
  58266. import { Mesh } from "babylonjs/Meshes/mesh";
  58267. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  58268. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  58269. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58270. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  58271. import { Plane } from "babylonjs/Maths/math.plane";
  58272. /**
  58273. * Class containing static functions to help procedurally build meshes
  58274. */
  58275. export class MeshBuilder {
  58276. /**
  58277. * Creates a box mesh
  58278. * * The parameter `size` sets the size (float) of each box side (default 1)
  58279. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  58280. * * 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)
  58281. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58282. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58283. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58284. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58285. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  58286. * @param name defines the name of the mesh
  58287. * @param options defines the options used to create the mesh
  58288. * @param scene defines the hosting scene
  58289. * @returns the box mesh
  58290. */
  58291. static CreateBox(name: string, options: {
  58292. size?: number;
  58293. width?: number;
  58294. height?: number;
  58295. depth?: number;
  58296. faceUV?: Vector4[];
  58297. faceColors?: Color4[];
  58298. sideOrientation?: number;
  58299. frontUVs?: Vector4;
  58300. backUVs?: Vector4;
  58301. updatable?: boolean;
  58302. }, scene?: Nullable<Scene>): Mesh;
  58303. /**
  58304. * Creates a tiled box mesh
  58305. * * faceTiles sets the pattern, tile size and number of tiles for a face
  58306. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58307. * @param name defines the name of the mesh
  58308. * @param options defines the options used to create the mesh
  58309. * @param scene defines the hosting scene
  58310. * @returns the tiled box mesh
  58311. */
  58312. static CreateTiledBox(name: string, options: {
  58313. pattern?: number;
  58314. size?: number;
  58315. width?: number;
  58316. height?: number;
  58317. depth: number;
  58318. tileSize?: number;
  58319. tileWidth?: number;
  58320. tileHeight?: number;
  58321. faceUV?: Vector4[];
  58322. faceColors?: Color4[];
  58323. alignHorizontal?: number;
  58324. alignVertical?: number;
  58325. sideOrientation?: number;
  58326. updatable?: boolean;
  58327. }, scene?: Nullable<Scene>): Mesh;
  58328. /**
  58329. * Creates a sphere mesh
  58330. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  58331. * * 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`)
  58332. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  58333. * * 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
  58334. * * 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)
  58335. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58336. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58337. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58338. * @param name defines the name of the mesh
  58339. * @param options defines the options used to create the mesh
  58340. * @param scene defines the hosting scene
  58341. * @returns the sphere mesh
  58342. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  58343. */
  58344. static CreateSphere(name: string, options: {
  58345. segments?: number;
  58346. diameter?: number;
  58347. diameterX?: number;
  58348. diameterY?: number;
  58349. diameterZ?: number;
  58350. arc?: number;
  58351. slice?: number;
  58352. sideOrientation?: number;
  58353. frontUVs?: Vector4;
  58354. backUVs?: Vector4;
  58355. updatable?: boolean;
  58356. }, scene?: Nullable<Scene>): Mesh;
  58357. /**
  58358. * Creates a plane polygonal mesh. By default, this is a disc
  58359. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  58360. * * 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
  58361. * * 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
  58362. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58363. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58364. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58365. * @param name defines the name of the mesh
  58366. * @param options defines the options used to create the mesh
  58367. * @param scene defines the hosting scene
  58368. * @returns the plane polygonal mesh
  58369. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  58370. */
  58371. static CreateDisc(name: string, options: {
  58372. radius?: number;
  58373. tessellation?: number;
  58374. arc?: number;
  58375. updatable?: boolean;
  58376. sideOrientation?: number;
  58377. frontUVs?: Vector4;
  58378. backUVs?: Vector4;
  58379. }, scene?: Nullable<Scene>): Mesh;
  58380. /**
  58381. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  58382. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  58383. * * 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`)
  58384. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  58385. * * 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
  58386. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58387. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58388. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58389. * @param name defines the name of the mesh
  58390. * @param options defines the options used to create the mesh
  58391. * @param scene defines the hosting scene
  58392. * @returns the icosahedron mesh
  58393. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  58394. */
  58395. static CreateIcoSphere(name: string, options: {
  58396. radius?: number;
  58397. radiusX?: number;
  58398. radiusY?: number;
  58399. radiusZ?: number;
  58400. flat?: boolean;
  58401. subdivisions?: number;
  58402. sideOrientation?: number;
  58403. frontUVs?: Vector4;
  58404. backUVs?: Vector4;
  58405. updatable?: boolean;
  58406. }, scene?: Nullable<Scene>): Mesh;
  58407. /**
  58408. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58409. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58410. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58411. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58412. * * 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
  58413. * * 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
  58414. * * 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
  58415. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58416. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58417. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58418. * * 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
  58419. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58420. * * 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
  58421. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58422. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58423. * @param name defines the name of the mesh
  58424. * @param options defines the options used to create the mesh
  58425. * @param scene defines the hosting scene
  58426. * @returns the ribbon mesh
  58427. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58428. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58429. */
  58430. static CreateRibbon(name: string, options: {
  58431. pathArray: Vector3[][];
  58432. closeArray?: boolean;
  58433. closePath?: boolean;
  58434. offset?: number;
  58435. updatable?: boolean;
  58436. sideOrientation?: number;
  58437. frontUVs?: Vector4;
  58438. backUVs?: Vector4;
  58439. instance?: Mesh;
  58440. invertUV?: boolean;
  58441. uvs?: Vector2[];
  58442. colors?: Color4[];
  58443. }, scene?: Nullable<Scene>): Mesh;
  58444. /**
  58445. * Creates a cylinder or a cone mesh
  58446. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  58447. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  58448. * * 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.
  58449. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  58450. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  58451. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  58452. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  58453. * * 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).
  58454. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  58455. * * 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).
  58456. * * 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
  58457. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  58458. * * 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
  58459. * * 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.
  58460. * * If `enclose` is false, a ring surface is one element.
  58461. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  58462. * * 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
  58463. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58464. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58465. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58466. * @param name defines the name of the mesh
  58467. * @param options defines the options used to create the mesh
  58468. * @param scene defines the hosting scene
  58469. * @returns the cylinder mesh
  58470. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  58471. */
  58472. static CreateCylinder(name: string, options: {
  58473. height?: number;
  58474. diameterTop?: number;
  58475. diameterBottom?: number;
  58476. diameter?: number;
  58477. tessellation?: number;
  58478. subdivisions?: number;
  58479. arc?: number;
  58480. faceColors?: Color4[];
  58481. faceUV?: Vector4[];
  58482. updatable?: boolean;
  58483. hasRings?: boolean;
  58484. enclose?: boolean;
  58485. cap?: number;
  58486. sideOrientation?: number;
  58487. frontUVs?: Vector4;
  58488. backUVs?: Vector4;
  58489. }, scene?: Nullable<Scene>): Mesh;
  58490. /**
  58491. * Creates a torus mesh
  58492. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  58493. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  58494. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  58495. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58496. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58497. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58498. * @param name defines the name of the mesh
  58499. * @param options defines the options used to create the mesh
  58500. * @param scene defines the hosting scene
  58501. * @returns the torus mesh
  58502. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  58503. */
  58504. static CreateTorus(name: string, options: {
  58505. diameter?: number;
  58506. thickness?: number;
  58507. tessellation?: number;
  58508. updatable?: boolean;
  58509. sideOrientation?: number;
  58510. frontUVs?: Vector4;
  58511. backUVs?: Vector4;
  58512. }, scene?: Nullable<Scene>): Mesh;
  58513. /**
  58514. * Creates a torus knot mesh
  58515. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  58516. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  58517. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  58518. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  58519. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58520. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58521. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58522. * @param name defines the name of the mesh
  58523. * @param options defines the options used to create the mesh
  58524. * @param scene defines the hosting scene
  58525. * @returns the torus knot mesh
  58526. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  58527. */
  58528. static CreateTorusKnot(name: string, options: {
  58529. radius?: number;
  58530. tube?: number;
  58531. radialSegments?: number;
  58532. tubularSegments?: number;
  58533. p?: number;
  58534. q?: number;
  58535. updatable?: boolean;
  58536. sideOrientation?: number;
  58537. frontUVs?: Vector4;
  58538. backUVs?: Vector4;
  58539. }, scene?: Nullable<Scene>): Mesh;
  58540. /**
  58541. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  58542. * * 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
  58543. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  58544. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  58545. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  58546. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  58547. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  58548. * * 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
  58549. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  58550. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58551. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  58552. * @param name defines the name of the new line system
  58553. * @param options defines the options used to create the line system
  58554. * @param scene defines the hosting scene
  58555. * @returns a new line system mesh
  58556. */
  58557. static CreateLineSystem(name: string, options: {
  58558. lines: Vector3[][];
  58559. updatable?: boolean;
  58560. instance?: Nullable<LinesMesh>;
  58561. colors?: Nullable<Color4[][]>;
  58562. useVertexAlpha?: boolean;
  58563. }, scene: Nullable<Scene>): LinesMesh;
  58564. /**
  58565. * Creates a line mesh
  58566. * 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
  58567. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  58568. * * The parameter `points` is an array successive Vector3
  58569. * * 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
  58570. * * The optional parameter `colors` is an array of successive Color4, one per line point
  58571. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  58572. * * When updating an instance, remember that only point positions can change, not the number of points
  58573. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58574. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  58575. * @param name defines the name of the new line system
  58576. * @param options defines the options used to create the line system
  58577. * @param scene defines the hosting scene
  58578. * @returns a new line mesh
  58579. */
  58580. static CreateLines(name: string, options: {
  58581. points: Vector3[];
  58582. updatable?: boolean;
  58583. instance?: Nullable<LinesMesh>;
  58584. colors?: Color4[];
  58585. useVertexAlpha?: boolean;
  58586. }, scene?: Nullable<Scene>): LinesMesh;
  58587. /**
  58588. * Creates a dashed line mesh
  58589. * * 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
  58590. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  58591. * * The parameter `points` is an array successive Vector3
  58592. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  58593. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  58594. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  58595. * * 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
  58596. * * When updating an instance, remember that only point positions can change, not the number of points
  58597. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58598. * @param name defines the name of the mesh
  58599. * @param options defines the options used to create the mesh
  58600. * @param scene defines the hosting scene
  58601. * @returns the dashed line mesh
  58602. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  58603. */
  58604. static CreateDashedLines(name: string, options: {
  58605. points: Vector3[];
  58606. dashSize?: number;
  58607. gapSize?: number;
  58608. dashNb?: number;
  58609. updatable?: boolean;
  58610. instance?: LinesMesh;
  58611. }, scene?: Nullable<Scene>): LinesMesh;
  58612. /**
  58613. * 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.
  58614. * * 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.
  58615. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58616. * * 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.
  58617. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58618. * * 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
  58619. * * 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
  58620. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58621. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58622. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58623. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58624. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58625. * @param name defines the name of the mesh
  58626. * @param options defines the options used to create the mesh
  58627. * @param scene defines the hosting scene
  58628. * @returns the extruded shape mesh
  58629. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58630. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58631. */
  58632. static ExtrudeShape(name: string, options: {
  58633. shape: Vector3[];
  58634. path: Vector3[];
  58635. scale?: number;
  58636. rotation?: number;
  58637. cap?: number;
  58638. updatable?: boolean;
  58639. sideOrientation?: number;
  58640. frontUVs?: Vector4;
  58641. backUVs?: Vector4;
  58642. instance?: Mesh;
  58643. invertUV?: boolean;
  58644. }, scene?: Nullable<Scene>): Mesh;
  58645. /**
  58646. * Creates an custom extruded shape mesh.
  58647. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  58648. * * 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.
  58649. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58650. * * 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
  58651. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  58652. * * 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
  58653. * * It must returns a float value that will be the scale value applied to the shape on each path point
  58654. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  58655. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  58656. * * 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
  58657. * * 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
  58658. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  58659. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58660. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58661. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58662. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58663. * @param name defines the name of the mesh
  58664. * @param options defines the options used to create the mesh
  58665. * @param scene defines the hosting scene
  58666. * @returns the custom extruded shape mesh
  58667. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  58668. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58669. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58670. */
  58671. static ExtrudeShapeCustom(name: string, options: {
  58672. shape: Vector3[];
  58673. path: Vector3[];
  58674. scaleFunction?: any;
  58675. rotationFunction?: any;
  58676. ribbonCloseArray?: boolean;
  58677. ribbonClosePath?: boolean;
  58678. cap?: number;
  58679. updatable?: boolean;
  58680. sideOrientation?: number;
  58681. frontUVs?: Vector4;
  58682. backUVs?: Vector4;
  58683. instance?: Mesh;
  58684. invertUV?: boolean;
  58685. }, scene?: Nullable<Scene>): Mesh;
  58686. /**
  58687. * Creates lathe mesh.
  58688. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  58689. * * 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
  58690. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  58691. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  58692. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  58693. * * 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
  58694. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  58695. * * 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
  58696. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58697. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58698. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58699. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58700. * @param name defines the name of the mesh
  58701. * @param options defines the options used to create the mesh
  58702. * @param scene defines the hosting scene
  58703. * @returns the lathe mesh
  58704. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  58705. */
  58706. static CreateLathe(name: string, options: {
  58707. shape: Vector3[];
  58708. radius?: number;
  58709. tessellation?: number;
  58710. clip?: number;
  58711. arc?: number;
  58712. closed?: boolean;
  58713. updatable?: boolean;
  58714. sideOrientation?: number;
  58715. frontUVs?: Vector4;
  58716. backUVs?: Vector4;
  58717. cap?: number;
  58718. invertUV?: boolean;
  58719. }, scene?: Nullable<Scene>): Mesh;
  58720. /**
  58721. * Creates a tiled plane mesh
  58722. * * You can set a limited pattern arrangement with the tiles
  58723. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58724. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58725. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58726. * @param name defines the name of the mesh
  58727. * @param options defines the options used to create the mesh
  58728. * @param scene defines the hosting scene
  58729. * @returns the plane mesh
  58730. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  58731. */
  58732. static CreateTiledPlane(name: string, options: {
  58733. pattern?: number;
  58734. tileSize?: number;
  58735. tileWidth?: number;
  58736. tileHeight?: number;
  58737. size?: number;
  58738. width?: number;
  58739. height?: number;
  58740. alignHorizontal?: number;
  58741. alignVertical?: number;
  58742. sideOrientation?: number;
  58743. frontUVs?: Vector4;
  58744. backUVs?: Vector4;
  58745. updatable?: boolean;
  58746. }, scene?: Nullable<Scene>): Mesh;
  58747. /**
  58748. * Creates a plane mesh
  58749. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  58750. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  58751. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  58752. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58753. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58754. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58755. * @param name defines the name of the mesh
  58756. * @param options defines the options used to create the mesh
  58757. * @param scene defines the hosting scene
  58758. * @returns the plane mesh
  58759. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  58760. */
  58761. static CreatePlane(name: string, options: {
  58762. size?: number;
  58763. width?: number;
  58764. height?: number;
  58765. sideOrientation?: number;
  58766. frontUVs?: Vector4;
  58767. backUVs?: Vector4;
  58768. updatable?: boolean;
  58769. sourcePlane?: Plane;
  58770. }, scene?: Nullable<Scene>): Mesh;
  58771. /**
  58772. * Creates a ground mesh
  58773. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  58774. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  58775. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58776. * @param name defines the name of the mesh
  58777. * @param options defines the options used to create the mesh
  58778. * @param scene defines the hosting scene
  58779. * @returns the ground mesh
  58780. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  58781. */
  58782. static CreateGround(name: string, options: {
  58783. width?: number;
  58784. height?: number;
  58785. subdivisions?: number;
  58786. subdivisionsX?: number;
  58787. subdivisionsY?: number;
  58788. updatable?: boolean;
  58789. }, scene?: Nullable<Scene>): Mesh;
  58790. /**
  58791. * Creates a tiled ground mesh
  58792. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  58793. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  58794. * * 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
  58795. * * 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
  58796. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58797. * @param name defines the name of the mesh
  58798. * @param options defines the options used to create the mesh
  58799. * @param scene defines the hosting scene
  58800. * @returns the tiled ground mesh
  58801. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  58802. */
  58803. static CreateTiledGround(name: string, options: {
  58804. xmin: number;
  58805. zmin: number;
  58806. xmax: number;
  58807. zmax: number;
  58808. subdivisions?: {
  58809. w: number;
  58810. h: number;
  58811. };
  58812. precision?: {
  58813. w: number;
  58814. h: number;
  58815. };
  58816. updatable?: boolean;
  58817. }, scene?: Nullable<Scene>): Mesh;
  58818. /**
  58819. * Creates a ground mesh from a height map
  58820. * * The parameter `url` sets the URL of the height map image resource.
  58821. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  58822. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  58823. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  58824. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  58825. * * 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.
  58826. * * 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).
  58827. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  58828. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58829. * @param name defines the name of the mesh
  58830. * @param url defines the url to the height map
  58831. * @param options defines the options used to create the mesh
  58832. * @param scene defines the hosting scene
  58833. * @returns the ground mesh
  58834. * @see https://doc.babylonjs.com/babylon101/height_map
  58835. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  58836. */
  58837. static CreateGroundFromHeightMap(name: string, url: string, options: {
  58838. width?: number;
  58839. height?: number;
  58840. subdivisions?: number;
  58841. minHeight?: number;
  58842. maxHeight?: number;
  58843. colorFilter?: Color3;
  58844. alphaFilter?: number;
  58845. updatable?: boolean;
  58846. onReady?: (mesh: GroundMesh) => void;
  58847. }, scene?: Nullable<Scene>): GroundMesh;
  58848. /**
  58849. * Creates a polygon mesh
  58850. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  58851. * * 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
  58852. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58853. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58854. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  58855. * * Remember you can only change the shape positions, not their number when updating a polygon
  58856. * @param name defines the name of the mesh
  58857. * @param options defines the options used to create the mesh
  58858. * @param scene defines the hosting scene
  58859. * @param earcutInjection can be used to inject your own earcut reference
  58860. * @returns the polygon mesh
  58861. */
  58862. static CreatePolygon(name: string, options: {
  58863. shape: Vector3[];
  58864. holes?: Vector3[][];
  58865. depth?: number;
  58866. faceUV?: Vector4[];
  58867. faceColors?: Color4[];
  58868. updatable?: boolean;
  58869. sideOrientation?: number;
  58870. frontUVs?: Vector4;
  58871. backUVs?: Vector4;
  58872. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58873. /**
  58874. * Creates an extruded polygon mesh, with depth in the Y direction.
  58875. * * 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)
  58876. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58877. * @param name defines the name of the mesh
  58878. * @param options defines the options used to create the mesh
  58879. * @param scene defines the hosting scene
  58880. * @param earcutInjection can be used to inject your own earcut reference
  58881. * @returns the polygon mesh
  58882. */
  58883. static ExtrudePolygon(name: string, options: {
  58884. shape: Vector3[];
  58885. holes?: Vector3[][];
  58886. depth?: number;
  58887. faceUV?: Vector4[];
  58888. faceColors?: Color4[];
  58889. updatable?: boolean;
  58890. sideOrientation?: number;
  58891. frontUVs?: Vector4;
  58892. backUVs?: Vector4;
  58893. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58894. /**
  58895. * Creates a tube mesh.
  58896. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58897. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  58898. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  58899. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  58900. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  58901. * * 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)
  58902. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  58903. * * 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
  58904. * * 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
  58905. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58906. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58907. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58908. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58909. * @param name defines the name of the mesh
  58910. * @param options defines the options used to create the mesh
  58911. * @param scene defines the hosting scene
  58912. * @returns the tube mesh
  58913. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58914. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  58915. */
  58916. static CreateTube(name: string, options: {
  58917. path: Vector3[];
  58918. radius?: number;
  58919. tessellation?: number;
  58920. radiusFunction?: {
  58921. (i: number, distance: number): number;
  58922. };
  58923. cap?: number;
  58924. arc?: number;
  58925. updatable?: boolean;
  58926. sideOrientation?: number;
  58927. frontUVs?: Vector4;
  58928. backUVs?: Vector4;
  58929. instance?: Mesh;
  58930. invertUV?: boolean;
  58931. }, scene?: Nullable<Scene>): Mesh;
  58932. /**
  58933. * Creates a polyhedron mesh
  58934. * * 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
  58935. * * The parameter `size` (positive float, default 1) sets the polygon size
  58936. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  58937. * * 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`
  58938. * * 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
  58939. * * 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)`)
  58940. * * 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
  58941. * * 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
  58942. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58943. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58944. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58945. * @param name defines the name of the mesh
  58946. * @param options defines the options used to create the mesh
  58947. * @param scene defines the hosting scene
  58948. * @returns the polyhedron mesh
  58949. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  58950. */
  58951. static CreatePolyhedron(name: string, options: {
  58952. type?: number;
  58953. size?: number;
  58954. sizeX?: number;
  58955. sizeY?: number;
  58956. sizeZ?: number;
  58957. custom?: any;
  58958. faceUV?: Vector4[];
  58959. faceColors?: Color4[];
  58960. flat?: boolean;
  58961. updatable?: boolean;
  58962. sideOrientation?: number;
  58963. frontUVs?: Vector4;
  58964. backUVs?: Vector4;
  58965. }, scene?: Nullable<Scene>): Mesh;
  58966. /**
  58967. * Creates a decal mesh.
  58968. * 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
  58969. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  58970. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  58971. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  58972. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  58973. * @param name defines the name of the mesh
  58974. * @param sourceMesh defines the mesh where the decal must be applied
  58975. * @param options defines the options used to create the mesh
  58976. * @param scene defines the hosting scene
  58977. * @returns the decal mesh
  58978. * @see https://doc.babylonjs.com/how_to/decals
  58979. */
  58980. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  58981. position?: Vector3;
  58982. normal?: Vector3;
  58983. size?: Vector3;
  58984. angle?: number;
  58985. }): Mesh;
  58986. }
  58987. }
  58988. declare module "babylonjs/Meshes/meshSimplification" {
  58989. import { Mesh } from "babylonjs/Meshes/mesh";
  58990. /**
  58991. * A simplifier interface for future simplification implementations
  58992. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58993. */
  58994. export interface ISimplifier {
  58995. /**
  58996. * Simplification of a given mesh according to the given settings.
  58997. * Since this requires computation, it is assumed that the function runs async.
  58998. * @param settings The settings of the simplification, including quality and distance
  58999. * @param successCallback A callback that will be called after the mesh was simplified.
  59000. * @param errorCallback in case of an error, this callback will be called. optional.
  59001. */
  59002. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  59003. }
  59004. /**
  59005. * Expected simplification settings.
  59006. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  59007. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59008. */
  59009. export interface ISimplificationSettings {
  59010. /**
  59011. * Gets or sets the expected quality
  59012. */
  59013. quality: number;
  59014. /**
  59015. * Gets or sets the distance when this optimized version should be used
  59016. */
  59017. distance: number;
  59018. /**
  59019. * Gets an already optimized mesh
  59020. */
  59021. optimizeMesh?: boolean;
  59022. }
  59023. /**
  59024. * Class used to specify simplification options
  59025. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59026. */
  59027. export class SimplificationSettings implements ISimplificationSettings {
  59028. /** expected quality */
  59029. quality: number;
  59030. /** distance when this optimized version should be used */
  59031. distance: number;
  59032. /** already optimized mesh */
  59033. optimizeMesh?: boolean | undefined;
  59034. /**
  59035. * Creates a SimplificationSettings
  59036. * @param quality expected quality
  59037. * @param distance distance when this optimized version should be used
  59038. * @param optimizeMesh already optimized mesh
  59039. */
  59040. constructor(
  59041. /** expected quality */
  59042. quality: number,
  59043. /** distance when this optimized version should be used */
  59044. distance: number,
  59045. /** already optimized mesh */
  59046. optimizeMesh?: boolean | undefined);
  59047. }
  59048. /**
  59049. * Interface used to define a simplification task
  59050. */
  59051. export interface ISimplificationTask {
  59052. /**
  59053. * Array of settings
  59054. */
  59055. settings: Array<ISimplificationSettings>;
  59056. /**
  59057. * Simplification type
  59058. */
  59059. simplificationType: SimplificationType;
  59060. /**
  59061. * Mesh to simplify
  59062. */
  59063. mesh: Mesh;
  59064. /**
  59065. * Callback called on success
  59066. */
  59067. successCallback?: () => void;
  59068. /**
  59069. * Defines if parallel processing can be used
  59070. */
  59071. parallelProcessing: boolean;
  59072. }
  59073. /**
  59074. * Queue used to order the simplification tasks
  59075. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59076. */
  59077. export class SimplificationQueue {
  59078. private _simplificationArray;
  59079. /**
  59080. * Gets a boolean indicating that the process is still running
  59081. */
  59082. running: boolean;
  59083. /**
  59084. * Creates a new queue
  59085. */
  59086. constructor();
  59087. /**
  59088. * Adds a new simplification task
  59089. * @param task defines a task to add
  59090. */
  59091. addTask(task: ISimplificationTask): void;
  59092. /**
  59093. * Execute next task
  59094. */
  59095. executeNext(): void;
  59096. /**
  59097. * Execute a simplification task
  59098. * @param task defines the task to run
  59099. */
  59100. runSimplification(task: ISimplificationTask): void;
  59101. private getSimplifier;
  59102. }
  59103. /**
  59104. * The implemented types of simplification
  59105. * At the moment only Quadratic Error Decimation is implemented
  59106. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59107. */
  59108. export enum SimplificationType {
  59109. /** Quadratic error decimation */
  59110. QUADRATIC = 0
  59111. }
  59112. }
  59113. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  59114. import { Scene } from "babylonjs/scene";
  59115. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  59116. import { ISceneComponent } from "babylonjs/sceneComponent";
  59117. module "babylonjs/scene" {
  59118. interface Scene {
  59119. /** @hidden (Backing field) */
  59120. _simplificationQueue: SimplificationQueue;
  59121. /**
  59122. * Gets or sets the simplification queue attached to the scene
  59123. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59124. */
  59125. simplificationQueue: SimplificationQueue;
  59126. }
  59127. }
  59128. module "babylonjs/Meshes/mesh" {
  59129. interface Mesh {
  59130. /**
  59131. * Simplify the mesh according to the given array of settings.
  59132. * Function will return immediately and will simplify async
  59133. * @param settings a collection of simplification settings
  59134. * @param parallelProcessing should all levels calculate parallel or one after the other
  59135. * @param simplificationType the type of simplification to run
  59136. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  59137. * @returns the current mesh
  59138. */
  59139. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  59140. }
  59141. }
  59142. /**
  59143. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  59144. * created in a scene
  59145. */
  59146. export class SimplicationQueueSceneComponent implements ISceneComponent {
  59147. /**
  59148. * The component name helpfull to identify the component in the list of scene components.
  59149. */
  59150. readonly name: string;
  59151. /**
  59152. * The scene the component belongs to.
  59153. */
  59154. scene: Scene;
  59155. /**
  59156. * Creates a new instance of the component for the given scene
  59157. * @param scene Defines the scene to register the component in
  59158. */
  59159. constructor(scene: Scene);
  59160. /**
  59161. * Registers the component in a given scene
  59162. */
  59163. register(): void;
  59164. /**
  59165. * Rebuilds the elements related to this component in case of
  59166. * context lost for instance.
  59167. */
  59168. rebuild(): void;
  59169. /**
  59170. * Disposes the component and the associated ressources
  59171. */
  59172. dispose(): void;
  59173. private _beforeCameraUpdate;
  59174. }
  59175. }
  59176. declare module "babylonjs/Meshes/Builders/index" {
  59177. export * from "babylonjs/Meshes/Builders/boxBuilder";
  59178. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  59179. export * from "babylonjs/Meshes/Builders/discBuilder";
  59180. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  59181. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  59182. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  59183. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  59184. export * from "babylonjs/Meshes/Builders/torusBuilder";
  59185. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  59186. export * from "babylonjs/Meshes/Builders/linesBuilder";
  59187. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  59188. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  59189. export * from "babylonjs/Meshes/Builders/latheBuilder";
  59190. export * from "babylonjs/Meshes/Builders/planeBuilder";
  59191. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  59192. export * from "babylonjs/Meshes/Builders/groundBuilder";
  59193. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  59194. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  59195. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  59196. export * from "babylonjs/Meshes/Builders/decalBuilder";
  59197. }
  59198. declare module "babylonjs/Meshes/index" {
  59199. export * from "babylonjs/Meshes/abstractMesh";
  59200. export * from "babylonjs/Meshes/buffer";
  59201. export * from "babylonjs/Meshes/Compression/index";
  59202. export * from "babylonjs/Meshes/csg";
  59203. export * from "babylonjs/Meshes/geometry";
  59204. export * from "babylonjs/Meshes/groundMesh";
  59205. export * from "babylonjs/Meshes/trailMesh";
  59206. export * from "babylonjs/Meshes/instancedMesh";
  59207. export * from "babylonjs/Meshes/linesMesh";
  59208. export * from "babylonjs/Meshes/mesh";
  59209. export * from "babylonjs/Meshes/mesh.vertexData";
  59210. export * from "babylonjs/Meshes/meshBuilder";
  59211. export * from "babylonjs/Meshes/meshSimplification";
  59212. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  59213. export * from "babylonjs/Meshes/polygonMesh";
  59214. export * from "babylonjs/Meshes/subMesh";
  59215. export * from "babylonjs/Meshes/meshLODLevel";
  59216. export * from "babylonjs/Meshes/transformNode";
  59217. export * from "babylonjs/Meshes/Builders/index";
  59218. export * from "babylonjs/Meshes/dataBuffer";
  59219. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  59220. }
  59221. declare module "babylonjs/Morph/index" {
  59222. export * from "babylonjs/Morph/morphTarget";
  59223. export * from "babylonjs/Morph/morphTargetManager";
  59224. }
  59225. declare module "babylonjs/Navigation/INavigationEngine" {
  59226. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59227. import { Vector3 } from "babylonjs/Maths/math";
  59228. import { Mesh } from "babylonjs/Meshes/mesh";
  59229. import { Scene } from "babylonjs/scene";
  59230. /**
  59231. * Navigation plugin interface to add navigation constrained by a navigation mesh
  59232. */
  59233. export interface INavigationEnginePlugin {
  59234. /**
  59235. * plugin name
  59236. */
  59237. name: string;
  59238. /**
  59239. * Creates a navigation mesh
  59240. * @param meshes array of all the geometry used to compute the navigatio mesh
  59241. * @param parameters bunch of parameters used to filter geometry
  59242. */
  59243. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  59244. /**
  59245. * Create a navigation mesh debug mesh
  59246. * @param scene is where the mesh will be added
  59247. * @returns debug display mesh
  59248. */
  59249. createDebugNavMesh(scene: Scene): Mesh;
  59250. /**
  59251. * Get a navigation mesh constrained position, closest to the parameter position
  59252. * @param position world position
  59253. * @returns the closest point to position constrained by the navigation mesh
  59254. */
  59255. getClosestPoint(position: Vector3): Vector3;
  59256. /**
  59257. * Get a navigation mesh constrained position, within a particular radius
  59258. * @param position world position
  59259. * @param maxRadius the maximum distance to the constrained world position
  59260. * @returns the closest point to position constrained by the navigation mesh
  59261. */
  59262. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  59263. /**
  59264. * Compute the final position from a segment made of destination-position
  59265. * @param position world position
  59266. * @param destination world position
  59267. * @returns the resulting point along the navmesh
  59268. */
  59269. moveAlong(position: Vector3, destination: Vector3): Vector3;
  59270. /**
  59271. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  59272. * @param start world position
  59273. * @param end world position
  59274. * @returns array containing world position composing the path
  59275. */
  59276. computePath(start: Vector3, end: Vector3): Vector3[];
  59277. /**
  59278. * If this plugin is supported
  59279. * @returns true if plugin is supported
  59280. */
  59281. isSupported(): boolean;
  59282. /**
  59283. * Create a new Crowd so you can add agents
  59284. * @param maxAgents the maximum agent count in the crowd
  59285. * @param maxAgentRadius the maximum radius an agent can have
  59286. * @param scene to attach the crowd to
  59287. * @returns the crowd you can add agents to
  59288. */
  59289. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  59290. /**
  59291. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59292. * The queries will try to find a solution within those bounds
  59293. * default is (1,1,1)
  59294. * @param extent x,y,z value that define the extent around the queries point of reference
  59295. */
  59296. setDefaultQueryExtent(extent: Vector3): void;
  59297. /**
  59298. * Get the Bounding box extent specified by setDefaultQueryExtent
  59299. * @returns the box extent values
  59300. */
  59301. getDefaultQueryExtent(): Vector3;
  59302. /**
  59303. * Release all resources
  59304. */
  59305. dispose(): void;
  59306. }
  59307. /**
  59308. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  59309. */
  59310. export interface ICrowd {
  59311. /**
  59312. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  59313. * You can attach anything to that node. The node position is updated in the scene update tick.
  59314. * @param pos world position that will be constrained by the navigation mesh
  59315. * @param parameters agent parameters
  59316. * @param transform hooked to the agent that will be update by the scene
  59317. * @returns agent index
  59318. */
  59319. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  59320. /**
  59321. * Returns the agent position in world space
  59322. * @param index agent index returned by addAgent
  59323. * @returns world space position
  59324. */
  59325. getAgentPosition(index: number): Vector3;
  59326. /**
  59327. * Gets the agent velocity in world space
  59328. * @param index agent index returned by addAgent
  59329. * @returns world space velocity
  59330. */
  59331. getAgentVelocity(index: number): Vector3;
  59332. /**
  59333. * remove a particular agent previously created
  59334. * @param index agent index returned by addAgent
  59335. */
  59336. removeAgent(index: number): void;
  59337. /**
  59338. * get the list of all agents attached to this crowd
  59339. * @returns list of agent indices
  59340. */
  59341. getAgents(): number[];
  59342. /**
  59343. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  59344. * @param deltaTime in seconds
  59345. */
  59346. update(deltaTime: number): void;
  59347. /**
  59348. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  59349. * @param index agent index returned by addAgent
  59350. * @param destination targeted world position
  59351. */
  59352. agentGoto(index: number, destination: Vector3): void;
  59353. /**
  59354. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59355. * The queries will try to find a solution within those bounds
  59356. * default is (1,1,1)
  59357. * @param extent x,y,z value that define the extent around the queries point of reference
  59358. */
  59359. setDefaultQueryExtent(extent: Vector3): void;
  59360. /**
  59361. * Get the Bounding box extent specified by setDefaultQueryExtent
  59362. * @returns the box extent values
  59363. */
  59364. getDefaultQueryExtent(): Vector3;
  59365. /**
  59366. * Release all resources
  59367. */
  59368. dispose(): void;
  59369. }
  59370. /**
  59371. * Configures an agent
  59372. */
  59373. export interface IAgentParameters {
  59374. /**
  59375. * Agent radius. [Limit: >= 0]
  59376. */
  59377. radius: number;
  59378. /**
  59379. * Agent height. [Limit: > 0]
  59380. */
  59381. height: number;
  59382. /**
  59383. * Maximum allowed acceleration. [Limit: >= 0]
  59384. */
  59385. maxAcceleration: number;
  59386. /**
  59387. * Maximum allowed speed. [Limit: >= 0]
  59388. */
  59389. maxSpeed: number;
  59390. /**
  59391. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  59392. */
  59393. collisionQueryRange: number;
  59394. /**
  59395. * The path visibility optimization range. [Limit: > 0]
  59396. */
  59397. pathOptimizationRange: number;
  59398. /**
  59399. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  59400. */
  59401. separationWeight: number;
  59402. }
  59403. /**
  59404. * Configures the navigation mesh creation
  59405. */
  59406. export interface INavMeshParameters {
  59407. /**
  59408. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  59409. */
  59410. cs: number;
  59411. /**
  59412. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  59413. */
  59414. ch: number;
  59415. /**
  59416. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  59417. */
  59418. walkableSlopeAngle: number;
  59419. /**
  59420. * Minimum floor to 'ceiling' height that will still allow the floor area to
  59421. * be considered walkable. [Limit: >= 3] [Units: vx]
  59422. */
  59423. walkableHeight: number;
  59424. /**
  59425. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  59426. */
  59427. walkableClimb: number;
  59428. /**
  59429. * The distance to erode/shrink the walkable area of the heightfield away from
  59430. * obstructions. [Limit: >=0] [Units: vx]
  59431. */
  59432. walkableRadius: number;
  59433. /**
  59434. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  59435. */
  59436. maxEdgeLen: number;
  59437. /**
  59438. * The maximum distance a simplfied contour's border edges should deviate
  59439. * the original raw contour. [Limit: >=0] [Units: vx]
  59440. */
  59441. maxSimplificationError: number;
  59442. /**
  59443. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  59444. */
  59445. minRegionArea: number;
  59446. /**
  59447. * Any regions with a span count smaller than this value will, if possible,
  59448. * be merged with larger regions. [Limit: >=0] [Units: vx]
  59449. */
  59450. mergeRegionArea: number;
  59451. /**
  59452. * The maximum number of vertices allowed for polygons generated during the
  59453. * contour to polygon conversion process. [Limit: >= 3]
  59454. */
  59455. maxVertsPerPoly: number;
  59456. /**
  59457. * Sets the sampling distance to use when generating the detail mesh.
  59458. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  59459. */
  59460. detailSampleDist: number;
  59461. /**
  59462. * The maximum distance the detail mesh surface should deviate from heightfield
  59463. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  59464. */
  59465. detailSampleMaxError: number;
  59466. }
  59467. }
  59468. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  59469. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  59470. import { Mesh } from "babylonjs/Meshes/mesh";
  59471. import { Scene } from "babylonjs/scene";
  59472. import { Vector3 } from "babylonjs/Maths/math";
  59473. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59474. /**
  59475. * RecastJS navigation plugin
  59476. */
  59477. export class RecastJSPlugin implements INavigationEnginePlugin {
  59478. /**
  59479. * Reference to the Recast library
  59480. */
  59481. bjsRECAST: any;
  59482. /**
  59483. * plugin name
  59484. */
  59485. name: string;
  59486. /**
  59487. * the first navmesh created. We might extend this to support multiple navmeshes
  59488. */
  59489. navMesh: any;
  59490. /**
  59491. * Initializes the recastJS plugin
  59492. * @param recastInjection can be used to inject your own recast reference
  59493. */
  59494. constructor(recastInjection?: any);
  59495. /**
  59496. * Creates a navigation mesh
  59497. * @param meshes array of all the geometry used to compute the navigatio mesh
  59498. * @param parameters bunch of parameters used to filter geometry
  59499. */
  59500. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  59501. /**
  59502. * Create a navigation mesh debug mesh
  59503. * @param scene is where the mesh will be added
  59504. * @returns debug display mesh
  59505. */
  59506. createDebugNavMesh(scene: Scene): Mesh;
  59507. /**
  59508. * Get a navigation mesh constrained position, closest to the parameter position
  59509. * @param position world position
  59510. * @returns the closest point to position constrained by the navigation mesh
  59511. */
  59512. getClosestPoint(position: Vector3): Vector3;
  59513. /**
  59514. * Get a navigation mesh constrained position, within a particular radius
  59515. * @param position world position
  59516. * @param maxRadius the maximum distance to the constrained world position
  59517. * @returns the closest point to position constrained by the navigation mesh
  59518. */
  59519. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  59520. /**
  59521. * Compute the final position from a segment made of destination-position
  59522. * @param position world position
  59523. * @param destination world position
  59524. * @returns the resulting point along the navmesh
  59525. */
  59526. moveAlong(position: Vector3, destination: Vector3): Vector3;
  59527. /**
  59528. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  59529. * @param start world position
  59530. * @param end world position
  59531. * @returns array containing world position composing the path
  59532. */
  59533. computePath(start: Vector3, end: Vector3): Vector3[];
  59534. /**
  59535. * Create a new Crowd so you can add agents
  59536. * @param maxAgents the maximum agent count in the crowd
  59537. * @param maxAgentRadius the maximum radius an agent can have
  59538. * @param scene to attach the crowd to
  59539. * @returns the crowd you can add agents to
  59540. */
  59541. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  59542. /**
  59543. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59544. * The queries will try to find a solution within those bounds
  59545. * default is (1,1,1)
  59546. * @param extent x,y,z value that define the extent around the queries point of reference
  59547. */
  59548. setDefaultQueryExtent(extent: Vector3): void;
  59549. /**
  59550. * Get the Bounding box extent specified by setDefaultQueryExtent
  59551. * @returns the box extent values
  59552. */
  59553. getDefaultQueryExtent(): Vector3;
  59554. /**
  59555. * Disposes
  59556. */
  59557. dispose(): void;
  59558. /**
  59559. * If this plugin is supported
  59560. * @returns true if plugin is supported
  59561. */
  59562. isSupported(): boolean;
  59563. }
  59564. /**
  59565. * Recast detour crowd implementation
  59566. */
  59567. export class RecastJSCrowd implements ICrowd {
  59568. /**
  59569. * Recast/detour plugin
  59570. */
  59571. bjsRECASTPlugin: RecastJSPlugin;
  59572. /**
  59573. * Link to the detour crowd
  59574. */
  59575. recastCrowd: any;
  59576. /**
  59577. * One transform per agent
  59578. */
  59579. transforms: TransformNode[];
  59580. /**
  59581. * All agents created
  59582. */
  59583. agents: number[];
  59584. /**
  59585. * Link to the scene is kept to unregister the crowd from the scene
  59586. */
  59587. private _scene;
  59588. /**
  59589. * Observer for crowd updates
  59590. */
  59591. private _onBeforeAnimationsObserver;
  59592. /**
  59593. * Constructor
  59594. * @param plugin recastJS plugin
  59595. * @param maxAgents the maximum agent count in the crowd
  59596. * @param maxAgentRadius the maximum radius an agent can have
  59597. * @param scene to attach the crowd to
  59598. * @returns the crowd you can add agents to
  59599. */
  59600. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  59601. /**
  59602. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  59603. * You can attach anything to that node. The node position is updated in the scene update tick.
  59604. * @param pos world position that will be constrained by the navigation mesh
  59605. * @param parameters agent parameters
  59606. * @param transform hooked to the agent that will be update by the scene
  59607. * @returns agent index
  59608. */
  59609. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  59610. /**
  59611. * Returns the agent position in world space
  59612. * @param index agent index returned by addAgent
  59613. * @returns world space position
  59614. */
  59615. getAgentPosition(index: number): Vector3;
  59616. /**
  59617. * Returns the agent velocity in world space
  59618. * @param index agent index returned by addAgent
  59619. * @returns world space velocity
  59620. */
  59621. getAgentVelocity(index: number): Vector3;
  59622. /**
  59623. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  59624. * @param index agent index returned by addAgent
  59625. * @param destination targeted world position
  59626. */
  59627. agentGoto(index: number, destination: Vector3): void;
  59628. /**
  59629. * remove a particular agent previously created
  59630. * @param index agent index returned by addAgent
  59631. */
  59632. removeAgent(index: number): void;
  59633. /**
  59634. * get the list of all agents attached to this crowd
  59635. * @returns list of agent indices
  59636. */
  59637. getAgents(): number[];
  59638. /**
  59639. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  59640. * @param deltaTime in seconds
  59641. */
  59642. update(deltaTime: number): void;
  59643. /**
  59644. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59645. * The queries will try to find a solution within those bounds
  59646. * default is (1,1,1)
  59647. * @param extent x,y,z value that define the extent around the queries point of reference
  59648. */
  59649. setDefaultQueryExtent(extent: Vector3): void;
  59650. /**
  59651. * Get the Bounding box extent specified by setDefaultQueryExtent
  59652. * @returns the box extent values
  59653. */
  59654. getDefaultQueryExtent(): Vector3;
  59655. /**
  59656. * Release all resources
  59657. */
  59658. dispose(): void;
  59659. }
  59660. }
  59661. declare module "babylonjs/Navigation/Plugins/index" {
  59662. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  59663. }
  59664. declare module "babylonjs/Navigation/index" {
  59665. export * from "babylonjs/Navigation/INavigationEngine";
  59666. export * from "babylonjs/Navigation/Plugins/index";
  59667. }
  59668. declare module "babylonjs/Offline/database" {
  59669. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  59670. /**
  59671. * Class used to enable access to IndexedDB
  59672. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  59673. */
  59674. export class Database implements IOfflineProvider {
  59675. private _callbackManifestChecked;
  59676. private _currentSceneUrl;
  59677. private _db;
  59678. private _enableSceneOffline;
  59679. private _enableTexturesOffline;
  59680. private _manifestVersionFound;
  59681. private _mustUpdateRessources;
  59682. private _hasReachedQuota;
  59683. private _isSupported;
  59684. private _idbFactory;
  59685. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  59686. private static IsUASupportingBlobStorage;
  59687. /**
  59688. * Gets a boolean indicating if Database storate is enabled (off by default)
  59689. */
  59690. static IDBStorageEnabled: boolean;
  59691. /**
  59692. * Gets a boolean indicating if scene must be saved in the database
  59693. */
  59694. readonly enableSceneOffline: boolean;
  59695. /**
  59696. * Gets a boolean indicating if textures must be saved in the database
  59697. */
  59698. readonly enableTexturesOffline: boolean;
  59699. /**
  59700. * Creates a new Database
  59701. * @param urlToScene defines the url to load the scene
  59702. * @param callbackManifestChecked defines the callback to use when manifest is checked
  59703. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  59704. */
  59705. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  59706. private static _ParseURL;
  59707. private static _ReturnFullUrlLocation;
  59708. private _checkManifestFile;
  59709. /**
  59710. * Open the database and make it available
  59711. * @param successCallback defines the callback to call on success
  59712. * @param errorCallback defines the callback to call on error
  59713. */
  59714. open(successCallback: () => void, errorCallback: () => void): void;
  59715. /**
  59716. * Loads an image from the database
  59717. * @param url defines the url to load from
  59718. * @param image defines the target DOM image
  59719. */
  59720. loadImage(url: string, image: HTMLImageElement): void;
  59721. private _loadImageFromDBAsync;
  59722. private _saveImageIntoDBAsync;
  59723. private _checkVersionFromDB;
  59724. private _loadVersionFromDBAsync;
  59725. private _saveVersionIntoDBAsync;
  59726. /**
  59727. * Loads a file from database
  59728. * @param url defines the URL to load from
  59729. * @param sceneLoaded defines a callback to call on success
  59730. * @param progressCallBack defines a callback to call when progress changed
  59731. * @param errorCallback defines a callback to call on error
  59732. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  59733. */
  59734. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  59735. private _loadFileAsync;
  59736. private _saveFileAsync;
  59737. /**
  59738. * Validates if xhr data is correct
  59739. * @param xhr defines the request to validate
  59740. * @param dataType defines the expected data type
  59741. * @returns true if data is correct
  59742. */
  59743. private static _ValidateXHRData;
  59744. }
  59745. }
  59746. declare module "babylonjs/Offline/index" {
  59747. export * from "babylonjs/Offline/database";
  59748. export * from "babylonjs/Offline/IOfflineProvider";
  59749. }
  59750. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  59751. /** @hidden */
  59752. export var gpuUpdateParticlesPixelShader: {
  59753. name: string;
  59754. shader: string;
  59755. };
  59756. }
  59757. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  59758. /** @hidden */
  59759. export var gpuUpdateParticlesVertexShader: {
  59760. name: string;
  59761. shader: string;
  59762. };
  59763. }
  59764. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  59765. /** @hidden */
  59766. export var clipPlaneFragmentDeclaration2: {
  59767. name: string;
  59768. shader: string;
  59769. };
  59770. }
  59771. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  59772. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  59773. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  59774. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59775. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  59776. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  59777. /** @hidden */
  59778. export var gpuRenderParticlesPixelShader: {
  59779. name: string;
  59780. shader: string;
  59781. };
  59782. }
  59783. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  59784. /** @hidden */
  59785. export var clipPlaneVertexDeclaration2: {
  59786. name: string;
  59787. shader: string;
  59788. };
  59789. }
  59790. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  59791. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  59792. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  59793. /** @hidden */
  59794. export var gpuRenderParticlesVertexShader: {
  59795. name: string;
  59796. shader: string;
  59797. };
  59798. }
  59799. declare module "babylonjs/Particles/gpuParticleSystem" {
  59800. import { Nullable } from "babylonjs/types";
  59801. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  59802. import { Observable } from "babylonjs/Misc/observable";
  59803. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  59804. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  59805. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  59806. import { Scene, IDisposable } from "babylonjs/scene";
  59807. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  59808. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  59809. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  59810. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  59811. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  59812. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  59813. /**
  59814. * This represents a GPU particle system in Babylon
  59815. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  59816. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  59817. */
  59818. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  59819. /**
  59820. * The layer mask we are rendering the particles through.
  59821. */
  59822. layerMask: number;
  59823. private _capacity;
  59824. private _activeCount;
  59825. private _currentActiveCount;
  59826. private _accumulatedCount;
  59827. private _renderEffect;
  59828. private _updateEffect;
  59829. private _buffer0;
  59830. private _buffer1;
  59831. private _spriteBuffer;
  59832. private _updateVAO;
  59833. private _renderVAO;
  59834. private _targetIndex;
  59835. private _sourceBuffer;
  59836. private _targetBuffer;
  59837. private _engine;
  59838. private _currentRenderId;
  59839. private _started;
  59840. private _stopped;
  59841. private _timeDelta;
  59842. private _randomTexture;
  59843. private _randomTexture2;
  59844. private _attributesStrideSize;
  59845. private _updateEffectOptions;
  59846. private _randomTextureSize;
  59847. private _actualFrame;
  59848. private readonly _rawTextureWidth;
  59849. /**
  59850. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  59851. */
  59852. static readonly IsSupported: boolean;
  59853. /**
  59854. * An event triggered when the system is disposed.
  59855. */
  59856. onDisposeObservable: Observable<GPUParticleSystem>;
  59857. /**
  59858. * Gets the maximum number of particles active at the same time.
  59859. * @returns The max number of active particles.
  59860. */
  59861. getCapacity(): number;
  59862. /**
  59863. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  59864. * to override the particles.
  59865. */
  59866. forceDepthWrite: boolean;
  59867. /**
  59868. * Gets or set the number of active particles
  59869. */
  59870. activeParticleCount: number;
  59871. private _preWarmDone;
  59872. /**
  59873. * Is this system ready to be used/rendered
  59874. * @return true if the system is ready
  59875. */
  59876. isReady(): boolean;
  59877. /**
  59878. * Gets if the system has been started. (Note: this will still be true after stop is called)
  59879. * @returns True if it has been started, otherwise false.
  59880. */
  59881. isStarted(): boolean;
  59882. /**
  59883. * Starts the particle system and begins to emit
  59884. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  59885. */
  59886. start(delay?: number): void;
  59887. /**
  59888. * Stops the particle system.
  59889. */
  59890. stop(): void;
  59891. /**
  59892. * Remove all active particles
  59893. */
  59894. reset(): void;
  59895. /**
  59896. * Returns the string "GPUParticleSystem"
  59897. * @returns a string containing the class name
  59898. */
  59899. getClassName(): string;
  59900. private _colorGradientsTexture;
  59901. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  59902. /**
  59903. * Adds a new color gradient
  59904. * @param gradient defines the gradient to use (between 0 and 1)
  59905. * @param color1 defines the color to affect to the specified gradient
  59906. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  59907. * @returns the current particle system
  59908. */
  59909. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  59910. /**
  59911. * Remove a specific color gradient
  59912. * @param gradient defines the gradient to remove
  59913. * @returns the current particle system
  59914. */
  59915. removeColorGradient(gradient: number): GPUParticleSystem;
  59916. private _angularSpeedGradientsTexture;
  59917. private _sizeGradientsTexture;
  59918. private _velocityGradientsTexture;
  59919. private _limitVelocityGradientsTexture;
  59920. private _dragGradientsTexture;
  59921. private _addFactorGradient;
  59922. /**
  59923. * Adds a new size gradient
  59924. * @param gradient defines the gradient to use (between 0 and 1)
  59925. * @param factor defines the size factor to affect to the specified gradient
  59926. * @returns the current particle system
  59927. */
  59928. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  59929. /**
  59930. * Remove a specific size gradient
  59931. * @param gradient defines the gradient to remove
  59932. * @returns the current particle system
  59933. */
  59934. removeSizeGradient(gradient: number): GPUParticleSystem;
  59935. /**
  59936. * Adds a new angular speed gradient
  59937. * @param gradient defines the gradient to use (between 0 and 1)
  59938. * @param factor defines the angular speed to affect to the specified gradient
  59939. * @returns the current particle system
  59940. */
  59941. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  59942. /**
  59943. * Remove a specific angular speed gradient
  59944. * @param gradient defines the gradient to remove
  59945. * @returns the current particle system
  59946. */
  59947. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  59948. /**
  59949. * Adds a new velocity gradient
  59950. * @param gradient defines the gradient to use (between 0 and 1)
  59951. * @param factor defines the velocity to affect to the specified gradient
  59952. * @returns the current particle system
  59953. */
  59954. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  59955. /**
  59956. * Remove a specific velocity gradient
  59957. * @param gradient defines the gradient to remove
  59958. * @returns the current particle system
  59959. */
  59960. removeVelocityGradient(gradient: number): GPUParticleSystem;
  59961. /**
  59962. * Adds a new limit velocity gradient
  59963. * @param gradient defines the gradient to use (between 0 and 1)
  59964. * @param factor defines the limit velocity value to affect to the specified gradient
  59965. * @returns the current particle system
  59966. */
  59967. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  59968. /**
  59969. * Remove a specific limit velocity gradient
  59970. * @param gradient defines the gradient to remove
  59971. * @returns the current particle system
  59972. */
  59973. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  59974. /**
  59975. * Adds a new drag gradient
  59976. * @param gradient defines the gradient to use (between 0 and 1)
  59977. * @param factor defines the drag value to affect to the specified gradient
  59978. * @returns the current particle system
  59979. */
  59980. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  59981. /**
  59982. * Remove a specific drag gradient
  59983. * @param gradient defines the gradient to remove
  59984. * @returns the current particle system
  59985. */
  59986. removeDragGradient(gradient: number): GPUParticleSystem;
  59987. /**
  59988. * Not supported by GPUParticleSystem
  59989. * @param gradient defines the gradient to use (between 0 and 1)
  59990. * @param factor defines the emit rate value to affect to the specified gradient
  59991. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  59992. * @returns the current particle system
  59993. */
  59994. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  59995. /**
  59996. * Not supported by GPUParticleSystem
  59997. * @param gradient defines the gradient to remove
  59998. * @returns the current particle system
  59999. */
  60000. removeEmitRateGradient(gradient: number): IParticleSystem;
  60001. /**
  60002. * Not supported by GPUParticleSystem
  60003. * @param gradient defines the gradient to use (between 0 and 1)
  60004. * @param factor defines the start size value to affect to the specified gradient
  60005. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60006. * @returns the current particle system
  60007. */
  60008. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60009. /**
  60010. * Not supported by GPUParticleSystem
  60011. * @param gradient defines the gradient to remove
  60012. * @returns the current particle system
  60013. */
  60014. removeStartSizeGradient(gradient: number): IParticleSystem;
  60015. /**
  60016. * Not supported by GPUParticleSystem
  60017. * @param gradient defines the gradient to use (between 0 and 1)
  60018. * @param min defines the color remap minimal range
  60019. * @param max defines the color remap maximal range
  60020. * @returns the current particle system
  60021. */
  60022. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  60023. /**
  60024. * Not supported by GPUParticleSystem
  60025. * @param gradient defines the gradient to remove
  60026. * @returns the current particle system
  60027. */
  60028. removeColorRemapGradient(): IParticleSystem;
  60029. /**
  60030. * Not supported by GPUParticleSystem
  60031. * @param gradient defines the gradient to use (between 0 and 1)
  60032. * @param min defines the alpha remap minimal range
  60033. * @param max defines the alpha remap maximal range
  60034. * @returns the current particle system
  60035. */
  60036. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  60037. /**
  60038. * Not supported by GPUParticleSystem
  60039. * @param gradient defines the gradient to remove
  60040. * @returns the current particle system
  60041. */
  60042. removeAlphaRemapGradient(): IParticleSystem;
  60043. /**
  60044. * Not supported by GPUParticleSystem
  60045. * @param gradient defines the gradient to use (between 0 and 1)
  60046. * @param color defines the color to affect to the specified gradient
  60047. * @returns the current particle system
  60048. */
  60049. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  60050. /**
  60051. * Not supported by GPUParticleSystem
  60052. * @param gradient defines the gradient to remove
  60053. * @returns the current particle system
  60054. */
  60055. removeRampGradient(): IParticleSystem;
  60056. /**
  60057. * Not supported by GPUParticleSystem
  60058. * @returns the list of ramp gradients
  60059. */
  60060. getRampGradients(): Nullable<Array<Color3Gradient>>;
  60061. /**
  60062. * Not supported by GPUParticleSystem
  60063. * Gets or sets a boolean indicating that ramp gradients must be used
  60064. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  60065. */
  60066. useRampGradients: boolean;
  60067. /**
  60068. * Not supported by GPUParticleSystem
  60069. * @param gradient defines the gradient to use (between 0 and 1)
  60070. * @param factor defines the life time factor to affect to the specified gradient
  60071. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60072. * @returns the current particle system
  60073. */
  60074. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60075. /**
  60076. * Not supported by GPUParticleSystem
  60077. * @param gradient defines the gradient to remove
  60078. * @returns the current particle system
  60079. */
  60080. removeLifeTimeGradient(gradient: number): IParticleSystem;
  60081. /**
  60082. * Instantiates a GPU particle system.
  60083. * 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.
  60084. * @param name The name of the particle system
  60085. * @param options The options used to create the system
  60086. * @param scene The scene the particle system belongs to
  60087. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  60088. */
  60089. constructor(name: string, options: Partial<{
  60090. capacity: number;
  60091. randomTextureSize: number;
  60092. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  60093. protected _reset(): void;
  60094. private _createUpdateVAO;
  60095. private _createRenderVAO;
  60096. private _initialize;
  60097. /** @hidden */
  60098. _recreateUpdateEffect(): void;
  60099. /** @hidden */
  60100. _recreateRenderEffect(): void;
  60101. /**
  60102. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  60103. * @param preWarm defines if we are in the pre-warmimg phase
  60104. */
  60105. animate(preWarm?: boolean): void;
  60106. private _createFactorGradientTexture;
  60107. private _createSizeGradientTexture;
  60108. private _createAngularSpeedGradientTexture;
  60109. private _createVelocityGradientTexture;
  60110. private _createLimitVelocityGradientTexture;
  60111. private _createDragGradientTexture;
  60112. private _createColorGradientTexture;
  60113. /**
  60114. * Renders the particle system in its current state
  60115. * @param preWarm defines if the system should only update the particles but not render them
  60116. * @returns the current number of particles
  60117. */
  60118. render(preWarm?: boolean): number;
  60119. /**
  60120. * Rebuilds the particle system
  60121. */
  60122. rebuild(): void;
  60123. private _releaseBuffers;
  60124. private _releaseVAOs;
  60125. /**
  60126. * Disposes the particle system and free the associated resources
  60127. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  60128. */
  60129. dispose(disposeTexture?: boolean): void;
  60130. /**
  60131. * Clones the particle system.
  60132. * @param name The name of the cloned object
  60133. * @param newEmitter The new emitter to use
  60134. * @returns the cloned particle system
  60135. */
  60136. clone(name: string, newEmitter: any): GPUParticleSystem;
  60137. /**
  60138. * Serializes the particle system to a JSON object.
  60139. * @returns the JSON object
  60140. */
  60141. serialize(): any;
  60142. /**
  60143. * Parses a JSON object to create a GPU particle system.
  60144. * @param parsedParticleSystem The JSON object to parse
  60145. * @param scene The scene to create the particle system in
  60146. * @param rootUrl The root url to use to load external dependencies like texture
  60147. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  60148. * @returns the parsed GPU particle system
  60149. */
  60150. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  60151. }
  60152. }
  60153. declare module "babylonjs/Particles/particleSystemSet" {
  60154. import { Nullable } from "babylonjs/types";
  60155. import { Color3 } from "babylonjs/Maths/math.color";
  60156. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60157. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60158. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60159. import { Scene, IDisposable } from "babylonjs/scene";
  60160. /**
  60161. * Represents a set of particle systems working together to create a specific effect
  60162. */
  60163. export class ParticleSystemSet implements IDisposable {
  60164. private _emitterCreationOptions;
  60165. private _emitterNode;
  60166. /**
  60167. * Gets the particle system list
  60168. */
  60169. systems: IParticleSystem[];
  60170. /**
  60171. * Gets the emitter node used with this set
  60172. */
  60173. readonly emitterNode: Nullable<TransformNode>;
  60174. /**
  60175. * Creates a new emitter mesh as a sphere
  60176. * @param options defines the options used to create the sphere
  60177. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  60178. * @param scene defines the hosting scene
  60179. */
  60180. setEmitterAsSphere(options: {
  60181. diameter: number;
  60182. segments: number;
  60183. color: Color3;
  60184. }, renderingGroupId: number, scene: Scene): void;
  60185. /**
  60186. * Starts all particle systems of the set
  60187. * @param emitter defines an optional mesh to use as emitter for the particle systems
  60188. */
  60189. start(emitter?: AbstractMesh): void;
  60190. /**
  60191. * Release all associated resources
  60192. */
  60193. dispose(): void;
  60194. /**
  60195. * Serialize the set into a JSON compatible object
  60196. * @returns a JSON compatible representation of the set
  60197. */
  60198. serialize(): any;
  60199. /**
  60200. * Parse a new ParticleSystemSet from a serialized source
  60201. * @param data defines a JSON compatible representation of the set
  60202. * @param scene defines the hosting scene
  60203. * @param gpu defines if we want GPU particles or CPU particles
  60204. * @returns a new ParticleSystemSet
  60205. */
  60206. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  60207. }
  60208. }
  60209. declare module "babylonjs/Particles/particleHelper" {
  60210. import { Nullable } from "babylonjs/types";
  60211. import { Scene } from "babylonjs/scene";
  60212. import { Vector3 } from "babylonjs/Maths/math.vector";
  60213. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60214. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60215. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  60216. /**
  60217. * This class is made for on one-liner static method to help creating particle system set.
  60218. */
  60219. export class ParticleHelper {
  60220. /**
  60221. * Gets or sets base Assets URL
  60222. */
  60223. static BaseAssetsUrl: string;
  60224. /**
  60225. * Create a default particle system that you can tweak
  60226. * @param emitter defines the emitter to use
  60227. * @param capacity defines the system capacity (default is 500 particles)
  60228. * @param scene defines the hosting scene
  60229. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  60230. * @returns the new Particle system
  60231. */
  60232. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  60233. /**
  60234. * This is the main static method (one-liner) of this helper to create different particle systems
  60235. * @param type This string represents the type to the particle system to create
  60236. * @param scene The scene where the particle system should live
  60237. * @param gpu If the system will use gpu
  60238. * @returns the ParticleSystemSet created
  60239. */
  60240. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  60241. /**
  60242. * Static function used to export a particle system to a ParticleSystemSet variable.
  60243. * Please note that the emitter shape is not exported
  60244. * @param systems defines the particle systems to export
  60245. * @returns the created particle system set
  60246. */
  60247. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  60248. }
  60249. }
  60250. declare module "babylonjs/Particles/particleSystemComponent" {
  60251. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60252. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  60253. import "babylonjs/Shaders/particles.vertex";
  60254. module "babylonjs/Engines/engine" {
  60255. interface Engine {
  60256. /**
  60257. * Create an effect to use with particle systems.
  60258. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  60259. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  60260. * @param uniformsNames defines a list of attribute names
  60261. * @param samplers defines an array of string used to represent textures
  60262. * @param defines defines the string containing the defines to use to compile the shaders
  60263. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  60264. * @param onCompiled defines a function to call when the effect creation is successful
  60265. * @param onError defines a function to call when the effect creation has failed
  60266. * @returns the new Effect
  60267. */
  60268. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  60269. }
  60270. }
  60271. module "babylonjs/Meshes/mesh" {
  60272. interface Mesh {
  60273. /**
  60274. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  60275. * @returns an array of IParticleSystem
  60276. */
  60277. getEmittedParticleSystems(): IParticleSystem[];
  60278. /**
  60279. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  60280. * @returns an array of IParticleSystem
  60281. */
  60282. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  60283. }
  60284. }
  60285. /**
  60286. * @hidden
  60287. */
  60288. export var _IDoNeedToBeInTheBuild: number;
  60289. }
  60290. declare module "babylonjs/Particles/index" {
  60291. export * from "babylonjs/Particles/baseParticleSystem";
  60292. export * from "babylonjs/Particles/EmitterTypes/index";
  60293. export * from "babylonjs/Particles/gpuParticleSystem";
  60294. export * from "babylonjs/Particles/IParticleSystem";
  60295. export * from "babylonjs/Particles/particle";
  60296. export * from "babylonjs/Particles/particleHelper";
  60297. export * from "babylonjs/Particles/particleSystem";
  60298. export * from "babylonjs/Particles/particleSystemComponent";
  60299. export * from "babylonjs/Particles/particleSystemSet";
  60300. export * from "babylonjs/Particles/solidParticle";
  60301. export * from "babylonjs/Particles/solidParticleSystem";
  60302. export * from "babylonjs/Particles/subEmitter";
  60303. }
  60304. declare module "babylonjs/Physics/physicsEngineComponent" {
  60305. import { Nullable } from "babylonjs/types";
  60306. import { Observable, Observer } from "babylonjs/Misc/observable";
  60307. import { Vector3 } from "babylonjs/Maths/math.vector";
  60308. import { Mesh } from "babylonjs/Meshes/mesh";
  60309. import { ISceneComponent } from "babylonjs/sceneComponent";
  60310. import { Scene } from "babylonjs/scene";
  60311. import { Node } from "babylonjs/node";
  60312. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  60313. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  60314. module "babylonjs/scene" {
  60315. interface Scene {
  60316. /** @hidden (Backing field) */
  60317. _physicsEngine: Nullable<IPhysicsEngine>;
  60318. /**
  60319. * Gets the current physics engine
  60320. * @returns a IPhysicsEngine or null if none attached
  60321. */
  60322. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  60323. /**
  60324. * Enables physics to the current scene
  60325. * @param gravity defines the scene's gravity for the physics engine
  60326. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  60327. * @return a boolean indicating if the physics engine was initialized
  60328. */
  60329. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  60330. /**
  60331. * Disables and disposes the physics engine associated with the scene
  60332. */
  60333. disablePhysicsEngine(): void;
  60334. /**
  60335. * Gets a boolean indicating if there is an active physics engine
  60336. * @returns a boolean indicating if there is an active physics engine
  60337. */
  60338. isPhysicsEnabled(): boolean;
  60339. /**
  60340. * Deletes a physics compound impostor
  60341. * @param compound defines the compound to delete
  60342. */
  60343. deleteCompoundImpostor(compound: any): void;
  60344. /**
  60345. * An event triggered when physic simulation is about to be run
  60346. */
  60347. onBeforePhysicsObservable: Observable<Scene>;
  60348. /**
  60349. * An event triggered when physic simulation has been done
  60350. */
  60351. onAfterPhysicsObservable: Observable<Scene>;
  60352. }
  60353. }
  60354. module "babylonjs/Meshes/abstractMesh" {
  60355. interface AbstractMesh {
  60356. /** @hidden */
  60357. _physicsImpostor: Nullable<PhysicsImpostor>;
  60358. /**
  60359. * Gets or sets impostor used for physic simulation
  60360. * @see http://doc.babylonjs.com/features/physics_engine
  60361. */
  60362. physicsImpostor: Nullable<PhysicsImpostor>;
  60363. /**
  60364. * Gets the current physics impostor
  60365. * @see http://doc.babylonjs.com/features/physics_engine
  60366. * @returns a physics impostor or null
  60367. */
  60368. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  60369. /** Apply a physic impulse to the mesh
  60370. * @param force defines the force to apply
  60371. * @param contactPoint defines where to apply the force
  60372. * @returns the current mesh
  60373. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  60374. */
  60375. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  60376. /**
  60377. * Creates a physic joint between two meshes
  60378. * @param otherMesh defines the other mesh to use
  60379. * @param pivot1 defines the pivot to use on this mesh
  60380. * @param pivot2 defines the pivot to use on the other mesh
  60381. * @param options defines additional options (can be plugin dependent)
  60382. * @returns the current mesh
  60383. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  60384. */
  60385. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  60386. /** @hidden */
  60387. _disposePhysicsObserver: Nullable<Observer<Node>>;
  60388. }
  60389. }
  60390. /**
  60391. * Defines the physics engine scene component responsible to manage a physics engine
  60392. */
  60393. export class PhysicsEngineSceneComponent implements ISceneComponent {
  60394. /**
  60395. * The component name helpful to identify the component in the list of scene components.
  60396. */
  60397. readonly name: string;
  60398. /**
  60399. * The scene the component belongs to.
  60400. */
  60401. scene: Scene;
  60402. /**
  60403. * Creates a new instance of the component for the given scene
  60404. * @param scene Defines the scene to register the component in
  60405. */
  60406. constructor(scene: Scene);
  60407. /**
  60408. * Registers the component in a given scene
  60409. */
  60410. register(): void;
  60411. /**
  60412. * Rebuilds the elements related to this component in case of
  60413. * context lost for instance.
  60414. */
  60415. rebuild(): void;
  60416. /**
  60417. * Disposes the component and the associated ressources
  60418. */
  60419. dispose(): void;
  60420. }
  60421. }
  60422. declare module "babylonjs/Physics/physicsHelper" {
  60423. import { Nullable } from "babylonjs/types";
  60424. import { Vector3 } from "babylonjs/Maths/math.vector";
  60425. import { Mesh } from "babylonjs/Meshes/mesh";
  60426. import { Scene } from "babylonjs/scene";
  60427. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  60428. /**
  60429. * A helper for physics simulations
  60430. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60431. */
  60432. export class PhysicsHelper {
  60433. private _scene;
  60434. private _physicsEngine;
  60435. /**
  60436. * Initializes the Physics helper
  60437. * @param scene Babylon.js scene
  60438. */
  60439. constructor(scene: Scene);
  60440. /**
  60441. * Applies a radial explosion impulse
  60442. * @param origin the origin of the explosion
  60443. * @param radiusOrEventOptions the radius or the options of radial explosion
  60444. * @param strength the explosion strength
  60445. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60446. * @returns A physics radial explosion event, or null
  60447. */
  60448. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  60449. /**
  60450. * Applies a radial explosion force
  60451. * @param origin the origin of the explosion
  60452. * @param radiusOrEventOptions the radius or the options of radial explosion
  60453. * @param strength the explosion strength
  60454. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60455. * @returns A physics radial explosion event, or null
  60456. */
  60457. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  60458. /**
  60459. * Creates a gravitational field
  60460. * @param origin the origin of the explosion
  60461. * @param radiusOrEventOptions the radius or the options of radial explosion
  60462. * @param strength the explosion strength
  60463. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60464. * @returns A physics gravitational field event, or null
  60465. */
  60466. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  60467. /**
  60468. * Creates a physics updraft event
  60469. * @param origin the origin of the updraft
  60470. * @param radiusOrEventOptions the radius or the options of the updraft
  60471. * @param strength the strength of the updraft
  60472. * @param height the height of the updraft
  60473. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  60474. * @returns A physics updraft event, or null
  60475. */
  60476. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  60477. /**
  60478. * Creates a physics vortex event
  60479. * @param origin the of the vortex
  60480. * @param radiusOrEventOptions the radius or the options of the vortex
  60481. * @param strength the strength of the vortex
  60482. * @param height the height of the vortex
  60483. * @returns a Physics vortex event, or null
  60484. * A physics vortex event or null
  60485. */
  60486. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  60487. }
  60488. /**
  60489. * Represents a physics radial explosion event
  60490. */
  60491. class PhysicsRadialExplosionEvent {
  60492. private _scene;
  60493. private _options;
  60494. private _sphere;
  60495. private _dataFetched;
  60496. /**
  60497. * Initializes a radial explosioin event
  60498. * @param _scene BabylonJS scene
  60499. * @param _options The options for the vortex event
  60500. */
  60501. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  60502. /**
  60503. * Returns the data related to the radial explosion event (sphere).
  60504. * @returns The radial explosion event data
  60505. */
  60506. getData(): PhysicsRadialExplosionEventData;
  60507. /**
  60508. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  60509. * @param impostor A physics imposter
  60510. * @param origin the origin of the explosion
  60511. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  60512. */
  60513. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  60514. /**
  60515. * Triggers affecterd impostors callbacks
  60516. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  60517. */
  60518. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  60519. /**
  60520. * Disposes the sphere.
  60521. * @param force Specifies if the sphere should be disposed by force
  60522. */
  60523. dispose(force?: boolean): void;
  60524. /*** Helpers ***/
  60525. private _prepareSphere;
  60526. private _intersectsWithSphere;
  60527. }
  60528. /**
  60529. * Represents a gravitational field event
  60530. */
  60531. class PhysicsGravitationalFieldEvent {
  60532. private _physicsHelper;
  60533. private _scene;
  60534. private _origin;
  60535. private _options;
  60536. private _tickCallback;
  60537. private _sphere;
  60538. private _dataFetched;
  60539. /**
  60540. * Initializes the physics gravitational field event
  60541. * @param _physicsHelper A physics helper
  60542. * @param _scene BabylonJS scene
  60543. * @param _origin The origin position of the gravitational field event
  60544. * @param _options The options for the vortex event
  60545. */
  60546. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  60547. /**
  60548. * Returns the data related to the gravitational field event (sphere).
  60549. * @returns A gravitational field event
  60550. */
  60551. getData(): PhysicsGravitationalFieldEventData;
  60552. /**
  60553. * Enables the gravitational field.
  60554. */
  60555. enable(): void;
  60556. /**
  60557. * Disables the gravitational field.
  60558. */
  60559. disable(): void;
  60560. /**
  60561. * Disposes the sphere.
  60562. * @param force The force to dispose from the gravitational field event
  60563. */
  60564. dispose(force?: boolean): void;
  60565. private _tick;
  60566. }
  60567. /**
  60568. * Represents a physics updraft event
  60569. */
  60570. class PhysicsUpdraftEvent {
  60571. private _scene;
  60572. private _origin;
  60573. private _options;
  60574. private _physicsEngine;
  60575. private _originTop;
  60576. private _originDirection;
  60577. private _tickCallback;
  60578. private _cylinder;
  60579. private _cylinderPosition;
  60580. private _dataFetched;
  60581. /**
  60582. * Initializes the physics updraft event
  60583. * @param _scene BabylonJS scene
  60584. * @param _origin The origin position of the updraft
  60585. * @param _options The options for the updraft event
  60586. */
  60587. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  60588. /**
  60589. * Returns the data related to the updraft event (cylinder).
  60590. * @returns A physics updraft event
  60591. */
  60592. getData(): PhysicsUpdraftEventData;
  60593. /**
  60594. * Enables the updraft.
  60595. */
  60596. enable(): void;
  60597. /**
  60598. * Disables the updraft.
  60599. */
  60600. disable(): void;
  60601. /**
  60602. * Disposes the cylinder.
  60603. * @param force Specifies if the updraft should be disposed by force
  60604. */
  60605. dispose(force?: boolean): void;
  60606. private getImpostorHitData;
  60607. private _tick;
  60608. /*** Helpers ***/
  60609. private _prepareCylinder;
  60610. private _intersectsWithCylinder;
  60611. }
  60612. /**
  60613. * Represents a physics vortex event
  60614. */
  60615. class PhysicsVortexEvent {
  60616. private _scene;
  60617. private _origin;
  60618. private _options;
  60619. private _physicsEngine;
  60620. private _originTop;
  60621. private _tickCallback;
  60622. private _cylinder;
  60623. private _cylinderPosition;
  60624. private _dataFetched;
  60625. /**
  60626. * Initializes the physics vortex event
  60627. * @param _scene The BabylonJS scene
  60628. * @param _origin The origin position of the vortex
  60629. * @param _options The options for the vortex event
  60630. */
  60631. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  60632. /**
  60633. * Returns the data related to the vortex event (cylinder).
  60634. * @returns The physics vortex event data
  60635. */
  60636. getData(): PhysicsVortexEventData;
  60637. /**
  60638. * Enables the vortex.
  60639. */
  60640. enable(): void;
  60641. /**
  60642. * Disables the cortex.
  60643. */
  60644. disable(): void;
  60645. /**
  60646. * Disposes the sphere.
  60647. * @param force
  60648. */
  60649. dispose(force?: boolean): void;
  60650. private getImpostorHitData;
  60651. private _tick;
  60652. /*** Helpers ***/
  60653. private _prepareCylinder;
  60654. private _intersectsWithCylinder;
  60655. }
  60656. /**
  60657. * Options fot the radial explosion event
  60658. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60659. */
  60660. export class PhysicsRadialExplosionEventOptions {
  60661. /**
  60662. * The radius of the sphere for the radial explosion.
  60663. */
  60664. radius: number;
  60665. /**
  60666. * The strenth of the explosion.
  60667. */
  60668. strength: number;
  60669. /**
  60670. * The strenght of the force in correspondence to the distance of the affected object
  60671. */
  60672. falloff: PhysicsRadialImpulseFalloff;
  60673. /**
  60674. * Sphere options for the radial explosion.
  60675. */
  60676. sphere: {
  60677. segments: number;
  60678. diameter: number;
  60679. };
  60680. /**
  60681. * Sphere options for the radial explosion.
  60682. */
  60683. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  60684. }
  60685. /**
  60686. * Options fot the updraft event
  60687. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60688. */
  60689. export class PhysicsUpdraftEventOptions {
  60690. /**
  60691. * The radius of the cylinder for the vortex
  60692. */
  60693. radius: number;
  60694. /**
  60695. * The strenth of the updraft.
  60696. */
  60697. strength: number;
  60698. /**
  60699. * The height of the cylinder for the updraft.
  60700. */
  60701. height: number;
  60702. /**
  60703. * The mode for the the updraft.
  60704. */
  60705. updraftMode: PhysicsUpdraftMode;
  60706. }
  60707. /**
  60708. * Options fot the vortex event
  60709. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60710. */
  60711. export class PhysicsVortexEventOptions {
  60712. /**
  60713. * The radius of the cylinder for the vortex
  60714. */
  60715. radius: number;
  60716. /**
  60717. * The strenth of the vortex.
  60718. */
  60719. strength: number;
  60720. /**
  60721. * The height of the cylinder for the vortex.
  60722. */
  60723. height: number;
  60724. /**
  60725. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  60726. */
  60727. centripetalForceThreshold: number;
  60728. /**
  60729. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  60730. */
  60731. centripetalForceMultiplier: number;
  60732. /**
  60733. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  60734. */
  60735. centrifugalForceMultiplier: number;
  60736. /**
  60737. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  60738. */
  60739. updraftForceMultiplier: number;
  60740. }
  60741. /**
  60742. * The strenght of the force in correspondence to the distance of the affected object
  60743. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60744. */
  60745. export enum PhysicsRadialImpulseFalloff {
  60746. /** Defines that impulse is constant in strength across it's whole radius */
  60747. Constant = 0,
  60748. /** Defines that impulse gets weaker if it's further from the origin */
  60749. Linear = 1
  60750. }
  60751. /**
  60752. * The strength of the force in correspondence to the distance of the affected object
  60753. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60754. */
  60755. export enum PhysicsUpdraftMode {
  60756. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  60757. Center = 0,
  60758. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  60759. Perpendicular = 1
  60760. }
  60761. /**
  60762. * Interface for a physics hit data
  60763. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60764. */
  60765. export interface PhysicsHitData {
  60766. /**
  60767. * The force applied at the contact point
  60768. */
  60769. force: Vector3;
  60770. /**
  60771. * The contact point
  60772. */
  60773. contactPoint: Vector3;
  60774. /**
  60775. * The distance from the origin to the contact point
  60776. */
  60777. distanceFromOrigin: number;
  60778. }
  60779. /**
  60780. * Interface for radial explosion event data
  60781. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60782. */
  60783. export interface PhysicsRadialExplosionEventData {
  60784. /**
  60785. * A sphere used for the radial explosion event
  60786. */
  60787. sphere: Mesh;
  60788. }
  60789. /**
  60790. * Interface for gravitational field event data
  60791. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60792. */
  60793. export interface PhysicsGravitationalFieldEventData {
  60794. /**
  60795. * A sphere mesh used for the gravitational field event
  60796. */
  60797. sphere: Mesh;
  60798. }
  60799. /**
  60800. * Interface for updraft event data
  60801. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60802. */
  60803. export interface PhysicsUpdraftEventData {
  60804. /**
  60805. * A cylinder used for the updraft event
  60806. */
  60807. cylinder: Mesh;
  60808. }
  60809. /**
  60810. * Interface for vortex event data
  60811. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60812. */
  60813. export interface PhysicsVortexEventData {
  60814. /**
  60815. * A cylinder used for the vortex event
  60816. */
  60817. cylinder: Mesh;
  60818. }
  60819. /**
  60820. * Interface for an affected physics impostor
  60821. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60822. */
  60823. export interface PhysicsAffectedImpostorWithData {
  60824. /**
  60825. * The impostor affected by the effect
  60826. */
  60827. impostor: PhysicsImpostor;
  60828. /**
  60829. * The data about the hit/horce from the explosion
  60830. */
  60831. hitData: PhysicsHitData;
  60832. }
  60833. }
  60834. declare module "babylonjs/Physics/Plugins/index" {
  60835. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  60836. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  60837. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  60838. }
  60839. declare module "babylonjs/Physics/index" {
  60840. export * from "babylonjs/Physics/IPhysicsEngine";
  60841. export * from "babylonjs/Physics/physicsEngine";
  60842. export * from "babylonjs/Physics/physicsEngineComponent";
  60843. export * from "babylonjs/Physics/physicsHelper";
  60844. export * from "babylonjs/Physics/physicsImpostor";
  60845. export * from "babylonjs/Physics/physicsJoint";
  60846. export * from "babylonjs/Physics/Plugins/index";
  60847. }
  60848. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  60849. /** @hidden */
  60850. export var blackAndWhitePixelShader: {
  60851. name: string;
  60852. shader: string;
  60853. };
  60854. }
  60855. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  60856. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60857. import { Camera } from "babylonjs/Cameras/camera";
  60858. import { Engine } from "babylonjs/Engines/engine";
  60859. import "babylonjs/Shaders/blackAndWhite.fragment";
  60860. /**
  60861. * Post process used to render in black and white
  60862. */
  60863. export class BlackAndWhitePostProcess extends PostProcess {
  60864. /**
  60865. * Linear about to convert he result to black and white (default: 1)
  60866. */
  60867. degree: number;
  60868. /**
  60869. * Creates a black and white post process
  60870. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  60871. * @param name The name of the effect.
  60872. * @param options The required width/height ratio to downsize to before computing the render pass.
  60873. * @param camera The camera to apply the render pass to.
  60874. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60875. * @param engine The engine which the post process will be applied. (default: current engine)
  60876. * @param reusable If the post process can be reused on the same frame. (default: false)
  60877. */
  60878. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60879. }
  60880. }
  60881. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  60882. import { Nullable } from "babylonjs/types";
  60883. import { Camera } from "babylonjs/Cameras/camera";
  60884. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60885. import { Engine } from "babylonjs/Engines/engine";
  60886. /**
  60887. * This represents a set of one or more post processes in Babylon.
  60888. * A post process can be used to apply a shader to a texture after it is rendered.
  60889. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60890. */
  60891. export class PostProcessRenderEffect {
  60892. private _postProcesses;
  60893. private _getPostProcesses;
  60894. private _singleInstance;
  60895. private _cameras;
  60896. private _indicesForCamera;
  60897. /**
  60898. * Name of the effect
  60899. * @hidden
  60900. */
  60901. _name: string;
  60902. /**
  60903. * Instantiates a post process render effect.
  60904. * A post process can be used to apply a shader to a texture after it is rendered.
  60905. * @param engine The engine the effect is tied to
  60906. * @param name The name of the effect
  60907. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  60908. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  60909. */
  60910. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  60911. /**
  60912. * Checks if all the post processes in the effect are supported.
  60913. */
  60914. readonly isSupported: boolean;
  60915. /**
  60916. * Updates the current state of the effect
  60917. * @hidden
  60918. */
  60919. _update(): void;
  60920. /**
  60921. * Attaches the effect on cameras
  60922. * @param cameras The camera to attach to.
  60923. * @hidden
  60924. */
  60925. _attachCameras(cameras: Camera): void;
  60926. /**
  60927. * Attaches the effect on cameras
  60928. * @param cameras The camera to attach to.
  60929. * @hidden
  60930. */
  60931. _attachCameras(cameras: Camera[]): void;
  60932. /**
  60933. * Detaches the effect on cameras
  60934. * @param cameras The camera to detatch from.
  60935. * @hidden
  60936. */
  60937. _detachCameras(cameras: Camera): void;
  60938. /**
  60939. * Detatches the effect on cameras
  60940. * @param cameras The camera to detatch from.
  60941. * @hidden
  60942. */
  60943. _detachCameras(cameras: Camera[]): void;
  60944. /**
  60945. * Enables the effect on given cameras
  60946. * @param cameras The camera to enable.
  60947. * @hidden
  60948. */
  60949. _enable(cameras: Camera): void;
  60950. /**
  60951. * Enables the effect on given cameras
  60952. * @param cameras The camera to enable.
  60953. * @hidden
  60954. */
  60955. _enable(cameras: Nullable<Camera[]>): void;
  60956. /**
  60957. * Disables the effect on the given cameras
  60958. * @param cameras The camera to disable.
  60959. * @hidden
  60960. */
  60961. _disable(cameras: Camera): void;
  60962. /**
  60963. * Disables the effect on the given cameras
  60964. * @param cameras The camera to disable.
  60965. * @hidden
  60966. */
  60967. _disable(cameras: Nullable<Camera[]>): void;
  60968. /**
  60969. * Gets a list of the post processes contained in the effect.
  60970. * @param camera The camera to get the post processes on.
  60971. * @returns The list of the post processes in the effect.
  60972. */
  60973. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  60974. }
  60975. }
  60976. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  60977. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60978. /** @hidden */
  60979. export var extractHighlightsPixelShader: {
  60980. name: string;
  60981. shader: string;
  60982. };
  60983. }
  60984. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  60985. import { Nullable } from "babylonjs/types";
  60986. import { Camera } from "babylonjs/Cameras/camera";
  60987. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60988. import { Engine } from "babylonjs/Engines/engine";
  60989. import "babylonjs/Shaders/extractHighlights.fragment";
  60990. /**
  60991. * 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.
  60992. */
  60993. export class ExtractHighlightsPostProcess extends PostProcess {
  60994. /**
  60995. * The luminance threshold, pixels below this value will be set to black.
  60996. */
  60997. threshold: number;
  60998. /** @hidden */
  60999. _exposure: number;
  61000. /**
  61001. * Post process which has the input texture to be used when performing highlight extraction
  61002. * @hidden
  61003. */
  61004. _inputPostProcess: Nullable<PostProcess>;
  61005. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61006. }
  61007. }
  61008. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  61009. /** @hidden */
  61010. export var bloomMergePixelShader: {
  61011. name: string;
  61012. shader: string;
  61013. };
  61014. }
  61015. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  61016. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61017. import { Nullable } from "babylonjs/types";
  61018. import { Engine } from "babylonjs/Engines/engine";
  61019. import { Camera } from "babylonjs/Cameras/camera";
  61020. import "babylonjs/Shaders/bloomMerge.fragment";
  61021. /**
  61022. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  61023. */
  61024. export class BloomMergePostProcess extends PostProcess {
  61025. /** Weight of the bloom to be added to the original input. */
  61026. weight: number;
  61027. /**
  61028. * Creates a new instance of @see BloomMergePostProcess
  61029. * @param name The name of the effect.
  61030. * @param originalFromInput Post process which's input will be used for the merge.
  61031. * @param blurred Blurred highlights post process which's output will be used.
  61032. * @param weight Weight of the bloom to be added to the original input.
  61033. * @param options The required width/height ratio to downsize to before computing the render pass.
  61034. * @param camera The camera to apply the render pass to.
  61035. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61036. * @param engine The engine which the post process will be applied. (default: current engine)
  61037. * @param reusable If the post process can be reused on the same frame. (default: false)
  61038. * @param textureType Type of textures used when performing the post process. (default: 0)
  61039. * @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)
  61040. */
  61041. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  61042. /** Weight of the bloom to be added to the original input. */
  61043. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61044. }
  61045. }
  61046. declare module "babylonjs/PostProcesses/bloomEffect" {
  61047. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  61048. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61049. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  61050. import { Camera } from "babylonjs/Cameras/camera";
  61051. import { Scene } from "babylonjs/scene";
  61052. /**
  61053. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  61054. */
  61055. export class BloomEffect extends PostProcessRenderEffect {
  61056. private bloomScale;
  61057. /**
  61058. * @hidden Internal
  61059. */
  61060. _effects: Array<PostProcess>;
  61061. /**
  61062. * @hidden Internal
  61063. */
  61064. _downscale: ExtractHighlightsPostProcess;
  61065. private _blurX;
  61066. private _blurY;
  61067. private _merge;
  61068. /**
  61069. * The luminance threshold to find bright areas of the image to bloom.
  61070. */
  61071. threshold: number;
  61072. /**
  61073. * The strength of the bloom.
  61074. */
  61075. weight: number;
  61076. /**
  61077. * Specifies the size of the bloom blur kernel, relative to the final output size
  61078. */
  61079. kernel: number;
  61080. /**
  61081. * Creates a new instance of @see BloomEffect
  61082. * @param scene The scene the effect belongs to.
  61083. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  61084. * @param bloomKernel The size of the kernel to be used when applying the blur.
  61085. * @param bloomWeight The the strength of bloom.
  61086. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  61087. * @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)
  61088. */
  61089. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  61090. /**
  61091. * Disposes each of the internal effects for a given camera.
  61092. * @param camera The camera to dispose the effect on.
  61093. */
  61094. disposeEffects(camera: Camera): void;
  61095. /**
  61096. * @hidden Internal
  61097. */
  61098. _updateEffects(): void;
  61099. /**
  61100. * Internal
  61101. * @returns if all the contained post processes are ready.
  61102. * @hidden
  61103. */
  61104. _isReady(): boolean;
  61105. }
  61106. }
  61107. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  61108. /** @hidden */
  61109. export var chromaticAberrationPixelShader: {
  61110. name: string;
  61111. shader: string;
  61112. };
  61113. }
  61114. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  61115. import { Vector2 } from "babylonjs/Maths/math.vector";
  61116. import { Nullable } from "babylonjs/types";
  61117. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61118. import { Camera } from "babylonjs/Cameras/camera";
  61119. import { Engine } from "babylonjs/Engines/engine";
  61120. import "babylonjs/Shaders/chromaticAberration.fragment";
  61121. /**
  61122. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  61123. */
  61124. export class ChromaticAberrationPostProcess extends PostProcess {
  61125. /**
  61126. * The amount of seperation of rgb channels (default: 30)
  61127. */
  61128. aberrationAmount: number;
  61129. /**
  61130. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  61131. */
  61132. radialIntensity: number;
  61133. /**
  61134. * 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))
  61135. */
  61136. direction: Vector2;
  61137. /**
  61138. * 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))
  61139. */
  61140. centerPosition: Vector2;
  61141. /**
  61142. * Creates a new instance ChromaticAberrationPostProcess
  61143. * @param name The name of the effect.
  61144. * @param screenWidth The width of the screen to apply the effect on.
  61145. * @param screenHeight The height of the screen to apply the effect on.
  61146. * @param options The required width/height ratio to downsize to before computing the render pass.
  61147. * @param camera The camera to apply the render pass to.
  61148. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61149. * @param engine The engine which the post process will be applied. (default: current engine)
  61150. * @param reusable If the post process can be reused on the same frame. (default: false)
  61151. * @param textureType Type of textures used when performing the post process. (default: 0)
  61152. * @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)
  61153. */
  61154. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61155. }
  61156. }
  61157. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  61158. /** @hidden */
  61159. export var circleOfConfusionPixelShader: {
  61160. name: string;
  61161. shader: string;
  61162. };
  61163. }
  61164. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  61165. import { Nullable } from "babylonjs/types";
  61166. import { Engine } from "babylonjs/Engines/engine";
  61167. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61168. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61169. import { Camera } from "babylonjs/Cameras/camera";
  61170. import "babylonjs/Shaders/circleOfConfusion.fragment";
  61171. /**
  61172. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  61173. */
  61174. export class CircleOfConfusionPostProcess extends PostProcess {
  61175. /**
  61176. * 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.
  61177. */
  61178. lensSize: number;
  61179. /**
  61180. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  61181. */
  61182. fStop: number;
  61183. /**
  61184. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  61185. */
  61186. focusDistance: number;
  61187. /**
  61188. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  61189. */
  61190. focalLength: number;
  61191. private _depthTexture;
  61192. /**
  61193. * Creates a new instance CircleOfConfusionPostProcess
  61194. * @param name The name of the effect.
  61195. * @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.
  61196. * @param options The required width/height ratio to downsize to before computing the render pass.
  61197. * @param camera The camera to apply the render pass to.
  61198. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61199. * @param engine The engine which the post process will be applied. (default: current engine)
  61200. * @param reusable If the post process can be reused on the same frame. (default: false)
  61201. * @param textureType Type of textures used when performing the post process. (default: 0)
  61202. * @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)
  61203. */
  61204. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61205. /**
  61206. * 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.
  61207. */
  61208. depthTexture: RenderTargetTexture;
  61209. }
  61210. }
  61211. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  61212. /** @hidden */
  61213. export var colorCorrectionPixelShader: {
  61214. name: string;
  61215. shader: string;
  61216. };
  61217. }
  61218. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  61219. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61220. import { Engine } from "babylonjs/Engines/engine";
  61221. import { Camera } from "babylonjs/Cameras/camera";
  61222. import "babylonjs/Shaders/colorCorrection.fragment";
  61223. /**
  61224. *
  61225. * This post-process allows the modification of rendered colors by using
  61226. * a 'look-up table' (LUT). This effect is also called Color Grading.
  61227. *
  61228. * The object needs to be provided an url to a texture containing the color
  61229. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  61230. * Use an image editing software to tweak the LUT to match your needs.
  61231. *
  61232. * For an example of a color LUT, see here:
  61233. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  61234. * For explanations on color grading, see here:
  61235. * @see http://udn.epicgames.com/Three/ColorGrading.html
  61236. *
  61237. */
  61238. export class ColorCorrectionPostProcess extends PostProcess {
  61239. private _colorTableTexture;
  61240. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61241. }
  61242. }
  61243. declare module "babylonjs/Shaders/convolution.fragment" {
  61244. /** @hidden */
  61245. export var convolutionPixelShader: {
  61246. name: string;
  61247. shader: string;
  61248. };
  61249. }
  61250. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  61251. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61252. import { Nullable } from "babylonjs/types";
  61253. import { Camera } from "babylonjs/Cameras/camera";
  61254. import { Engine } from "babylonjs/Engines/engine";
  61255. import "babylonjs/Shaders/convolution.fragment";
  61256. /**
  61257. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  61258. * input texture to perform effects such as edge detection or sharpening
  61259. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  61260. */
  61261. export class ConvolutionPostProcess extends PostProcess {
  61262. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  61263. kernel: number[];
  61264. /**
  61265. * Creates a new instance ConvolutionPostProcess
  61266. * @param name The name of the effect.
  61267. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  61268. * @param options The required width/height ratio to downsize to before computing the render pass.
  61269. * @param camera The camera to apply the render pass to.
  61270. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61271. * @param engine The engine which the post process will be applied. (default: current engine)
  61272. * @param reusable If the post process can be reused on the same frame. (default: false)
  61273. * @param textureType Type of textures used when performing the post process. (default: 0)
  61274. */
  61275. constructor(name: string,
  61276. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  61277. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61278. /**
  61279. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61280. */
  61281. static EdgeDetect0Kernel: number[];
  61282. /**
  61283. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61284. */
  61285. static EdgeDetect1Kernel: number[];
  61286. /**
  61287. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61288. */
  61289. static EdgeDetect2Kernel: number[];
  61290. /**
  61291. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61292. */
  61293. static SharpenKernel: number[];
  61294. /**
  61295. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61296. */
  61297. static EmbossKernel: number[];
  61298. /**
  61299. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61300. */
  61301. static GaussianKernel: number[];
  61302. }
  61303. }
  61304. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  61305. import { Nullable } from "babylonjs/types";
  61306. import { Vector2 } from "babylonjs/Maths/math.vector";
  61307. import { Camera } from "babylonjs/Cameras/camera";
  61308. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61309. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  61310. import { Engine } from "babylonjs/Engines/engine";
  61311. import { Scene } from "babylonjs/scene";
  61312. /**
  61313. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  61314. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  61315. * based on samples that have a large difference in distance than the center pixel.
  61316. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  61317. */
  61318. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  61319. direction: Vector2;
  61320. /**
  61321. * Creates a new instance CircleOfConfusionPostProcess
  61322. * @param name The name of the effect.
  61323. * @param scene The scene the effect belongs to.
  61324. * @param direction The direction the blur should be applied.
  61325. * @param kernel The size of the kernel used to blur.
  61326. * @param options The required width/height ratio to downsize to before computing the render pass.
  61327. * @param camera The camera to apply the render pass to.
  61328. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  61329. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  61330. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61331. * @param engine The engine which the post process will be applied. (default: current engine)
  61332. * @param reusable If the post process can be reused on the same frame. (default: false)
  61333. * @param textureType Type of textures used when performing the post process. (default: 0)
  61334. * @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)
  61335. */
  61336. 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);
  61337. }
  61338. }
  61339. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  61340. /** @hidden */
  61341. export var depthOfFieldMergePixelShader: {
  61342. name: string;
  61343. shader: string;
  61344. };
  61345. }
  61346. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  61347. import { Nullable } from "babylonjs/types";
  61348. import { Camera } from "babylonjs/Cameras/camera";
  61349. import { Effect } from "babylonjs/Materials/effect";
  61350. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61351. import { Engine } from "babylonjs/Engines/engine";
  61352. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  61353. /**
  61354. * Options to be set when merging outputs from the default pipeline.
  61355. */
  61356. export class DepthOfFieldMergePostProcessOptions {
  61357. /**
  61358. * The original image to merge on top of
  61359. */
  61360. originalFromInput: PostProcess;
  61361. /**
  61362. * Parameters to perform the merge of the depth of field effect
  61363. */
  61364. depthOfField?: {
  61365. circleOfConfusion: PostProcess;
  61366. blurSteps: Array<PostProcess>;
  61367. };
  61368. /**
  61369. * Parameters to perform the merge of bloom effect
  61370. */
  61371. bloom?: {
  61372. blurred: PostProcess;
  61373. weight: number;
  61374. };
  61375. }
  61376. /**
  61377. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  61378. */
  61379. export class DepthOfFieldMergePostProcess extends PostProcess {
  61380. private blurSteps;
  61381. /**
  61382. * Creates a new instance of DepthOfFieldMergePostProcess
  61383. * @param name The name of the effect.
  61384. * @param originalFromInput Post process which's input will be used for the merge.
  61385. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  61386. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  61387. * @param options The required width/height ratio to downsize to before computing the render pass.
  61388. * @param camera The camera to apply the render pass to.
  61389. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61390. * @param engine The engine which the post process will be applied. (default: current engine)
  61391. * @param reusable If the post process can be reused on the same frame. (default: false)
  61392. * @param textureType Type of textures used when performing the post process. (default: 0)
  61393. * @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)
  61394. */
  61395. 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);
  61396. /**
  61397. * Updates the effect with the current post process compile time values and recompiles the shader.
  61398. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  61399. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  61400. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  61401. * @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
  61402. * @param onCompiled Called when the shader has been compiled.
  61403. * @param onError Called if there is an error when compiling a shader.
  61404. */
  61405. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  61406. }
  61407. }
  61408. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  61409. import { Nullable } from "babylonjs/types";
  61410. import { Camera } from "babylonjs/Cameras/camera";
  61411. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61412. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61413. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  61414. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  61415. import { Scene } from "babylonjs/scene";
  61416. /**
  61417. * Specifies the level of max blur that should be applied when using the depth of field effect
  61418. */
  61419. export enum DepthOfFieldEffectBlurLevel {
  61420. /**
  61421. * Subtle blur
  61422. */
  61423. Low = 0,
  61424. /**
  61425. * Medium blur
  61426. */
  61427. Medium = 1,
  61428. /**
  61429. * Large blur
  61430. */
  61431. High = 2
  61432. }
  61433. /**
  61434. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  61435. */
  61436. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  61437. private _circleOfConfusion;
  61438. /**
  61439. * @hidden Internal, blurs from high to low
  61440. */
  61441. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  61442. private _depthOfFieldBlurY;
  61443. private _dofMerge;
  61444. /**
  61445. * @hidden Internal post processes in depth of field effect
  61446. */
  61447. _effects: Array<PostProcess>;
  61448. /**
  61449. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  61450. */
  61451. focalLength: number;
  61452. /**
  61453. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  61454. */
  61455. fStop: number;
  61456. /**
  61457. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  61458. */
  61459. focusDistance: number;
  61460. /**
  61461. * 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.
  61462. */
  61463. lensSize: number;
  61464. /**
  61465. * Creates a new instance DepthOfFieldEffect
  61466. * @param scene The scene the effect belongs to.
  61467. * @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.
  61468. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  61469. * @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)
  61470. */
  61471. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  61472. /**
  61473. * Get the current class name of the current effet
  61474. * @returns "DepthOfFieldEffect"
  61475. */
  61476. getClassName(): string;
  61477. /**
  61478. * 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.
  61479. */
  61480. depthTexture: RenderTargetTexture;
  61481. /**
  61482. * Disposes each of the internal effects for a given camera.
  61483. * @param camera The camera to dispose the effect on.
  61484. */
  61485. disposeEffects(camera: Camera): void;
  61486. /**
  61487. * @hidden Internal
  61488. */
  61489. _updateEffects(): void;
  61490. /**
  61491. * Internal
  61492. * @returns if all the contained post processes are ready.
  61493. * @hidden
  61494. */
  61495. _isReady(): boolean;
  61496. }
  61497. }
  61498. declare module "babylonjs/Shaders/displayPass.fragment" {
  61499. /** @hidden */
  61500. export var displayPassPixelShader: {
  61501. name: string;
  61502. shader: string;
  61503. };
  61504. }
  61505. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  61506. import { Nullable } from "babylonjs/types";
  61507. import { Camera } from "babylonjs/Cameras/camera";
  61508. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61509. import { Engine } from "babylonjs/Engines/engine";
  61510. import "babylonjs/Shaders/displayPass.fragment";
  61511. /**
  61512. * DisplayPassPostProcess which produces an output the same as it's input
  61513. */
  61514. export class DisplayPassPostProcess extends PostProcess {
  61515. /**
  61516. * Creates the DisplayPassPostProcess
  61517. * @param name The name of the effect.
  61518. * @param options The required width/height ratio to downsize to before computing the render pass.
  61519. * @param camera The camera to apply the render pass to.
  61520. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61521. * @param engine The engine which the post process will be applied. (default: current engine)
  61522. * @param reusable If the post process can be reused on the same frame. (default: false)
  61523. */
  61524. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61525. }
  61526. }
  61527. declare module "babylonjs/Shaders/filter.fragment" {
  61528. /** @hidden */
  61529. export var filterPixelShader: {
  61530. name: string;
  61531. shader: string;
  61532. };
  61533. }
  61534. declare module "babylonjs/PostProcesses/filterPostProcess" {
  61535. import { Nullable } from "babylonjs/types";
  61536. import { Matrix } from "babylonjs/Maths/math.vector";
  61537. import { Camera } from "babylonjs/Cameras/camera";
  61538. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61539. import { Engine } from "babylonjs/Engines/engine";
  61540. import "babylonjs/Shaders/filter.fragment";
  61541. /**
  61542. * Applies a kernel filter to the image
  61543. */
  61544. export class FilterPostProcess extends PostProcess {
  61545. /** The matrix to be applied to the image */
  61546. kernelMatrix: Matrix;
  61547. /**
  61548. *
  61549. * @param name The name of the effect.
  61550. * @param kernelMatrix The matrix to be applied to the image
  61551. * @param options The required width/height ratio to downsize to before computing the render pass.
  61552. * @param camera The camera to apply the render pass to.
  61553. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61554. * @param engine The engine which the post process will be applied. (default: current engine)
  61555. * @param reusable If the post process can be reused on the same frame. (default: false)
  61556. */
  61557. constructor(name: string,
  61558. /** The matrix to be applied to the image */
  61559. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61560. }
  61561. }
  61562. declare module "babylonjs/Shaders/fxaa.fragment" {
  61563. /** @hidden */
  61564. export var fxaaPixelShader: {
  61565. name: string;
  61566. shader: string;
  61567. };
  61568. }
  61569. declare module "babylonjs/Shaders/fxaa.vertex" {
  61570. /** @hidden */
  61571. export var fxaaVertexShader: {
  61572. name: string;
  61573. shader: string;
  61574. };
  61575. }
  61576. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  61577. import { Nullable } from "babylonjs/types";
  61578. import { Camera } from "babylonjs/Cameras/camera";
  61579. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61580. import { Engine } from "babylonjs/Engines/engine";
  61581. import "babylonjs/Shaders/fxaa.fragment";
  61582. import "babylonjs/Shaders/fxaa.vertex";
  61583. /**
  61584. * Fxaa post process
  61585. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  61586. */
  61587. export class FxaaPostProcess extends PostProcess {
  61588. /** @hidden */
  61589. texelWidth: number;
  61590. /** @hidden */
  61591. texelHeight: number;
  61592. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61593. private _getDefines;
  61594. }
  61595. }
  61596. declare module "babylonjs/Shaders/grain.fragment" {
  61597. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61598. /** @hidden */
  61599. export var grainPixelShader: {
  61600. name: string;
  61601. shader: string;
  61602. };
  61603. }
  61604. declare module "babylonjs/PostProcesses/grainPostProcess" {
  61605. import { Nullable } from "babylonjs/types";
  61606. import { Camera } from "babylonjs/Cameras/camera";
  61607. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61608. import { Engine } from "babylonjs/Engines/engine";
  61609. import "babylonjs/Shaders/grain.fragment";
  61610. /**
  61611. * The GrainPostProcess adds noise to the image at mid luminance levels
  61612. */
  61613. export class GrainPostProcess extends PostProcess {
  61614. /**
  61615. * The intensity of the grain added (default: 30)
  61616. */
  61617. intensity: number;
  61618. /**
  61619. * If the grain should be randomized on every frame
  61620. */
  61621. animated: boolean;
  61622. /**
  61623. * Creates a new instance of @see GrainPostProcess
  61624. * @param name The name of the effect.
  61625. * @param options The required width/height ratio to downsize to before computing the render pass.
  61626. * @param camera The camera to apply the render pass to.
  61627. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61628. * @param engine The engine which the post process will be applied. (default: current engine)
  61629. * @param reusable If the post process can be reused on the same frame. (default: false)
  61630. * @param textureType Type of textures used when performing the post process. (default: 0)
  61631. * @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)
  61632. */
  61633. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61634. }
  61635. }
  61636. declare module "babylonjs/Shaders/highlights.fragment" {
  61637. /** @hidden */
  61638. export var highlightsPixelShader: {
  61639. name: string;
  61640. shader: string;
  61641. };
  61642. }
  61643. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  61644. import { Nullable } from "babylonjs/types";
  61645. import { Camera } from "babylonjs/Cameras/camera";
  61646. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61647. import { Engine } from "babylonjs/Engines/engine";
  61648. import "babylonjs/Shaders/highlights.fragment";
  61649. /**
  61650. * Extracts highlights from the image
  61651. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  61652. */
  61653. export class HighlightsPostProcess extends PostProcess {
  61654. /**
  61655. * Extracts highlights from the image
  61656. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  61657. * @param name The name of the effect.
  61658. * @param options The required width/height ratio to downsize to before computing the render pass.
  61659. * @param camera The camera to apply the render pass to.
  61660. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61661. * @param engine The engine which the post process will be applied. (default: current engine)
  61662. * @param reusable If the post process can be reused on the same frame. (default: false)
  61663. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  61664. */
  61665. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61666. }
  61667. }
  61668. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  61669. /** @hidden */
  61670. export var mrtFragmentDeclaration: {
  61671. name: string;
  61672. shader: string;
  61673. };
  61674. }
  61675. declare module "babylonjs/Shaders/geometry.fragment" {
  61676. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  61677. /** @hidden */
  61678. export var geometryPixelShader: {
  61679. name: string;
  61680. shader: string;
  61681. };
  61682. }
  61683. declare module "babylonjs/Shaders/geometry.vertex" {
  61684. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61685. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61686. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61687. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61688. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61689. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61690. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61691. /** @hidden */
  61692. export var geometryVertexShader: {
  61693. name: string;
  61694. shader: string;
  61695. };
  61696. }
  61697. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  61698. import { Matrix } from "babylonjs/Maths/math.vector";
  61699. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61700. import { Mesh } from "babylonjs/Meshes/mesh";
  61701. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  61702. import { Effect } from "babylonjs/Materials/effect";
  61703. import { Scene } from "babylonjs/scene";
  61704. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61705. import "babylonjs/Shaders/geometry.fragment";
  61706. import "babylonjs/Shaders/geometry.vertex";
  61707. /** @hidden */
  61708. interface ISavedTransformationMatrix {
  61709. world: Matrix;
  61710. viewProjection: Matrix;
  61711. }
  61712. /**
  61713. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  61714. */
  61715. export class GeometryBufferRenderer {
  61716. /**
  61717. * Constant used to retrieve the position texture index in the G-Buffer textures array
  61718. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  61719. */
  61720. static readonly POSITION_TEXTURE_TYPE: number;
  61721. /**
  61722. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  61723. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  61724. */
  61725. static readonly VELOCITY_TEXTURE_TYPE: number;
  61726. /**
  61727. * Dictionary used to store the previous transformation matrices of each rendered mesh
  61728. * in order to compute objects velocities when enableVelocity is set to "true"
  61729. * @hidden
  61730. */
  61731. _previousTransformationMatrices: {
  61732. [index: number]: ISavedTransformationMatrix;
  61733. };
  61734. /**
  61735. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  61736. * in order to compute objects velocities when enableVelocity is set to "true"
  61737. * @hidden
  61738. */
  61739. _previousBonesTransformationMatrices: {
  61740. [index: number]: Float32Array;
  61741. };
  61742. /**
  61743. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  61744. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  61745. */
  61746. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  61747. private _scene;
  61748. private _multiRenderTarget;
  61749. private _ratio;
  61750. private _enablePosition;
  61751. private _enableVelocity;
  61752. private _positionIndex;
  61753. private _velocityIndex;
  61754. protected _effect: Effect;
  61755. protected _cachedDefines: string;
  61756. /**
  61757. * Set the render list (meshes to be rendered) used in the G buffer.
  61758. */
  61759. renderList: Mesh[];
  61760. /**
  61761. * Gets wether or not G buffer are supported by the running hardware.
  61762. * This requires draw buffer supports
  61763. */
  61764. readonly isSupported: boolean;
  61765. /**
  61766. * Returns the index of the given texture type in the G-Buffer textures array
  61767. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  61768. * @returns the index of the given texture type in the G-Buffer textures array
  61769. */
  61770. getTextureIndex(textureType: number): number;
  61771. /**
  61772. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  61773. */
  61774. /**
  61775. * Sets whether or not objects positions are enabled for the G buffer.
  61776. */
  61777. enablePosition: boolean;
  61778. /**
  61779. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  61780. */
  61781. /**
  61782. * Sets wether or not objects velocities are enabled for the G buffer.
  61783. */
  61784. enableVelocity: boolean;
  61785. /**
  61786. * Gets the scene associated with the buffer.
  61787. */
  61788. readonly scene: Scene;
  61789. /**
  61790. * Gets the ratio used by the buffer during its creation.
  61791. * How big is the buffer related to the main canvas.
  61792. */
  61793. readonly ratio: number;
  61794. /** @hidden */
  61795. static _SceneComponentInitialization: (scene: Scene) => void;
  61796. /**
  61797. * Creates a new G Buffer for the scene
  61798. * @param scene The scene the buffer belongs to
  61799. * @param ratio How big is the buffer related to the main canvas.
  61800. */
  61801. constructor(scene: Scene, ratio?: number);
  61802. /**
  61803. * Checks wether everything is ready to render a submesh to the G buffer.
  61804. * @param subMesh the submesh to check readiness for
  61805. * @param useInstances is the mesh drawn using instance or not
  61806. * @returns true if ready otherwise false
  61807. */
  61808. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61809. /**
  61810. * Gets the current underlying G Buffer.
  61811. * @returns the buffer
  61812. */
  61813. getGBuffer(): MultiRenderTarget;
  61814. /**
  61815. * Gets the number of samples used to render the buffer (anti aliasing).
  61816. */
  61817. /**
  61818. * Sets the number of samples used to render the buffer (anti aliasing).
  61819. */
  61820. samples: number;
  61821. /**
  61822. * Disposes the renderer and frees up associated resources.
  61823. */
  61824. dispose(): void;
  61825. protected _createRenderTargets(): void;
  61826. private _copyBonesTransformationMatrices;
  61827. }
  61828. }
  61829. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  61830. import { Nullable } from "babylonjs/types";
  61831. import { Scene } from "babylonjs/scene";
  61832. import { ISceneComponent } from "babylonjs/sceneComponent";
  61833. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  61834. module "babylonjs/scene" {
  61835. interface Scene {
  61836. /** @hidden (Backing field) */
  61837. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  61838. /**
  61839. * Gets or Sets the current geometry buffer associated to the scene.
  61840. */
  61841. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  61842. /**
  61843. * Enables a GeometryBufferRender and associates it with the scene
  61844. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  61845. * @returns the GeometryBufferRenderer
  61846. */
  61847. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  61848. /**
  61849. * Disables the GeometryBufferRender associated with the scene
  61850. */
  61851. disableGeometryBufferRenderer(): void;
  61852. }
  61853. }
  61854. /**
  61855. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  61856. * in several rendering techniques.
  61857. */
  61858. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  61859. /**
  61860. * The component name helpful to identify the component in the list of scene components.
  61861. */
  61862. readonly name: string;
  61863. /**
  61864. * The scene the component belongs to.
  61865. */
  61866. scene: Scene;
  61867. /**
  61868. * Creates a new instance of the component for the given scene
  61869. * @param scene Defines the scene to register the component in
  61870. */
  61871. constructor(scene: Scene);
  61872. /**
  61873. * Registers the component in a given scene
  61874. */
  61875. register(): void;
  61876. /**
  61877. * Rebuilds the elements related to this component in case of
  61878. * context lost for instance.
  61879. */
  61880. rebuild(): void;
  61881. /**
  61882. * Disposes the component and the associated ressources
  61883. */
  61884. dispose(): void;
  61885. private _gatherRenderTargets;
  61886. }
  61887. }
  61888. declare module "babylonjs/Shaders/motionBlur.fragment" {
  61889. /** @hidden */
  61890. export var motionBlurPixelShader: {
  61891. name: string;
  61892. shader: string;
  61893. };
  61894. }
  61895. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  61896. import { Nullable } from "babylonjs/types";
  61897. import { Camera } from "babylonjs/Cameras/camera";
  61898. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61899. import { Scene } from "babylonjs/scene";
  61900. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61901. import "babylonjs/Animations/animatable";
  61902. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  61903. import "babylonjs/Shaders/motionBlur.fragment";
  61904. import { Engine } from "babylonjs/Engines/engine";
  61905. /**
  61906. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  61907. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  61908. * As an example, all you have to do is to create the post-process:
  61909. * var mb = new BABYLON.MotionBlurPostProcess(
  61910. * 'mb', // The name of the effect.
  61911. * scene, // The scene containing the objects to blur according to their velocity.
  61912. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  61913. * camera // The camera to apply the render pass to.
  61914. * );
  61915. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  61916. */
  61917. export class MotionBlurPostProcess extends PostProcess {
  61918. /**
  61919. * Defines how much the image is blurred by the movement. Default value is equal to 1
  61920. */
  61921. motionStrength: number;
  61922. /**
  61923. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  61924. */
  61925. /**
  61926. * Sets the number of iterations to be used for motion blur quality
  61927. */
  61928. motionBlurSamples: number;
  61929. private _motionBlurSamples;
  61930. private _geometryBufferRenderer;
  61931. /**
  61932. * Creates a new instance MotionBlurPostProcess
  61933. * @param name The name of the effect.
  61934. * @param scene The scene containing the objects to blur according to their velocity.
  61935. * @param options The required width/height ratio to downsize to before computing the render pass.
  61936. * @param camera The camera to apply the render pass to.
  61937. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61938. * @param engine The engine which the post process will be applied. (default: current engine)
  61939. * @param reusable If the post process can be reused on the same frame. (default: false)
  61940. * @param textureType Type of textures used when performing the post process. (default: 0)
  61941. * @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)
  61942. */
  61943. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61944. /**
  61945. * Excludes the given skinned mesh from computing bones velocities.
  61946. * 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.
  61947. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  61948. */
  61949. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  61950. /**
  61951. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  61952. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  61953. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  61954. */
  61955. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  61956. /**
  61957. * Disposes the post process.
  61958. * @param camera The camera to dispose the post process on.
  61959. */
  61960. dispose(camera?: Camera): void;
  61961. }
  61962. }
  61963. declare module "babylonjs/Shaders/refraction.fragment" {
  61964. /** @hidden */
  61965. export var refractionPixelShader: {
  61966. name: string;
  61967. shader: string;
  61968. };
  61969. }
  61970. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  61971. import { Color3 } from "babylonjs/Maths/math.color";
  61972. import { Camera } from "babylonjs/Cameras/camera";
  61973. import { Texture } from "babylonjs/Materials/Textures/texture";
  61974. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61975. import { Engine } from "babylonjs/Engines/engine";
  61976. import "babylonjs/Shaders/refraction.fragment";
  61977. /**
  61978. * Post process which applies a refractin texture
  61979. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  61980. */
  61981. export class RefractionPostProcess extends PostProcess {
  61982. /** the base color of the refraction (used to taint the rendering) */
  61983. color: Color3;
  61984. /** simulated refraction depth */
  61985. depth: number;
  61986. /** the coefficient of the base color (0 to remove base color tainting) */
  61987. colorLevel: number;
  61988. private _refTexture;
  61989. private _ownRefractionTexture;
  61990. /**
  61991. * Gets or sets the refraction texture
  61992. * Please note that you are responsible for disposing the texture if you set it manually
  61993. */
  61994. refractionTexture: Texture;
  61995. /**
  61996. * Initializes the RefractionPostProcess
  61997. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  61998. * @param name The name of the effect.
  61999. * @param refractionTextureUrl Url of the refraction texture to use
  62000. * @param color the base color of the refraction (used to taint the rendering)
  62001. * @param depth simulated refraction depth
  62002. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  62003. * @param camera The camera to apply the render pass to.
  62004. * @param options The required width/height ratio to downsize to before computing the render pass.
  62005. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62006. * @param engine The engine which the post process will be applied. (default: current engine)
  62007. * @param reusable If the post process can be reused on the same frame. (default: false)
  62008. */
  62009. constructor(name: string, refractionTextureUrl: string,
  62010. /** the base color of the refraction (used to taint the rendering) */
  62011. color: Color3,
  62012. /** simulated refraction depth */
  62013. depth: number,
  62014. /** the coefficient of the base color (0 to remove base color tainting) */
  62015. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62016. /**
  62017. * Disposes of the post process
  62018. * @param camera Camera to dispose post process on
  62019. */
  62020. dispose(camera: Camera): void;
  62021. }
  62022. }
  62023. declare module "babylonjs/Shaders/sharpen.fragment" {
  62024. /** @hidden */
  62025. export var sharpenPixelShader: {
  62026. name: string;
  62027. shader: string;
  62028. };
  62029. }
  62030. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  62031. import { Nullable } from "babylonjs/types";
  62032. import { Camera } from "babylonjs/Cameras/camera";
  62033. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62034. import "babylonjs/Shaders/sharpen.fragment";
  62035. import { Engine } from "babylonjs/Engines/engine";
  62036. /**
  62037. * The SharpenPostProcess applies a sharpen kernel to every pixel
  62038. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  62039. */
  62040. export class SharpenPostProcess extends PostProcess {
  62041. /**
  62042. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  62043. */
  62044. colorAmount: number;
  62045. /**
  62046. * How much sharpness should be applied (default: 0.3)
  62047. */
  62048. edgeAmount: number;
  62049. /**
  62050. * Creates a new instance ConvolutionPostProcess
  62051. * @param name The name of the effect.
  62052. * @param options The required width/height ratio to downsize to before computing the render pass.
  62053. * @param camera The camera to apply the render pass to.
  62054. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62055. * @param engine The engine which the post process will be applied. (default: current engine)
  62056. * @param reusable If the post process can be reused on the same frame. (default: false)
  62057. * @param textureType Type of textures used when performing the post process. (default: 0)
  62058. * @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)
  62059. */
  62060. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62061. }
  62062. }
  62063. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  62064. import { Nullable } from "babylonjs/types";
  62065. import { Camera } from "babylonjs/Cameras/camera";
  62066. import { Engine } from "babylonjs/Engines/engine";
  62067. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62068. import { IInspectable } from "babylonjs/Misc/iInspectable";
  62069. /**
  62070. * PostProcessRenderPipeline
  62071. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62072. */
  62073. export class PostProcessRenderPipeline {
  62074. private engine;
  62075. private _renderEffects;
  62076. private _renderEffectsForIsolatedPass;
  62077. /**
  62078. * List of inspectable custom properties (used by the Inspector)
  62079. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  62080. */
  62081. inspectableCustomProperties: IInspectable[];
  62082. /**
  62083. * @hidden
  62084. */
  62085. protected _cameras: Camera[];
  62086. /** @hidden */
  62087. _name: string;
  62088. /**
  62089. * Gets pipeline name
  62090. */
  62091. readonly name: string;
  62092. /**
  62093. * Initializes a PostProcessRenderPipeline
  62094. * @param engine engine to add the pipeline to
  62095. * @param name name of the pipeline
  62096. */
  62097. constructor(engine: Engine, name: string);
  62098. /**
  62099. * Gets the class name
  62100. * @returns "PostProcessRenderPipeline"
  62101. */
  62102. getClassName(): string;
  62103. /**
  62104. * If all the render effects in the pipeline are supported
  62105. */
  62106. readonly isSupported: boolean;
  62107. /**
  62108. * Adds an effect to the pipeline
  62109. * @param renderEffect the effect to add
  62110. */
  62111. addEffect(renderEffect: PostProcessRenderEffect): void;
  62112. /** @hidden */
  62113. _rebuild(): void;
  62114. /** @hidden */
  62115. _enableEffect(renderEffectName: string, cameras: Camera): void;
  62116. /** @hidden */
  62117. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  62118. /** @hidden */
  62119. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  62120. /** @hidden */
  62121. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  62122. /** @hidden */
  62123. _attachCameras(cameras: Camera, unique: boolean): void;
  62124. /** @hidden */
  62125. _attachCameras(cameras: Camera[], unique: boolean): void;
  62126. /** @hidden */
  62127. _detachCameras(cameras: Camera): void;
  62128. /** @hidden */
  62129. _detachCameras(cameras: Nullable<Camera[]>): void;
  62130. /** @hidden */
  62131. _update(): void;
  62132. /** @hidden */
  62133. _reset(): void;
  62134. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  62135. /**
  62136. * Disposes of the pipeline
  62137. */
  62138. dispose(): void;
  62139. }
  62140. }
  62141. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  62142. import { Camera } from "babylonjs/Cameras/camera";
  62143. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62144. /**
  62145. * PostProcessRenderPipelineManager class
  62146. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62147. */
  62148. export class PostProcessRenderPipelineManager {
  62149. private _renderPipelines;
  62150. /**
  62151. * Initializes a PostProcessRenderPipelineManager
  62152. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62153. */
  62154. constructor();
  62155. /**
  62156. * Gets the list of supported render pipelines
  62157. */
  62158. readonly supportedPipelines: PostProcessRenderPipeline[];
  62159. /**
  62160. * Adds a pipeline to the manager
  62161. * @param renderPipeline The pipeline to add
  62162. */
  62163. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  62164. /**
  62165. * Attaches a camera to the pipeline
  62166. * @param renderPipelineName The name of the pipeline to attach to
  62167. * @param cameras the camera to attach
  62168. * @param unique if the camera can be attached multiple times to the pipeline
  62169. */
  62170. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  62171. /**
  62172. * Detaches a camera from the pipeline
  62173. * @param renderPipelineName The name of the pipeline to detach from
  62174. * @param cameras the camera to detach
  62175. */
  62176. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  62177. /**
  62178. * Enables an effect by name on a pipeline
  62179. * @param renderPipelineName the name of the pipeline to enable the effect in
  62180. * @param renderEffectName the name of the effect to enable
  62181. * @param cameras the cameras that the effect should be enabled on
  62182. */
  62183. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  62184. /**
  62185. * Disables an effect by name on a pipeline
  62186. * @param renderPipelineName the name of the pipeline to disable the effect in
  62187. * @param renderEffectName the name of the effect to disable
  62188. * @param cameras the cameras that the effect should be disabled on
  62189. */
  62190. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  62191. /**
  62192. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  62193. */
  62194. update(): void;
  62195. /** @hidden */
  62196. _rebuild(): void;
  62197. /**
  62198. * Disposes of the manager and pipelines
  62199. */
  62200. dispose(): void;
  62201. }
  62202. }
  62203. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  62204. import { ISceneComponent } from "babylonjs/sceneComponent";
  62205. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  62206. import { Scene } from "babylonjs/scene";
  62207. module "babylonjs/scene" {
  62208. interface Scene {
  62209. /** @hidden (Backing field) */
  62210. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  62211. /**
  62212. * Gets the postprocess render pipeline manager
  62213. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62214. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  62215. */
  62216. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  62217. }
  62218. }
  62219. /**
  62220. * Defines the Render Pipeline scene component responsible to rendering pipelines
  62221. */
  62222. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  62223. /**
  62224. * The component name helpfull to identify the component in the list of scene components.
  62225. */
  62226. readonly name: string;
  62227. /**
  62228. * The scene the component belongs to.
  62229. */
  62230. scene: Scene;
  62231. /**
  62232. * Creates a new instance of the component for the given scene
  62233. * @param scene Defines the scene to register the component in
  62234. */
  62235. constructor(scene: Scene);
  62236. /**
  62237. * Registers the component in a given scene
  62238. */
  62239. register(): void;
  62240. /**
  62241. * Rebuilds the elements related to this component in case of
  62242. * context lost for instance.
  62243. */
  62244. rebuild(): void;
  62245. /**
  62246. * Disposes the component and the associated ressources
  62247. */
  62248. dispose(): void;
  62249. private _gatherRenderTargets;
  62250. }
  62251. }
  62252. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  62253. import { Nullable } from "babylonjs/types";
  62254. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  62255. import { Camera } from "babylonjs/Cameras/camera";
  62256. import { IDisposable } from "babylonjs/scene";
  62257. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  62258. import { Scene } from "babylonjs/scene";
  62259. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  62260. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  62261. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  62262. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  62263. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  62264. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62265. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  62266. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62267. import { Animation } from "babylonjs/Animations/animation";
  62268. /**
  62269. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  62270. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  62271. */
  62272. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  62273. private _scene;
  62274. private _camerasToBeAttached;
  62275. /**
  62276. * ID of the sharpen post process,
  62277. */
  62278. private readonly SharpenPostProcessId;
  62279. /**
  62280. * @ignore
  62281. * ID of the image processing post process;
  62282. */
  62283. readonly ImageProcessingPostProcessId: string;
  62284. /**
  62285. * @ignore
  62286. * ID of the Fast Approximate Anti-Aliasing post process;
  62287. */
  62288. readonly FxaaPostProcessId: string;
  62289. /**
  62290. * ID of the chromatic aberration post process,
  62291. */
  62292. private readonly ChromaticAberrationPostProcessId;
  62293. /**
  62294. * ID of the grain post process
  62295. */
  62296. private readonly GrainPostProcessId;
  62297. /**
  62298. * Sharpen post process which will apply a sharpen convolution to enhance edges
  62299. */
  62300. sharpen: SharpenPostProcess;
  62301. private _sharpenEffect;
  62302. private bloom;
  62303. /**
  62304. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  62305. */
  62306. depthOfField: DepthOfFieldEffect;
  62307. /**
  62308. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  62309. */
  62310. fxaa: FxaaPostProcess;
  62311. /**
  62312. * Image post processing pass used to perform operations such as tone mapping or color grading.
  62313. */
  62314. imageProcessing: ImageProcessingPostProcess;
  62315. /**
  62316. * Chromatic aberration post process which will shift rgb colors in the image
  62317. */
  62318. chromaticAberration: ChromaticAberrationPostProcess;
  62319. private _chromaticAberrationEffect;
  62320. /**
  62321. * Grain post process which add noise to the image
  62322. */
  62323. grain: GrainPostProcess;
  62324. private _grainEffect;
  62325. /**
  62326. * Glow post process which adds a glow to emissive areas of the image
  62327. */
  62328. private _glowLayer;
  62329. /**
  62330. * Animations which can be used to tweak settings over a period of time
  62331. */
  62332. animations: Animation[];
  62333. private _imageProcessingConfigurationObserver;
  62334. private _sharpenEnabled;
  62335. private _bloomEnabled;
  62336. private _depthOfFieldEnabled;
  62337. private _depthOfFieldBlurLevel;
  62338. private _fxaaEnabled;
  62339. private _imageProcessingEnabled;
  62340. private _defaultPipelineTextureType;
  62341. private _bloomScale;
  62342. private _chromaticAberrationEnabled;
  62343. private _grainEnabled;
  62344. private _buildAllowed;
  62345. /**
  62346. * Gets active scene
  62347. */
  62348. readonly scene: Scene;
  62349. /**
  62350. * Enable or disable the sharpen process from the pipeline
  62351. */
  62352. sharpenEnabled: boolean;
  62353. private _resizeObserver;
  62354. private _hardwareScaleLevel;
  62355. private _bloomKernel;
  62356. /**
  62357. * Specifies the size of the bloom blur kernel, relative to the final output size
  62358. */
  62359. bloomKernel: number;
  62360. /**
  62361. * Specifies the weight of the bloom in the final rendering
  62362. */
  62363. private _bloomWeight;
  62364. /**
  62365. * Specifies the luma threshold for the area that will be blurred by the bloom
  62366. */
  62367. private _bloomThreshold;
  62368. private _hdr;
  62369. /**
  62370. * The strength of the bloom.
  62371. */
  62372. bloomWeight: number;
  62373. /**
  62374. * The strength of the bloom.
  62375. */
  62376. bloomThreshold: number;
  62377. /**
  62378. * The scale of the bloom, lower value will provide better performance.
  62379. */
  62380. bloomScale: number;
  62381. /**
  62382. * Enable or disable the bloom from the pipeline
  62383. */
  62384. bloomEnabled: boolean;
  62385. private _rebuildBloom;
  62386. /**
  62387. * If the depth of field is enabled.
  62388. */
  62389. depthOfFieldEnabled: boolean;
  62390. /**
  62391. * Blur level of the depth of field effect. (Higher blur will effect performance)
  62392. */
  62393. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  62394. /**
  62395. * If the anti aliasing is enabled.
  62396. */
  62397. fxaaEnabled: boolean;
  62398. private _samples;
  62399. /**
  62400. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  62401. */
  62402. samples: number;
  62403. /**
  62404. * If image processing is enabled.
  62405. */
  62406. imageProcessingEnabled: boolean;
  62407. /**
  62408. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  62409. */
  62410. glowLayerEnabled: boolean;
  62411. /**
  62412. * Gets the glow layer (or null if not defined)
  62413. */
  62414. readonly glowLayer: Nullable<GlowLayer>;
  62415. /**
  62416. * Enable or disable the chromaticAberration process from the pipeline
  62417. */
  62418. chromaticAberrationEnabled: boolean;
  62419. /**
  62420. * Enable or disable the grain process from the pipeline
  62421. */
  62422. grainEnabled: boolean;
  62423. /**
  62424. * @constructor
  62425. * @param name - The rendering pipeline name (default: "")
  62426. * @param hdr - If high dynamic range textures should be used (default: true)
  62427. * @param scene - The scene linked to this pipeline (default: the last created scene)
  62428. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  62429. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  62430. */
  62431. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  62432. /**
  62433. * Get the class name
  62434. * @returns "DefaultRenderingPipeline"
  62435. */
  62436. getClassName(): string;
  62437. /**
  62438. * Force the compilation of the entire pipeline.
  62439. */
  62440. prepare(): void;
  62441. private _hasCleared;
  62442. private _prevPostProcess;
  62443. private _prevPrevPostProcess;
  62444. private _setAutoClearAndTextureSharing;
  62445. private _depthOfFieldSceneObserver;
  62446. private _buildPipeline;
  62447. private _disposePostProcesses;
  62448. /**
  62449. * Adds a camera to the pipeline
  62450. * @param camera the camera to be added
  62451. */
  62452. addCamera(camera: Camera): void;
  62453. /**
  62454. * Removes a camera from the pipeline
  62455. * @param camera the camera to remove
  62456. */
  62457. removeCamera(camera: Camera): void;
  62458. /**
  62459. * Dispose of the pipeline and stop all post processes
  62460. */
  62461. dispose(): void;
  62462. /**
  62463. * Serialize the rendering pipeline (Used when exporting)
  62464. * @returns the serialized object
  62465. */
  62466. serialize(): any;
  62467. /**
  62468. * Parse the serialized pipeline
  62469. * @param source Source pipeline.
  62470. * @param scene The scene to load the pipeline to.
  62471. * @param rootUrl The URL of the serialized pipeline.
  62472. * @returns An instantiated pipeline from the serialized object.
  62473. */
  62474. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  62475. }
  62476. }
  62477. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  62478. /** @hidden */
  62479. export var lensHighlightsPixelShader: {
  62480. name: string;
  62481. shader: string;
  62482. };
  62483. }
  62484. declare module "babylonjs/Shaders/depthOfField.fragment" {
  62485. /** @hidden */
  62486. export var depthOfFieldPixelShader: {
  62487. name: string;
  62488. shader: string;
  62489. };
  62490. }
  62491. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  62492. import { Camera } from "babylonjs/Cameras/camera";
  62493. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62494. import { Scene } from "babylonjs/scene";
  62495. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62496. import "babylonjs/Shaders/chromaticAberration.fragment";
  62497. import "babylonjs/Shaders/lensHighlights.fragment";
  62498. import "babylonjs/Shaders/depthOfField.fragment";
  62499. /**
  62500. * BABYLON.JS Chromatic Aberration GLSL Shader
  62501. * Author: Olivier Guyot
  62502. * Separates very slightly R, G and B colors on the edges of the screen
  62503. * Inspired by Francois Tarlier & Martins Upitis
  62504. */
  62505. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  62506. /**
  62507. * @ignore
  62508. * The chromatic aberration PostProcess id in the pipeline
  62509. */
  62510. LensChromaticAberrationEffect: string;
  62511. /**
  62512. * @ignore
  62513. * The highlights enhancing PostProcess id in the pipeline
  62514. */
  62515. HighlightsEnhancingEffect: string;
  62516. /**
  62517. * @ignore
  62518. * The depth-of-field PostProcess id in the pipeline
  62519. */
  62520. LensDepthOfFieldEffect: string;
  62521. private _scene;
  62522. private _depthTexture;
  62523. private _grainTexture;
  62524. private _chromaticAberrationPostProcess;
  62525. private _highlightsPostProcess;
  62526. private _depthOfFieldPostProcess;
  62527. private _edgeBlur;
  62528. private _grainAmount;
  62529. private _chromaticAberration;
  62530. private _distortion;
  62531. private _highlightsGain;
  62532. private _highlightsThreshold;
  62533. private _dofDistance;
  62534. private _dofAperture;
  62535. private _dofDarken;
  62536. private _dofPentagon;
  62537. private _blurNoise;
  62538. /**
  62539. * @constructor
  62540. *
  62541. * Effect parameters are as follow:
  62542. * {
  62543. * chromatic_aberration: number; // from 0 to x (1 for realism)
  62544. * edge_blur: number; // from 0 to x (1 for realism)
  62545. * distortion: number; // from 0 to x (1 for realism)
  62546. * grain_amount: number; // from 0 to 1
  62547. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  62548. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  62549. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  62550. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  62551. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  62552. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  62553. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  62554. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  62555. * }
  62556. * Note: if an effect parameter is unset, effect is disabled
  62557. *
  62558. * @param name The rendering pipeline name
  62559. * @param parameters - An object containing all parameters (see above)
  62560. * @param scene The scene linked to this pipeline
  62561. * @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)
  62562. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62563. */
  62564. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  62565. /**
  62566. * Get the class name
  62567. * @returns "LensRenderingPipeline"
  62568. */
  62569. getClassName(): string;
  62570. /**
  62571. * Gets associated scene
  62572. */
  62573. readonly scene: Scene;
  62574. /**
  62575. * Gets or sets the edge blur
  62576. */
  62577. edgeBlur: number;
  62578. /**
  62579. * Gets or sets the grain amount
  62580. */
  62581. grainAmount: number;
  62582. /**
  62583. * Gets or sets the chromatic aberration amount
  62584. */
  62585. chromaticAberration: number;
  62586. /**
  62587. * Gets or sets the depth of field aperture
  62588. */
  62589. dofAperture: number;
  62590. /**
  62591. * Gets or sets the edge distortion
  62592. */
  62593. edgeDistortion: number;
  62594. /**
  62595. * Gets or sets the depth of field distortion
  62596. */
  62597. dofDistortion: number;
  62598. /**
  62599. * Gets or sets the darken out of focus amount
  62600. */
  62601. darkenOutOfFocus: number;
  62602. /**
  62603. * Gets or sets a boolean indicating if blur noise is enabled
  62604. */
  62605. blurNoise: boolean;
  62606. /**
  62607. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  62608. */
  62609. pentagonBokeh: boolean;
  62610. /**
  62611. * Gets or sets the highlight grain amount
  62612. */
  62613. highlightsGain: number;
  62614. /**
  62615. * Gets or sets the highlight threshold
  62616. */
  62617. highlightsThreshold: number;
  62618. /**
  62619. * Sets the amount of blur at the edges
  62620. * @param amount blur amount
  62621. */
  62622. setEdgeBlur(amount: number): void;
  62623. /**
  62624. * Sets edge blur to 0
  62625. */
  62626. disableEdgeBlur(): void;
  62627. /**
  62628. * Sets the amout of grain
  62629. * @param amount Amount of grain
  62630. */
  62631. setGrainAmount(amount: number): void;
  62632. /**
  62633. * Set grain amount to 0
  62634. */
  62635. disableGrain(): void;
  62636. /**
  62637. * Sets the chromatic aberration amount
  62638. * @param amount amount of chromatic aberration
  62639. */
  62640. setChromaticAberration(amount: number): void;
  62641. /**
  62642. * Sets chromatic aberration amount to 0
  62643. */
  62644. disableChromaticAberration(): void;
  62645. /**
  62646. * Sets the EdgeDistortion amount
  62647. * @param amount amount of EdgeDistortion
  62648. */
  62649. setEdgeDistortion(amount: number): void;
  62650. /**
  62651. * Sets edge distortion to 0
  62652. */
  62653. disableEdgeDistortion(): void;
  62654. /**
  62655. * Sets the FocusDistance amount
  62656. * @param amount amount of FocusDistance
  62657. */
  62658. setFocusDistance(amount: number): void;
  62659. /**
  62660. * Disables depth of field
  62661. */
  62662. disableDepthOfField(): void;
  62663. /**
  62664. * Sets the Aperture amount
  62665. * @param amount amount of Aperture
  62666. */
  62667. setAperture(amount: number): void;
  62668. /**
  62669. * Sets the DarkenOutOfFocus amount
  62670. * @param amount amount of DarkenOutOfFocus
  62671. */
  62672. setDarkenOutOfFocus(amount: number): void;
  62673. private _pentagonBokehIsEnabled;
  62674. /**
  62675. * Creates a pentagon bokeh effect
  62676. */
  62677. enablePentagonBokeh(): void;
  62678. /**
  62679. * Disables the pentagon bokeh effect
  62680. */
  62681. disablePentagonBokeh(): void;
  62682. /**
  62683. * Enables noise blur
  62684. */
  62685. enableNoiseBlur(): void;
  62686. /**
  62687. * Disables noise blur
  62688. */
  62689. disableNoiseBlur(): void;
  62690. /**
  62691. * Sets the HighlightsGain amount
  62692. * @param amount amount of HighlightsGain
  62693. */
  62694. setHighlightsGain(amount: number): void;
  62695. /**
  62696. * Sets the HighlightsThreshold amount
  62697. * @param amount amount of HighlightsThreshold
  62698. */
  62699. setHighlightsThreshold(amount: number): void;
  62700. /**
  62701. * Disables highlights
  62702. */
  62703. disableHighlights(): void;
  62704. /**
  62705. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  62706. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  62707. */
  62708. dispose(disableDepthRender?: boolean): void;
  62709. private _createChromaticAberrationPostProcess;
  62710. private _createHighlightsPostProcess;
  62711. private _createDepthOfFieldPostProcess;
  62712. private _createGrainTexture;
  62713. }
  62714. }
  62715. declare module "babylonjs/Shaders/ssao2.fragment" {
  62716. /** @hidden */
  62717. export var ssao2PixelShader: {
  62718. name: string;
  62719. shader: string;
  62720. };
  62721. }
  62722. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  62723. /** @hidden */
  62724. export var ssaoCombinePixelShader: {
  62725. name: string;
  62726. shader: string;
  62727. };
  62728. }
  62729. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  62730. import { Camera } from "babylonjs/Cameras/camera";
  62731. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62732. import { Scene } from "babylonjs/scene";
  62733. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62734. import "babylonjs/Shaders/ssao2.fragment";
  62735. import "babylonjs/Shaders/ssaoCombine.fragment";
  62736. /**
  62737. * Render pipeline to produce ssao effect
  62738. */
  62739. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  62740. /**
  62741. * @ignore
  62742. * The PassPostProcess id in the pipeline that contains the original scene color
  62743. */
  62744. SSAOOriginalSceneColorEffect: string;
  62745. /**
  62746. * @ignore
  62747. * The SSAO PostProcess id in the pipeline
  62748. */
  62749. SSAORenderEffect: string;
  62750. /**
  62751. * @ignore
  62752. * The horizontal blur PostProcess id in the pipeline
  62753. */
  62754. SSAOBlurHRenderEffect: string;
  62755. /**
  62756. * @ignore
  62757. * The vertical blur PostProcess id in the pipeline
  62758. */
  62759. SSAOBlurVRenderEffect: string;
  62760. /**
  62761. * @ignore
  62762. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  62763. */
  62764. SSAOCombineRenderEffect: string;
  62765. /**
  62766. * The output strength of the SSAO post-process. Default value is 1.0.
  62767. */
  62768. totalStrength: number;
  62769. /**
  62770. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  62771. */
  62772. maxZ: number;
  62773. /**
  62774. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  62775. */
  62776. minZAspect: number;
  62777. private _samples;
  62778. /**
  62779. * Number of samples used for the SSAO calculations. Default value is 8
  62780. */
  62781. samples: number;
  62782. private _textureSamples;
  62783. /**
  62784. * Number of samples to use for antialiasing
  62785. */
  62786. textureSamples: number;
  62787. /**
  62788. * Ratio object used for SSAO ratio and blur ratio
  62789. */
  62790. private _ratio;
  62791. /**
  62792. * Dynamically generated sphere sampler.
  62793. */
  62794. private _sampleSphere;
  62795. /**
  62796. * Blur filter offsets
  62797. */
  62798. private _samplerOffsets;
  62799. private _expensiveBlur;
  62800. /**
  62801. * If bilateral blur should be used
  62802. */
  62803. expensiveBlur: boolean;
  62804. /**
  62805. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  62806. */
  62807. radius: number;
  62808. /**
  62809. * The base color of the SSAO post-process
  62810. * The final result is "base + ssao" between [0, 1]
  62811. */
  62812. base: number;
  62813. /**
  62814. * Support test.
  62815. */
  62816. static readonly IsSupported: boolean;
  62817. private _scene;
  62818. private _depthTexture;
  62819. private _normalTexture;
  62820. private _randomTexture;
  62821. private _originalColorPostProcess;
  62822. private _ssaoPostProcess;
  62823. private _blurHPostProcess;
  62824. private _blurVPostProcess;
  62825. private _ssaoCombinePostProcess;
  62826. private _firstUpdate;
  62827. /**
  62828. * Gets active scene
  62829. */
  62830. readonly scene: Scene;
  62831. /**
  62832. * @constructor
  62833. * @param name The rendering pipeline name
  62834. * @param scene The scene linked to this pipeline
  62835. * @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 }
  62836. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62837. */
  62838. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  62839. /**
  62840. * Get the class name
  62841. * @returns "SSAO2RenderingPipeline"
  62842. */
  62843. getClassName(): string;
  62844. /**
  62845. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  62846. */
  62847. dispose(disableGeometryBufferRenderer?: boolean): void;
  62848. private _createBlurPostProcess;
  62849. /** @hidden */
  62850. _rebuild(): void;
  62851. private _bits;
  62852. private _radicalInverse_VdC;
  62853. private _hammersley;
  62854. private _hemisphereSample_uniform;
  62855. private _generateHemisphere;
  62856. private _createSSAOPostProcess;
  62857. private _createSSAOCombinePostProcess;
  62858. private _createRandomTexture;
  62859. /**
  62860. * Serialize the rendering pipeline (Used when exporting)
  62861. * @returns the serialized object
  62862. */
  62863. serialize(): any;
  62864. /**
  62865. * Parse the serialized pipeline
  62866. * @param source Source pipeline.
  62867. * @param scene The scene to load the pipeline to.
  62868. * @param rootUrl The URL of the serialized pipeline.
  62869. * @returns An instantiated pipeline from the serialized object.
  62870. */
  62871. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  62872. }
  62873. }
  62874. declare module "babylonjs/Shaders/ssao.fragment" {
  62875. /** @hidden */
  62876. export var ssaoPixelShader: {
  62877. name: string;
  62878. shader: string;
  62879. };
  62880. }
  62881. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  62882. import { Camera } from "babylonjs/Cameras/camera";
  62883. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62884. import { Scene } from "babylonjs/scene";
  62885. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62886. import "babylonjs/Shaders/ssao.fragment";
  62887. import "babylonjs/Shaders/ssaoCombine.fragment";
  62888. /**
  62889. * Render pipeline to produce ssao effect
  62890. */
  62891. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  62892. /**
  62893. * @ignore
  62894. * The PassPostProcess id in the pipeline that contains the original scene color
  62895. */
  62896. SSAOOriginalSceneColorEffect: string;
  62897. /**
  62898. * @ignore
  62899. * The SSAO PostProcess id in the pipeline
  62900. */
  62901. SSAORenderEffect: string;
  62902. /**
  62903. * @ignore
  62904. * The horizontal blur PostProcess id in the pipeline
  62905. */
  62906. SSAOBlurHRenderEffect: string;
  62907. /**
  62908. * @ignore
  62909. * The vertical blur PostProcess id in the pipeline
  62910. */
  62911. SSAOBlurVRenderEffect: string;
  62912. /**
  62913. * @ignore
  62914. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  62915. */
  62916. SSAOCombineRenderEffect: string;
  62917. /**
  62918. * The output strength of the SSAO post-process. Default value is 1.0.
  62919. */
  62920. totalStrength: number;
  62921. /**
  62922. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  62923. */
  62924. radius: number;
  62925. /**
  62926. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  62927. * Must not be equal to fallOff and superior to fallOff.
  62928. * Default value is 0.0075
  62929. */
  62930. area: number;
  62931. /**
  62932. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  62933. * Must not be equal to area and inferior to area.
  62934. * Default value is 0.000001
  62935. */
  62936. fallOff: number;
  62937. /**
  62938. * The base color of the SSAO post-process
  62939. * The final result is "base + ssao" between [0, 1]
  62940. */
  62941. base: number;
  62942. private _scene;
  62943. private _depthTexture;
  62944. private _randomTexture;
  62945. private _originalColorPostProcess;
  62946. private _ssaoPostProcess;
  62947. private _blurHPostProcess;
  62948. private _blurVPostProcess;
  62949. private _ssaoCombinePostProcess;
  62950. private _firstUpdate;
  62951. /**
  62952. * Gets active scene
  62953. */
  62954. readonly scene: Scene;
  62955. /**
  62956. * @constructor
  62957. * @param name - The rendering pipeline name
  62958. * @param scene - The scene linked to this pipeline
  62959. * @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 }
  62960. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  62961. */
  62962. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  62963. /**
  62964. * Get the class name
  62965. * @returns "SSAORenderingPipeline"
  62966. */
  62967. getClassName(): string;
  62968. /**
  62969. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  62970. */
  62971. dispose(disableDepthRender?: boolean): void;
  62972. private _createBlurPostProcess;
  62973. /** @hidden */
  62974. _rebuild(): void;
  62975. private _createSSAOPostProcess;
  62976. private _createSSAOCombinePostProcess;
  62977. private _createRandomTexture;
  62978. }
  62979. }
  62980. declare module "babylonjs/Shaders/standard.fragment" {
  62981. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  62982. /** @hidden */
  62983. export var standardPixelShader: {
  62984. name: string;
  62985. shader: string;
  62986. };
  62987. }
  62988. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  62989. import { Nullable } from "babylonjs/types";
  62990. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  62991. import { Camera } from "babylonjs/Cameras/camera";
  62992. import { Texture } from "babylonjs/Materials/Textures/texture";
  62993. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62994. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62995. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  62996. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  62997. import { IDisposable } from "babylonjs/scene";
  62998. import { SpotLight } from "babylonjs/Lights/spotLight";
  62999. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  63000. import { Scene } from "babylonjs/scene";
  63001. import { Animation } from "babylonjs/Animations/animation";
  63002. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63003. import "babylonjs/Shaders/standard.fragment";
  63004. /**
  63005. * Standard rendering pipeline
  63006. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  63007. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  63008. */
  63009. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  63010. /**
  63011. * Public members
  63012. */
  63013. /**
  63014. * Post-process which contains the original scene color before the pipeline applies all the effects
  63015. */
  63016. originalPostProcess: Nullable<PostProcess>;
  63017. /**
  63018. * Post-process used to down scale an image x4
  63019. */
  63020. downSampleX4PostProcess: Nullable<PostProcess>;
  63021. /**
  63022. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  63023. */
  63024. brightPassPostProcess: Nullable<PostProcess>;
  63025. /**
  63026. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  63027. */
  63028. blurHPostProcesses: PostProcess[];
  63029. /**
  63030. * Post-process array storing all the vertical blur post-processes used by the pipeline
  63031. */
  63032. blurVPostProcesses: PostProcess[];
  63033. /**
  63034. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  63035. */
  63036. textureAdderPostProcess: Nullable<PostProcess>;
  63037. /**
  63038. * Post-process used to create volumetric lighting effect
  63039. */
  63040. volumetricLightPostProcess: Nullable<PostProcess>;
  63041. /**
  63042. * Post-process used to smooth the previous volumetric light post-process on the X axis
  63043. */
  63044. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  63045. /**
  63046. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  63047. */
  63048. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  63049. /**
  63050. * Post-process used to merge the volumetric light effect and the real scene color
  63051. */
  63052. volumetricLightMergePostProces: Nullable<PostProcess>;
  63053. /**
  63054. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  63055. */
  63056. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  63057. /**
  63058. * Base post-process used to calculate the average luminance of the final image for HDR
  63059. */
  63060. luminancePostProcess: Nullable<PostProcess>;
  63061. /**
  63062. * Post-processes used to create down sample post-processes in order to get
  63063. * the average luminance of the final image for HDR
  63064. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  63065. */
  63066. luminanceDownSamplePostProcesses: PostProcess[];
  63067. /**
  63068. * Post-process used to create a HDR effect (light adaptation)
  63069. */
  63070. hdrPostProcess: Nullable<PostProcess>;
  63071. /**
  63072. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  63073. */
  63074. textureAdderFinalPostProcess: Nullable<PostProcess>;
  63075. /**
  63076. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  63077. */
  63078. lensFlareFinalPostProcess: Nullable<PostProcess>;
  63079. /**
  63080. * Post-process used to merge the final HDR post-process and the real scene color
  63081. */
  63082. hdrFinalPostProcess: Nullable<PostProcess>;
  63083. /**
  63084. * Post-process used to create a lens flare effect
  63085. */
  63086. lensFlarePostProcess: Nullable<PostProcess>;
  63087. /**
  63088. * Post-process that merges the result of the lens flare post-process and the real scene color
  63089. */
  63090. lensFlareComposePostProcess: Nullable<PostProcess>;
  63091. /**
  63092. * Post-process used to create a motion blur effect
  63093. */
  63094. motionBlurPostProcess: Nullable<PostProcess>;
  63095. /**
  63096. * Post-process used to create a depth of field effect
  63097. */
  63098. depthOfFieldPostProcess: Nullable<PostProcess>;
  63099. /**
  63100. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  63101. */
  63102. fxaaPostProcess: Nullable<FxaaPostProcess>;
  63103. /**
  63104. * Represents the brightness threshold in order to configure the illuminated surfaces
  63105. */
  63106. brightThreshold: number;
  63107. /**
  63108. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  63109. */
  63110. blurWidth: number;
  63111. /**
  63112. * Sets if the blur for highlighted surfaces must be only horizontal
  63113. */
  63114. horizontalBlur: boolean;
  63115. /**
  63116. * Gets the overall exposure used by the pipeline
  63117. */
  63118. /**
  63119. * Sets the overall exposure used by the pipeline
  63120. */
  63121. exposure: number;
  63122. /**
  63123. * Texture used typically to simulate "dirty" on camera lens
  63124. */
  63125. lensTexture: Nullable<Texture>;
  63126. /**
  63127. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  63128. */
  63129. volumetricLightCoefficient: number;
  63130. /**
  63131. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  63132. */
  63133. volumetricLightPower: number;
  63134. /**
  63135. * Used the set the blur intensity to smooth the volumetric lights
  63136. */
  63137. volumetricLightBlurScale: number;
  63138. /**
  63139. * Light (spot or directional) used to generate the volumetric lights rays
  63140. * The source light must have a shadow generate so the pipeline can get its
  63141. * depth map
  63142. */
  63143. sourceLight: Nullable<SpotLight | DirectionalLight>;
  63144. /**
  63145. * For eye adaptation, represents the minimum luminance the eye can see
  63146. */
  63147. hdrMinimumLuminance: number;
  63148. /**
  63149. * For eye adaptation, represents the decrease luminance speed
  63150. */
  63151. hdrDecreaseRate: number;
  63152. /**
  63153. * For eye adaptation, represents the increase luminance speed
  63154. */
  63155. hdrIncreaseRate: number;
  63156. /**
  63157. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  63158. */
  63159. /**
  63160. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  63161. */
  63162. hdrAutoExposure: boolean;
  63163. /**
  63164. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  63165. */
  63166. lensColorTexture: Nullable<Texture>;
  63167. /**
  63168. * The overall strengh for the lens flare effect
  63169. */
  63170. lensFlareStrength: number;
  63171. /**
  63172. * Dispersion coefficient for lens flare ghosts
  63173. */
  63174. lensFlareGhostDispersal: number;
  63175. /**
  63176. * Main lens flare halo width
  63177. */
  63178. lensFlareHaloWidth: number;
  63179. /**
  63180. * Based on the lens distortion effect, defines how much the lens flare result
  63181. * is distorted
  63182. */
  63183. lensFlareDistortionStrength: number;
  63184. /**
  63185. * Configures the blur intensity used for for lens flare (halo)
  63186. */
  63187. lensFlareBlurWidth: number;
  63188. /**
  63189. * Lens star texture must be used to simulate rays on the flares and is available
  63190. * in the documentation
  63191. */
  63192. lensStarTexture: Nullable<Texture>;
  63193. /**
  63194. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  63195. * flare effect by taking account of the dirt texture
  63196. */
  63197. lensFlareDirtTexture: Nullable<Texture>;
  63198. /**
  63199. * Represents the focal length for the depth of field effect
  63200. */
  63201. depthOfFieldDistance: number;
  63202. /**
  63203. * Represents the blur intensity for the blurred part of the depth of field effect
  63204. */
  63205. depthOfFieldBlurWidth: number;
  63206. /**
  63207. * Gets how much the image is blurred by the movement while using the motion blur post-process
  63208. */
  63209. /**
  63210. * Sets how much the image is blurred by the movement while using the motion blur post-process
  63211. */
  63212. motionStrength: number;
  63213. /**
  63214. * Gets wether or not the motion blur post-process is object based or screen based.
  63215. */
  63216. /**
  63217. * Sets wether or not the motion blur post-process should be object based or screen based
  63218. */
  63219. objectBasedMotionBlur: boolean;
  63220. /**
  63221. * List of animations for the pipeline (IAnimatable implementation)
  63222. */
  63223. animations: Animation[];
  63224. /**
  63225. * Private members
  63226. */
  63227. private _scene;
  63228. private _currentDepthOfFieldSource;
  63229. private _basePostProcess;
  63230. private _fixedExposure;
  63231. private _currentExposure;
  63232. private _hdrAutoExposure;
  63233. private _hdrCurrentLuminance;
  63234. private _motionStrength;
  63235. private _isObjectBasedMotionBlur;
  63236. private _floatTextureType;
  63237. private _camerasToBeAttached;
  63238. private _ratio;
  63239. private _bloomEnabled;
  63240. private _depthOfFieldEnabled;
  63241. private _vlsEnabled;
  63242. private _lensFlareEnabled;
  63243. private _hdrEnabled;
  63244. private _motionBlurEnabled;
  63245. private _fxaaEnabled;
  63246. private _motionBlurSamples;
  63247. private _volumetricLightStepsCount;
  63248. private _samples;
  63249. /**
  63250. * @ignore
  63251. * Specifies if the bloom pipeline is enabled
  63252. */
  63253. BloomEnabled: boolean;
  63254. /**
  63255. * @ignore
  63256. * Specifies if the depth of field pipeline is enabed
  63257. */
  63258. DepthOfFieldEnabled: boolean;
  63259. /**
  63260. * @ignore
  63261. * Specifies if the lens flare pipeline is enabed
  63262. */
  63263. LensFlareEnabled: boolean;
  63264. /**
  63265. * @ignore
  63266. * Specifies if the HDR pipeline is enabled
  63267. */
  63268. HDREnabled: boolean;
  63269. /**
  63270. * @ignore
  63271. * Specifies if the volumetric lights scattering effect is enabled
  63272. */
  63273. VLSEnabled: boolean;
  63274. /**
  63275. * @ignore
  63276. * Specifies if the motion blur effect is enabled
  63277. */
  63278. MotionBlurEnabled: boolean;
  63279. /**
  63280. * Specifies if anti-aliasing is enabled
  63281. */
  63282. fxaaEnabled: boolean;
  63283. /**
  63284. * Specifies the number of steps used to calculate the volumetric lights
  63285. * Typically in interval [50, 200]
  63286. */
  63287. volumetricLightStepsCount: number;
  63288. /**
  63289. * Specifies the number of samples used for the motion blur effect
  63290. * Typically in interval [16, 64]
  63291. */
  63292. motionBlurSamples: number;
  63293. /**
  63294. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  63295. */
  63296. samples: number;
  63297. /**
  63298. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  63299. * @constructor
  63300. * @param name The rendering pipeline name
  63301. * @param scene The scene linked to this pipeline
  63302. * @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)
  63303. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  63304. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63305. */
  63306. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  63307. private _buildPipeline;
  63308. private _createDownSampleX4PostProcess;
  63309. private _createBrightPassPostProcess;
  63310. private _createBlurPostProcesses;
  63311. private _createTextureAdderPostProcess;
  63312. private _createVolumetricLightPostProcess;
  63313. private _createLuminancePostProcesses;
  63314. private _createHdrPostProcess;
  63315. private _createLensFlarePostProcess;
  63316. private _createDepthOfFieldPostProcess;
  63317. private _createMotionBlurPostProcess;
  63318. private _getDepthTexture;
  63319. private _disposePostProcesses;
  63320. /**
  63321. * Dispose of the pipeline and stop all post processes
  63322. */
  63323. dispose(): void;
  63324. /**
  63325. * Serialize the rendering pipeline (Used when exporting)
  63326. * @returns the serialized object
  63327. */
  63328. serialize(): any;
  63329. /**
  63330. * Parse the serialized pipeline
  63331. * @param source Source pipeline.
  63332. * @param scene The scene to load the pipeline to.
  63333. * @param rootUrl The URL of the serialized pipeline.
  63334. * @returns An instantiated pipeline from the serialized object.
  63335. */
  63336. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  63337. /**
  63338. * Luminance steps
  63339. */
  63340. static LuminanceSteps: number;
  63341. }
  63342. }
  63343. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  63344. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  63345. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  63346. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  63347. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  63348. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  63349. }
  63350. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  63351. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  63352. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63353. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63354. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  63355. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63356. }
  63357. declare module "babylonjs/Shaders/tonemap.fragment" {
  63358. /** @hidden */
  63359. export var tonemapPixelShader: {
  63360. name: string;
  63361. shader: string;
  63362. };
  63363. }
  63364. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  63365. import { Camera } from "babylonjs/Cameras/camera";
  63366. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63367. import "babylonjs/Shaders/tonemap.fragment";
  63368. import { Engine } from "babylonjs/Engines/engine";
  63369. /** Defines operator used for tonemapping */
  63370. export enum TonemappingOperator {
  63371. /** Hable */
  63372. Hable = 0,
  63373. /** Reinhard */
  63374. Reinhard = 1,
  63375. /** HejiDawson */
  63376. HejiDawson = 2,
  63377. /** Photographic */
  63378. Photographic = 3
  63379. }
  63380. /**
  63381. * Defines a post process to apply tone mapping
  63382. */
  63383. export class TonemapPostProcess extends PostProcess {
  63384. private _operator;
  63385. /** Defines the required exposure adjustement */
  63386. exposureAdjustment: number;
  63387. /**
  63388. * Creates a new TonemapPostProcess
  63389. * @param name defines the name of the postprocess
  63390. * @param _operator defines the operator to use
  63391. * @param exposureAdjustment defines the required exposure adjustement
  63392. * @param camera defines the camera to use (can be null)
  63393. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  63394. * @param engine defines the hosting engine (can be ignore if camera is set)
  63395. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63396. */
  63397. constructor(name: string, _operator: TonemappingOperator,
  63398. /** Defines the required exposure adjustement */
  63399. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  63400. }
  63401. }
  63402. declare module "babylonjs/Shaders/depth.vertex" {
  63403. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63404. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63405. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63406. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63407. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63408. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63409. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63410. /** @hidden */
  63411. export var depthVertexShader: {
  63412. name: string;
  63413. shader: string;
  63414. };
  63415. }
  63416. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  63417. /** @hidden */
  63418. export var volumetricLightScatteringPixelShader: {
  63419. name: string;
  63420. shader: string;
  63421. };
  63422. }
  63423. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  63424. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63425. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63426. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63427. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63428. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63429. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63430. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63431. /** @hidden */
  63432. export var volumetricLightScatteringPassVertexShader: {
  63433. name: string;
  63434. shader: string;
  63435. };
  63436. }
  63437. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  63438. /** @hidden */
  63439. export var volumetricLightScatteringPassPixelShader: {
  63440. name: string;
  63441. shader: string;
  63442. };
  63443. }
  63444. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  63445. import { Vector3 } from "babylonjs/Maths/math.vector";
  63446. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63447. import { Mesh } from "babylonjs/Meshes/mesh";
  63448. import { Camera } from "babylonjs/Cameras/camera";
  63449. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63450. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63451. import { Scene } from "babylonjs/scene";
  63452. import "babylonjs/Meshes/Builders/planeBuilder";
  63453. import "babylonjs/Shaders/depth.vertex";
  63454. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  63455. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  63456. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  63457. import { Engine } from "babylonjs/Engines/engine";
  63458. /**
  63459. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  63460. */
  63461. export class VolumetricLightScatteringPostProcess extends PostProcess {
  63462. private _volumetricLightScatteringPass;
  63463. private _volumetricLightScatteringRTT;
  63464. private _viewPort;
  63465. private _screenCoordinates;
  63466. private _cachedDefines;
  63467. /**
  63468. * If not undefined, the mesh position is computed from the attached node position
  63469. */
  63470. attachedNode: {
  63471. position: Vector3;
  63472. };
  63473. /**
  63474. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  63475. */
  63476. customMeshPosition: Vector3;
  63477. /**
  63478. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  63479. */
  63480. useCustomMeshPosition: boolean;
  63481. /**
  63482. * If the post-process should inverse the light scattering direction
  63483. */
  63484. invert: boolean;
  63485. /**
  63486. * The internal mesh used by the post-process
  63487. */
  63488. mesh: Mesh;
  63489. /**
  63490. * @hidden
  63491. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  63492. */
  63493. useDiffuseColor: boolean;
  63494. /**
  63495. * Array containing the excluded meshes not rendered in the internal pass
  63496. */
  63497. excludedMeshes: AbstractMesh[];
  63498. /**
  63499. * Controls the overall intensity of the post-process
  63500. */
  63501. exposure: number;
  63502. /**
  63503. * Dissipates each sample's contribution in range [0, 1]
  63504. */
  63505. decay: number;
  63506. /**
  63507. * Controls the overall intensity of each sample
  63508. */
  63509. weight: number;
  63510. /**
  63511. * Controls the density of each sample
  63512. */
  63513. density: number;
  63514. /**
  63515. * @constructor
  63516. * @param name The post-process name
  63517. * @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)
  63518. * @param camera The camera that the post-process will be attached to
  63519. * @param mesh The mesh used to create the light scattering
  63520. * @param samples The post-process quality, default 100
  63521. * @param samplingModeThe post-process filtering mode
  63522. * @param engine The babylon engine
  63523. * @param reusable If the post-process is reusable
  63524. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  63525. */
  63526. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  63527. /**
  63528. * Returns the string "VolumetricLightScatteringPostProcess"
  63529. * @returns "VolumetricLightScatteringPostProcess"
  63530. */
  63531. getClassName(): string;
  63532. private _isReady;
  63533. /**
  63534. * Sets the new light position for light scattering effect
  63535. * @param position The new custom light position
  63536. */
  63537. setCustomMeshPosition(position: Vector3): void;
  63538. /**
  63539. * Returns the light position for light scattering effect
  63540. * @return Vector3 The custom light position
  63541. */
  63542. getCustomMeshPosition(): Vector3;
  63543. /**
  63544. * Disposes the internal assets and detaches the post-process from the camera
  63545. */
  63546. dispose(camera: Camera): void;
  63547. /**
  63548. * Returns the render target texture used by the post-process
  63549. * @return the render target texture used by the post-process
  63550. */
  63551. getPass(): RenderTargetTexture;
  63552. private _meshExcluded;
  63553. private _createPass;
  63554. private _updateMeshScreenCoordinates;
  63555. /**
  63556. * Creates a default mesh for the Volumeric Light Scattering post-process
  63557. * @param name The mesh name
  63558. * @param scene The scene where to create the mesh
  63559. * @return the default mesh
  63560. */
  63561. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  63562. }
  63563. }
  63564. declare module "babylonjs/PostProcesses/index" {
  63565. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  63566. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  63567. export * from "babylonjs/PostProcesses/bloomEffect";
  63568. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  63569. export * from "babylonjs/PostProcesses/blurPostProcess";
  63570. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  63571. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  63572. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  63573. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  63574. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  63575. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  63576. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  63577. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  63578. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  63579. export * from "babylonjs/PostProcesses/filterPostProcess";
  63580. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  63581. export * from "babylonjs/PostProcesses/grainPostProcess";
  63582. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  63583. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  63584. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  63585. export * from "babylonjs/PostProcesses/passPostProcess";
  63586. export * from "babylonjs/PostProcesses/postProcess";
  63587. export * from "babylonjs/PostProcesses/postProcessManager";
  63588. export * from "babylonjs/PostProcesses/refractionPostProcess";
  63589. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  63590. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  63591. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  63592. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  63593. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  63594. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  63595. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  63596. }
  63597. declare module "babylonjs/Probes/index" {
  63598. export * from "babylonjs/Probes/reflectionProbe";
  63599. }
  63600. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  63601. import { Scene } from "babylonjs/scene";
  63602. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63603. import { SmartArray } from "babylonjs/Misc/smartArray";
  63604. import { ISceneComponent } from "babylonjs/sceneComponent";
  63605. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  63606. import "babylonjs/Meshes/Builders/boxBuilder";
  63607. import "babylonjs/Shaders/color.fragment";
  63608. import "babylonjs/Shaders/color.vertex";
  63609. import { Color3 } from "babylonjs/Maths/math.color";
  63610. module "babylonjs/scene" {
  63611. interface Scene {
  63612. /** @hidden (Backing field) */
  63613. _boundingBoxRenderer: BoundingBoxRenderer;
  63614. /** @hidden (Backing field) */
  63615. _forceShowBoundingBoxes: boolean;
  63616. /**
  63617. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  63618. */
  63619. forceShowBoundingBoxes: boolean;
  63620. /**
  63621. * Gets the bounding box renderer associated with the scene
  63622. * @returns a BoundingBoxRenderer
  63623. */
  63624. getBoundingBoxRenderer(): BoundingBoxRenderer;
  63625. }
  63626. }
  63627. module "babylonjs/Meshes/abstractMesh" {
  63628. interface AbstractMesh {
  63629. /** @hidden (Backing field) */
  63630. _showBoundingBox: boolean;
  63631. /**
  63632. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  63633. */
  63634. showBoundingBox: boolean;
  63635. }
  63636. }
  63637. /**
  63638. * Component responsible of rendering the bounding box of the meshes in a scene.
  63639. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  63640. */
  63641. export class BoundingBoxRenderer implements ISceneComponent {
  63642. /**
  63643. * The component name helpfull to identify the component in the list of scene components.
  63644. */
  63645. readonly name: string;
  63646. /**
  63647. * The scene the component belongs to.
  63648. */
  63649. scene: Scene;
  63650. /**
  63651. * Color of the bounding box lines placed in front of an object
  63652. */
  63653. frontColor: Color3;
  63654. /**
  63655. * Color of the bounding box lines placed behind an object
  63656. */
  63657. backColor: Color3;
  63658. /**
  63659. * Defines if the renderer should show the back lines or not
  63660. */
  63661. showBackLines: boolean;
  63662. /**
  63663. * @hidden
  63664. */
  63665. renderList: SmartArray<BoundingBox>;
  63666. private _colorShader;
  63667. private _vertexBuffers;
  63668. private _indexBuffer;
  63669. private _fillIndexBuffer;
  63670. private _fillIndexData;
  63671. /**
  63672. * Instantiates a new bounding box renderer in a scene.
  63673. * @param scene the scene the renderer renders in
  63674. */
  63675. constructor(scene: Scene);
  63676. /**
  63677. * Registers the component in a given scene
  63678. */
  63679. register(): void;
  63680. private _evaluateSubMesh;
  63681. private _activeMesh;
  63682. private _prepareRessources;
  63683. private _createIndexBuffer;
  63684. /**
  63685. * Rebuilds the elements related to this component in case of
  63686. * context lost for instance.
  63687. */
  63688. rebuild(): void;
  63689. /**
  63690. * @hidden
  63691. */
  63692. reset(): void;
  63693. /**
  63694. * Render the bounding boxes of a specific rendering group
  63695. * @param renderingGroupId defines the rendering group to render
  63696. */
  63697. render(renderingGroupId: number): void;
  63698. /**
  63699. * In case of occlusion queries, we can render the occlusion bounding box through this method
  63700. * @param mesh Define the mesh to render the occlusion bounding box for
  63701. */
  63702. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  63703. /**
  63704. * Dispose and release the resources attached to this renderer.
  63705. */
  63706. dispose(): void;
  63707. }
  63708. }
  63709. declare module "babylonjs/Shaders/depth.fragment" {
  63710. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  63711. /** @hidden */
  63712. export var depthPixelShader: {
  63713. name: string;
  63714. shader: string;
  63715. };
  63716. }
  63717. declare module "babylonjs/Rendering/depthRenderer" {
  63718. import { Nullable } from "babylonjs/types";
  63719. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63720. import { Scene } from "babylonjs/scene";
  63721. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63722. import { Camera } from "babylonjs/Cameras/camera";
  63723. import "babylonjs/Shaders/depth.fragment";
  63724. import "babylonjs/Shaders/depth.vertex";
  63725. /**
  63726. * This represents a depth renderer in Babylon.
  63727. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  63728. */
  63729. export class DepthRenderer {
  63730. private _scene;
  63731. private _depthMap;
  63732. private _effect;
  63733. private readonly _storeNonLinearDepth;
  63734. private readonly _clearColor;
  63735. /** Get if the depth renderer is using packed depth or not */
  63736. readonly isPacked: boolean;
  63737. private _cachedDefines;
  63738. private _camera;
  63739. /**
  63740. * Specifiess that the depth renderer will only be used within
  63741. * the camera it is created for.
  63742. * This can help forcing its rendering during the camera processing.
  63743. */
  63744. useOnlyInActiveCamera: boolean;
  63745. /** @hidden */
  63746. static _SceneComponentInitialization: (scene: Scene) => void;
  63747. /**
  63748. * Instantiates a depth renderer
  63749. * @param scene The scene the renderer belongs to
  63750. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  63751. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  63752. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63753. */
  63754. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  63755. /**
  63756. * Creates the depth rendering effect and checks if the effect is ready.
  63757. * @param subMesh The submesh to be used to render the depth map of
  63758. * @param useInstances If multiple world instances should be used
  63759. * @returns if the depth renderer is ready to render the depth map
  63760. */
  63761. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63762. /**
  63763. * Gets the texture which the depth map will be written to.
  63764. * @returns The depth map texture
  63765. */
  63766. getDepthMap(): RenderTargetTexture;
  63767. /**
  63768. * Disposes of the depth renderer.
  63769. */
  63770. dispose(): void;
  63771. }
  63772. }
  63773. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  63774. import { Nullable } from "babylonjs/types";
  63775. import { Scene } from "babylonjs/scene";
  63776. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  63777. import { Camera } from "babylonjs/Cameras/camera";
  63778. import { ISceneComponent } from "babylonjs/sceneComponent";
  63779. module "babylonjs/scene" {
  63780. interface Scene {
  63781. /** @hidden (Backing field) */
  63782. _depthRenderer: {
  63783. [id: string]: DepthRenderer;
  63784. };
  63785. /**
  63786. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  63787. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  63788. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63789. * @returns the created depth renderer
  63790. */
  63791. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  63792. /**
  63793. * Disables a depth renderer for a given camera
  63794. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  63795. */
  63796. disableDepthRenderer(camera?: Nullable<Camera>): void;
  63797. }
  63798. }
  63799. /**
  63800. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  63801. * in several rendering techniques.
  63802. */
  63803. export class DepthRendererSceneComponent implements ISceneComponent {
  63804. /**
  63805. * The component name helpfull to identify the component in the list of scene components.
  63806. */
  63807. readonly name: string;
  63808. /**
  63809. * The scene the component belongs to.
  63810. */
  63811. scene: Scene;
  63812. /**
  63813. * Creates a new instance of the component for the given scene
  63814. * @param scene Defines the scene to register the component in
  63815. */
  63816. constructor(scene: Scene);
  63817. /**
  63818. * Registers the component in a given scene
  63819. */
  63820. register(): void;
  63821. /**
  63822. * Rebuilds the elements related to this component in case of
  63823. * context lost for instance.
  63824. */
  63825. rebuild(): void;
  63826. /**
  63827. * Disposes the component and the associated ressources
  63828. */
  63829. dispose(): void;
  63830. private _gatherRenderTargets;
  63831. private _gatherActiveCameraRenderTargets;
  63832. }
  63833. }
  63834. declare module "babylonjs/Shaders/outline.fragment" {
  63835. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  63836. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  63837. /** @hidden */
  63838. export var outlinePixelShader: {
  63839. name: string;
  63840. shader: string;
  63841. };
  63842. }
  63843. declare module "babylonjs/Shaders/outline.vertex" {
  63844. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63845. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63846. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63847. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63848. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  63849. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63850. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63851. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63852. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  63853. /** @hidden */
  63854. export var outlineVertexShader: {
  63855. name: string;
  63856. shader: string;
  63857. };
  63858. }
  63859. declare module "babylonjs/Rendering/outlineRenderer" {
  63860. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63861. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  63862. import { Scene } from "babylonjs/scene";
  63863. import { ISceneComponent } from "babylonjs/sceneComponent";
  63864. import "babylonjs/Shaders/outline.fragment";
  63865. import "babylonjs/Shaders/outline.vertex";
  63866. module "babylonjs/scene" {
  63867. interface Scene {
  63868. /** @hidden */
  63869. _outlineRenderer: OutlineRenderer;
  63870. /**
  63871. * Gets the outline renderer associated with the scene
  63872. * @returns a OutlineRenderer
  63873. */
  63874. getOutlineRenderer(): OutlineRenderer;
  63875. }
  63876. }
  63877. module "babylonjs/Meshes/abstractMesh" {
  63878. interface AbstractMesh {
  63879. /** @hidden (Backing field) */
  63880. _renderOutline: boolean;
  63881. /**
  63882. * Gets or sets a boolean indicating if the outline must be rendered as well
  63883. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  63884. */
  63885. renderOutline: boolean;
  63886. /** @hidden (Backing field) */
  63887. _renderOverlay: boolean;
  63888. /**
  63889. * Gets or sets a boolean indicating if the overlay must be rendered as well
  63890. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  63891. */
  63892. renderOverlay: boolean;
  63893. }
  63894. }
  63895. /**
  63896. * This class is responsible to draw bothe outline/overlay of meshes.
  63897. * It should not be used directly but through the available method on mesh.
  63898. */
  63899. export class OutlineRenderer implements ISceneComponent {
  63900. /**
  63901. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  63902. */
  63903. private static _StencilReference;
  63904. /**
  63905. * The name of the component. Each component must have a unique name.
  63906. */
  63907. name: string;
  63908. /**
  63909. * The scene the component belongs to.
  63910. */
  63911. scene: Scene;
  63912. /**
  63913. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  63914. */
  63915. zOffset: number;
  63916. private _engine;
  63917. private _effect;
  63918. private _cachedDefines;
  63919. private _savedDepthWrite;
  63920. /**
  63921. * Instantiates a new outline renderer. (There could be only one per scene).
  63922. * @param scene Defines the scene it belongs to
  63923. */
  63924. constructor(scene: Scene);
  63925. /**
  63926. * Register the component to one instance of a scene.
  63927. */
  63928. register(): void;
  63929. /**
  63930. * Rebuilds the elements related to this component in case of
  63931. * context lost for instance.
  63932. */
  63933. rebuild(): void;
  63934. /**
  63935. * Disposes the component and the associated ressources.
  63936. */
  63937. dispose(): void;
  63938. /**
  63939. * Renders the outline in the canvas.
  63940. * @param subMesh Defines the sumesh to render
  63941. * @param batch Defines the batch of meshes in case of instances
  63942. * @param useOverlay Defines if the rendering is for the overlay or the outline
  63943. */
  63944. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  63945. /**
  63946. * Returns whether or not the outline renderer is ready for a given submesh.
  63947. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  63948. * @param subMesh Defines the submesh to check readyness for
  63949. * @param useInstances Defines wheter wee are trying to render instances or not
  63950. * @returns true if ready otherwise false
  63951. */
  63952. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63953. private _beforeRenderingMesh;
  63954. private _afterRenderingMesh;
  63955. }
  63956. }
  63957. declare module "babylonjs/Rendering/index" {
  63958. export * from "babylonjs/Rendering/boundingBoxRenderer";
  63959. export * from "babylonjs/Rendering/depthRenderer";
  63960. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  63961. export * from "babylonjs/Rendering/edgesRenderer";
  63962. export * from "babylonjs/Rendering/geometryBufferRenderer";
  63963. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  63964. export * from "babylonjs/Rendering/outlineRenderer";
  63965. export * from "babylonjs/Rendering/renderingGroup";
  63966. export * from "babylonjs/Rendering/renderingManager";
  63967. export * from "babylonjs/Rendering/utilityLayerRenderer";
  63968. }
  63969. declare module "babylonjs/Sprites/spritePackedManager" {
  63970. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  63971. import { Scene } from "babylonjs/scene";
  63972. /**
  63973. * Class used to manage multiple sprites of different sizes on the same spritesheet
  63974. * @see http://doc.babylonjs.com/babylon101/sprites
  63975. */
  63976. export class SpritePackedManager extends SpriteManager {
  63977. /** defines the packed manager's name */
  63978. name: string;
  63979. /**
  63980. * Creates a new sprite manager from a packed sprite sheet
  63981. * @param name defines the manager's name
  63982. * @param imgUrl defines the sprite sheet url
  63983. * @param capacity defines the maximum allowed number of sprites
  63984. * @param scene defines the hosting scene
  63985. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  63986. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  63987. * @param samplingMode defines the smapling mode to use with spritesheet
  63988. * @param fromPacked set to true; do not alter
  63989. */
  63990. constructor(
  63991. /** defines the packed manager's name */
  63992. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  63993. }
  63994. }
  63995. declare module "babylonjs/Sprites/index" {
  63996. export * from "babylonjs/Sprites/sprite";
  63997. export * from "babylonjs/Sprites/spriteManager";
  63998. export * from "babylonjs/Sprites/spritePackedManager";
  63999. export * from "babylonjs/Sprites/spriteSceneComponent";
  64000. }
  64001. declare module "babylonjs/Misc/assetsManager" {
  64002. import { Scene } from "babylonjs/scene";
  64003. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64004. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  64005. import { Skeleton } from "babylonjs/Bones/skeleton";
  64006. import { Observable } from "babylonjs/Misc/observable";
  64007. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64008. import { Texture } from "babylonjs/Materials/Textures/texture";
  64009. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  64010. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  64011. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  64012. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  64013. /**
  64014. * Defines the list of states available for a task inside a AssetsManager
  64015. */
  64016. export enum AssetTaskState {
  64017. /**
  64018. * Initialization
  64019. */
  64020. INIT = 0,
  64021. /**
  64022. * Running
  64023. */
  64024. RUNNING = 1,
  64025. /**
  64026. * Done
  64027. */
  64028. DONE = 2,
  64029. /**
  64030. * Error
  64031. */
  64032. ERROR = 3
  64033. }
  64034. /**
  64035. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  64036. */
  64037. export abstract class AbstractAssetTask {
  64038. /**
  64039. * Task name
  64040. */ name: string;
  64041. /**
  64042. * Callback called when the task is successful
  64043. */
  64044. onSuccess: (task: any) => void;
  64045. /**
  64046. * Callback called when the task is not successful
  64047. */
  64048. onError: (task: any, message?: string, exception?: any) => void;
  64049. /**
  64050. * Creates a new AssetsManager
  64051. * @param name defines the name of the task
  64052. */
  64053. constructor(
  64054. /**
  64055. * Task name
  64056. */ name: string);
  64057. private _isCompleted;
  64058. private _taskState;
  64059. private _errorObject;
  64060. /**
  64061. * Get if the task is completed
  64062. */
  64063. readonly isCompleted: boolean;
  64064. /**
  64065. * Gets the current state of the task
  64066. */
  64067. readonly taskState: AssetTaskState;
  64068. /**
  64069. * Gets the current error object (if task is in error)
  64070. */
  64071. readonly errorObject: {
  64072. message?: string;
  64073. exception?: any;
  64074. };
  64075. /**
  64076. * Internal only
  64077. * @hidden
  64078. */
  64079. _setErrorObject(message?: string, exception?: any): void;
  64080. /**
  64081. * Execute the current task
  64082. * @param scene defines the scene where you want your assets to be loaded
  64083. * @param onSuccess is a callback called when the task is successfully executed
  64084. * @param onError is a callback called if an error occurs
  64085. */
  64086. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64087. /**
  64088. * Execute the current task
  64089. * @param scene defines the scene where you want your assets to be loaded
  64090. * @param onSuccess is a callback called when the task is successfully executed
  64091. * @param onError is a callback called if an error occurs
  64092. */
  64093. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64094. /**
  64095. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  64096. * This can be used with failed tasks that have the reason for failure fixed.
  64097. */
  64098. reset(): void;
  64099. private onErrorCallback;
  64100. private onDoneCallback;
  64101. }
  64102. /**
  64103. * Define the interface used by progress events raised during assets loading
  64104. */
  64105. export interface IAssetsProgressEvent {
  64106. /**
  64107. * Defines the number of remaining tasks to process
  64108. */
  64109. remainingCount: number;
  64110. /**
  64111. * Defines the total number of tasks
  64112. */
  64113. totalCount: number;
  64114. /**
  64115. * Defines the task that was just processed
  64116. */
  64117. task: AbstractAssetTask;
  64118. }
  64119. /**
  64120. * Class used to share progress information about assets loading
  64121. */
  64122. export class AssetsProgressEvent implements IAssetsProgressEvent {
  64123. /**
  64124. * Defines the number of remaining tasks to process
  64125. */
  64126. remainingCount: number;
  64127. /**
  64128. * Defines the total number of tasks
  64129. */
  64130. totalCount: number;
  64131. /**
  64132. * Defines the task that was just processed
  64133. */
  64134. task: AbstractAssetTask;
  64135. /**
  64136. * Creates a AssetsProgressEvent
  64137. * @param remainingCount defines the number of remaining tasks to process
  64138. * @param totalCount defines the total number of tasks
  64139. * @param task defines the task that was just processed
  64140. */
  64141. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  64142. }
  64143. /**
  64144. * Define a task used by AssetsManager to load meshes
  64145. */
  64146. export class MeshAssetTask extends AbstractAssetTask {
  64147. /**
  64148. * Defines the name of the task
  64149. */
  64150. name: string;
  64151. /**
  64152. * Defines the list of mesh's names you want to load
  64153. */
  64154. meshesNames: any;
  64155. /**
  64156. * Defines the root url to use as a base to load your meshes and associated resources
  64157. */
  64158. rootUrl: string;
  64159. /**
  64160. * Defines the filename of the scene to load from
  64161. */
  64162. sceneFilename: string;
  64163. /**
  64164. * Gets the list of loaded meshes
  64165. */
  64166. loadedMeshes: Array<AbstractMesh>;
  64167. /**
  64168. * Gets the list of loaded particle systems
  64169. */
  64170. loadedParticleSystems: Array<IParticleSystem>;
  64171. /**
  64172. * Gets the list of loaded skeletons
  64173. */
  64174. loadedSkeletons: Array<Skeleton>;
  64175. /**
  64176. * Gets the list of loaded animation groups
  64177. */
  64178. loadedAnimationGroups: Array<AnimationGroup>;
  64179. /**
  64180. * Callback called when the task is successful
  64181. */
  64182. onSuccess: (task: MeshAssetTask) => void;
  64183. /**
  64184. * Callback called when the task is successful
  64185. */
  64186. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  64187. /**
  64188. * Creates a new MeshAssetTask
  64189. * @param name defines the name of the task
  64190. * @param meshesNames defines the list of mesh's names you want to load
  64191. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  64192. * @param sceneFilename defines the filename of the scene to load from
  64193. */
  64194. constructor(
  64195. /**
  64196. * Defines the name of the task
  64197. */
  64198. name: string,
  64199. /**
  64200. * Defines the list of mesh's names you want to load
  64201. */
  64202. meshesNames: any,
  64203. /**
  64204. * Defines the root url to use as a base to load your meshes and associated resources
  64205. */
  64206. rootUrl: string,
  64207. /**
  64208. * Defines the filename of the scene to load from
  64209. */
  64210. sceneFilename: string);
  64211. /**
  64212. * Execute the current task
  64213. * @param scene defines the scene where you want your assets to be loaded
  64214. * @param onSuccess is a callback called when the task is successfully executed
  64215. * @param onError is a callback called if an error occurs
  64216. */
  64217. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64218. }
  64219. /**
  64220. * Define a task used by AssetsManager to load text content
  64221. */
  64222. export class TextFileAssetTask extends AbstractAssetTask {
  64223. /**
  64224. * Defines the name of the task
  64225. */
  64226. name: string;
  64227. /**
  64228. * Defines the location of the file to load
  64229. */
  64230. url: string;
  64231. /**
  64232. * Gets the loaded text string
  64233. */
  64234. text: string;
  64235. /**
  64236. * Callback called when the task is successful
  64237. */
  64238. onSuccess: (task: TextFileAssetTask) => void;
  64239. /**
  64240. * Callback called when the task is successful
  64241. */
  64242. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  64243. /**
  64244. * Creates a new TextFileAssetTask object
  64245. * @param name defines the name of the task
  64246. * @param url defines the location of the file to load
  64247. */
  64248. constructor(
  64249. /**
  64250. * Defines the name of the task
  64251. */
  64252. name: string,
  64253. /**
  64254. * Defines the location of the file to load
  64255. */
  64256. url: string);
  64257. /**
  64258. * Execute the current task
  64259. * @param scene defines the scene where you want your assets to be loaded
  64260. * @param onSuccess is a callback called when the task is successfully executed
  64261. * @param onError is a callback called if an error occurs
  64262. */
  64263. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64264. }
  64265. /**
  64266. * Define a task used by AssetsManager to load binary data
  64267. */
  64268. export class BinaryFileAssetTask extends AbstractAssetTask {
  64269. /**
  64270. * Defines the name of the task
  64271. */
  64272. name: string;
  64273. /**
  64274. * Defines the location of the file to load
  64275. */
  64276. url: string;
  64277. /**
  64278. * Gets the lodaded data (as an array buffer)
  64279. */
  64280. data: ArrayBuffer;
  64281. /**
  64282. * Callback called when the task is successful
  64283. */
  64284. onSuccess: (task: BinaryFileAssetTask) => void;
  64285. /**
  64286. * Callback called when the task is successful
  64287. */
  64288. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  64289. /**
  64290. * Creates a new BinaryFileAssetTask object
  64291. * @param name defines the name of the new task
  64292. * @param url defines the location of the file to load
  64293. */
  64294. constructor(
  64295. /**
  64296. * Defines the name of the task
  64297. */
  64298. name: string,
  64299. /**
  64300. * Defines the location of the file to load
  64301. */
  64302. url: string);
  64303. /**
  64304. * Execute the current task
  64305. * @param scene defines the scene where you want your assets to be loaded
  64306. * @param onSuccess is a callback called when the task is successfully executed
  64307. * @param onError is a callback called if an error occurs
  64308. */
  64309. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64310. }
  64311. /**
  64312. * Define a task used by AssetsManager to load images
  64313. */
  64314. export class ImageAssetTask extends AbstractAssetTask {
  64315. /**
  64316. * Defines the name of the task
  64317. */
  64318. name: string;
  64319. /**
  64320. * Defines the location of the image to load
  64321. */
  64322. url: string;
  64323. /**
  64324. * Gets the loaded images
  64325. */
  64326. image: HTMLImageElement;
  64327. /**
  64328. * Callback called when the task is successful
  64329. */
  64330. onSuccess: (task: ImageAssetTask) => void;
  64331. /**
  64332. * Callback called when the task is successful
  64333. */
  64334. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  64335. /**
  64336. * Creates a new ImageAssetTask
  64337. * @param name defines the name of the task
  64338. * @param url defines the location of the image to load
  64339. */
  64340. constructor(
  64341. /**
  64342. * Defines the name of the task
  64343. */
  64344. name: string,
  64345. /**
  64346. * Defines the location of the image to load
  64347. */
  64348. url: string);
  64349. /**
  64350. * Execute the current task
  64351. * @param scene defines the scene where you want your assets to be loaded
  64352. * @param onSuccess is a callback called when the task is successfully executed
  64353. * @param onError is a callback called if an error occurs
  64354. */
  64355. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64356. }
  64357. /**
  64358. * Defines the interface used by texture loading tasks
  64359. */
  64360. export interface ITextureAssetTask<TEX extends BaseTexture> {
  64361. /**
  64362. * Gets the loaded texture
  64363. */
  64364. texture: TEX;
  64365. }
  64366. /**
  64367. * Define a task used by AssetsManager to load 2D textures
  64368. */
  64369. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  64370. /**
  64371. * Defines the name of the task
  64372. */
  64373. name: string;
  64374. /**
  64375. * Defines the location of the file to load
  64376. */
  64377. url: string;
  64378. /**
  64379. * Defines if mipmap should not be generated (default is false)
  64380. */
  64381. noMipmap?: boolean | undefined;
  64382. /**
  64383. * Defines if texture must be inverted on Y axis (default is false)
  64384. */
  64385. invertY?: boolean | undefined;
  64386. /**
  64387. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64388. */
  64389. samplingMode: number;
  64390. /**
  64391. * Gets the loaded texture
  64392. */
  64393. texture: Texture;
  64394. /**
  64395. * Callback called when the task is successful
  64396. */
  64397. onSuccess: (task: TextureAssetTask) => void;
  64398. /**
  64399. * Callback called when the task is successful
  64400. */
  64401. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  64402. /**
  64403. * Creates a new TextureAssetTask object
  64404. * @param name defines the name of the task
  64405. * @param url defines the location of the file to load
  64406. * @param noMipmap defines if mipmap should not be generated (default is false)
  64407. * @param invertY defines if texture must be inverted on Y axis (default is false)
  64408. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64409. */
  64410. constructor(
  64411. /**
  64412. * Defines the name of the task
  64413. */
  64414. name: string,
  64415. /**
  64416. * Defines the location of the file to load
  64417. */
  64418. url: string,
  64419. /**
  64420. * Defines if mipmap should not be generated (default is false)
  64421. */
  64422. noMipmap?: boolean | undefined,
  64423. /**
  64424. * Defines if texture must be inverted on Y axis (default is false)
  64425. */
  64426. invertY?: boolean | undefined,
  64427. /**
  64428. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64429. */
  64430. samplingMode?: number);
  64431. /**
  64432. * Execute the current task
  64433. * @param scene defines the scene where you want your assets to be loaded
  64434. * @param onSuccess is a callback called when the task is successfully executed
  64435. * @param onError is a callback called if an error occurs
  64436. */
  64437. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64438. }
  64439. /**
  64440. * Define a task used by AssetsManager to load cube textures
  64441. */
  64442. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  64443. /**
  64444. * Defines the name of the task
  64445. */
  64446. name: string;
  64447. /**
  64448. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64449. */
  64450. url: string;
  64451. /**
  64452. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64453. */
  64454. extensions?: string[] | undefined;
  64455. /**
  64456. * Defines if mipmaps should not be generated (default is false)
  64457. */
  64458. noMipmap?: boolean | undefined;
  64459. /**
  64460. * Defines the explicit list of files (undefined by default)
  64461. */
  64462. files?: string[] | undefined;
  64463. /**
  64464. * Gets the loaded texture
  64465. */
  64466. texture: CubeTexture;
  64467. /**
  64468. * Callback called when the task is successful
  64469. */
  64470. onSuccess: (task: CubeTextureAssetTask) => void;
  64471. /**
  64472. * Callback called when the task is successful
  64473. */
  64474. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  64475. /**
  64476. * Creates a new CubeTextureAssetTask
  64477. * @param name defines the name of the task
  64478. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64479. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64480. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64481. * @param files defines the explicit list of files (undefined by default)
  64482. */
  64483. constructor(
  64484. /**
  64485. * Defines the name of the task
  64486. */
  64487. name: string,
  64488. /**
  64489. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64490. */
  64491. url: string,
  64492. /**
  64493. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64494. */
  64495. extensions?: string[] | undefined,
  64496. /**
  64497. * Defines if mipmaps should not be generated (default is false)
  64498. */
  64499. noMipmap?: boolean | undefined,
  64500. /**
  64501. * Defines the explicit list of files (undefined by default)
  64502. */
  64503. files?: string[] | undefined);
  64504. /**
  64505. * Execute the current task
  64506. * @param scene defines the scene where you want your assets to be loaded
  64507. * @param onSuccess is a callback called when the task is successfully executed
  64508. * @param onError is a callback called if an error occurs
  64509. */
  64510. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64511. }
  64512. /**
  64513. * Define a task used by AssetsManager to load HDR cube textures
  64514. */
  64515. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  64516. /**
  64517. * Defines the name of the task
  64518. */
  64519. name: string;
  64520. /**
  64521. * Defines the location of the file to load
  64522. */
  64523. url: string;
  64524. /**
  64525. * Defines the desired size (the more it increases the longer the generation will be)
  64526. */
  64527. size: number;
  64528. /**
  64529. * Defines if mipmaps should not be generated (default is false)
  64530. */
  64531. noMipmap: boolean;
  64532. /**
  64533. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64534. */
  64535. generateHarmonics: boolean;
  64536. /**
  64537. * 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)
  64538. */
  64539. gammaSpace: boolean;
  64540. /**
  64541. * Internal Use Only
  64542. */
  64543. reserved: boolean;
  64544. /**
  64545. * Gets the loaded texture
  64546. */
  64547. texture: HDRCubeTexture;
  64548. /**
  64549. * Callback called when the task is successful
  64550. */
  64551. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  64552. /**
  64553. * Callback called when the task is successful
  64554. */
  64555. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  64556. /**
  64557. * Creates a new HDRCubeTextureAssetTask object
  64558. * @param name defines the name of the task
  64559. * @param url defines the location of the file to load
  64560. * @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.
  64561. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64562. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64563. * @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)
  64564. * @param reserved Internal use only
  64565. */
  64566. constructor(
  64567. /**
  64568. * Defines the name of the task
  64569. */
  64570. name: string,
  64571. /**
  64572. * Defines the location of the file to load
  64573. */
  64574. url: string,
  64575. /**
  64576. * Defines the desired size (the more it increases the longer the generation will be)
  64577. */
  64578. size: number,
  64579. /**
  64580. * Defines if mipmaps should not be generated (default is false)
  64581. */
  64582. noMipmap?: boolean,
  64583. /**
  64584. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64585. */
  64586. generateHarmonics?: boolean,
  64587. /**
  64588. * 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)
  64589. */
  64590. gammaSpace?: boolean,
  64591. /**
  64592. * Internal Use Only
  64593. */
  64594. reserved?: boolean);
  64595. /**
  64596. * Execute the current task
  64597. * @param scene defines the scene where you want your assets to be loaded
  64598. * @param onSuccess is a callback called when the task is successfully executed
  64599. * @param onError is a callback called if an error occurs
  64600. */
  64601. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64602. }
  64603. /**
  64604. * Define a task used by AssetsManager to load Equirectangular cube textures
  64605. */
  64606. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  64607. /**
  64608. * Defines the name of the task
  64609. */
  64610. name: string;
  64611. /**
  64612. * Defines the location of the file to load
  64613. */
  64614. url: string;
  64615. /**
  64616. * Defines the desired size (the more it increases the longer the generation will be)
  64617. */
  64618. size: number;
  64619. /**
  64620. * Defines if mipmaps should not be generated (default is false)
  64621. */
  64622. noMipmap: boolean;
  64623. /**
  64624. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  64625. * but the standard material would require them in Gamma space) (default is true)
  64626. */
  64627. gammaSpace: boolean;
  64628. /**
  64629. * Gets the loaded texture
  64630. */
  64631. texture: EquiRectangularCubeTexture;
  64632. /**
  64633. * Callback called when the task is successful
  64634. */
  64635. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  64636. /**
  64637. * Callback called when the task is successful
  64638. */
  64639. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  64640. /**
  64641. * Creates a new EquiRectangularCubeTextureAssetTask object
  64642. * @param name defines the name of the task
  64643. * @param url defines the location of the file to load
  64644. * @param size defines the desired size (the more it increases the longer the generation will be)
  64645. * If the size is omitted this implies you are using a preprocessed cubemap.
  64646. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64647. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  64648. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  64649. * (default is true)
  64650. */
  64651. constructor(
  64652. /**
  64653. * Defines the name of the task
  64654. */
  64655. name: string,
  64656. /**
  64657. * Defines the location of the file to load
  64658. */
  64659. url: string,
  64660. /**
  64661. * Defines the desired size (the more it increases the longer the generation will be)
  64662. */
  64663. size: number,
  64664. /**
  64665. * Defines if mipmaps should not be generated (default is false)
  64666. */
  64667. noMipmap?: boolean,
  64668. /**
  64669. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  64670. * but the standard material would require them in Gamma space) (default is true)
  64671. */
  64672. gammaSpace?: boolean);
  64673. /**
  64674. * Execute the current task
  64675. * @param scene defines the scene where you want your assets to be loaded
  64676. * @param onSuccess is a callback called when the task is successfully executed
  64677. * @param onError is a callback called if an error occurs
  64678. */
  64679. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64680. }
  64681. /**
  64682. * This class can be used to easily import assets into a scene
  64683. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  64684. */
  64685. export class AssetsManager {
  64686. private _scene;
  64687. private _isLoading;
  64688. protected _tasks: AbstractAssetTask[];
  64689. protected _waitingTasksCount: number;
  64690. protected _totalTasksCount: number;
  64691. /**
  64692. * Callback called when all tasks are processed
  64693. */
  64694. onFinish: (tasks: AbstractAssetTask[]) => void;
  64695. /**
  64696. * Callback called when a task is successful
  64697. */
  64698. onTaskSuccess: (task: AbstractAssetTask) => void;
  64699. /**
  64700. * Callback called when a task had an error
  64701. */
  64702. onTaskError: (task: AbstractAssetTask) => void;
  64703. /**
  64704. * Callback called when a task is done (whatever the result is)
  64705. */
  64706. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  64707. /**
  64708. * Observable called when all tasks are processed
  64709. */
  64710. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  64711. /**
  64712. * Observable called when a task had an error
  64713. */
  64714. onTaskErrorObservable: Observable<AbstractAssetTask>;
  64715. /**
  64716. * Observable called when all tasks were executed
  64717. */
  64718. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  64719. /**
  64720. * Observable called when a task is done (whatever the result is)
  64721. */
  64722. onProgressObservable: Observable<IAssetsProgressEvent>;
  64723. /**
  64724. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  64725. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  64726. */
  64727. useDefaultLoadingScreen: boolean;
  64728. /**
  64729. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  64730. * when all assets have been downloaded.
  64731. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  64732. */
  64733. autoHideLoadingUI: boolean;
  64734. /**
  64735. * Creates a new AssetsManager
  64736. * @param scene defines the scene to work on
  64737. */
  64738. constructor(scene: Scene);
  64739. /**
  64740. * Add a MeshAssetTask to the list of active tasks
  64741. * @param taskName defines the name of the new task
  64742. * @param meshesNames defines the name of meshes to load
  64743. * @param rootUrl defines the root url to use to locate files
  64744. * @param sceneFilename defines the filename of the scene file
  64745. * @returns a new MeshAssetTask object
  64746. */
  64747. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  64748. /**
  64749. * Add a TextFileAssetTask to the list of active tasks
  64750. * @param taskName defines the name of the new task
  64751. * @param url defines the url of the file to load
  64752. * @returns a new TextFileAssetTask object
  64753. */
  64754. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  64755. /**
  64756. * Add a BinaryFileAssetTask to the list of active tasks
  64757. * @param taskName defines the name of the new task
  64758. * @param url defines the url of the file to load
  64759. * @returns a new BinaryFileAssetTask object
  64760. */
  64761. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  64762. /**
  64763. * Add a ImageAssetTask to the list of active tasks
  64764. * @param taskName defines the name of the new task
  64765. * @param url defines the url of the file to load
  64766. * @returns a new ImageAssetTask object
  64767. */
  64768. addImageTask(taskName: string, url: string): ImageAssetTask;
  64769. /**
  64770. * Add a TextureAssetTask to the list of active tasks
  64771. * @param taskName defines the name of the new task
  64772. * @param url defines the url of the file to load
  64773. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64774. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  64775. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64776. * @returns a new TextureAssetTask object
  64777. */
  64778. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  64779. /**
  64780. * Add a CubeTextureAssetTask to the list of active tasks
  64781. * @param taskName defines the name of the new task
  64782. * @param url defines the url of the file to load
  64783. * @param extensions defines the extension to use to load the cube map (can be null)
  64784. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64785. * @param files defines the list of files to load (can be null)
  64786. * @returns a new CubeTextureAssetTask object
  64787. */
  64788. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  64789. /**
  64790. *
  64791. * Add a HDRCubeTextureAssetTask to the list of active tasks
  64792. * @param taskName defines the name of the new task
  64793. * @param url defines the url of the file to load
  64794. * @param size defines the size you want for the cubemap (can be null)
  64795. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64796. * @param generateHarmonics defines if you want to automatically generate (true by default)
  64797. * @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)
  64798. * @param reserved Internal use only
  64799. * @returns a new HDRCubeTextureAssetTask object
  64800. */
  64801. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  64802. /**
  64803. *
  64804. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  64805. * @param taskName defines the name of the new task
  64806. * @param url defines the url of the file to load
  64807. * @param size defines the size you want for the cubemap (can be null)
  64808. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64809. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  64810. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  64811. * @returns a new EquiRectangularCubeTextureAssetTask object
  64812. */
  64813. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  64814. /**
  64815. * Remove a task from the assets manager.
  64816. * @param task the task to remove
  64817. */
  64818. removeTask(task: AbstractAssetTask): void;
  64819. private _decreaseWaitingTasksCount;
  64820. private _runTask;
  64821. /**
  64822. * Reset the AssetsManager and remove all tasks
  64823. * @return the current instance of the AssetsManager
  64824. */
  64825. reset(): AssetsManager;
  64826. /**
  64827. * Start the loading process
  64828. * @return the current instance of the AssetsManager
  64829. */
  64830. load(): AssetsManager;
  64831. /**
  64832. * Start the loading process as an async operation
  64833. * @return a promise returning the list of failed tasks
  64834. */
  64835. loadAsync(): Promise<void>;
  64836. }
  64837. }
  64838. declare module "babylonjs/Misc/deferred" {
  64839. /**
  64840. * Wrapper class for promise with external resolve and reject.
  64841. */
  64842. export class Deferred<T> {
  64843. /**
  64844. * The promise associated with this deferred object.
  64845. */
  64846. readonly promise: Promise<T>;
  64847. private _resolve;
  64848. private _reject;
  64849. /**
  64850. * The resolve method of the promise associated with this deferred object.
  64851. */
  64852. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  64853. /**
  64854. * The reject method of the promise associated with this deferred object.
  64855. */
  64856. readonly reject: (reason?: any) => void;
  64857. /**
  64858. * Constructor for this deferred object.
  64859. */
  64860. constructor();
  64861. }
  64862. }
  64863. declare module "babylonjs/Misc/meshExploder" {
  64864. import { Mesh } from "babylonjs/Meshes/mesh";
  64865. /**
  64866. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  64867. */
  64868. export class MeshExploder {
  64869. private _centerMesh;
  64870. private _meshes;
  64871. private _meshesOrigins;
  64872. private _toCenterVectors;
  64873. private _scaledDirection;
  64874. private _newPosition;
  64875. private _centerPosition;
  64876. /**
  64877. * Explodes meshes from a center mesh.
  64878. * @param meshes The meshes to explode.
  64879. * @param centerMesh The mesh to be center of explosion.
  64880. */
  64881. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  64882. private _setCenterMesh;
  64883. /**
  64884. * Get class name
  64885. * @returns "MeshExploder"
  64886. */
  64887. getClassName(): string;
  64888. /**
  64889. * "Exploded meshes"
  64890. * @returns Array of meshes with the centerMesh at index 0.
  64891. */
  64892. getMeshes(): Array<Mesh>;
  64893. /**
  64894. * Explodes meshes giving a specific direction
  64895. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  64896. */
  64897. explode(direction?: number): void;
  64898. }
  64899. }
  64900. declare module "babylonjs/Misc/filesInput" {
  64901. import { Engine } from "babylonjs/Engines/engine";
  64902. import { Scene } from "babylonjs/scene";
  64903. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  64904. /**
  64905. * Class used to help managing file picking and drag'n'drop
  64906. */
  64907. export class FilesInput {
  64908. /**
  64909. * List of files ready to be loaded
  64910. */
  64911. static readonly FilesToLoad: {
  64912. [key: string]: File;
  64913. };
  64914. /**
  64915. * Callback called when a file is processed
  64916. */
  64917. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  64918. private _engine;
  64919. private _currentScene;
  64920. private _sceneLoadedCallback;
  64921. private _progressCallback;
  64922. private _additionalRenderLoopLogicCallback;
  64923. private _textureLoadingCallback;
  64924. private _startingProcessingFilesCallback;
  64925. private _onReloadCallback;
  64926. private _errorCallback;
  64927. private _elementToMonitor;
  64928. private _sceneFileToLoad;
  64929. private _filesToLoad;
  64930. /**
  64931. * Creates a new FilesInput
  64932. * @param engine defines the rendering engine
  64933. * @param scene defines the hosting scene
  64934. * @param sceneLoadedCallback callback called when scene is loaded
  64935. * @param progressCallback callback called to track progress
  64936. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  64937. * @param textureLoadingCallback callback called when a texture is loading
  64938. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  64939. * @param onReloadCallback callback called when a reload is requested
  64940. * @param errorCallback callback call if an error occurs
  64941. */
  64942. 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);
  64943. private _dragEnterHandler;
  64944. private _dragOverHandler;
  64945. private _dropHandler;
  64946. /**
  64947. * Calls this function to listen to drag'n'drop events on a specific DOM element
  64948. * @param elementToMonitor defines the DOM element to track
  64949. */
  64950. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  64951. /**
  64952. * Release all associated resources
  64953. */
  64954. dispose(): void;
  64955. private renderFunction;
  64956. private drag;
  64957. private drop;
  64958. private _traverseFolder;
  64959. private _processFiles;
  64960. /**
  64961. * Load files from a drop event
  64962. * @param event defines the drop event to use as source
  64963. */
  64964. loadFiles(event: any): void;
  64965. private _processReload;
  64966. /**
  64967. * Reload the current scene from the loaded files
  64968. */
  64969. reload(): void;
  64970. }
  64971. }
  64972. declare module "babylonjs/Misc/HighDynamicRange/index" {
  64973. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  64974. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  64975. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  64976. }
  64977. declare module "babylonjs/Misc/sceneOptimizer" {
  64978. import { Scene, IDisposable } from "babylonjs/scene";
  64979. import { Observable } from "babylonjs/Misc/observable";
  64980. /**
  64981. * Defines the root class used to create scene optimization to use with SceneOptimizer
  64982. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64983. */
  64984. export class SceneOptimization {
  64985. /**
  64986. * Defines the priority of this optimization (0 by default which means first in the list)
  64987. */
  64988. priority: number;
  64989. /**
  64990. * Gets a string describing the action executed by the current optimization
  64991. * @returns description string
  64992. */
  64993. getDescription(): string;
  64994. /**
  64995. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64996. * @param scene defines the current scene where to apply this optimization
  64997. * @param optimizer defines the current optimizer
  64998. * @returns true if everything that can be done was applied
  64999. */
  65000. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65001. /**
  65002. * Creates the SceneOptimization object
  65003. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65004. * @param desc defines the description associated with the optimization
  65005. */
  65006. constructor(
  65007. /**
  65008. * Defines the priority of this optimization (0 by default which means first in the list)
  65009. */
  65010. priority?: number);
  65011. }
  65012. /**
  65013. * Defines an optimization used to reduce the size of render target textures
  65014. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65015. */
  65016. export class TextureOptimization extends SceneOptimization {
  65017. /**
  65018. * Defines the priority of this optimization (0 by default which means first in the list)
  65019. */
  65020. priority: number;
  65021. /**
  65022. * 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
  65023. */
  65024. maximumSize: number;
  65025. /**
  65026. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65027. */
  65028. step: number;
  65029. /**
  65030. * Gets a string describing the action executed by the current optimization
  65031. * @returns description string
  65032. */
  65033. getDescription(): string;
  65034. /**
  65035. * Creates the TextureOptimization object
  65036. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65037. * @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
  65038. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65039. */
  65040. constructor(
  65041. /**
  65042. * Defines the priority of this optimization (0 by default which means first in the list)
  65043. */
  65044. priority?: number,
  65045. /**
  65046. * 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
  65047. */
  65048. maximumSize?: number,
  65049. /**
  65050. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65051. */
  65052. step?: number);
  65053. /**
  65054. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65055. * @param scene defines the current scene where to apply this optimization
  65056. * @param optimizer defines the current optimizer
  65057. * @returns true if everything that can be done was applied
  65058. */
  65059. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65060. }
  65061. /**
  65062. * Defines an optimization used to increase or decrease the rendering resolution
  65063. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65064. */
  65065. export class HardwareScalingOptimization extends SceneOptimization {
  65066. /**
  65067. * Defines the priority of this optimization (0 by default which means first in the list)
  65068. */
  65069. priority: number;
  65070. /**
  65071. * Defines the maximum scale to use (2 by default)
  65072. */
  65073. maximumScale: number;
  65074. /**
  65075. * Defines the step to use between two passes (0.5 by default)
  65076. */
  65077. step: number;
  65078. private _currentScale;
  65079. private _directionOffset;
  65080. /**
  65081. * Gets a string describing the action executed by the current optimization
  65082. * @return description string
  65083. */
  65084. getDescription(): string;
  65085. /**
  65086. * Creates the HardwareScalingOptimization object
  65087. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65088. * @param maximumScale defines the maximum scale to use (2 by default)
  65089. * @param step defines the step to use between two passes (0.5 by default)
  65090. */
  65091. constructor(
  65092. /**
  65093. * Defines the priority of this optimization (0 by default which means first in the list)
  65094. */
  65095. priority?: number,
  65096. /**
  65097. * Defines the maximum scale to use (2 by default)
  65098. */
  65099. maximumScale?: number,
  65100. /**
  65101. * Defines the step to use between two passes (0.5 by default)
  65102. */
  65103. step?: number);
  65104. /**
  65105. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65106. * @param scene defines the current scene where to apply this optimization
  65107. * @param optimizer defines the current optimizer
  65108. * @returns true if everything that can be done was applied
  65109. */
  65110. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65111. }
  65112. /**
  65113. * Defines an optimization used to remove shadows
  65114. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65115. */
  65116. export class ShadowsOptimization extends SceneOptimization {
  65117. /**
  65118. * Gets a string describing the action executed by the current optimization
  65119. * @return description string
  65120. */
  65121. getDescription(): string;
  65122. /**
  65123. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65124. * @param scene defines the current scene where to apply this optimization
  65125. * @param optimizer defines the current optimizer
  65126. * @returns true if everything that can be done was applied
  65127. */
  65128. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65129. }
  65130. /**
  65131. * Defines an optimization used to turn post-processes off
  65132. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65133. */
  65134. export class PostProcessesOptimization extends SceneOptimization {
  65135. /**
  65136. * Gets a string describing the action executed by the current optimization
  65137. * @return description string
  65138. */
  65139. getDescription(): string;
  65140. /**
  65141. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65142. * @param scene defines the current scene where to apply this optimization
  65143. * @param optimizer defines the current optimizer
  65144. * @returns true if everything that can be done was applied
  65145. */
  65146. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65147. }
  65148. /**
  65149. * Defines an optimization used to turn lens flares off
  65150. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65151. */
  65152. export class LensFlaresOptimization extends SceneOptimization {
  65153. /**
  65154. * Gets a string describing the action executed by the current optimization
  65155. * @return description string
  65156. */
  65157. getDescription(): string;
  65158. /**
  65159. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65160. * @param scene defines the current scene where to apply this optimization
  65161. * @param optimizer defines the current optimizer
  65162. * @returns true if everything that can be done was applied
  65163. */
  65164. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65165. }
  65166. /**
  65167. * Defines an optimization based on user defined callback.
  65168. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65169. */
  65170. export class CustomOptimization extends SceneOptimization {
  65171. /**
  65172. * Callback called to apply the custom optimization.
  65173. */
  65174. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  65175. /**
  65176. * Callback called to get custom description
  65177. */
  65178. onGetDescription: () => string;
  65179. /**
  65180. * Gets a string describing the action executed by the current optimization
  65181. * @returns description string
  65182. */
  65183. getDescription(): string;
  65184. /**
  65185. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65186. * @param scene defines the current scene where to apply this optimization
  65187. * @param optimizer defines the current optimizer
  65188. * @returns true if everything that can be done was applied
  65189. */
  65190. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65191. }
  65192. /**
  65193. * Defines an optimization used to turn particles off
  65194. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65195. */
  65196. export class ParticlesOptimization extends SceneOptimization {
  65197. /**
  65198. * Gets a string describing the action executed by the current optimization
  65199. * @return description string
  65200. */
  65201. getDescription(): string;
  65202. /**
  65203. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65204. * @param scene defines the current scene where to apply this optimization
  65205. * @param optimizer defines the current optimizer
  65206. * @returns true if everything that can be done was applied
  65207. */
  65208. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65209. }
  65210. /**
  65211. * Defines an optimization used to turn render targets off
  65212. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65213. */
  65214. export class RenderTargetsOptimization extends SceneOptimization {
  65215. /**
  65216. * Gets a string describing the action executed by the current optimization
  65217. * @return description string
  65218. */
  65219. getDescription(): string;
  65220. /**
  65221. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65222. * @param scene defines the current scene where to apply this optimization
  65223. * @param optimizer defines the current optimizer
  65224. * @returns true if everything that can be done was applied
  65225. */
  65226. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65227. }
  65228. /**
  65229. * Defines an optimization used to merge meshes with compatible materials
  65230. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65231. */
  65232. export class MergeMeshesOptimization extends SceneOptimization {
  65233. private static _UpdateSelectionTree;
  65234. /**
  65235. * Gets or sets a boolean which defines if optimization octree has to be updated
  65236. */
  65237. /**
  65238. * Gets or sets a boolean which defines if optimization octree has to be updated
  65239. */
  65240. static UpdateSelectionTree: boolean;
  65241. /**
  65242. * Gets a string describing the action executed by the current optimization
  65243. * @return description string
  65244. */
  65245. getDescription(): string;
  65246. private _canBeMerged;
  65247. /**
  65248. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65249. * @param scene defines the current scene where to apply this optimization
  65250. * @param optimizer defines the current optimizer
  65251. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  65252. * @returns true if everything that can be done was applied
  65253. */
  65254. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  65255. }
  65256. /**
  65257. * Defines a list of options used by SceneOptimizer
  65258. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65259. */
  65260. export class SceneOptimizerOptions {
  65261. /**
  65262. * Defines the target frame rate to reach (60 by default)
  65263. */
  65264. targetFrameRate: number;
  65265. /**
  65266. * Defines the interval between two checkes (2000ms by default)
  65267. */
  65268. trackerDuration: number;
  65269. /**
  65270. * Gets the list of optimizations to apply
  65271. */
  65272. optimizations: SceneOptimization[];
  65273. /**
  65274. * Creates a new list of options used by SceneOptimizer
  65275. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  65276. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  65277. */
  65278. constructor(
  65279. /**
  65280. * Defines the target frame rate to reach (60 by default)
  65281. */
  65282. targetFrameRate?: number,
  65283. /**
  65284. * Defines the interval between two checkes (2000ms by default)
  65285. */
  65286. trackerDuration?: number);
  65287. /**
  65288. * Add a new optimization
  65289. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  65290. * @returns the current SceneOptimizerOptions
  65291. */
  65292. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  65293. /**
  65294. * Add a new custom optimization
  65295. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  65296. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  65297. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65298. * @returns the current SceneOptimizerOptions
  65299. */
  65300. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  65301. /**
  65302. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  65303. * @param targetFrameRate defines the target frame rate (60 by default)
  65304. * @returns a SceneOptimizerOptions object
  65305. */
  65306. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65307. /**
  65308. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  65309. * @param targetFrameRate defines the target frame rate (60 by default)
  65310. * @returns a SceneOptimizerOptions object
  65311. */
  65312. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65313. /**
  65314. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  65315. * @param targetFrameRate defines the target frame rate (60 by default)
  65316. * @returns a SceneOptimizerOptions object
  65317. */
  65318. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65319. }
  65320. /**
  65321. * Class used to run optimizations in order to reach a target frame rate
  65322. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65323. */
  65324. export class SceneOptimizer implements IDisposable {
  65325. private _isRunning;
  65326. private _options;
  65327. private _scene;
  65328. private _currentPriorityLevel;
  65329. private _targetFrameRate;
  65330. private _trackerDuration;
  65331. private _currentFrameRate;
  65332. private _sceneDisposeObserver;
  65333. private _improvementMode;
  65334. /**
  65335. * Defines an observable called when the optimizer reaches the target frame rate
  65336. */
  65337. onSuccessObservable: Observable<SceneOptimizer>;
  65338. /**
  65339. * Defines an observable called when the optimizer enables an optimization
  65340. */
  65341. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  65342. /**
  65343. * Defines an observable called when the optimizer is not able to reach the target frame rate
  65344. */
  65345. onFailureObservable: Observable<SceneOptimizer>;
  65346. /**
  65347. * Gets a boolean indicating if the optimizer is in improvement mode
  65348. */
  65349. readonly isInImprovementMode: boolean;
  65350. /**
  65351. * Gets the current priority level (0 at start)
  65352. */
  65353. readonly currentPriorityLevel: number;
  65354. /**
  65355. * Gets the current frame rate checked by the SceneOptimizer
  65356. */
  65357. readonly currentFrameRate: number;
  65358. /**
  65359. * Gets or sets the current target frame rate (60 by default)
  65360. */
  65361. /**
  65362. * Gets or sets the current target frame rate (60 by default)
  65363. */
  65364. targetFrameRate: number;
  65365. /**
  65366. * Gets or sets the current interval between two checks (every 2000ms by default)
  65367. */
  65368. /**
  65369. * Gets or sets the current interval between two checks (every 2000ms by default)
  65370. */
  65371. trackerDuration: number;
  65372. /**
  65373. * Gets the list of active optimizations
  65374. */
  65375. readonly optimizations: SceneOptimization[];
  65376. /**
  65377. * Creates a new SceneOptimizer
  65378. * @param scene defines the scene to work on
  65379. * @param options defines the options to use with the SceneOptimizer
  65380. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  65381. * @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)
  65382. */
  65383. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  65384. /**
  65385. * Stops the current optimizer
  65386. */
  65387. stop(): void;
  65388. /**
  65389. * Reset the optimizer to initial step (current priority level = 0)
  65390. */
  65391. reset(): void;
  65392. /**
  65393. * Start the optimizer. By default it will try to reach a specific framerate
  65394. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  65395. */
  65396. start(): void;
  65397. private _checkCurrentState;
  65398. /**
  65399. * Release all resources
  65400. */
  65401. dispose(): void;
  65402. /**
  65403. * Helper function to create a SceneOptimizer with one single line of code
  65404. * @param scene defines the scene to work on
  65405. * @param options defines the options to use with the SceneOptimizer
  65406. * @param onSuccess defines a callback to call on success
  65407. * @param onFailure defines a callback to call on failure
  65408. * @returns the new SceneOptimizer object
  65409. */
  65410. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  65411. }
  65412. }
  65413. declare module "babylonjs/Misc/sceneSerializer" {
  65414. import { Scene } from "babylonjs/scene";
  65415. /**
  65416. * Class used to serialize a scene into a string
  65417. */
  65418. export class SceneSerializer {
  65419. /**
  65420. * Clear cache used by a previous serialization
  65421. */
  65422. static ClearCache(): void;
  65423. /**
  65424. * Serialize a scene into a JSON compatible object
  65425. * @param scene defines the scene to serialize
  65426. * @returns a JSON compatible object
  65427. */
  65428. static Serialize(scene: Scene): any;
  65429. /**
  65430. * Serialize a mesh into a JSON compatible object
  65431. * @param toSerialize defines the mesh to serialize
  65432. * @param withParents defines if parents must be serialized as well
  65433. * @param withChildren defines if children must be serialized as well
  65434. * @returns a JSON compatible object
  65435. */
  65436. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  65437. }
  65438. }
  65439. declare module "babylonjs/Misc/textureTools" {
  65440. import { Texture } from "babylonjs/Materials/Textures/texture";
  65441. /**
  65442. * Class used to host texture specific utilities
  65443. */
  65444. export class TextureTools {
  65445. /**
  65446. * Uses the GPU to create a copy texture rescaled at a given size
  65447. * @param texture Texture to copy from
  65448. * @param width defines the desired width
  65449. * @param height defines the desired height
  65450. * @param useBilinearMode defines if bilinear mode has to be used
  65451. * @return the generated texture
  65452. */
  65453. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  65454. }
  65455. }
  65456. declare module "babylonjs/Misc/videoRecorder" {
  65457. import { Nullable } from "babylonjs/types";
  65458. import { Engine } from "babylonjs/Engines/engine";
  65459. /**
  65460. * This represents the different options available for the video capture.
  65461. */
  65462. export interface VideoRecorderOptions {
  65463. /** Defines the mime type of the video. */
  65464. mimeType: string;
  65465. /** Defines the FPS the video should be recorded at. */
  65466. fps: number;
  65467. /** Defines the chunk size for the recording data. */
  65468. recordChunckSize: number;
  65469. /** The audio tracks to attach to the recording. */
  65470. audioTracks?: MediaStreamTrack[];
  65471. }
  65472. /**
  65473. * This can help with recording videos from BabylonJS.
  65474. * This is based on the available WebRTC functionalities of the browser.
  65475. *
  65476. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  65477. */
  65478. export class VideoRecorder {
  65479. private static readonly _defaultOptions;
  65480. /**
  65481. * Returns whether or not the VideoRecorder is available in your browser.
  65482. * @param engine Defines the Babylon Engine.
  65483. * @returns true if supported otherwise false.
  65484. */
  65485. static IsSupported(engine: Engine): boolean;
  65486. private readonly _options;
  65487. private _canvas;
  65488. private _mediaRecorder;
  65489. private _recordedChunks;
  65490. private _fileName;
  65491. private _resolve;
  65492. private _reject;
  65493. /**
  65494. * True when a recording is already in progress.
  65495. */
  65496. readonly isRecording: boolean;
  65497. /**
  65498. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  65499. * @param engine Defines the BabylonJS Engine you wish to record.
  65500. * @param options Defines options that can be used to customize the capture.
  65501. */
  65502. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  65503. /**
  65504. * Stops the current recording before the default capture timeout passed in the startRecording function.
  65505. */
  65506. stopRecording(): void;
  65507. /**
  65508. * Starts recording the canvas for a max duration specified in parameters.
  65509. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  65510. * If null no automatic download will start and you can rely on the promise to get the data back.
  65511. * @param maxDuration Defines the maximum recording time in seconds.
  65512. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  65513. * @return A promise callback at the end of the recording with the video data in Blob.
  65514. */
  65515. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  65516. /**
  65517. * Releases internal resources used during the recording.
  65518. */
  65519. dispose(): void;
  65520. private _handleDataAvailable;
  65521. private _handleError;
  65522. private _handleStop;
  65523. }
  65524. }
  65525. declare module "babylonjs/Misc/screenshotTools" {
  65526. import { Camera } from "babylonjs/Cameras/camera";
  65527. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  65528. import { Engine } from "babylonjs/Engines/engine";
  65529. /**
  65530. * Class containing a set of static utilities functions for screenshots
  65531. */
  65532. export class ScreenshotTools {
  65533. /**
  65534. * Captures a screenshot of the current rendering
  65535. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65536. * @param engine defines the rendering engine
  65537. * @param camera defines the source camera
  65538. * @param size This parameter can be set to a single number or to an object with the
  65539. * following (optional) properties: precision, width, height. If a single number is passed,
  65540. * it will be used for both width and height. If an object is passed, the screenshot size
  65541. * will be derived from the parameters. The precision property is a multiplier allowing
  65542. * rendering at a higher or lower resolution
  65543. * @param successCallback defines the callback receives a single parameter which contains the
  65544. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  65545. * src parameter of an <img> to display it
  65546. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  65547. * Check your browser for supported MIME types
  65548. */
  65549. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  65550. /**
  65551. * Captures a screenshot of the current rendering
  65552. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65553. * @param engine defines the rendering engine
  65554. * @param camera defines the source camera
  65555. * @param size This parameter can be set to a single number or to an object with the
  65556. * following (optional) properties: precision, width, height. If a single number is passed,
  65557. * it will be used for both width and height. If an object is passed, the screenshot size
  65558. * will be derived from the parameters. The precision property is a multiplier allowing
  65559. * rendering at a higher or lower resolution
  65560. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  65561. * Check your browser for supported MIME types
  65562. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  65563. * to the src parameter of an <img> to display it
  65564. */
  65565. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  65566. /**
  65567. * Generates an image screenshot from the specified camera.
  65568. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65569. * @param engine The engine to use for rendering
  65570. * @param camera The camera to use for rendering
  65571. * @param size This parameter can be set to a single number or to an object with the
  65572. * following (optional) properties: precision, width, height. If a single number is passed,
  65573. * it will be used for both width and height. If an object is passed, the screenshot size
  65574. * will be derived from the parameters. The precision property is a multiplier allowing
  65575. * rendering at a higher or lower resolution
  65576. * @param successCallback The callback receives a single parameter which contains the
  65577. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  65578. * src parameter of an <img> to display it
  65579. * @param mimeType The MIME type of the screenshot image (default: image/png).
  65580. * Check your browser for supported MIME types
  65581. * @param samples Texture samples (default: 1)
  65582. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  65583. * @param fileName A name for for the downloaded file.
  65584. */
  65585. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  65586. /**
  65587. * Generates an image screenshot from the specified camera.
  65588. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65589. * @param engine The engine to use for rendering
  65590. * @param camera The camera to use for rendering
  65591. * @param size This parameter can be set to a single number or to an object with the
  65592. * following (optional) properties: precision, width, height. If a single number is passed,
  65593. * it will be used for both width and height. If an object is passed, the screenshot size
  65594. * will be derived from the parameters. The precision property is a multiplier allowing
  65595. * rendering at a higher or lower resolution
  65596. * @param mimeType The MIME type of the screenshot image (default: image/png).
  65597. * Check your browser for supported MIME types
  65598. * @param samples Texture samples (default: 1)
  65599. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  65600. * @param fileName A name for for the downloaded file.
  65601. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  65602. * to the src parameter of an <img> to display it
  65603. */
  65604. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  65605. /**
  65606. * Gets height and width for screenshot size
  65607. * @private
  65608. */
  65609. private static _getScreenshotSize;
  65610. }
  65611. }
  65612. declare module "babylonjs/Misc/index" {
  65613. export * from "babylonjs/Misc/andOrNotEvaluator";
  65614. export * from "babylonjs/Misc/assetsManager";
  65615. export * from "babylonjs/Misc/dds";
  65616. export * from "babylonjs/Misc/decorators";
  65617. export * from "babylonjs/Misc/deferred";
  65618. export * from "babylonjs/Misc/environmentTextureTools";
  65619. export * from "babylonjs/Misc/meshExploder";
  65620. export * from "babylonjs/Misc/filesInput";
  65621. export * from "babylonjs/Misc/HighDynamicRange/index";
  65622. export * from "babylonjs/Misc/khronosTextureContainer";
  65623. export * from "babylonjs/Misc/observable";
  65624. export * from "babylonjs/Misc/performanceMonitor";
  65625. export * from "babylonjs/Misc/promise";
  65626. export * from "babylonjs/Misc/sceneOptimizer";
  65627. export * from "babylonjs/Misc/sceneSerializer";
  65628. export * from "babylonjs/Misc/smartArray";
  65629. export * from "babylonjs/Misc/stringDictionary";
  65630. export * from "babylonjs/Misc/tags";
  65631. export * from "babylonjs/Misc/textureTools";
  65632. export * from "babylonjs/Misc/tga";
  65633. export * from "babylonjs/Misc/tools";
  65634. export * from "babylonjs/Misc/videoRecorder";
  65635. export * from "babylonjs/Misc/virtualJoystick";
  65636. export * from "babylonjs/Misc/workerPool";
  65637. export * from "babylonjs/Misc/logger";
  65638. export * from "babylonjs/Misc/typeStore";
  65639. export * from "babylonjs/Misc/filesInputStore";
  65640. export * from "babylonjs/Misc/deepCopier";
  65641. export * from "babylonjs/Misc/pivotTools";
  65642. export * from "babylonjs/Misc/precisionDate";
  65643. export * from "babylonjs/Misc/screenshotTools";
  65644. export * from "babylonjs/Misc/typeStore";
  65645. export * from "babylonjs/Misc/webRequest";
  65646. export * from "babylonjs/Misc/iInspectable";
  65647. export * from "babylonjs/Misc/brdfTextureTools";
  65648. export * from "babylonjs/Misc/rgbdTextureTools";
  65649. export * from "babylonjs/Misc/gradients";
  65650. export * from "babylonjs/Misc/perfCounter";
  65651. export * from "babylonjs/Misc/fileRequest";
  65652. export * from "babylonjs/Misc/customAnimationFrameRequester";
  65653. export * from "babylonjs/Misc/retryStrategy";
  65654. export * from "babylonjs/Misc/loadFileError";
  65655. export * from "babylonjs/Misc/interfaces/screenshotSize";
  65656. }
  65657. declare module "babylonjs/index" {
  65658. export * from "babylonjs/abstractScene";
  65659. export * from "babylonjs/Actions/index";
  65660. export * from "babylonjs/Animations/index";
  65661. export * from "babylonjs/assetContainer";
  65662. export * from "babylonjs/Audio/index";
  65663. export * from "babylonjs/Behaviors/index";
  65664. export * from "babylonjs/Bones/index";
  65665. export * from "babylonjs/Cameras/index";
  65666. export * from "babylonjs/Collisions/index";
  65667. export * from "babylonjs/Culling/index";
  65668. export * from "babylonjs/Debug/index";
  65669. export * from "babylonjs/Engines/index";
  65670. export * from "babylonjs/Events/index";
  65671. export * from "babylonjs/Gamepads/index";
  65672. export * from "babylonjs/Gizmos/index";
  65673. export * from "babylonjs/Helpers/index";
  65674. export * from "babylonjs/Instrumentation/index";
  65675. export * from "babylonjs/Layers/index";
  65676. export * from "babylonjs/LensFlares/index";
  65677. export * from "babylonjs/Lights/index";
  65678. export * from "babylonjs/Loading/index";
  65679. export * from "babylonjs/Materials/index";
  65680. export * from "babylonjs/Maths/index";
  65681. export * from "babylonjs/Meshes/index";
  65682. export * from "babylonjs/Morph/index";
  65683. export * from "babylonjs/Navigation/index";
  65684. export * from "babylonjs/node";
  65685. export * from "babylonjs/Offline/index";
  65686. export * from "babylonjs/Particles/index";
  65687. export * from "babylonjs/Physics/index";
  65688. export * from "babylonjs/PostProcesses/index";
  65689. export * from "babylonjs/Probes/index";
  65690. export * from "babylonjs/Rendering/index";
  65691. export * from "babylonjs/scene";
  65692. export * from "babylonjs/sceneComponent";
  65693. export * from "babylonjs/Sprites/index";
  65694. export * from "babylonjs/States/index";
  65695. export * from "babylonjs/Misc/index";
  65696. export * from "babylonjs/types";
  65697. }
  65698. declare module "babylonjs/Animations/pathCursor" {
  65699. import { Vector3 } from "babylonjs/Maths/math.vector";
  65700. import { Path2 } from "babylonjs/Maths/math.path";
  65701. /**
  65702. * A cursor which tracks a point on a path
  65703. */
  65704. export class PathCursor {
  65705. private path;
  65706. /**
  65707. * Stores path cursor callbacks for when an onchange event is triggered
  65708. */
  65709. private _onchange;
  65710. /**
  65711. * The value of the path cursor
  65712. */
  65713. value: number;
  65714. /**
  65715. * The animation array of the path cursor
  65716. */
  65717. animations: Animation[];
  65718. /**
  65719. * Initializes the path cursor
  65720. * @param path The path to track
  65721. */
  65722. constructor(path: Path2);
  65723. /**
  65724. * Gets the cursor point on the path
  65725. * @returns A point on the path cursor at the cursor location
  65726. */
  65727. getPoint(): Vector3;
  65728. /**
  65729. * Moves the cursor ahead by the step amount
  65730. * @param step The amount to move the cursor forward
  65731. * @returns This path cursor
  65732. */
  65733. moveAhead(step?: number): PathCursor;
  65734. /**
  65735. * Moves the cursor behind by the step amount
  65736. * @param step The amount to move the cursor back
  65737. * @returns This path cursor
  65738. */
  65739. moveBack(step?: number): PathCursor;
  65740. /**
  65741. * Moves the cursor by the step amount
  65742. * If the step amount is greater than one, an exception is thrown
  65743. * @param step The amount to move the cursor
  65744. * @returns This path cursor
  65745. */
  65746. move(step: number): PathCursor;
  65747. /**
  65748. * Ensures that the value is limited between zero and one
  65749. * @returns This path cursor
  65750. */
  65751. private ensureLimits;
  65752. /**
  65753. * Runs onchange callbacks on change (used by the animation engine)
  65754. * @returns This path cursor
  65755. */
  65756. private raiseOnChange;
  65757. /**
  65758. * Executes a function on change
  65759. * @param f A path cursor onchange callback
  65760. * @returns This path cursor
  65761. */
  65762. onchange(f: (cursor: PathCursor) => void): PathCursor;
  65763. }
  65764. }
  65765. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  65766. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  65767. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  65768. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  65769. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  65770. }
  65771. declare module "babylonjs/Engines/Processors/Expressions/index" {
  65772. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  65773. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  65774. }
  65775. declare module "babylonjs/Engines/Processors/index" {
  65776. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  65777. export * from "babylonjs/Engines/Processors/Expressions/index";
  65778. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  65779. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  65780. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  65781. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  65782. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  65783. export * from "babylonjs/Engines/Processors/shaderProcessor";
  65784. }
  65785. declare module "babylonjs/Legacy/legacy" {
  65786. import * as Babylon from "babylonjs/index";
  65787. export * from "babylonjs/index";
  65788. }
  65789. declare module "babylonjs/Shaders/blur.fragment" {
  65790. /** @hidden */
  65791. export var blurPixelShader: {
  65792. name: string;
  65793. shader: string;
  65794. };
  65795. }
  65796. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  65797. /** @hidden */
  65798. export var pointCloudVertexDeclaration: {
  65799. name: string;
  65800. shader: string;
  65801. };
  65802. }
  65803. declare module "babylonjs" {
  65804. export * from "babylonjs/Legacy/legacy";
  65805. }
  65806. declare module BABYLON {
  65807. /** Alias type for value that can be null */
  65808. export type Nullable<T> = T | null;
  65809. /**
  65810. * Alias type for number that are floats
  65811. * @ignorenaming
  65812. */
  65813. export type float = number;
  65814. /**
  65815. * Alias type for number that are doubles.
  65816. * @ignorenaming
  65817. */
  65818. export type double = number;
  65819. /**
  65820. * Alias type for number that are integer
  65821. * @ignorenaming
  65822. */
  65823. export type int = number;
  65824. /** Alias type for number array or Float32Array */
  65825. export type FloatArray = number[] | Float32Array;
  65826. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  65827. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  65828. /**
  65829. * Alias for types that can be used by a Buffer or VertexBuffer.
  65830. */
  65831. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  65832. /**
  65833. * Alias type for primitive types
  65834. * @ignorenaming
  65835. */
  65836. type Primitive = undefined | null | boolean | string | number | Function;
  65837. /**
  65838. * Type modifier to make all the properties of an object Readonly
  65839. */
  65840. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  65841. /**
  65842. * Type modifier to make all the properties of an object Readonly recursively
  65843. */
  65844. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  65845. /** @hidden */
  65846. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  65847. }
  65848. /** @hidden */
  65849. /** @hidden */
  65850. type DeepImmutableObject<T> = {
  65851. readonly [K in keyof T]: DeepImmutable<T[K]>;
  65852. };
  65853. }
  65854. declare module BABYLON {
  65855. /**
  65856. * A class serves as a medium between the observable and its observers
  65857. */
  65858. export class EventState {
  65859. /**
  65860. * Create a new EventState
  65861. * @param mask defines the mask associated with this state
  65862. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  65863. * @param target defines the original target of the state
  65864. * @param currentTarget defines the current target of the state
  65865. */
  65866. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  65867. /**
  65868. * Initialize the current event state
  65869. * @param mask defines the mask associated with this state
  65870. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  65871. * @param target defines the original target of the state
  65872. * @param currentTarget defines the current target of the state
  65873. * @returns the current event state
  65874. */
  65875. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  65876. /**
  65877. * An Observer can set this property to true to prevent subsequent observers of being notified
  65878. */
  65879. skipNextObservers: boolean;
  65880. /**
  65881. * Get the mask value that were used to trigger the event corresponding to this EventState object
  65882. */
  65883. mask: number;
  65884. /**
  65885. * The object that originally notified the event
  65886. */
  65887. target?: any;
  65888. /**
  65889. * The current object in the bubbling phase
  65890. */
  65891. currentTarget?: any;
  65892. /**
  65893. * This will be populated with the return value of the last function that was executed.
  65894. * If it is the first function in the callback chain it will be the event data.
  65895. */
  65896. lastReturnValue?: any;
  65897. }
  65898. /**
  65899. * Represent an Observer registered to a given Observable object.
  65900. */
  65901. export class Observer<T> {
  65902. /**
  65903. * Defines the callback to call when the observer is notified
  65904. */
  65905. callback: (eventData: T, eventState: EventState) => void;
  65906. /**
  65907. * Defines the mask of the observer (used to filter notifications)
  65908. */
  65909. mask: number;
  65910. /**
  65911. * Defines the current scope used to restore the JS context
  65912. */
  65913. scope: any;
  65914. /** @hidden */
  65915. _willBeUnregistered: boolean;
  65916. /**
  65917. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  65918. */
  65919. unregisterOnNextCall: boolean;
  65920. /**
  65921. * Creates a new observer
  65922. * @param callback defines the callback to call when the observer is notified
  65923. * @param mask defines the mask of the observer (used to filter notifications)
  65924. * @param scope defines the current scope used to restore the JS context
  65925. */
  65926. constructor(
  65927. /**
  65928. * Defines the callback to call when the observer is notified
  65929. */
  65930. callback: (eventData: T, eventState: EventState) => void,
  65931. /**
  65932. * Defines the mask of the observer (used to filter notifications)
  65933. */
  65934. mask: number,
  65935. /**
  65936. * Defines the current scope used to restore the JS context
  65937. */
  65938. scope?: any);
  65939. }
  65940. /**
  65941. * Represent a list of observers registered to multiple Observables object.
  65942. */
  65943. export class MultiObserver<T> {
  65944. private _observers;
  65945. private _observables;
  65946. /**
  65947. * Release associated resources
  65948. */
  65949. dispose(): void;
  65950. /**
  65951. * Raise a callback when one of the observable will notify
  65952. * @param observables defines a list of observables to watch
  65953. * @param callback defines the callback to call on notification
  65954. * @param mask defines the mask used to filter notifications
  65955. * @param scope defines the current scope used to restore the JS context
  65956. * @returns the new MultiObserver
  65957. */
  65958. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  65959. }
  65960. /**
  65961. * The Observable class is a simple implementation of the Observable pattern.
  65962. *
  65963. * 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.
  65964. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  65965. * 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).
  65966. * 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.
  65967. */
  65968. export class Observable<T> {
  65969. private _observers;
  65970. private _eventState;
  65971. private _onObserverAdded;
  65972. /**
  65973. * Gets the list of observers
  65974. */
  65975. readonly observers: Array<Observer<T>>;
  65976. /**
  65977. * Creates a new observable
  65978. * @param onObserverAdded defines a callback to call when a new observer is added
  65979. */
  65980. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  65981. /**
  65982. * Create a new Observer with the specified callback
  65983. * @param callback the callback that will be executed for that Observer
  65984. * @param mask the mask used to filter observers
  65985. * @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.
  65986. * @param scope optional scope for the callback to be called from
  65987. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  65988. * @returns the new observer created for the callback
  65989. */
  65990. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  65991. /**
  65992. * Create a new Observer with the specified callback and unregisters after the next notification
  65993. * @param callback the callback that will be executed for that Observer
  65994. * @returns the new observer created for the callback
  65995. */
  65996. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  65997. /**
  65998. * Remove an Observer from the Observable object
  65999. * @param observer the instance of the Observer to remove
  66000. * @returns false if it doesn't belong to this Observable
  66001. */
  66002. remove(observer: Nullable<Observer<T>>): boolean;
  66003. /**
  66004. * Remove a callback from the Observable object
  66005. * @param callback the callback to remove
  66006. * @param scope optional scope. If used only the callbacks with this scope will be removed
  66007. * @returns false if it doesn't belong to this Observable
  66008. */
  66009. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  66010. private _deferUnregister;
  66011. private _remove;
  66012. /**
  66013. * Moves the observable to the top of the observer list making it get called first when notified
  66014. * @param observer the observer to move
  66015. */
  66016. makeObserverTopPriority(observer: Observer<T>): void;
  66017. /**
  66018. * Moves the observable to the bottom of the observer list making it get called last when notified
  66019. * @param observer the observer to move
  66020. */
  66021. makeObserverBottomPriority(observer: Observer<T>): void;
  66022. /**
  66023. * Notify all Observers by calling their respective callback with the given data
  66024. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  66025. * @param eventData defines the data to send to all observers
  66026. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  66027. * @param target defines the original target of the state
  66028. * @param currentTarget defines the current target of the state
  66029. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  66030. */
  66031. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  66032. /**
  66033. * Calling this will execute each callback, expecting it to be a promise or return a value.
  66034. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  66035. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  66036. * and it is crucial that all callbacks will be executed.
  66037. * The order of the callbacks is kept, callbacks are not executed parallel.
  66038. *
  66039. * @param eventData The data to be sent to each callback
  66040. * @param mask is used to filter observers defaults to -1
  66041. * @param target defines the callback target (see EventState)
  66042. * @param currentTarget defines he current object in the bubbling phase
  66043. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  66044. */
  66045. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  66046. /**
  66047. * Notify a specific observer
  66048. * @param observer defines the observer to notify
  66049. * @param eventData defines the data to be sent to each callback
  66050. * @param mask is used to filter observers defaults to -1
  66051. */
  66052. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  66053. /**
  66054. * Gets a boolean indicating if the observable has at least one observer
  66055. * @returns true is the Observable has at least one Observer registered
  66056. */
  66057. hasObservers(): boolean;
  66058. /**
  66059. * Clear the list of observers
  66060. */
  66061. clear(): void;
  66062. /**
  66063. * Clone the current observable
  66064. * @returns a new observable
  66065. */
  66066. clone(): Observable<T>;
  66067. /**
  66068. * Does this observable handles observer registered with a given mask
  66069. * @param mask defines the mask to be tested
  66070. * @return whether or not one observer registered with the given mask is handeled
  66071. **/
  66072. hasSpecificMask(mask?: number): boolean;
  66073. }
  66074. }
  66075. declare module BABYLON {
  66076. /**
  66077. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  66078. * Babylon.js
  66079. */
  66080. export class DomManagement {
  66081. /**
  66082. * Checks if the window object exists
  66083. * @returns true if the window object exists
  66084. */
  66085. static IsWindowObjectExist(): boolean;
  66086. /**
  66087. * Checks if the navigator object exists
  66088. * @returns true if the navigator object exists
  66089. */
  66090. static IsNavigatorAvailable(): boolean;
  66091. /**
  66092. * Extracts text content from a DOM element hierarchy
  66093. * @param element defines the root element
  66094. * @returns a string
  66095. */
  66096. static GetDOMTextContent(element: HTMLElement): string;
  66097. }
  66098. }
  66099. declare module BABYLON {
  66100. /**
  66101. * Logger used througouht the application to allow configuration of
  66102. * the log level required for the messages.
  66103. */
  66104. export class Logger {
  66105. /**
  66106. * No log
  66107. */
  66108. static readonly NoneLogLevel: number;
  66109. /**
  66110. * Only message logs
  66111. */
  66112. static readonly MessageLogLevel: number;
  66113. /**
  66114. * Only warning logs
  66115. */
  66116. static readonly WarningLogLevel: number;
  66117. /**
  66118. * Only error logs
  66119. */
  66120. static readonly ErrorLogLevel: number;
  66121. /**
  66122. * All logs
  66123. */
  66124. static readonly AllLogLevel: number;
  66125. private static _LogCache;
  66126. /**
  66127. * Gets a value indicating the number of loading errors
  66128. * @ignorenaming
  66129. */
  66130. static errorsCount: number;
  66131. /**
  66132. * Callback called when a new log is added
  66133. */
  66134. static OnNewCacheEntry: (entry: string) => void;
  66135. private static _AddLogEntry;
  66136. private static _FormatMessage;
  66137. private static _LogDisabled;
  66138. private static _LogEnabled;
  66139. private static _WarnDisabled;
  66140. private static _WarnEnabled;
  66141. private static _ErrorDisabled;
  66142. private static _ErrorEnabled;
  66143. /**
  66144. * Log a message to the console
  66145. */
  66146. static Log: (message: string) => void;
  66147. /**
  66148. * Write a warning message to the console
  66149. */
  66150. static Warn: (message: string) => void;
  66151. /**
  66152. * Write an error message to the console
  66153. */
  66154. static Error: (message: string) => void;
  66155. /**
  66156. * Gets current log cache (list of logs)
  66157. */
  66158. static readonly LogCache: string;
  66159. /**
  66160. * Clears the log cache
  66161. */
  66162. static ClearLogCache(): void;
  66163. /**
  66164. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  66165. */
  66166. static LogLevels: number;
  66167. }
  66168. }
  66169. declare module BABYLON {
  66170. /** @hidden */
  66171. export class _TypeStore {
  66172. /** @hidden */
  66173. static RegisteredTypes: {
  66174. [key: string]: Object;
  66175. };
  66176. /** @hidden */
  66177. static GetClass(fqdn: string): any;
  66178. }
  66179. }
  66180. declare module BABYLON {
  66181. /**
  66182. * Class containing a set of static utilities functions for deep copy.
  66183. */
  66184. export class DeepCopier {
  66185. /**
  66186. * Tries to copy an object by duplicating every property
  66187. * @param source defines the source object
  66188. * @param destination defines the target object
  66189. * @param doNotCopyList defines a list of properties to avoid
  66190. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  66191. */
  66192. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  66193. }
  66194. }
  66195. declare module BABYLON {
  66196. /**
  66197. * Class containing a set of static utilities functions for precision date
  66198. */
  66199. export class PrecisionDate {
  66200. /**
  66201. * Gets either window.performance.now() if supported or Date.now() else
  66202. */
  66203. static readonly Now: number;
  66204. }
  66205. }
  66206. declare module BABYLON {
  66207. /** @hidden */
  66208. export class _DevTools {
  66209. static WarnImport(name: string): string;
  66210. }
  66211. }
  66212. declare module BABYLON {
  66213. /**
  66214. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  66215. */
  66216. export class WebRequest {
  66217. private _xhr;
  66218. /**
  66219. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  66220. * i.e. when loading files, where the server/service expects an Authorization header
  66221. */
  66222. static CustomRequestHeaders: {
  66223. [key: string]: string;
  66224. };
  66225. /**
  66226. * Add callback functions in this array to update all the requests before they get sent to the network
  66227. */
  66228. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  66229. private _injectCustomRequestHeaders;
  66230. /**
  66231. * Gets or sets a function to be called when loading progress changes
  66232. */
  66233. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  66234. /**
  66235. * Returns client's state
  66236. */
  66237. readonly readyState: number;
  66238. /**
  66239. * Returns client's status
  66240. */
  66241. readonly status: number;
  66242. /**
  66243. * Returns client's status as a text
  66244. */
  66245. readonly statusText: string;
  66246. /**
  66247. * Returns client's response
  66248. */
  66249. readonly response: any;
  66250. /**
  66251. * Returns client's response url
  66252. */
  66253. readonly responseURL: string;
  66254. /**
  66255. * Returns client's response as text
  66256. */
  66257. readonly responseText: string;
  66258. /**
  66259. * Gets or sets the expected response type
  66260. */
  66261. responseType: XMLHttpRequestResponseType;
  66262. /** @hidden */
  66263. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  66264. /** @hidden */
  66265. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  66266. /**
  66267. * Cancels any network activity
  66268. */
  66269. abort(): void;
  66270. /**
  66271. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  66272. * @param body defines an optional request body
  66273. */
  66274. send(body?: Document | BodyInit | null): void;
  66275. /**
  66276. * Sets the request method, request URL
  66277. * @param method defines the method to use (GET, POST, etc..)
  66278. * @param url defines the url to connect with
  66279. */
  66280. open(method: string, url: string): void;
  66281. }
  66282. }
  66283. declare module BABYLON {
  66284. /**
  66285. * File request interface
  66286. */
  66287. export interface IFileRequest {
  66288. /**
  66289. * Raised when the request is complete (success or error).
  66290. */
  66291. onCompleteObservable: Observable<IFileRequest>;
  66292. /**
  66293. * Aborts the request for a file.
  66294. */
  66295. abort: () => void;
  66296. }
  66297. }
  66298. declare module BABYLON {
  66299. /**
  66300. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  66301. */
  66302. export class PerformanceMonitor {
  66303. private _enabled;
  66304. private _rollingFrameTime;
  66305. private _lastFrameTimeMs;
  66306. /**
  66307. * constructor
  66308. * @param frameSampleSize The number of samples required to saturate the sliding window
  66309. */
  66310. constructor(frameSampleSize?: number);
  66311. /**
  66312. * Samples current frame
  66313. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  66314. */
  66315. sampleFrame(timeMs?: number): void;
  66316. /**
  66317. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  66318. */
  66319. readonly averageFrameTime: number;
  66320. /**
  66321. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  66322. */
  66323. readonly averageFrameTimeVariance: number;
  66324. /**
  66325. * Returns the frame time of the most recent frame
  66326. */
  66327. readonly instantaneousFrameTime: number;
  66328. /**
  66329. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  66330. */
  66331. readonly averageFPS: number;
  66332. /**
  66333. * Returns the average framerate in frames per second using the most recent frame time
  66334. */
  66335. readonly instantaneousFPS: number;
  66336. /**
  66337. * Returns true if enough samples have been taken to completely fill the sliding window
  66338. */
  66339. readonly isSaturated: boolean;
  66340. /**
  66341. * Enables contributions to the sliding window sample set
  66342. */
  66343. enable(): void;
  66344. /**
  66345. * Disables contributions to the sliding window sample set
  66346. * Samples will not be interpolated over the disabled period
  66347. */
  66348. disable(): void;
  66349. /**
  66350. * Returns true if sampling is enabled
  66351. */
  66352. readonly isEnabled: boolean;
  66353. /**
  66354. * Resets performance monitor
  66355. */
  66356. reset(): void;
  66357. }
  66358. /**
  66359. * RollingAverage
  66360. *
  66361. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  66362. */
  66363. export class RollingAverage {
  66364. /**
  66365. * Current average
  66366. */
  66367. average: number;
  66368. /**
  66369. * Current variance
  66370. */
  66371. variance: number;
  66372. protected _samples: Array<number>;
  66373. protected _sampleCount: number;
  66374. protected _pos: number;
  66375. protected _m2: number;
  66376. /**
  66377. * constructor
  66378. * @param length The number of samples required to saturate the sliding window
  66379. */
  66380. constructor(length: number);
  66381. /**
  66382. * Adds a sample to the sample set
  66383. * @param v The sample value
  66384. */
  66385. add(v: number): void;
  66386. /**
  66387. * Returns previously added values or null if outside of history or outside the sliding window domain
  66388. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  66389. * @return Value previously recorded with add() or null if outside of range
  66390. */
  66391. history(i: number): number;
  66392. /**
  66393. * Returns true if enough samples have been taken to completely fill the sliding window
  66394. * @return true if sample-set saturated
  66395. */
  66396. isSaturated(): boolean;
  66397. /**
  66398. * Resets the rolling average (equivalent to 0 samples taken so far)
  66399. */
  66400. reset(): void;
  66401. /**
  66402. * Wraps a value around the sample range boundaries
  66403. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  66404. * @return Wrapped position in sample range
  66405. */
  66406. protected _wrapPosition(i: number): number;
  66407. }
  66408. }
  66409. declare module BABYLON {
  66410. /**
  66411. * This class implement a typical dictionary using a string as key and the generic type T as value.
  66412. * The underlying implementation relies on an associative array to ensure the best performances.
  66413. * The value can be anything including 'null' but except 'undefined'
  66414. */
  66415. export class StringDictionary<T> {
  66416. /**
  66417. * This will clear this dictionary and copy the content from the 'source' one.
  66418. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  66419. * @param source the dictionary to take the content from and copy to this dictionary
  66420. */
  66421. copyFrom(source: StringDictionary<T>): void;
  66422. /**
  66423. * Get a value based from its key
  66424. * @param key the given key to get the matching value from
  66425. * @return the value if found, otherwise undefined is returned
  66426. */
  66427. get(key: string): T | undefined;
  66428. /**
  66429. * Get a value from its key or add it if it doesn't exist.
  66430. * This method will ensure you that a given key/data will be present in the dictionary.
  66431. * @param key the given key to get the matching value from
  66432. * @param factory the factory that will create the value if the key is not present in the dictionary.
  66433. * The factory will only be invoked if there's no data for the given key.
  66434. * @return the value corresponding to the key.
  66435. */
  66436. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  66437. /**
  66438. * Get a value from its key if present in the dictionary otherwise add it
  66439. * @param key the key to get the value from
  66440. * @param val if there's no such key/value pair in the dictionary add it with this value
  66441. * @return the value corresponding to the key
  66442. */
  66443. getOrAdd(key: string, val: T): T;
  66444. /**
  66445. * Check if there's a given key in the dictionary
  66446. * @param key the key to check for
  66447. * @return true if the key is present, false otherwise
  66448. */
  66449. contains(key: string): boolean;
  66450. /**
  66451. * Add a new key and its corresponding value
  66452. * @param key the key to add
  66453. * @param value the value corresponding to the key
  66454. * @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
  66455. */
  66456. add(key: string, value: T): boolean;
  66457. /**
  66458. * Update a specific value associated to a key
  66459. * @param key defines the key to use
  66460. * @param value defines the value to store
  66461. * @returns true if the value was updated (or false if the key was not found)
  66462. */
  66463. set(key: string, value: T): boolean;
  66464. /**
  66465. * Get the element of the given key and remove it from the dictionary
  66466. * @param key defines the key to search
  66467. * @returns the value associated with the key or null if not found
  66468. */
  66469. getAndRemove(key: string): Nullable<T>;
  66470. /**
  66471. * Remove a key/value from the dictionary.
  66472. * @param key the key to remove
  66473. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  66474. */
  66475. remove(key: string): boolean;
  66476. /**
  66477. * Clear the whole content of the dictionary
  66478. */
  66479. clear(): void;
  66480. /**
  66481. * Gets the current count
  66482. */
  66483. readonly count: number;
  66484. /**
  66485. * Execute a callback on each key/val of the dictionary.
  66486. * Note that you can remove any element in this dictionary in the callback implementation
  66487. * @param callback the callback to execute on a given key/value pair
  66488. */
  66489. forEach(callback: (key: string, val: T) => void): void;
  66490. /**
  66491. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  66492. * If the callback returns null or undefined the method will iterate to the next key/value pair
  66493. * Note that you can remove any element in this dictionary in the callback implementation
  66494. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  66495. * @returns the first item
  66496. */
  66497. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  66498. private _count;
  66499. private _data;
  66500. }
  66501. }
  66502. declare module BABYLON {
  66503. /**
  66504. * Class used to store gfx data (like WebGLBuffer)
  66505. */
  66506. export class DataBuffer {
  66507. /**
  66508. * Gets or sets the number of objects referencing this buffer
  66509. */
  66510. references: number;
  66511. /** Gets or sets the size of the underlying buffer */
  66512. capacity: number;
  66513. /**
  66514. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  66515. */
  66516. is32Bits: boolean;
  66517. /**
  66518. * Gets the underlying buffer
  66519. */
  66520. readonly underlyingResource: any;
  66521. }
  66522. }
  66523. declare module BABYLON {
  66524. /**
  66525. * Class used to store data that will be store in GPU memory
  66526. */
  66527. export class Buffer {
  66528. private _engine;
  66529. private _buffer;
  66530. /** @hidden */
  66531. _data: Nullable<DataArray>;
  66532. private _updatable;
  66533. private _instanced;
  66534. /**
  66535. * Gets the byte stride.
  66536. */
  66537. readonly byteStride: number;
  66538. /**
  66539. * Constructor
  66540. * @param engine the engine
  66541. * @param data the data to use for this buffer
  66542. * @param updatable whether the data is updatable
  66543. * @param stride the stride (optional)
  66544. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  66545. * @param instanced whether the buffer is instanced (optional)
  66546. * @param useBytes set to true if the stride in in bytes (optional)
  66547. */
  66548. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  66549. /**
  66550. * Create a new VertexBuffer based on the current buffer
  66551. * @param kind defines the vertex buffer kind (position, normal, etc.)
  66552. * @param offset defines offset in the buffer (0 by default)
  66553. * @param size defines the size in floats of attributes (position is 3 for instance)
  66554. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  66555. * @param instanced defines if the vertex buffer contains indexed data
  66556. * @param useBytes defines if the offset and stride are in bytes
  66557. * @returns the new vertex buffer
  66558. */
  66559. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  66560. /**
  66561. * Gets a boolean indicating if the Buffer is updatable?
  66562. * @returns true if the buffer is updatable
  66563. */
  66564. isUpdatable(): boolean;
  66565. /**
  66566. * Gets current buffer's data
  66567. * @returns a DataArray or null
  66568. */
  66569. getData(): Nullable<DataArray>;
  66570. /**
  66571. * Gets underlying native buffer
  66572. * @returns underlying native buffer
  66573. */
  66574. getBuffer(): Nullable<DataBuffer>;
  66575. /**
  66576. * Gets the stride in float32 units (i.e. byte stride / 4).
  66577. * May not be an integer if the byte stride is not divisible by 4.
  66578. * DEPRECATED. Use byteStride instead.
  66579. * @returns the stride in float32 units
  66580. */
  66581. getStrideSize(): number;
  66582. /**
  66583. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  66584. * @param data defines the data to store
  66585. */
  66586. create(data?: Nullable<DataArray>): void;
  66587. /** @hidden */
  66588. _rebuild(): void;
  66589. /**
  66590. * Update current buffer data
  66591. * @param data defines the data to store
  66592. */
  66593. update(data: DataArray): void;
  66594. /**
  66595. * Updates the data directly.
  66596. * @param data the new data
  66597. * @param offset the new offset
  66598. * @param vertexCount the vertex count (optional)
  66599. * @param useBytes set to true if the offset is in bytes
  66600. */
  66601. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  66602. /**
  66603. * Release all resources
  66604. */
  66605. dispose(): void;
  66606. }
  66607. /**
  66608. * Specialized buffer used to store vertex data
  66609. */
  66610. export class VertexBuffer {
  66611. /** @hidden */
  66612. _buffer: Buffer;
  66613. private _kind;
  66614. private _size;
  66615. private _ownsBuffer;
  66616. private _instanced;
  66617. private _instanceDivisor;
  66618. /**
  66619. * The byte type.
  66620. */
  66621. static readonly BYTE: number;
  66622. /**
  66623. * The unsigned byte type.
  66624. */
  66625. static readonly UNSIGNED_BYTE: number;
  66626. /**
  66627. * The short type.
  66628. */
  66629. static readonly SHORT: number;
  66630. /**
  66631. * The unsigned short type.
  66632. */
  66633. static readonly UNSIGNED_SHORT: number;
  66634. /**
  66635. * The integer type.
  66636. */
  66637. static readonly INT: number;
  66638. /**
  66639. * The unsigned integer type.
  66640. */
  66641. static readonly UNSIGNED_INT: number;
  66642. /**
  66643. * The float type.
  66644. */
  66645. static readonly FLOAT: number;
  66646. /**
  66647. * Gets or sets the instance divisor when in instanced mode
  66648. */
  66649. instanceDivisor: number;
  66650. /**
  66651. * Gets the byte stride.
  66652. */
  66653. readonly byteStride: number;
  66654. /**
  66655. * Gets the byte offset.
  66656. */
  66657. readonly byteOffset: number;
  66658. /**
  66659. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  66660. */
  66661. readonly normalized: boolean;
  66662. /**
  66663. * Gets the data type of each component in the array.
  66664. */
  66665. readonly type: number;
  66666. /**
  66667. * Constructor
  66668. * @param engine the engine
  66669. * @param data the data to use for this vertex buffer
  66670. * @param kind the vertex buffer kind
  66671. * @param updatable whether the data is updatable
  66672. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  66673. * @param stride the stride (optional)
  66674. * @param instanced whether the buffer is instanced (optional)
  66675. * @param offset the offset of the data (optional)
  66676. * @param size the number of components (optional)
  66677. * @param type the type of the component (optional)
  66678. * @param normalized whether the data contains normalized data (optional)
  66679. * @param useBytes set to true if stride and offset are in bytes (optional)
  66680. */
  66681. 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);
  66682. /** @hidden */
  66683. _rebuild(): void;
  66684. /**
  66685. * Returns the kind of the VertexBuffer (string)
  66686. * @returns a string
  66687. */
  66688. getKind(): string;
  66689. /**
  66690. * Gets a boolean indicating if the VertexBuffer is updatable?
  66691. * @returns true if the buffer is updatable
  66692. */
  66693. isUpdatable(): boolean;
  66694. /**
  66695. * Gets current buffer's data
  66696. * @returns a DataArray or null
  66697. */
  66698. getData(): Nullable<DataArray>;
  66699. /**
  66700. * Gets underlying native buffer
  66701. * @returns underlying native buffer
  66702. */
  66703. getBuffer(): Nullable<DataBuffer>;
  66704. /**
  66705. * Gets the stride in float32 units (i.e. byte stride / 4).
  66706. * May not be an integer if the byte stride is not divisible by 4.
  66707. * DEPRECATED. Use byteStride instead.
  66708. * @returns the stride in float32 units
  66709. */
  66710. getStrideSize(): number;
  66711. /**
  66712. * Returns the offset as a multiple of the type byte length.
  66713. * DEPRECATED. Use byteOffset instead.
  66714. * @returns the offset in bytes
  66715. */
  66716. getOffset(): number;
  66717. /**
  66718. * Returns the number of components per vertex attribute (integer)
  66719. * @returns the size in float
  66720. */
  66721. getSize(): number;
  66722. /**
  66723. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  66724. * @returns true if this buffer is instanced
  66725. */
  66726. getIsInstanced(): boolean;
  66727. /**
  66728. * Returns the instancing divisor, zero for non-instanced (integer).
  66729. * @returns a number
  66730. */
  66731. getInstanceDivisor(): number;
  66732. /**
  66733. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  66734. * @param data defines the data to store
  66735. */
  66736. create(data?: DataArray): void;
  66737. /**
  66738. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  66739. * This function will create a new buffer if the current one is not updatable
  66740. * @param data defines the data to store
  66741. */
  66742. update(data: DataArray): void;
  66743. /**
  66744. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  66745. * Returns the directly updated WebGLBuffer.
  66746. * @param data the new data
  66747. * @param offset the new offset
  66748. * @param useBytes set to true if the offset is in bytes
  66749. */
  66750. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  66751. /**
  66752. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  66753. */
  66754. dispose(): void;
  66755. /**
  66756. * Enumerates each value of this vertex buffer as numbers.
  66757. * @param count the number of values to enumerate
  66758. * @param callback the callback function called for each value
  66759. */
  66760. forEach(count: number, callback: (value: number, index: number) => void): void;
  66761. /**
  66762. * Positions
  66763. */
  66764. static readonly PositionKind: string;
  66765. /**
  66766. * Normals
  66767. */
  66768. static readonly NormalKind: string;
  66769. /**
  66770. * Tangents
  66771. */
  66772. static readonly TangentKind: string;
  66773. /**
  66774. * Texture coordinates
  66775. */
  66776. static readonly UVKind: string;
  66777. /**
  66778. * Texture coordinates 2
  66779. */
  66780. static readonly UV2Kind: string;
  66781. /**
  66782. * Texture coordinates 3
  66783. */
  66784. static readonly UV3Kind: string;
  66785. /**
  66786. * Texture coordinates 4
  66787. */
  66788. static readonly UV4Kind: string;
  66789. /**
  66790. * Texture coordinates 5
  66791. */
  66792. static readonly UV5Kind: string;
  66793. /**
  66794. * Texture coordinates 6
  66795. */
  66796. static readonly UV6Kind: string;
  66797. /**
  66798. * Colors
  66799. */
  66800. static readonly ColorKind: string;
  66801. /**
  66802. * Matrix indices (for bones)
  66803. */
  66804. static readonly MatricesIndicesKind: string;
  66805. /**
  66806. * Matrix weights (for bones)
  66807. */
  66808. static readonly MatricesWeightsKind: string;
  66809. /**
  66810. * Additional matrix indices (for bones)
  66811. */
  66812. static readonly MatricesIndicesExtraKind: string;
  66813. /**
  66814. * Additional matrix weights (for bones)
  66815. */
  66816. static readonly MatricesWeightsExtraKind: string;
  66817. /**
  66818. * Deduces the stride given a kind.
  66819. * @param kind The kind string to deduce
  66820. * @returns The deduced stride
  66821. */
  66822. static DeduceStride(kind: string): number;
  66823. /**
  66824. * Gets the byte length of the given type.
  66825. * @param type the type
  66826. * @returns the number of bytes
  66827. */
  66828. static GetTypeByteLength(type: number): number;
  66829. /**
  66830. * Enumerates each value of the given parameters as numbers.
  66831. * @param data the data to enumerate
  66832. * @param byteOffset the byte offset of the data
  66833. * @param byteStride the byte stride of the data
  66834. * @param componentCount the number of components per element
  66835. * @param componentType the type of the component
  66836. * @param count the number of values to enumerate
  66837. * @param normalized whether the data is normalized
  66838. * @param callback the callback function called for each value
  66839. */
  66840. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  66841. private static _GetFloatValue;
  66842. }
  66843. }
  66844. declare module BABYLON {
  66845. /**
  66846. * Scalar computation library
  66847. */
  66848. export class Scalar {
  66849. /**
  66850. * Two pi constants convenient for computation.
  66851. */
  66852. static TwoPi: number;
  66853. /**
  66854. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  66855. * @param a number
  66856. * @param b number
  66857. * @param epsilon (default = 1.401298E-45)
  66858. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  66859. */
  66860. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  66861. /**
  66862. * Returns a string : the upper case translation of the number i to hexadecimal.
  66863. * @param i number
  66864. * @returns the upper case translation of the number i to hexadecimal.
  66865. */
  66866. static ToHex(i: number): string;
  66867. /**
  66868. * Returns -1 if value is negative and +1 is value is positive.
  66869. * @param value the value
  66870. * @returns the value itself if it's equal to zero.
  66871. */
  66872. static Sign(value: number): number;
  66873. /**
  66874. * Returns the value itself if it's between min and max.
  66875. * Returns min if the value is lower than min.
  66876. * Returns max if the value is greater than max.
  66877. * @param value the value to clmap
  66878. * @param min the min value to clamp to (default: 0)
  66879. * @param max the max value to clamp to (default: 1)
  66880. * @returns the clamped value
  66881. */
  66882. static Clamp(value: number, min?: number, max?: number): number;
  66883. /**
  66884. * the log2 of value.
  66885. * @param value the value to compute log2 of
  66886. * @returns the log2 of value.
  66887. */
  66888. static Log2(value: number): number;
  66889. /**
  66890. * Loops the value, so that it is never larger than length and never smaller than 0.
  66891. *
  66892. * This is similar to the modulo operator but it works with floating point numbers.
  66893. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  66894. * With t = 5 and length = 2.5, the result would be 0.0.
  66895. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  66896. * @param value the value
  66897. * @param length the length
  66898. * @returns the looped value
  66899. */
  66900. static Repeat(value: number, length: number): number;
  66901. /**
  66902. * Normalize the value between 0.0 and 1.0 using min and max values
  66903. * @param value value to normalize
  66904. * @param min max to normalize between
  66905. * @param max min to normalize between
  66906. * @returns the normalized value
  66907. */
  66908. static Normalize(value: number, min: number, max: number): number;
  66909. /**
  66910. * Denormalize the value from 0.0 and 1.0 using min and max values
  66911. * @param normalized value to denormalize
  66912. * @param min max to denormalize between
  66913. * @param max min to denormalize between
  66914. * @returns the denormalized value
  66915. */
  66916. static Denormalize(normalized: number, min: number, max: number): number;
  66917. /**
  66918. * Calculates the shortest difference between two given angles given in degrees.
  66919. * @param current current angle in degrees
  66920. * @param target target angle in degrees
  66921. * @returns the delta
  66922. */
  66923. static DeltaAngle(current: number, target: number): number;
  66924. /**
  66925. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  66926. * @param tx value
  66927. * @param length length
  66928. * @returns The returned value will move back and forth between 0 and length
  66929. */
  66930. static PingPong(tx: number, length: number): number;
  66931. /**
  66932. * Interpolates between min and max with smoothing at the limits.
  66933. *
  66934. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  66935. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  66936. * @param from from
  66937. * @param to to
  66938. * @param tx value
  66939. * @returns the smooth stepped value
  66940. */
  66941. static SmoothStep(from: number, to: number, tx: number): number;
  66942. /**
  66943. * Moves a value current towards target.
  66944. *
  66945. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  66946. * Negative values of maxDelta pushes the value away from target.
  66947. * @param current current value
  66948. * @param target target value
  66949. * @param maxDelta max distance to move
  66950. * @returns resulting value
  66951. */
  66952. static MoveTowards(current: number, target: number, maxDelta: number): number;
  66953. /**
  66954. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  66955. *
  66956. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  66957. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  66958. * @param current current value
  66959. * @param target target value
  66960. * @param maxDelta max distance to move
  66961. * @returns resulting angle
  66962. */
  66963. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  66964. /**
  66965. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  66966. * @param start start value
  66967. * @param end target value
  66968. * @param amount amount to lerp between
  66969. * @returns the lerped value
  66970. */
  66971. static Lerp(start: number, end: number, amount: number): number;
  66972. /**
  66973. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  66974. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  66975. * @param start start value
  66976. * @param end target value
  66977. * @param amount amount to lerp between
  66978. * @returns the lerped value
  66979. */
  66980. static LerpAngle(start: number, end: number, amount: number): number;
  66981. /**
  66982. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  66983. * @param a start value
  66984. * @param b target value
  66985. * @param value value between a and b
  66986. * @returns the inverseLerp value
  66987. */
  66988. static InverseLerp(a: number, b: number, value: number): number;
  66989. /**
  66990. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  66991. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  66992. * @param value1 spline value
  66993. * @param tangent1 spline value
  66994. * @param value2 spline value
  66995. * @param tangent2 spline value
  66996. * @param amount input value
  66997. * @returns hermite result
  66998. */
  66999. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  67000. /**
  67001. * Returns a random float number between and min and max values
  67002. * @param min min value of random
  67003. * @param max max value of random
  67004. * @returns random value
  67005. */
  67006. static RandomRange(min: number, max: number): number;
  67007. /**
  67008. * This function returns percentage of a number in a given range.
  67009. *
  67010. * RangeToPercent(40,20,60) will return 0.5 (50%)
  67011. * RangeToPercent(34,0,100) will return 0.34 (34%)
  67012. * @param number to convert to percentage
  67013. * @param min min range
  67014. * @param max max range
  67015. * @returns the percentage
  67016. */
  67017. static RangeToPercent(number: number, min: number, max: number): number;
  67018. /**
  67019. * This function returns number that corresponds to the percentage in a given range.
  67020. *
  67021. * PercentToRange(0.34,0,100) will return 34.
  67022. * @param percent to convert to number
  67023. * @param min min range
  67024. * @param max max range
  67025. * @returns the number
  67026. */
  67027. static PercentToRange(percent: number, min: number, max: number): number;
  67028. /**
  67029. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  67030. * @param angle The angle to normalize in radian.
  67031. * @return The converted angle.
  67032. */
  67033. static NormalizeRadians(angle: number): number;
  67034. }
  67035. }
  67036. declare module BABYLON {
  67037. /**
  67038. * Constant used to convert a value to gamma space
  67039. * @ignorenaming
  67040. */
  67041. export const ToGammaSpace: number;
  67042. /**
  67043. * Constant used to convert a value to linear space
  67044. * @ignorenaming
  67045. */
  67046. export const ToLinearSpace = 2.2;
  67047. /**
  67048. * Constant used to define the minimal number value in Babylon.js
  67049. * @ignorenaming
  67050. */
  67051. let Epsilon: number;
  67052. }
  67053. declare module BABYLON {
  67054. /**
  67055. * Class used to represent a viewport on screen
  67056. */
  67057. export class Viewport {
  67058. /** viewport left coordinate */
  67059. x: number;
  67060. /** viewport top coordinate */
  67061. y: number;
  67062. /**viewport width */
  67063. width: number;
  67064. /** viewport height */
  67065. height: number;
  67066. /**
  67067. * Creates a Viewport object located at (x, y) and sized (width, height)
  67068. * @param x defines viewport left coordinate
  67069. * @param y defines viewport top coordinate
  67070. * @param width defines the viewport width
  67071. * @param height defines the viewport height
  67072. */
  67073. constructor(
  67074. /** viewport left coordinate */
  67075. x: number,
  67076. /** viewport top coordinate */
  67077. y: number,
  67078. /**viewport width */
  67079. width: number,
  67080. /** viewport height */
  67081. height: number);
  67082. /**
  67083. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  67084. * @param renderWidth defines the rendering width
  67085. * @param renderHeight defines the rendering height
  67086. * @returns a new Viewport
  67087. */
  67088. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  67089. /**
  67090. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  67091. * @param renderWidth defines the rendering width
  67092. * @param renderHeight defines the rendering height
  67093. * @param ref defines the target viewport
  67094. * @returns the current viewport
  67095. */
  67096. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  67097. /**
  67098. * Returns a new Viewport copied from the current one
  67099. * @returns a new Viewport
  67100. */
  67101. clone(): Viewport;
  67102. }
  67103. }
  67104. declare module BABYLON {
  67105. /**
  67106. * Class containing a set of static utilities functions for arrays.
  67107. */
  67108. export class ArrayTools {
  67109. /**
  67110. * Returns an array of the given size filled with element built from the given constructor and the paramters
  67111. * @param size the number of element to construct and put in the array
  67112. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  67113. * @returns a new array filled with new objects
  67114. */
  67115. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  67116. }
  67117. }
  67118. declare module BABYLON {
  67119. /**
  67120. * @hidden
  67121. */
  67122. export interface IColor4Like {
  67123. r: float;
  67124. g: float;
  67125. b: float;
  67126. a: float;
  67127. }
  67128. /**
  67129. * @hidden
  67130. */
  67131. export interface IColor3Like {
  67132. r: float;
  67133. g: float;
  67134. b: float;
  67135. }
  67136. /**
  67137. * @hidden
  67138. */
  67139. export interface IVector4Like {
  67140. x: float;
  67141. y: float;
  67142. z: float;
  67143. w: float;
  67144. }
  67145. /**
  67146. * @hidden
  67147. */
  67148. export interface IVector3Like {
  67149. x: float;
  67150. y: float;
  67151. z: float;
  67152. }
  67153. /**
  67154. * @hidden
  67155. */
  67156. export interface IVector2Like {
  67157. x: float;
  67158. y: float;
  67159. }
  67160. /**
  67161. * @hidden
  67162. */
  67163. export interface IMatrixLike {
  67164. toArray(): DeepImmutable<Float32Array>;
  67165. updateFlag: int;
  67166. }
  67167. /**
  67168. * @hidden
  67169. */
  67170. export interface IViewportLike {
  67171. x: float;
  67172. y: float;
  67173. width: float;
  67174. height: float;
  67175. }
  67176. /**
  67177. * @hidden
  67178. */
  67179. export interface IPlaneLike {
  67180. normal: IVector3Like;
  67181. d: float;
  67182. normalize(): void;
  67183. }
  67184. }
  67185. declare module BABYLON {
  67186. /**
  67187. * Class representing a vector containing 2 coordinates
  67188. */
  67189. export class Vector2 {
  67190. /** defines the first coordinate */
  67191. x: number;
  67192. /** defines the second coordinate */
  67193. y: number;
  67194. /**
  67195. * Creates a new Vector2 from the given x and y coordinates
  67196. * @param x defines the first coordinate
  67197. * @param y defines the second coordinate
  67198. */
  67199. constructor(
  67200. /** defines the first coordinate */
  67201. x?: number,
  67202. /** defines the second coordinate */
  67203. y?: number);
  67204. /**
  67205. * Gets a string with the Vector2 coordinates
  67206. * @returns a string with the Vector2 coordinates
  67207. */
  67208. toString(): string;
  67209. /**
  67210. * Gets class name
  67211. * @returns the string "Vector2"
  67212. */
  67213. getClassName(): string;
  67214. /**
  67215. * Gets current vector hash code
  67216. * @returns the Vector2 hash code as a number
  67217. */
  67218. getHashCode(): number;
  67219. /**
  67220. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  67221. * @param array defines the source array
  67222. * @param index defines the offset in source array
  67223. * @returns the current Vector2
  67224. */
  67225. toArray(array: FloatArray, index?: number): Vector2;
  67226. /**
  67227. * Copy the current vector to an array
  67228. * @returns a new array with 2 elements: the Vector2 coordinates.
  67229. */
  67230. asArray(): number[];
  67231. /**
  67232. * Sets the Vector2 coordinates with the given Vector2 coordinates
  67233. * @param source defines the source Vector2
  67234. * @returns the current updated Vector2
  67235. */
  67236. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  67237. /**
  67238. * Sets the Vector2 coordinates with the given floats
  67239. * @param x defines the first coordinate
  67240. * @param y defines the second coordinate
  67241. * @returns the current updated Vector2
  67242. */
  67243. copyFromFloats(x: number, y: number): Vector2;
  67244. /**
  67245. * Sets the Vector2 coordinates with the given floats
  67246. * @param x defines the first coordinate
  67247. * @param y defines the second coordinate
  67248. * @returns the current updated Vector2
  67249. */
  67250. set(x: number, y: number): Vector2;
  67251. /**
  67252. * Add another vector with the current one
  67253. * @param otherVector defines the other vector
  67254. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  67255. */
  67256. add(otherVector: DeepImmutable<Vector2>): Vector2;
  67257. /**
  67258. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  67259. * @param otherVector defines the other vector
  67260. * @param result defines the target vector
  67261. * @returns the unmodified current Vector2
  67262. */
  67263. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67264. /**
  67265. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  67266. * @param otherVector defines the other vector
  67267. * @returns the current updated Vector2
  67268. */
  67269. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67270. /**
  67271. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  67272. * @param otherVector defines the other vector
  67273. * @returns a new Vector2
  67274. */
  67275. addVector3(otherVector: Vector3): Vector2;
  67276. /**
  67277. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  67278. * @param otherVector defines the other vector
  67279. * @returns a new Vector2
  67280. */
  67281. subtract(otherVector: Vector2): Vector2;
  67282. /**
  67283. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  67284. * @param otherVector defines the other vector
  67285. * @param result defines the target vector
  67286. * @returns the unmodified current Vector2
  67287. */
  67288. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67289. /**
  67290. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  67291. * @param otherVector defines the other vector
  67292. * @returns the current updated Vector2
  67293. */
  67294. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67295. /**
  67296. * Multiplies in place the current Vector2 coordinates by the given ones
  67297. * @param otherVector defines the other vector
  67298. * @returns the current updated Vector2
  67299. */
  67300. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67301. /**
  67302. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  67303. * @param otherVector defines the other vector
  67304. * @returns a new Vector2
  67305. */
  67306. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  67307. /**
  67308. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  67309. * @param otherVector defines the other vector
  67310. * @param result defines the target vector
  67311. * @returns the unmodified current Vector2
  67312. */
  67313. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67314. /**
  67315. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  67316. * @param x defines the first coordinate
  67317. * @param y defines the second coordinate
  67318. * @returns a new Vector2
  67319. */
  67320. multiplyByFloats(x: number, y: number): Vector2;
  67321. /**
  67322. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  67323. * @param otherVector defines the other vector
  67324. * @returns a new Vector2
  67325. */
  67326. divide(otherVector: Vector2): Vector2;
  67327. /**
  67328. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  67329. * @param otherVector defines the other vector
  67330. * @param result defines the target vector
  67331. * @returns the unmodified current Vector2
  67332. */
  67333. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67334. /**
  67335. * Divides the current Vector2 coordinates by the given ones
  67336. * @param otherVector defines the other vector
  67337. * @returns the current updated Vector2
  67338. */
  67339. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67340. /**
  67341. * Gets a new Vector2 with current Vector2 negated coordinates
  67342. * @returns a new Vector2
  67343. */
  67344. negate(): Vector2;
  67345. /**
  67346. * Multiply the Vector2 coordinates by scale
  67347. * @param scale defines the scaling factor
  67348. * @returns the current updated Vector2
  67349. */
  67350. scaleInPlace(scale: number): Vector2;
  67351. /**
  67352. * Returns a new Vector2 scaled by "scale" from the current Vector2
  67353. * @param scale defines the scaling factor
  67354. * @returns a new Vector2
  67355. */
  67356. scale(scale: number): Vector2;
  67357. /**
  67358. * Scale the current Vector2 values by a factor to a given Vector2
  67359. * @param scale defines the scale factor
  67360. * @param result defines the Vector2 object where to store the result
  67361. * @returns the unmodified current Vector2
  67362. */
  67363. scaleToRef(scale: number, result: Vector2): Vector2;
  67364. /**
  67365. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  67366. * @param scale defines the scale factor
  67367. * @param result defines the Vector2 object where to store the result
  67368. * @returns the unmodified current Vector2
  67369. */
  67370. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  67371. /**
  67372. * Gets a boolean if two vectors are equals
  67373. * @param otherVector defines the other vector
  67374. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  67375. */
  67376. equals(otherVector: DeepImmutable<Vector2>): boolean;
  67377. /**
  67378. * Gets a boolean if two vectors are equals (using an epsilon value)
  67379. * @param otherVector defines the other vector
  67380. * @param epsilon defines the minimal distance to consider equality
  67381. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  67382. */
  67383. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  67384. /**
  67385. * Gets a new Vector2 from current Vector2 floored values
  67386. * @returns a new Vector2
  67387. */
  67388. floor(): Vector2;
  67389. /**
  67390. * Gets a new Vector2 from current Vector2 floored values
  67391. * @returns a new Vector2
  67392. */
  67393. fract(): Vector2;
  67394. /**
  67395. * Gets the length of the vector
  67396. * @returns the vector length (float)
  67397. */
  67398. length(): number;
  67399. /**
  67400. * Gets the vector squared length
  67401. * @returns the vector squared length (float)
  67402. */
  67403. lengthSquared(): number;
  67404. /**
  67405. * Normalize the vector
  67406. * @returns the current updated Vector2
  67407. */
  67408. normalize(): Vector2;
  67409. /**
  67410. * Gets a new Vector2 copied from the Vector2
  67411. * @returns a new Vector2
  67412. */
  67413. clone(): Vector2;
  67414. /**
  67415. * Gets a new Vector2(0, 0)
  67416. * @returns a new Vector2
  67417. */
  67418. static Zero(): Vector2;
  67419. /**
  67420. * Gets a new Vector2(1, 1)
  67421. * @returns a new Vector2
  67422. */
  67423. static One(): Vector2;
  67424. /**
  67425. * Gets a new Vector2 set from the given index element of the given array
  67426. * @param array defines the data source
  67427. * @param offset defines the offset in the data source
  67428. * @returns a new Vector2
  67429. */
  67430. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  67431. /**
  67432. * Sets "result" from the given index element of the given array
  67433. * @param array defines the data source
  67434. * @param offset defines the offset in the data source
  67435. * @param result defines the target vector
  67436. */
  67437. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  67438. /**
  67439. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  67440. * @param value1 defines 1st point of control
  67441. * @param value2 defines 2nd point of control
  67442. * @param value3 defines 3rd point of control
  67443. * @param value4 defines 4th point of control
  67444. * @param amount defines the interpolation factor
  67445. * @returns a new Vector2
  67446. */
  67447. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  67448. /**
  67449. * 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".
  67450. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  67451. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  67452. * @param value defines the value to clamp
  67453. * @param min defines the lower limit
  67454. * @param max defines the upper limit
  67455. * @returns a new Vector2
  67456. */
  67457. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  67458. /**
  67459. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  67460. * @param value1 defines the 1st control point
  67461. * @param tangent1 defines the outgoing tangent
  67462. * @param value2 defines the 2nd control point
  67463. * @param tangent2 defines the incoming tangent
  67464. * @param amount defines the interpolation factor
  67465. * @returns a new Vector2
  67466. */
  67467. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  67468. /**
  67469. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  67470. * @param start defines the start vector
  67471. * @param end defines the end vector
  67472. * @param amount defines the interpolation factor
  67473. * @returns a new Vector2
  67474. */
  67475. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  67476. /**
  67477. * Gets the dot product of the vector "left" and the vector "right"
  67478. * @param left defines first vector
  67479. * @param right defines second vector
  67480. * @returns the dot product (float)
  67481. */
  67482. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  67483. /**
  67484. * Returns a new Vector2 equal to the normalized given vector
  67485. * @param vector defines the vector to normalize
  67486. * @returns a new Vector2
  67487. */
  67488. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  67489. /**
  67490. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  67491. * @param left defines 1st vector
  67492. * @param right defines 2nd vector
  67493. * @returns a new Vector2
  67494. */
  67495. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  67496. /**
  67497. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  67498. * @param left defines 1st vector
  67499. * @param right defines 2nd vector
  67500. * @returns a new Vector2
  67501. */
  67502. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  67503. /**
  67504. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  67505. * @param vector defines the vector to transform
  67506. * @param transformation defines the matrix to apply
  67507. * @returns a new Vector2
  67508. */
  67509. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  67510. /**
  67511. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  67512. * @param vector defines the vector to transform
  67513. * @param transformation defines the matrix to apply
  67514. * @param result defines the target vector
  67515. */
  67516. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  67517. /**
  67518. * Determines if a given vector is included in a triangle
  67519. * @param p defines the vector to test
  67520. * @param p0 defines 1st triangle point
  67521. * @param p1 defines 2nd triangle point
  67522. * @param p2 defines 3rd triangle point
  67523. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  67524. */
  67525. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  67526. /**
  67527. * Gets the distance between the vectors "value1" and "value2"
  67528. * @param value1 defines first vector
  67529. * @param value2 defines second vector
  67530. * @returns the distance between vectors
  67531. */
  67532. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  67533. /**
  67534. * Returns the squared distance between the vectors "value1" and "value2"
  67535. * @param value1 defines first vector
  67536. * @param value2 defines second vector
  67537. * @returns the squared distance between vectors
  67538. */
  67539. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  67540. /**
  67541. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  67542. * @param value1 defines first vector
  67543. * @param value2 defines second vector
  67544. * @returns a new Vector2
  67545. */
  67546. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  67547. /**
  67548. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  67549. * @param p defines the middle point
  67550. * @param segA defines one point of the segment
  67551. * @param segB defines the other point of the segment
  67552. * @returns the shortest distance
  67553. */
  67554. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  67555. }
  67556. /**
  67557. * Classed used to store (x,y,z) vector representation
  67558. * A Vector3 is the main object used in 3D geometry
  67559. * It can represent etiher the coordinates of a point the space, either a direction
  67560. * Reminder: js uses a left handed forward facing system
  67561. */
  67562. export class Vector3 {
  67563. /**
  67564. * Defines the first coordinates (on X axis)
  67565. */
  67566. x: number;
  67567. /**
  67568. * Defines the second coordinates (on Y axis)
  67569. */
  67570. y: number;
  67571. /**
  67572. * Defines the third coordinates (on Z axis)
  67573. */
  67574. z: number;
  67575. private static _UpReadOnly;
  67576. private static _ZeroReadOnly;
  67577. /**
  67578. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  67579. * @param x defines the first coordinates (on X axis)
  67580. * @param y defines the second coordinates (on Y axis)
  67581. * @param z defines the third coordinates (on Z axis)
  67582. */
  67583. constructor(
  67584. /**
  67585. * Defines the first coordinates (on X axis)
  67586. */
  67587. x?: number,
  67588. /**
  67589. * Defines the second coordinates (on Y axis)
  67590. */
  67591. y?: number,
  67592. /**
  67593. * Defines the third coordinates (on Z axis)
  67594. */
  67595. z?: number);
  67596. /**
  67597. * Creates a string representation of the Vector3
  67598. * @returns a string with the Vector3 coordinates.
  67599. */
  67600. toString(): string;
  67601. /**
  67602. * Gets the class name
  67603. * @returns the string "Vector3"
  67604. */
  67605. getClassName(): string;
  67606. /**
  67607. * Creates the Vector3 hash code
  67608. * @returns a number which tends to be unique between Vector3 instances
  67609. */
  67610. getHashCode(): number;
  67611. /**
  67612. * Creates an array containing three elements : the coordinates of the Vector3
  67613. * @returns a new array of numbers
  67614. */
  67615. asArray(): number[];
  67616. /**
  67617. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  67618. * @param array defines the destination array
  67619. * @param index defines the offset in the destination array
  67620. * @returns the current Vector3
  67621. */
  67622. toArray(array: FloatArray, index?: number): Vector3;
  67623. /**
  67624. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  67625. * @returns a new Quaternion object, computed from the Vector3 coordinates
  67626. */
  67627. toQuaternion(): Quaternion;
  67628. /**
  67629. * Adds the given vector to the current Vector3
  67630. * @param otherVector defines the second operand
  67631. * @returns the current updated Vector3
  67632. */
  67633. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67634. /**
  67635. * Adds the given coordinates to the current Vector3
  67636. * @param x defines the x coordinate of the operand
  67637. * @param y defines the y coordinate of the operand
  67638. * @param z defines the z coordinate of the operand
  67639. * @returns the current updated Vector3
  67640. */
  67641. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67642. /**
  67643. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  67644. * @param otherVector defines the second operand
  67645. * @returns the resulting Vector3
  67646. */
  67647. add(otherVector: DeepImmutable<Vector3>): Vector3;
  67648. /**
  67649. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  67650. * @param otherVector defines the second operand
  67651. * @param result defines the Vector3 object where to store the result
  67652. * @returns the current Vector3
  67653. */
  67654. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67655. /**
  67656. * Subtract the given vector from the current Vector3
  67657. * @param otherVector defines the second operand
  67658. * @returns the current updated Vector3
  67659. */
  67660. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67661. /**
  67662. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  67663. * @param otherVector defines the second operand
  67664. * @returns the resulting Vector3
  67665. */
  67666. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  67667. /**
  67668. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  67669. * @param otherVector defines the second operand
  67670. * @param result defines the Vector3 object where to store the result
  67671. * @returns the current Vector3
  67672. */
  67673. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67674. /**
  67675. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  67676. * @param x defines the x coordinate of the operand
  67677. * @param y defines the y coordinate of the operand
  67678. * @param z defines the z coordinate of the operand
  67679. * @returns the resulting Vector3
  67680. */
  67681. subtractFromFloats(x: number, y: number, z: number): Vector3;
  67682. /**
  67683. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  67684. * @param x defines the x coordinate of the operand
  67685. * @param y defines the y coordinate of the operand
  67686. * @param z defines the z coordinate of the operand
  67687. * @param result defines the Vector3 object where to store the result
  67688. * @returns the current Vector3
  67689. */
  67690. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  67691. /**
  67692. * Gets a new Vector3 set with the current Vector3 negated coordinates
  67693. * @returns a new Vector3
  67694. */
  67695. negate(): Vector3;
  67696. /**
  67697. * Multiplies the Vector3 coordinates by the float "scale"
  67698. * @param scale defines the multiplier factor
  67699. * @returns the current updated Vector3
  67700. */
  67701. scaleInPlace(scale: number): Vector3;
  67702. /**
  67703. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  67704. * @param scale defines the multiplier factor
  67705. * @returns a new Vector3
  67706. */
  67707. scale(scale: number): Vector3;
  67708. /**
  67709. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  67710. * @param scale defines the multiplier factor
  67711. * @param result defines the Vector3 object where to store the result
  67712. * @returns the current Vector3
  67713. */
  67714. scaleToRef(scale: number, result: Vector3): Vector3;
  67715. /**
  67716. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  67717. * @param scale defines the scale factor
  67718. * @param result defines the Vector3 object where to store the result
  67719. * @returns the unmodified current Vector3
  67720. */
  67721. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  67722. /**
  67723. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  67724. * @param otherVector defines the second operand
  67725. * @returns true if both vectors are equals
  67726. */
  67727. equals(otherVector: DeepImmutable<Vector3>): boolean;
  67728. /**
  67729. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  67730. * @param otherVector defines the second operand
  67731. * @param epsilon defines the minimal distance to define values as equals
  67732. * @returns true if both vectors are distant less than epsilon
  67733. */
  67734. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  67735. /**
  67736. * Returns true if the current Vector3 coordinates equals the given floats
  67737. * @param x defines the x coordinate of the operand
  67738. * @param y defines the y coordinate of the operand
  67739. * @param z defines the z coordinate of the operand
  67740. * @returns true if both vectors are equals
  67741. */
  67742. equalsToFloats(x: number, y: number, z: number): boolean;
  67743. /**
  67744. * Multiplies the current Vector3 coordinates by the given ones
  67745. * @param otherVector defines the second operand
  67746. * @returns the current updated Vector3
  67747. */
  67748. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67749. /**
  67750. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  67751. * @param otherVector defines the second operand
  67752. * @returns the new Vector3
  67753. */
  67754. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  67755. /**
  67756. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  67757. * @param otherVector defines the second operand
  67758. * @param result defines the Vector3 object where to store the result
  67759. * @returns the current Vector3
  67760. */
  67761. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67762. /**
  67763. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  67764. * @param x defines the x coordinate of the operand
  67765. * @param y defines the y coordinate of the operand
  67766. * @param z defines the z coordinate of the operand
  67767. * @returns the new Vector3
  67768. */
  67769. multiplyByFloats(x: number, y: number, z: number): Vector3;
  67770. /**
  67771. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  67772. * @param otherVector defines the second operand
  67773. * @returns the new Vector3
  67774. */
  67775. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  67776. /**
  67777. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  67778. * @param otherVector defines the second operand
  67779. * @param result defines the Vector3 object where to store the result
  67780. * @returns the current Vector3
  67781. */
  67782. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67783. /**
  67784. * Divides the current Vector3 coordinates by the given ones.
  67785. * @param otherVector defines the second operand
  67786. * @returns the current updated Vector3
  67787. */
  67788. divideInPlace(otherVector: Vector3): Vector3;
  67789. /**
  67790. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  67791. * @param other defines the second operand
  67792. * @returns the current updated Vector3
  67793. */
  67794. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  67795. /**
  67796. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  67797. * @param other defines the second operand
  67798. * @returns the current updated Vector3
  67799. */
  67800. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  67801. /**
  67802. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  67803. * @param x defines the x coordinate of the operand
  67804. * @param y defines the y coordinate of the operand
  67805. * @param z defines the z coordinate of the operand
  67806. * @returns the current updated Vector3
  67807. */
  67808. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67809. /**
  67810. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  67811. * @param x defines the x coordinate of the operand
  67812. * @param y defines the y coordinate of the operand
  67813. * @param z defines the z coordinate of the operand
  67814. * @returns the current updated Vector3
  67815. */
  67816. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67817. /**
  67818. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  67819. * Check if is non uniform within a certain amount of decimal places to account for this
  67820. * @param epsilon the amount the values can differ
  67821. * @returns if the the vector is non uniform to a certain number of decimal places
  67822. */
  67823. isNonUniformWithinEpsilon(epsilon: number): boolean;
  67824. /**
  67825. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  67826. */
  67827. readonly isNonUniform: boolean;
  67828. /**
  67829. * Gets a new Vector3 from current Vector3 floored values
  67830. * @returns a new Vector3
  67831. */
  67832. floor(): Vector3;
  67833. /**
  67834. * Gets a new Vector3 from current Vector3 floored values
  67835. * @returns a new Vector3
  67836. */
  67837. fract(): Vector3;
  67838. /**
  67839. * Gets the length of the Vector3
  67840. * @returns the length of the Vector3
  67841. */
  67842. length(): number;
  67843. /**
  67844. * Gets the squared length of the Vector3
  67845. * @returns squared length of the Vector3
  67846. */
  67847. lengthSquared(): number;
  67848. /**
  67849. * Normalize the current Vector3.
  67850. * Please note that this is an in place operation.
  67851. * @returns the current updated Vector3
  67852. */
  67853. normalize(): Vector3;
  67854. /**
  67855. * Reorders the x y z properties of the vector in place
  67856. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  67857. * @returns the current updated vector
  67858. */
  67859. reorderInPlace(order: string): this;
  67860. /**
  67861. * Rotates the vector around 0,0,0 by a quaternion
  67862. * @param quaternion the rotation quaternion
  67863. * @param result vector to store the result
  67864. * @returns the resulting vector
  67865. */
  67866. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  67867. /**
  67868. * Rotates a vector around a given point
  67869. * @param quaternion the rotation quaternion
  67870. * @param point the point to rotate around
  67871. * @param result vector to store the result
  67872. * @returns the resulting vector
  67873. */
  67874. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  67875. /**
  67876. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  67877. * The cross product is then orthogonal to both current and "other"
  67878. * @param other defines the right operand
  67879. * @returns the cross product
  67880. */
  67881. cross(other: Vector3): Vector3;
  67882. /**
  67883. * Normalize the current Vector3 with the given input length.
  67884. * Please note that this is an in place operation.
  67885. * @param len the length of the vector
  67886. * @returns the current updated Vector3
  67887. */
  67888. normalizeFromLength(len: number): Vector3;
  67889. /**
  67890. * Normalize the current Vector3 to a new vector
  67891. * @returns the new Vector3
  67892. */
  67893. normalizeToNew(): Vector3;
  67894. /**
  67895. * Normalize the current Vector3 to the reference
  67896. * @param reference define the Vector3 to update
  67897. * @returns the updated Vector3
  67898. */
  67899. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  67900. /**
  67901. * Creates a new Vector3 copied from the current Vector3
  67902. * @returns the new Vector3
  67903. */
  67904. clone(): Vector3;
  67905. /**
  67906. * Copies the given vector coordinates to the current Vector3 ones
  67907. * @param source defines the source Vector3
  67908. * @returns the current updated Vector3
  67909. */
  67910. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  67911. /**
  67912. * Copies the given floats to the current Vector3 coordinates
  67913. * @param x defines the x coordinate of the operand
  67914. * @param y defines the y coordinate of the operand
  67915. * @param z defines the z coordinate of the operand
  67916. * @returns the current updated Vector3
  67917. */
  67918. copyFromFloats(x: number, y: number, z: number): Vector3;
  67919. /**
  67920. * Copies the given floats to the current Vector3 coordinates
  67921. * @param x defines the x coordinate of the operand
  67922. * @param y defines the y coordinate of the operand
  67923. * @param z defines the z coordinate of the operand
  67924. * @returns the current updated Vector3
  67925. */
  67926. set(x: number, y: number, z: number): Vector3;
  67927. /**
  67928. * Copies the given float to the current Vector3 coordinates
  67929. * @param v defines the x, y and z coordinates of the operand
  67930. * @returns the current updated Vector3
  67931. */
  67932. setAll(v: number): Vector3;
  67933. /**
  67934. * Get the clip factor between two vectors
  67935. * @param vector0 defines the first operand
  67936. * @param vector1 defines the second operand
  67937. * @param axis defines the axis to use
  67938. * @param size defines the size along the axis
  67939. * @returns the clip factor
  67940. */
  67941. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  67942. /**
  67943. * Get angle between two vectors
  67944. * @param vector0 angle between vector0 and vector1
  67945. * @param vector1 angle between vector0 and vector1
  67946. * @param normal direction of the normal
  67947. * @return the angle between vector0 and vector1
  67948. */
  67949. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  67950. /**
  67951. * Returns a new Vector3 set from the index "offset" of the given array
  67952. * @param array defines the source array
  67953. * @param offset defines the offset in the source array
  67954. * @returns the new Vector3
  67955. */
  67956. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  67957. /**
  67958. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  67959. * This function is deprecated. Use FromArray instead
  67960. * @param array defines the source array
  67961. * @param offset defines the offset in the source array
  67962. * @returns the new Vector3
  67963. */
  67964. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  67965. /**
  67966. * Sets the given vector "result" with the element values from the index "offset" of the given array
  67967. * @param array defines the source array
  67968. * @param offset defines the offset in the source array
  67969. * @param result defines the Vector3 where to store the result
  67970. */
  67971. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  67972. /**
  67973. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  67974. * This function is deprecated. Use FromArrayToRef instead.
  67975. * @param array defines the source array
  67976. * @param offset defines the offset in the source array
  67977. * @param result defines the Vector3 where to store the result
  67978. */
  67979. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  67980. /**
  67981. * Sets the given vector "result" with the given floats.
  67982. * @param x defines the x coordinate of the source
  67983. * @param y defines the y coordinate of the source
  67984. * @param z defines the z coordinate of the source
  67985. * @param result defines the Vector3 where to store the result
  67986. */
  67987. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  67988. /**
  67989. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  67990. * @returns a new empty Vector3
  67991. */
  67992. static Zero(): Vector3;
  67993. /**
  67994. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  67995. * @returns a new unit Vector3
  67996. */
  67997. static One(): Vector3;
  67998. /**
  67999. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  68000. * @returns a new up Vector3
  68001. */
  68002. static Up(): Vector3;
  68003. /**
  68004. * Gets a up Vector3 that must not be updated
  68005. */
  68006. static readonly UpReadOnly: DeepImmutable<Vector3>;
  68007. /**
  68008. * Gets a zero Vector3 that must not be updated
  68009. */
  68010. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  68011. /**
  68012. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  68013. * @returns a new down Vector3
  68014. */
  68015. static Down(): Vector3;
  68016. /**
  68017. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  68018. * @returns a new forward Vector3
  68019. */
  68020. static Forward(): Vector3;
  68021. /**
  68022. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  68023. * @returns a new forward Vector3
  68024. */
  68025. static Backward(): Vector3;
  68026. /**
  68027. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  68028. * @returns a new right Vector3
  68029. */
  68030. static Right(): Vector3;
  68031. /**
  68032. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  68033. * @returns a new left Vector3
  68034. */
  68035. static Left(): Vector3;
  68036. /**
  68037. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  68038. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  68039. * @param vector defines the Vector3 to transform
  68040. * @param transformation defines the transformation matrix
  68041. * @returns the transformed Vector3
  68042. */
  68043. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  68044. /**
  68045. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  68046. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  68047. * @param vector defines the Vector3 to transform
  68048. * @param transformation defines the transformation matrix
  68049. * @param result defines the Vector3 where to store the result
  68050. */
  68051. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68052. /**
  68053. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  68054. * This method computes tranformed coordinates only, not transformed direction vectors
  68055. * @param x define the x coordinate of the source vector
  68056. * @param y define the y coordinate of the source vector
  68057. * @param z define the z coordinate of the source vector
  68058. * @param transformation defines the transformation matrix
  68059. * @param result defines the Vector3 where to store the result
  68060. */
  68061. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68062. /**
  68063. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  68064. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68065. * @param vector defines the Vector3 to transform
  68066. * @param transformation defines the transformation matrix
  68067. * @returns the new Vector3
  68068. */
  68069. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  68070. /**
  68071. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  68072. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68073. * @param vector defines the Vector3 to transform
  68074. * @param transformation defines the transformation matrix
  68075. * @param result defines the Vector3 where to store the result
  68076. */
  68077. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68078. /**
  68079. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  68080. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68081. * @param x define the x coordinate of the source vector
  68082. * @param y define the y coordinate of the source vector
  68083. * @param z define the z coordinate of the source vector
  68084. * @param transformation defines the transformation matrix
  68085. * @param result defines the Vector3 where to store the result
  68086. */
  68087. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68088. /**
  68089. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  68090. * @param value1 defines the first control point
  68091. * @param value2 defines the second control point
  68092. * @param value3 defines the third control point
  68093. * @param value4 defines the fourth control point
  68094. * @param amount defines the amount on the spline to use
  68095. * @returns the new Vector3
  68096. */
  68097. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  68098. /**
  68099. * 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"
  68100. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  68101. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  68102. * @param value defines the current value
  68103. * @param min defines the lower range value
  68104. * @param max defines the upper range value
  68105. * @returns the new Vector3
  68106. */
  68107. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  68108. /**
  68109. * 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"
  68110. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  68111. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  68112. * @param value defines the current value
  68113. * @param min defines the lower range value
  68114. * @param max defines the upper range value
  68115. * @param result defines the Vector3 where to store the result
  68116. */
  68117. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  68118. /**
  68119. * Checks if a given vector is inside a specific range
  68120. * @param v defines the vector to test
  68121. * @param min defines the minimum range
  68122. * @param max defines the maximum range
  68123. */
  68124. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  68125. /**
  68126. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  68127. * @param value1 defines the first control point
  68128. * @param tangent1 defines the first tangent vector
  68129. * @param value2 defines the second control point
  68130. * @param tangent2 defines the second tangent vector
  68131. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  68132. * @returns the new Vector3
  68133. */
  68134. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  68135. /**
  68136. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  68137. * @param start defines the start value
  68138. * @param end defines the end value
  68139. * @param amount max defines amount between both (between 0 and 1)
  68140. * @returns the new Vector3
  68141. */
  68142. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  68143. /**
  68144. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  68145. * @param start defines the start value
  68146. * @param end defines the end value
  68147. * @param amount max defines amount between both (between 0 and 1)
  68148. * @param result defines the Vector3 where to store the result
  68149. */
  68150. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  68151. /**
  68152. * Returns the dot product (float) between the vectors "left" and "right"
  68153. * @param left defines the left operand
  68154. * @param right defines the right operand
  68155. * @returns the dot product
  68156. */
  68157. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  68158. /**
  68159. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  68160. * The cross product is then orthogonal to both "left" and "right"
  68161. * @param left defines the left operand
  68162. * @param right defines the right operand
  68163. * @returns the cross product
  68164. */
  68165. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68166. /**
  68167. * Sets the given vector "result" with the cross product of "left" and "right"
  68168. * The cross product is then orthogonal to both "left" and "right"
  68169. * @param left defines the left operand
  68170. * @param right defines the right operand
  68171. * @param result defines the Vector3 where to store the result
  68172. */
  68173. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  68174. /**
  68175. * Returns a new Vector3 as the normalization of the given vector
  68176. * @param vector defines the Vector3 to normalize
  68177. * @returns the new Vector3
  68178. */
  68179. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  68180. /**
  68181. * Sets the given vector "result" with the normalization of the given first vector
  68182. * @param vector defines the Vector3 to normalize
  68183. * @param result defines the Vector3 where to store the result
  68184. */
  68185. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  68186. /**
  68187. * Project a Vector3 onto screen space
  68188. * @param vector defines the Vector3 to project
  68189. * @param world defines the world matrix to use
  68190. * @param transform defines the transform (view x projection) matrix to use
  68191. * @param viewport defines the screen viewport to use
  68192. * @returns the new Vector3
  68193. */
  68194. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  68195. /** @hidden */
  68196. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  68197. /**
  68198. * Unproject from screen space to object space
  68199. * @param source defines the screen space Vector3 to use
  68200. * @param viewportWidth defines the current width of the viewport
  68201. * @param viewportHeight defines the current height of the viewport
  68202. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68203. * @param transform defines the transform (view x projection) matrix to use
  68204. * @returns the new Vector3
  68205. */
  68206. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  68207. /**
  68208. * Unproject from screen space to object space
  68209. * @param source defines the screen space Vector3 to use
  68210. * @param viewportWidth defines the current width of the viewport
  68211. * @param viewportHeight defines the current height of the viewport
  68212. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68213. * @param view defines the view matrix to use
  68214. * @param projection defines the projection matrix to use
  68215. * @returns the new Vector3
  68216. */
  68217. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  68218. /**
  68219. * Unproject from screen space to object space
  68220. * @param source defines the screen space Vector3 to use
  68221. * @param viewportWidth defines the current width of the viewport
  68222. * @param viewportHeight defines the current height of the viewport
  68223. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68224. * @param view defines the view matrix to use
  68225. * @param projection defines the projection matrix to use
  68226. * @param result defines the Vector3 where to store the result
  68227. */
  68228. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  68229. /**
  68230. * Unproject from screen space to object space
  68231. * @param sourceX defines the screen space x coordinate to use
  68232. * @param sourceY defines the screen space y coordinate to use
  68233. * @param sourceZ defines the screen space z coordinate to use
  68234. * @param viewportWidth defines the current width of the viewport
  68235. * @param viewportHeight defines the current height of the viewport
  68236. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68237. * @param view defines the view matrix to use
  68238. * @param projection defines the projection matrix to use
  68239. * @param result defines the Vector3 where to store the result
  68240. */
  68241. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  68242. /**
  68243. * Gets the minimal coordinate values between two Vector3
  68244. * @param left defines the first operand
  68245. * @param right defines the second operand
  68246. * @returns the new Vector3
  68247. */
  68248. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68249. /**
  68250. * Gets the maximal coordinate values between two Vector3
  68251. * @param left defines the first operand
  68252. * @param right defines the second operand
  68253. * @returns the new Vector3
  68254. */
  68255. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68256. /**
  68257. * Returns the distance between the vectors "value1" and "value2"
  68258. * @param value1 defines the first operand
  68259. * @param value2 defines the second operand
  68260. * @returns the distance
  68261. */
  68262. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  68263. /**
  68264. * Returns the squared distance between the vectors "value1" and "value2"
  68265. * @param value1 defines the first operand
  68266. * @param value2 defines the second operand
  68267. * @returns the squared distance
  68268. */
  68269. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  68270. /**
  68271. * Returns a new Vector3 located at the center between "value1" and "value2"
  68272. * @param value1 defines the first operand
  68273. * @param value2 defines the second operand
  68274. * @returns the new Vector3
  68275. */
  68276. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  68277. /**
  68278. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  68279. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  68280. * to something in order to rotate it from its local system to the given target system
  68281. * Note: axis1, axis2 and axis3 are normalized during this operation
  68282. * @param axis1 defines the first axis
  68283. * @param axis2 defines the second axis
  68284. * @param axis3 defines the third axis
  68285. * @returns a new Vector3
  68286. */
  68287. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  68288. /**
  68289. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  68290. * @param axis1 defines the first axis
  68291. * @param axis2 defines the second axis
  68292. * @param axis3 defines the third axis
  68293. * @param ref defines the Vector3 where to store the result
  68294. */
  68295. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  68296. }
  68297. /**
  68298. * Vector4 class created for EulerAngle class conversion to Quaternion
  68299. */
  68300. export class Vector4 {
  68301. /** x value of the vector */
  68302. x: number;
  68303. /** y value of the vector */
  68304. y: number;
  68305. /** z value of the vector */
  68306. z: number;
  68307. /** w value of the vector */
  68308. w: number;
  68309. /**
  68310. * Creates a Vector4 object from the given floats.
  68311. * @param x x value of the vector
  68312. * @param y y value of the vector
  68313. * @param z z value of the vector
  68314. * @param w w value of the vector
  68315. */
  68316. constructor(
  68317. /** x value of the vector */
  68318. x: number,
  68319. /** y value of the vector */
  68320. y: number,
  68321. /** z value of the vector */
  68322. z: number,
  68323. /** w value of the vector */
  68324. w: number);
  68325. /**
  68326. * Returns the string with the Vector4 coordinates.
  68327. * @returns a string containing all the vector values
  68328. */
  68329. toString(): string;
  68330. /**
  68331. * Returns the string "Vector4".
  68332. * @returns "Vector4"
  68333. */
  68334. getClassName(): string;
  68335. /**
  68336. * Returns the Vector4 hash code.
  68337. * @returns a unique hash code
  68338. */
  68339. getHashCode(): number;
  68340. /**
  68341. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  68342. * @returns the resulting array
  68343. */
  68344. asArray(): number[];
  68345. /**
  68346. * Populates the given array from the given index with the Vector4 coordinates.
  68347. * @param array array to populate
  68348. * @param index index of the array to start at (default: 0)
  68349. * @returns the Vector4.
  68350. */
  68351. toArray(array: FloatArray, index?: number): Vector4;
  68352. /**
  68353. * Adds the given vector to the current Vector4.
  68354. * @param otherVector the vector to add
  68355. * @returns the updated Vector4.
  68356. */
  68357. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68358. /**
  68359. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  68360. * @param otherVector the vector to add
  68361. * @returns the resulting vector
  68362. */
  68363. add(otherVector: DeepImmutable<Vector4>): Vector4;
  68364. /**
  68365. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  68366. * @param otherVector the vector to add
  68367. * @param result the vector to store the result
  68368. * @returns the current Vector4.
  68369. */
  68370. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68371. /**
  68372. * Subtract in place the given vector from the current Vector4.
  68373. * @param otherVector the vector to subtract
  68374. * @returns the updated Vector4.
  68375. */
  68376. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68377. /**
  68378. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  68379. * @param otherVector the vector to add
  68380. * @returns the new vector with the result
  68381. */
  68382. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  68383. /**
  68384. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  68385. * @param otherVector the vector to subtract
  68386. * @param result the vector to store the result
  68387. * @returns the current Vector4.
  68388. */
  68389. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68390. /**
  68391. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68392. */
  68393. /**
  68394. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68395. * @param x value to subtract
  68396. * @param y value to subtract
  68397. * @param z value to subtract
  68398. * @param w value to subtract
  68399. * @returns new vector containing the result
  68400. */
  68401. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  68402. /**
  68403. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68404. * @param x value to subtract
  68405. * @param y value to subtract
  68406. * @param z value to subtract
  68407. * @param w value to subtract
  68408. * @param result the vector to store the result in
  68409. * @returns the current Vector4.
  68410. */
  68411. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  68412. /**
  68413. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  68414. * @returns a new vector with the negated values
  68415. */
  68416. negate(): Vector4;
  68417. /**
  68418. * Multiplies the current Vector4 coordinates by scale (float).
  68419. * @param scale the number to scale with
  68420. * @returns the updated Vector4.
  68421. */
  68422. scaleInPlace(scale: number): Vector4;
  68423. /**
  68424. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  68425. * @param scale the number to scale with
  68426. * @returns a new vector with the result
  68427. */
  68428. scale(scale: number): Vector4;
  68429. /**
  68430. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  68431. * @param scale the number to scale with
  68432. * @param result a vector to store the result in
  68433. * @returns the current Vector4.
  68434. */
  68435. scaleToRef(scale: number, result: Vector4): Vector4;
  68436. /**
  68437. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  68438. * @param scale defines the scale factor
  68439. * @param result defines the Vector4 object where to store the result
  68440. * @returns the unmodified current Vector4
  68441. */
  68442. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  68443. /**
  68444. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  68445. * @param otherVector the vector to compare against
  68446. * @returns true if they are equal
  68447. */
  68448. equals(otherVector: DeepImmutable<Vector4>): boolean;
  68449. /**
  68450. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  68451. * @param otherVector vector to compare against
  68452. * @param epsilon (Default: very small number)
  68453. * @returns true if they are equal
  68454. */
  68455. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  68456. /**
  68457. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  68458. * @param x x value to compare against
  68459. * @param y y value to compare against
  68460. * @param z z value to compare against
  68461. * @param w w value to compare against
  68462. * @returns true if equal
  68463. */
  68464. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  68465. /**
  68466. * Multiplies in place the current Vector4 by the given one.
  68467. * @param otherVector vector to multiple with
  68468. * @returns the updated Vector4.
  68469. */
  68470. multiplyInPlace(otherVector: Vector4): Vector4;
  68471. /**
  68472. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  68473. * @param otherVector vector to multiple with
  68474. * @returns resulting new vector
  68475. */
  68476. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  68477. /**
  68478. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  68479. * @param otherVector vector to multiple with
  68480. * @param result vector to store the result
  68481. * @returns the current Vector4.
  68482. */
  68483. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68484. /**
  68485. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  68486. * @param x x value multiply with
  68487. * @param y y value multiply with
  68488. * @param z z value multiply with
  68489. * @param w w value multiply with
  68490. * @returns resulting new vector
  68491. */
  68492. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  68493. /**
  68494. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  68495. * @param otherVector vector to devide with
  68496. * @returns resulting new vector
  68497. */
  68498. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  68499. /**
  68500. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  68501. * @param otherVector vector to devide with
  68502. * @param result vector to store the result
  68503. * @returns the current Vector4.
  68504. */
  68505. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68506. /**
  68507. * Divides the current Vector3 coordinates by the given ones.
  68508. * @param otherVector vector to devide with
  68509. * @returns the updated Vector3.
  68510. */
  68511. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68512. /**
  68513. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  68514. * @param other defines the second operand
  68515. * @returns the current updated Vector4
  68516. */
  68517. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  68518. /**
  68519. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  68520. * @param other defines the second operand
  68521. * @returns the current updated Vector4
  68522. */
  68523. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  68524. /**
  68525. * Gets a new Vector4 from current Vector4 floored values
  68526. * @returns a new Vector4
  68527. */
  68528. floor(): Vector4;
  68529. /**
  68530. * Gets a new Vector4 from current Vector3 floored values
  68531. * @returns a new Vector4
  68532. */
  68533. fract(): Vector4;
  68534. /**
  68535. * Returns the Vector4 length (float).
  68536. * @returns the length
  68537. */
  68538. length(): number;
  68539. /**
  68540. * Returns the Vector4 squared length (float).
  68541. * @returns the length squared
  68542. */
  68543. lengthSquared(): number;
  68544. /**
  68545. * Normalizes in place the Vector4.
  68546. * @returns the updated Vector4.
  68547. */
  68548. normalize(): Vector4;
  68549. /**
  68550. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  68551. * @returns this converted to a new vector3
  68552. */
  68553. toVector3(): Vector3;
  68554. /**
  68555. * Returns a new Vector4 copied from the current one.
  68556. * @returns the new cloned vector
  68557. */
  68558. clone(): Vector4;
  68559. /**
  68560. * Updates the current Vector4 with the given one coordinates.
  68561. * @param source the source vector to copy from
  68562. * @returns the updated Vector4.
  68563. */
  68564. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  68565. /**
  68566. * Updates the current Vector4 coordinates with the given floats.
  68567. * @param x float to copy from
  68568. * @param y float to copy from
  68569. * @param z float to copy from
  68570. * @param w float to copy from
  68571. * @returns the updated Vector4.
  68572. */
  68573. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  68574. /**
  68575. * Updates the current Vector4 coordinates with the given floats.
  68576. * @param x float to set from
  68577. * @param y float to set from
  68578. * @param z float to set from
  68579. * @param w float to set from
  68580. * @returns the updated Vector4.
  68581. */
  68582. set(x: number, y: number, z: number, w: number): Vector4;
  68583. /**
  68584. * Copies the given float to the current Vector3 coordinates
  68585. * @param v defines the x, y, z and w coordinates of the operand
  68586. * @returns the current updated Vector3
  68587. */
  68588. setAll(v: number): Vector4;
  68589. /**
  68590. * Returns a new Vector4 set from the starting index of the given array.
  68591. * @param array the array to pull values from
  68592. * @param offset the offset into the array to start at
  68593. * @returns the new vector
  68594. */
  68595. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  68596. /**
  68597. * Updates the given vector "result" from the starting index of the given array.
  68598. * @param array the array to pull values from
  68599. * @param offset the offset into the array to start at
  68600. * @param result the vector to store the result in
  68601. */
  68602. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  68603. /**
  68604. * Updates the given vector "result" from the starting index of the given Float32Array.
  68605. * @param array the array to pull values from
  68606. * @param offset the offset into the array to start at
  68607. * @param result the vector to store the result in
  68608. */
  68609. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  68610. /**
  68611. * Updates the given vector "result" coordinates from the given floats.
  68612. * @param x float to set from
  68613. * @param y float to set from
  68614. * @param z float to set from
  68615. * @param w float to set from
  68616. * @param result the vector to the floats in
  68617. */
  68618. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  68619. /**
  68620. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  68621. * @returns the new vector
  68622. */
  68623. static Zero(): Vector4;
  68624. /**
  68625. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  68626. * @returns the new vector
  68627. */
  68628. static One(): Vector4;
  68629. /**
  68630. * Returns a new normalized Vector4 from the given one.
  68631. * @param vector the vector to normalize
  68632. * @returns the vector
  68633. */
  68634. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  68635. /**
  68636. * Updates the given vector "result" from the normalization of the given one.
  68637. * @param vector the vector to normalize
  68638. * @param result the vector to store the result in
  68639. */
  68640. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  68641. /**
  68642. * Returns a vector with the minimum values from the left and right vectors
  68643. * @param left left vector to minimize
  68644. * @param right right vector to minimize
  68645. * @returns a new vector with the minimum of the left and right vector values
  68646. */
  68647. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  68648. /**
  68649. * Returns a vector with the maximum values from the left and right vectors
  68650. * @param left left vector to maximize
  68651. * @param right right vector to maximize
  68652. * @returns a new vector with the maximum of the left and right vector values
  68653. */
  68654. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  68655. /**
  68656. * Returns the distance (float) between the vectors "value1" and "value2".
  68657. * @param value1 value to calulate the distance between
  68658. * @param value2 value to calulate the distance between
  68659. * @return the distance between the two vectors
  68660. */
  68661. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  68662. /**
  68663. * Returns the squared distance (float) between the vectors "value1" and "value2".
  68664. * @param value1 value to calulate the distance between
  68665. * @param value2 value to calulate the distance between
  68666. * @return the distance between the two vectors squared
  68667. */
  68668. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  68669. /**
  68670. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  68671. * @param value1 value to calulate the center between
  68672. * @param value2 value to calulate the center between
  68673. * @return the center between the two vectors
  68674. */
  68675. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  68676. /**
  68677. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  68678. * This methods computes transformed normalized direction vectors only.
  68679. * @param vector the vector to transform
  68680. * @param transformation the transformation matrix to apply
  68681. * @returns the new vector
  68682. */
  68683. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  68684. /**
  68685. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  68686. * This methods computes transformed normalized direction vectors only.
  68687. * @param vector the vector to transform
  68688. * @param transformation the transformation matrix to apply
  68689. * @param result the vector to store the result in
  68690. */
  68691. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  68692. /**
  68693. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  68694. * This methods computes transformed normalized direction vectors only.
  68695. * @param x value to transform
  68696. * @param y value to transform
  68697. * @param z value to transform
  68698. * @param w value to transform
  68699. * @param transformation the transformation matrix to apply
  68700. * @param result the vector to store the results in
  68701. */
  68702. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  68703. /**
  68704. * Creates a new Vector4 from a Vector3
  68705. * @param source defines the source data
  68706. * @param w defines the 4th component (default is 0)
  68707. * @returns a new Vector4
  68708. */
  68709. static FromVector3(source: Vector3, w?: number): Vector4;
  68710. }
  68711. /**
  68712. * Class used to store quaternion data
  68713. * @see https://en.wikipedia.org/wiki/Quaternion
  68714. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  68715. */
  68716. export class Quaternion {
  68717. /** defines the first component (0 by default) */
  68718. x: number;
  68719. /** defines the second component (0 by default) */
  68720. y: number;
  68721. /** defines the third component (0 by default) */
  68722. z: number;
  68723. /** defines the fourth component (1.0 by default) */
  68724. w: number;
  68725. /**
  68726. * Creates a new Quaternion from the given floats
  68727. * @param x defines the first component (0 by default)
  68728. * @param y defines the second component (0 by default)
  68729. * @param z defines the third component (0 by default)
  68730. * @param w defines the fourth component (1.0 by default)
  68731. */
  68732. constructor(
  68733. /** defines the first component (0 by default) */
  68734. x?: number,
  68735. /** defines the second component (0 by default) */
  68736. y?: number,
  68737. /** defines the third component (0 by default) */
  68738. z?: number,
  68739. /** defines the fourth component (1.0 by default) */
  68740. w?: number);
  68741. /**
  68742. * Gets a string representation for the current quaternion
  68743. * @returns a string with the Quaternion coordinates
  68744. */
  68745. toString(): string;
  68746. /**
  68747. * Gets the class name of the quaternion
  68748. * @returns the string "Quaternion"
  68749. */
  68750. getClassName(): string;
  68751. /**
  68752. * Gets a hash code for this quaternion
  68753. * @returns the quaternion hash code
  68754. */
  68755. getHashCode(): number;
  68756. /**
  68757. * Copy the quaternion to an array
  68758. * @returns a new array populated with 4 elements from the quaternion coordinates
  68759. */
  68760. asArray(): number[];
  68761. /**
  68762. * Check if two quaternions are equals
  68763. * @param otherQuaternion defines the second operand
  68764. * @return true if the current quaternion and the given one coordinates are strictly equals
  68765. */
  68766. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  68767. /**
  68768. * Clone the current quaternion
  68769. * @returns a new quaternion copied from the current one
  68770. */
  68771. clone(): Quaternion;
  68772. /**
  68773. * Copy a quaternion to the current one
  68774. * @param other defines the other quaternion
  68775. * @returns the updated current quaternion
  68776. */
  68777. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  68778. /**
  68779. * Updates the current quaternion with the given float coordinates
  68780. * @param x defines the x coordinate
  68781. * @param y defines the y coordinate
  68782. * @param z defines the z coordinate
  68783. * @param w defines the w coordinate
  68784. * @returns the updated current quaternion
  68785. */
  68786. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  68787. /**
  68788. * Updates the current quaternion from the given float coordinates
  68789. * @param x defines the x coordinate
  68790. * @param y defines the y coordinate
  68791. * @param z defines the z coordinate
  68792. * @param w defines the w coordinate
  68793. * @returns the updated current quaternion
  68794. */
  68795. set(x: number, y: number, z: number, w: number): Quaternion;
  68796. /**
  68797. * Adds two quaternions
  68798. * @param other defines the second operand
  68799. * @returns a new quaternion as the addition result of the given one and the current quaternion
  68800. */
  68801. add(other: DeepImmutable<Quaternion>): Quaternion;
  68802. /**
  68803. * Add a quaternion to the current one
  68804. * @param other defines the quaternion to add
  68805. * @returns the current quaternion
  68806. */
  68807. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  68808. /**
  68809. * Subtract two quaternions
  68810. * @param other defines the second operand
  68811. * @returns a new quaternion as the subtraction result of the given one from the current one
  68812. */
  68813. subtract(other: Quaternion): Quaternion;
  68814. /**
  68815. * Multiplies the current quaternion by a scale factor
  68816. * @param value defines the scale factor
  68817. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  68818. */
  68819. scale(value: number): Quaternion;
  68820. /**
  68821. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  68822. * @param scale defines the scale factor
  68823. * @param result defines the Quaternion object where to store the result
  68824. * @returns the unmodified current quaternion
  68825. */
  68826. scaleToRef(scale: number, result: Quaternion): Quaternion;
  68827. /**
  68828. * Multiplies in place the current quaternion by a scale factor
  68829. * @param value defines the scale factor
  68830. * @returns the current modified quaternion
  68831. */
  68832. scaleInPlace(value: number): Quaternion;
  68833. /**
  68834. * Scale the current quaternion values by a factor and add the result to a given quaternion
  68835. * @param scale defines the scale factor
  68836. * @param result defines the Quaternion object where to store the result
  68837. * @returns the unmodified current quaternion
  68838. */
  68839. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  68840. /**
  68841. * Multiplies two quaternions
  68842. * @param q1 defines the second operand
  68843. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  68844. */
  68845. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  68846. /**
  68847. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  68848. * @param q1 defines the second operand
  68849. * @param result defines the target quaternion
  68850. * @returns the current quaternion
  68851. */
  68852. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  68853. /**
  68854. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  68855. * @param q1 defines the second operand
  68856. * @returns the currentupdated quaternion
  68857. */
  68858. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  68859. /**
  68860. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  68861. * @param ref defines the target quaternion
  68862. * @returns the current quaternion
  68863. */
  68864. conjugateToRef(ref: Quaternion): Quaternion;
  68865. /**
  68866. * Conjugates in place (1-q) the current quaternion
  68867. * @returns the current updated quaternion
  68868. */
  68869. conjugateInPlace(): Quaternion;
  68870. /**
  68871. * Conjugates in place (1-q) the current quaternion
  68872. * @returns a new quaternion
  68873. */
  68874. conjugate(): Quaternion;
  68875. /**
  68876. * Gets length of current quaternion
  68877. * @returns the quaternion length (float)
  68878. */
  68879. length(): number;
  68880. /**
  68881. * Normalize in place the current quaternion
  68882. * @returns the current updated quaternion
  68883. */
  68884. normalize(): Quaternion;
  68885. /**
  68886. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  68887. * @param order is a reserved parameter and is ignore for now
  68888. * @returns a new Vector3 containing the Euler angles
  68889. */
  68890. toEulerAngles(order?: string): Vector3;
  68891. /**
  68892. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  68893. * @param result defines the vector which will be filled with the Euler angles
  68894. * @param order is a reserved parameter and is ignore for now
  68895. * @returns the current unchanged quaternion
  68896. */
  68897. toEulerAnglesToRef(result: Vector3): Quaternion;
  68898. /**
  68899. * Updates the given rotation matrix with the current quaternion values
  68900. * @param result defines the target matrix
  68901. * @returns the current unchanged quaternion
  68902. */
  68903. toRotationMatrix(result: Matrix): Quaternion;
  68904. /**
  68905. * Updates the current quaternion from the given rotation matrix values
  68906. * @param matrix defines the source matrix
  68907. * @returns the current updated quaternion
  68908. */
  68909. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  68910. /**
  68911. * Creates a new quaternion from a rotation matrix
  68912. * @param matrix defines the source matrix
  68913. * @returns a new quaternion created from the given rotation matrix values
  68914. */
  68915. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  68916. /**
  68917. * Updates the given quaternion with the given rotation matrix values
  68918. * @param matrix defines the source matrix
  68919. * @param result defines the target quaternion
  68920. */
  68921. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  68922. /**
  68923. * Returns the dot product (float) between the quaternions "left" and "right"
  68924. * @param left defines the left operand
  68925. * @param right defines the right operand
  68926. * @returns the dot product
  68927. */
  68928. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  68929. /**
  68930. * Checks if the two quaternions are close to each other
  68931. * @param quat0 defines the first quaternion to check
  68932. * @param quat1 defines the second quaternion to check
  68933. * @returns true if the two quaternions are close to each other
  68934. */
  68935. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  68936. /**
  68937. * Creates an empty quaternion
  68938. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  68939. */
  68940. static Zero(): Quaternion;
  68941. /**
  68942. * Inverse a given quaternion
  68943. * @param q defines the source quaternion
  68944. * @returns a new quaternion as the inverted current quaternion
  68945. */
  68946. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  68947. /**
  68948. * Inverse a given quaternion
  68949. * @param q defines the source quaternion
  68950. * @param result the quaternion the result will be stored in
  68951. * @returns the result quaternion
  68952. */
  68953. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  68954. /**
  68955. * Creates an identity quaternion
  68956. * @returns the identity quaternion
  68957. */
  68958. static Identity(): Quaternion;
  68959. /**
  68960. * Gets a boolean indicating if the given quaternion is identity
  68961. * @param quaternion defines the quaternion to check
  68962. * @returns true if the quaternion is identity
  68963. */
  68964. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  68965. /**
  68966. * Creates a quaternion from a rotation around an axis
  68967. * @param axis defines the axis to use
  68968. * @param angle defines the angle to use
  68969. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  68970. */
  68971. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  68972. /**
  68973. * Creates a rotation around an axis and stores it into the given quaternion
  68974. * @param axis defines the axis to use
  68975. * @param angle defines the angle to use
  68976. * @param result defines the target quaternion
  68977. * @returns the target quaternion
  68978. */
  68979. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  68980. /**
  68981. * Creates a new quaternion from data stored into an array
  68982. * @param array defines the data source
  68983. * @param offset defines the offset in the source array where the data starts
  68984. * @returns a new quaternion
  68985. */
  68986. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  68987. /**
  68988. * Create a quaternion from Euler rotation angles
  68989. * @param x Pitch
  68990. * @param y Yaw
  68991. * @param z Roll
  68992. * @returns the new Quaternion
  68993. */
  68994. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  68995. /**
  68996. * Updates a quaternion from Euler rotation angles
  68997. * @param x Pitch
  68998. * @param y Yaw
  68999. * @param z Roll
  69000. * @param result the quaternion to store the result
  69001. * @returns the updated quaternion
  69002. */
  69003. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  69004. /**
  69005. * Create a quaternion from Euler rotation vector
  69006. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  69007. * @returns the new Quaternion
  69008. */
  69009. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  69010. /**
  69011. * Updates a quaternion from Euler rotation vector
  69012. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  69013. * @param result the quaternion to store the result
  69014. * @returns the updated quaternion
  69015. */
  69016. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  69017. /**
  69018. * Creates a new quaternion from the given Euler float angles (y, x, z)
  69019. * @param yaw defines the rotation around Y axis
  69020. * @param pitch defines the rotation around X axis
  69021. * @param roll defines the rotation around Z axis
  69022. * @returns the new quaternion
  69023. */
  69024. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  69025. /**
  69026. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  69027. * @param yaw defines the rotation around Y axis
  69028. * @param pitch defines the rotation around X axis
  69029. * @param roll defines the rotation around Z axis
  69030. * @param result defines the target quaternion
  69031. */
  69032. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  69033. /**
  69034. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  69035. * @param alpha defines the rotation around first axis
  69036. * @param beta defines the rotation around second axis
  69037. * @param gamma defines the rotation around third axis
  69038. * @returns the new quaternion
  69039. */
  69040. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  69041. /**
  69042. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  69043. * @param alpha defines the rotation around first axis
  69044. * @param beta defines the rotation around second axis
  69045. * @param gamma defines the rotation around third axis
  69046. * @param result defines the target quaternion
  69047. */
  69048. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  69049. /**
  69050. * 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)
  69051. * @param axis1 defines the first axis
  69052. * @param axis2 defines the second axis
  69053. * @param axis3 defines the third axis
  69054. * @returns the new quaternion
  69055. */
  69056. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  69057. /**
  69058. * 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
  69059. * @param axis1 defines the first axis
  69060. * @param axis2 defines the second axis
  69061. * @param axis3 defines the third axis
  69062. * @param ref defines the target quaternion
  69063. */
  69064. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  69065. /**
  69066. * Interpolates between two quaternions
  69067. * @param left defines first quaternion
  69068. * @param right defines second quaternion
  69069. * @param amount defines the gradient to use
  69070. * @returns the new interpolated quaternion
  69071. */
  69072. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  69073. /**
  69074. * Interpolates between two quaternions and stores it into a target quaternion
  69075. * @param left defines first quaternion
  69076. * @param right defines second quaternion
  69077. * @param amount defines the gradient to use
  69078. * @param result defines the target quaternion
  69079. */
  69080. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  69081. /**
  69082. * Interpolate between two quaternions using Hermite interpolation
  69083. * @param value1 defines first quaternion
  69084. * @param tangent1 defines the incoming tangent
  69085. * @param value2 defines second quaternion
  69086. * @param tangent2 defines the outgoing tangent
  69087. * @param amount defines the target quaternion
  69088. * @returns the new interpolated quaternion
  69089. */
  69090. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  69091. }
  69092. /**
  69093. * Class used to store matrix data (4x4)
  69094. */
  69095. export class Matrix {
  69096. private static _updateFlagSeed;
  69097. private static _identityReadOnly;
  69098. private _isIdentity;
  69099. private _isIdentityDirty;
  69100. private _isIdentity3x2;
  69101. private _isIdentity3x2Dirty;
  69102. /**
  69103. * Gets the update flag of the matrix which is an unique number for the matrix.
  69104. * It will be incremented every time the matrix data change.
  69105. * You can use it to speed the comparison between two versions of the same matrix.
  69106. */
  69107. updateFlag: number;
  69108. private readonly _m;
  69109. /**
  69110. * Gets the internal data of the matrix
  69111. */
  69112. readonly m: DeepImmutable<Float32Array>;
  69113. /** @hidden */
  69114. _markAsUpdated(): void;
  69115. /** @hidden */
  69116. private _updateIdentityStatus;
  69117. /**
  69118. * Creates an empty matrix (filled with zeros)
  69119. */
  69120. constructor();
  69121. /**
  69122. * Check if the current matrix is identity
  69123. * @returns true is the matrix is the identity matrix
  69124. */
  69125. isIdentity(): boolean;
  69126. /**
  69127. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  69128. * @returns true is the matrix is the identity matrix
  69129. */
  69130. isIdentityAs3x2(): boolean;
  69131. /**
  69132. * Gets the determinant of the matrix
  69133. * @returns the matrix determinant
  69134. */
  69135. determinant(): number;
  69136. /**
  69137. * Returns the matrix as a Float32Array
  69138. * @returns the matrix underlying array
  69139. */
  69140. toArray(): DeepImmutable<Float32Array>;
  69141. /**
  69142. * Returns the matrix as a Float32Array
  69143. * @returns the matrix underlying array.
  69144. */
  69145. asArray(): DeepImmutable<Float32Array>;
  69146. /**
  69147. * Inverts the current matrix in place
  69148. * @returns the current inverted matrix
  69149. */
  69150. invert(): Matrix;
  69151. /**
  69152. * Sets all the matrix elements to zero
  69153. * @returns the current matrix
  69154. */
  69155. reset(): Matrix;
  69156. /**
  69157. * Adds the current matrix with a second one
  69158. * @param other defines the matrix to add
  69159. * @returns a new matrix as the addition of the current matrix and the given one
  69160. */
  69161. add(other: DeepImmutable<Matrix>): Matrix;
  69162. /**
  69163. * Sets the given matrix "result" to the addition of the current matrix and the given one
  69164. * @param other defines the matrix to add
  69165. * @param result defines the target matrix
  69166. * @returns the current matrix
  69167. */
  69168. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  69169. /**
  69170. * Adds in place the given matrix to the current matrix
  69171. * @param other defines the second operand
  69172. * @returns the current updated matrix
  69173. */
  69174. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  69175. /**
  69176. * Sets the given matrix to the current inverted Matrix
  69177. * @param other defines the target matrix
  69178. * @returns the unmodified current matrix
  69179. */
  69180. invertToRef(other: Matrix): Matrix;
  69181. /**
  69182. * add a value at the specified position in the current Matrix
  69183. * @param index the index of the value within the matrix. between 0 and 15.
  69184. * @param value the value to be added
  69185. * @returns the current updated matrix
  69186. */
  69187. addAtIndex(index: number, value: number): Matrix;
  69188. /**
  69189. * mutiply the specified position in the current Matrix by a value
  69190. * @param index the index of the value within the matrix. between 0 and 15.
  69191. * @param value the value to be added
  69192. * @returns the current updated matrix
  69193. */
  69194. multiplyAtIndex(index: number, value: number): Matrix;
  69195. /**
  69196. * Inserts the translation vector (using 3 floats) in the current matrix
  69197. * @param x defines the 1st component of the translation
  69198. * @param y defines the 2nd component of the translation
  69199. * @param z defines the 3rd component of the translation
  69200. * @returns the current updated matrix
  69201. */
  69202. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  69203. /**
  69204. * Adds the translation vector (using 3 floats) in the current matrix
  69205. * @param x defines the 1st component of the translation
  69206. * @param y defines the 2nd component of the translation
  69207. * @param z defines the 3rd component of the translation
  69208. * @returns the current updated matrix
  69209. */
  69210. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  69211. /**
  69212. * Inserts the translation vector in the current matrix
  69213. * @param vector3 defines the translation to insert
  69214. * @returns the current updated matrix
  69215. */
  69216. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  69217. /**
  69218. * Gets the translation value of the current matrix
  69219. * @returns a new Vector3 as the extracted translation from the matrix
  69220. */
  69221. getTranslation(): Vector3;
  69222. /**
  69223. * Fill a Vector3 with the extracted translation from the matrix
  69224. * @param result defines the Vector3 where to store the translation
  69225. * @returns the current matrix
  69226. */
  69227. getTranslationToRef(result: Vector3): Matrix;
  69228. /**
  69229. * Remove rotation and scaling part from the matrix
  69230. * @returns the updated matrix
  69231. */
  69232. removeRotationAndScaling(): Matrix;
  69233. /**
  69234. * Multiply two matrices
  69235. * @param other defines the second operand
  69236. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  69237. */
  69238. multiply(other: DeepImmutable<Matrix>): Matrix;
  69239. /**
  69240. * Copy the current matrix from the given one
  69241. * @param other defines the source matrix
  69242. * @returns the current updated matrix
  69243. */
  69244. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  69245. /**
  69246. * Populates the given array from the starting index with the current matrix values
  69247. * @param array defines the target array
  69248. * @param offset defines the offset in the target array where to start storing values
  69249. * @returns the current matrix
  69250. */
  69251. copyToArray(array: Float32Array, offset?: number): Matrix;
  69252. /**
  69253. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  69254. * @param other defines the second operand
  69255. * @param result defines the matrix where to store the multiplication
  69256. * @returns the current matrix
  69257. */
  69258. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  69259. /**
  69260. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  69261. * @param other defines the second operand
  69262. * @param result defines the array where to store the multiplication
  69263. * @param offset defines the offset in the target array where to start storing values
  69264. * @returns the current matrix
  69265. */
  69266. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  69267. /**
  69268. * Check equality between this matrix and a second one
  69269. * @param value defines the second matrix to compare
  69270. * @returns true is the current matrix and the given one values are strictly equal
  69271. */
  69272. equals(value: DeepImmutable<Matrix>): boolean;
  69273. /**
  69274. * Clone the current matrix
  69275. * @returns a new matrix from the current matrix
  69276. */
  69277. clone(): Matrix;
  69278. /**
  69279. * Returns the name of the current matrix class
  69280. * @returns the string "Matrix"
  69281. */
  69282. getClassName(): string;
  69283. /**
  69284. * Gets the hash code of the current matrix
  69285. * @returns the hash code
  69286. */
  69287. getHashCode(): number;
  69288. /**
  69289. * Decomposes the current Matrix into a translation, rotation and scaling components
  69290. * @param scale defines the scale vector3 given as a reference to update
  69291. * @param rotation defines the rotation quaternion given as a reference to update
  69292. * @param translation defines the translation vector3 given as a reference to update
  69293. * @returns true if operation was successful
  69294. */
  69295. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  69296. /**
  69297. * Gets specific row of the matrix
  69298. * @param index defines the number of the row to get
  69299. * @returns the index-th row of the current matrix as a new Vector4
  69300. */
  69301. getRow(index: number): Nullable<Vector4>;
  69302. /**
  69303. * Sets the index-th row of the current matrix to the vector4 values
  69304. * @param index defines the number of the row to set
  69305. * @param row defines the target vector4
  69306. * @returns the updated current matrix
  69307. */
  69308. setRow(index: number, row: Vector4): Matrix;
  69309. /**
  69310. * Compute the transpose of the matrix
  69311. * @returns the new transposed matrix
  69312. */
  69313. transpose(): Matrix;
  69314. /**
  69315. * Compute the transpose of the matrix and store it in a given matrix
  69316. * @param result defines the target matrix
  69317. * @returns the current matrix
  69318. */
  69319. transposeToRef(result: Matrix): Matrix;
  69320. /**
  69321. * Sets the index-th row of the current matrix with the given 4 x float values
  69322. * @param index defines the row index
  69323. * @param x defines the x component to set
  69324. * @param y defines the y component to set
  69325. * @param z defines the z component to set
  69326. * @param w defines the w component to set
  69327. * @returns the updated current matrix
  69328. */
  69329. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  69330. /**
  69331. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  69332. * @param scale defines the scale factor
  69333. * @returns a new matrix
  69334. */
  69335. scale(scale: number): Matrix;
  69336. /**
  69337. * Scale the current matrix values by a factor to a given result matrix
  69338. * @param scale defines the scale factor
  69339. * @param result defines the matrix to store the result
  69340. * @returns the current matrix
  69341. */
  69342. scaleToRef(scale: number, result: Matrix): Matrix;
  69343. /**
  69344. * Scale the current matrix values by a factor and add the result to a given matrix
  69345. * @param scale defines the scale factor
  69346. * @param result defines the Matrix to store the result
  69347. * @returns the current matrix
  69348. */
  69349. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  69350. /**
  69351. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  69352. * @param ref matrix to store the result
  69353. */
  69354. toNormalMatrix(ref: Matrix): void;
  69355. /**
  69356. * Gets only rotation part of the current matrix
  69357. * @returns a new matrix sets to the extracted rotation matrix from the current one
  69358. */
  69359. getRotationMatrix(): Matrix;
  69360. /**
  69361. * Extracts the rotation matrix from the current one and sets it as the given "result"
  69362. * @param result defines the target matrix to store data to
  69363. * @returns the current matrix
  69364. */
  69365. getRotationMatrixToRef(result: Matrix): Matrix;
  69366. /**
  69367. * Toggles model matrix from being right handed to left handed in place and vice versa
  69368. */
  69369. toggleModelMatrixHandInPlace(): void;
  69370. /**
  69371. * Toggles projection matrix from being right handed to left handed in place and vice versa
  69372. */
  69373. toggleProjectionMatrixHandInPlace(): void;
  69374. /**
  69375. * Creates a matrix from an array
  69376. * @param array defines the source array
  69377. * @param offset defines an offset in the source array
  69378. * @returns a new Matrix set from the starting index of the given array
  69379. */
  69380. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  69381. /**
  69382. * Copy the content of an array into a given matrix
  69383. * @param array defines the source array
  69384. * @param offset defines an offset in the source array
  69385. * @param result defines the target matrix
  69386. */
  69387. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  69388. /**
  69389. * Stores an array into a matrix after having multiplied each component by a given factor
  69390. * @param array defines the source array
  69391. * @param offset defines the offset in the source array
  69392. * @param scale defines the scaling factor
  69393. * @param result defines the target matrix
  69394. */
  69395. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  69396. /**
  69397. * Gets an identity matrix that must not be updated
  69398. */
  69399. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  69400. /**
  69401. * Stores a list of values (16) inside a given matrix
  69402. * @param initialM11 defines 1st value of 1st row
  69403. * @param initialM12 defines 2nd value of 1st row
  69404. * @param initialM13 defines 3rd value of 1st row
  69405. * @param initialM14 defines 4th value of 1st row
  69406. * @param initialM21 defines 1st value of 2nd row
  69407. * @param initialM22 defines 2nd value of 2nd row
  69408. * @param initialM23 defines 3rd value of 2nd row
  69409. * @param initialM24 defines 4th value of 2nd row
  69410. * @param initialM31 defines 1st value of 3rd row
  69411. * @param initialM32 defines 2nd value of 3rd row
  69412. * @param initialM33 defines 3rd value of 3rd row
  69413. * @param initialM34 defines 4th value of 3rd row
  69414. * @param initialM41 defines 1st value of 4th row
  69415. * @param initialM42 defines 2nd value of 4th row
  69416. * @param initialM43 defines 3rd value of 4th row
  69417. * @param initialM44 defines 4th value of 4th row
  69418. * @param result defines the target matrix
  69419. */
  69420. 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;
  69421. /**
  69422. * Creates new matrix from a list of values (16)
  69423. * @param initialM11 defines 1st value of 1st row
  69424. * @param initialM12 defines 2nd value of 1st row
  69425. * @param initialM13 defines 3rd value of 1st row
  69426. * @param initialM14 defines 4th value of 1st row
  69427. * @param initialM21 defines 1st value of 2nd row
  69428. * @param initialM22 defines 2nd value of 2nd row
  69429. * @param initialM23 defines 3rd value of 2nd row
  69430. * @param initialM24 defines 4th value of 2nd row
  69431. * @param initialM31 defines 1st value of 3rd row
  69432. * @param initialM32 defines 2nd value of 3rd row
  69433. * @param initialM33 defines 3rd value of 3rd row
  69434. * @param initialM34 defines 4th value of 3rd row
  69435. * @param initialM41 defines 1st value of 4th row
  69436. * @param initialM42 defines 2nd value of 4th row
  69437. * @param initialM43 defines 3rd value of 4th row
  69438. * @param initialM44 defines 4th value of 4th row
  69439. * @returns the new matrix
  69440. */
  69441. 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;
  69442. /**
  69443. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  69444. * @param scale defines the scale vector3
  69445. * @param rotation defines the rotation quaternion
  69446. * @param translation defines the translation vector3
  69447. * @returns a new matrix
  69448. */
  69449. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  69450. /**
  69451. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  69452. * @param scale defines the scale vector3
  69453. * @param rotation defines the rotation quaternion
  69454. * @param translation defines the translation vector3
  69455. * @param result defines the target matrix
  69456. */
  69457. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  69458. /**
  69459. * Creates a new identity matrix
  69460. * @returns a new identity matrix
  69461. */
  69462. static Identity(): Matrix;
  69463. /**
  69464. * Creates a new identity matrix and stores the result in a given matrix
  69465. * @param result defines the target matrix
  69466. */
  69467. static IdentityToRef(result: Matrix): void;
  69468. /**
  69469. * Creates a new zero matrix
  69470. * @returns a new zero matrix
  69471. */
  69472. static Zero(): Matrix;
  69473. /**
  69474. * Creates a new rotation matrix for "angle" radians around the X axis
  69475. * @param angle defines the angle (in radians) to use
  69476. * @return the new matrix
  69477. */
  69478. static RotationX(angle: number): Matrix;
  69479. /**
  69480. * Creates a new matrix as the invert of a given matrix
  69481. * @param source defines the source matrix
  69482. * @returns the new matrix
  69483. */
  69484. static Invert(source: DeepImmutable<Matrix>): Matrix;
  69485. /**
  69486. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  69487. * @param angle defines the angle (in radians) to use
  69488. * @param result defines the target matrix
  69489. */
  69490. static RotationXToRef(angle: number, result: Matrix): void;
  69491. /**
  69492. * Creates a new rotation matrix for "angle" radians around the Y axis
  69493. * @param angle defines the angle (in radians) to use
  69494. * @return the new matrix
  69495. */
  69496. static RotationY(angle: number): Matrix;
  69497. /**
  69498. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  69499. * @param angle defines the angle (in radians) to use
  69500. * @param result defines the target matrix
  69501. */
  69502. static RotationYToRef(angle: number, result: Matrix): void;
  69503. /**
  69504. * Creates a new rotation matrix for "angle" radians around the Z axis
  69505. * @param angle defines the angle (in radians) to use
  69506. * @return the new matrix
  69507. */
  69508. static RotationZ(angle: number): Matrix;
  69509. /**
  69510. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  69511. * @param angle defines the angle (in radians) to use
  69512. * @param result defines the target matrix
  69513. */
  69514. static RotationZToRef(angle: number, result: Matrix): void;
  69515. /**
  69516. * Creates a new rotation matrix for "angle" radians around the given axis
  69517. * @param axis defines the axis to use
  69518. * @param angle defines the angle (in radians) to use
  69519. * @return the new matrix
  69520. */
  69521. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  69522. /**
  69523. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  69524. * @param axis defines the axis to use
  69525. * @param angle defines the angle (in radians) to use
  69526. * @param result defines the target matrix
  69527. */
  69528. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  69529. /**
  69530. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  69531. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  69532. * @param from defines the vector to align
  69533. * @param to defines the vector to align to
  69534. * @param result defines the target matrix
  69535. */
  69536. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  69537. /**
  69538. * Creates a rotation matrix
  69539. * @param yaw defines the yaw angle in radians (Y axis)
  69540. * @param pitch defines the pitch angle in radians (X axis)
  69541. * @param roll defines the roll angle in radians (X axis)
  69542. * @returns the new rotation matrix
  69543. */
  69544. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  69545. /**
  69546. * Creates a rotation matrix and stores it in a given matrix
  69547. * @param yaw defines the yaw angle in radians (Y axis)
  69548. * @param pitch defines the pitch angle in radians (X axis)
  69549. * @param roll defines the roll angle in radians (X axis)
  69550. * @param result defines the target matrix
  69551. */
  69552. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  69553. /**
  69554. * Creates a scaling matrix
  69555. * @param x defines the scale factor on X axis
  69556. * @param y defines the scale factor on Y axis
  69557. * @param z defines the scale factor on Z axis
  69558. * @returns the new matrix
  69559. */
  69560. static Scaling(x: number, y: number, z: number): Matrix;
  69561. /**
  69562. * Creates a scaling matrix and stores it in a given matrix
  69563. * @param x defines the scale factor on X axis
  69564. * @param y defines the scale factor on Y axis
  69565. * @param z defines the scale factor on Z axis
  69566. * @param result defines the target matrix
  69567. */
  69568. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  69569. /**
  69570. * Creates a translation matrix
  69571. * @param x defines the translation on X axis
  69572. * @param y defines the translation on Y axis
  69573. * @param z defines the translationon Z axis
  69574. * @returns the new matrix
  69575. */
  69576. static Translation(x: number, y: number, z: number): Matrix;
  69577. /**
  69578. * Creates a translation matrix and stores it in a given matrix
  69579. * @param x defines the translation on X axis
  69580. * @param y defines the translation on Y axis
  69581. * @param z defines the translationon Z axis
  69582. * @param result defines the target matrix
  69583. */
  69584. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  69585. /**
  69586. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  69587. * @param startValue defines the start value
  69588. * @param endValue defines the end value
  69589. * @param gradient defines the gradient factor
  69590. * @returns the new matrix
  69591. */
  69592. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  69593. /**
  69594. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  69595. * @param startValue defines the start value
  69596. * @param endValue defines the end value
  69597. * @param gradient defines the gradient factor
  69598. * @param result defines the Matrix object where to store data
  69599. */
  69600. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  69601. /**
  69602. * Builds a new matrix whose values are computed by:
  69603. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  69604. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  69605. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  69606. * @param startValue defines the first matrix
  69607. * @param endValue defines the second matrix
  69608. * @param gradient defines the gradient between the two matrices
  69609. * @returns the new matrix
  69610. */
  69611. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  69612. /**
  69613. * Update a matrix to values which are computed by:
  69614. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  69615. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  69616. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  69617. * @param startValue defines the first matrix
  69618. * @param endValue defines the second matrix
  69619. * @param gradient defines the gradient between the two matrices
  69620. * @param result defines the target matrix
  69621. */
  69622. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  69623. /**
  69624. * 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"
  69625. * This function works in left handed mode
  69626. * @param eye defines the final position of the entity
  69627. * @param target defines where the entity should look at
  69628. * @param up defines the up vector for the entity
  69629. * @returns the new matrix
  69630. */
  69631. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  69632. /**
  69633. * 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".
  69634. * This function works in left handed mode
  69635. * @param eye defines the final position of the entity
  69636. * @param target defines where the entity should look at
  69637. * @param up defines the up vector for the entity
  69638. * @param result defines the target matrix
  69639. */
  69640. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  69641. /**
  69642. * 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"
  69643. * This function works in right handed mode
  69644. * @param eye defines the final position of the entity
  69645. * @param target defines where the entity should look at
  69646. * @param up defines the up vector for the entity
  69647. * @returns the new matrix
  69648. */
  69649. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  69650. /**
  69651. * 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".
  69652. * This function works in right handed mode
  69653. * @param eye defines the final position of the entity
  69654. * @param target defines where the entity should look at
  69655. * @param up defines the up vector for the entity
  69656. * @param result defines the target matrix
  69657. */
  69658. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  69659. /**
  69660. * Create a left-handed orthographic projection matrix
  69661. * @param width defines the viewport width
  69662. * @param height defines the viewport height
  69663. * @param znear defines the near clip plane
  69664. * @param zfar defines the far clip plane
  69665. * @returns a new matrix as a left-handed orthographic projection matrix
  69666. */
  69667. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  69668. /**
  69669. * Store a left-handed orthographic projection to a given matrix
  69670. * @param width defines the viewport width
  69671. * @param height defines the viewport height
  69672. * @param znear defines the near clip plane
  69673. * @param zfar defines the far clip plane
  69674. * @param result defines the target matrix
  69675. */
  69676. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  69677. /**
  69678. * Create a left-handed orthographic projection matrix
  69679. * @param left defines the viewport left coordinate
  69680. * @param right defines the viewport right coordinate
  69681. * @param bottom defines the viewport bottom coordinate
  69682. * @param top defines the viewport top coordinate
  69683. * @param znear defines the near clip plane
  69684. * @param zfar defines the far clip plane
  69685. * @returns a new matrix as a left-handed orthographic projection matrix
  69686. */
  69687. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  69688. /**
  69689. * Stores a left-handed orthographic projection into a given matrix
  69690. * @param left defines the viewport left coordinate
  69691. * @param right defines the viewport right coordinate
  69692. * @param bottom defines the viewport bottom coordinate
  69693. * @param top defines the viewport top coordinate
  69694. * @param znear defines the near clip plane
  69695. * @param zfar defines the far clip plane
  69696. * @param result defines the target matrix
  69697. */
  69698. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  69699. /**
  69700. * Creates a right-handed orthographic projection matrix
  69701. * @param left defines the viewport left coordinate
  69702. * @param right defines the viewport right coordinate
  69703. * @param bottom defines the viewport bottom coordinate
  69704. * @param top defines the viewport top coordinate
  69705. * @param znear defines the near clip plane
  69706. * @param zfar defines the far clip plane
  69707. * @returns a new matrix as a right-handed orthographic projection matrix
  69708. */
  69709. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  69710. /**
  69711. * Stores a right-handed orthographic projection into a given matrix
  69712. * @param left defines the viewport left coordinate
  69713. * @param right defines the viewport right coordinate
  69714. * @param bottom defines the viewport bottom coordinate
  69715. * @param top defines the viewport top coordinate
  69716. * @param znear defines the near clip plane
  69717. * @param zfar defines the far clip plane
  69718. * @param result defines the target matrix
  69719. */
  69720. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  69721. /**
  69722. * Creates a left-handed perspective projection matrix
  69723. * @param width defines the viewport width
  69724. * @param height defines the viewport height
  69725. * @param znear defines the near clip plane
  69726. * @param zfar defines the far clip plane
  69727. * @returns a new matrix as a left-handed perspective projection matrix
  69728. */
  69729. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  69730. /**
  69731. * Creates a left-handed perspective projection matrix
  69732. * @param fov defines the horizontal field of view
  69733. * @param aspect defines the aspect ratio
  69734. * @param znear defines the near clip plane
  69735. * @param zfar defines the far clip plane
  69736. * @returns a new matrix as a left-handed perspective projection matrix
  69737. */
  69738. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  69739. /**
  69740. * Stores a left-handed perspective projection into a given matrix
  69741. * @param fov defines the horizontal field of view
  69742. * @param aspect defines the aspect ratio
  69743. * @param znear defines the near clip plane
  69744. * @param zfar defines the far clip plane
  69745. * @param result defines the target matrix
  69746. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  69747. */
  69748. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  69749. /**
  69750. * Creates a right-handed perspective projection matrix
  69751. * @param fov defines the horizontal field of view
  69752. * @param aspect defines the aspect ratio
  69753. * @param znear defines the near clip plane
  69754. * @param zfar defines the far clip plane
  69755. * @returns a new matrix as a right-handed perspective projection matrix
  69756. */
  69757. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  69758. /**
  69759. * Stores a right-handed perspective projection into a given matrix
  69760. * @param fov defines the horizontal field of view
  69761. * @param aspect defines the aspect ratio
  69762. * @param znear defines the near clip plane
  69763. * @param zfar defines the far clip plane
  69764. * @param result defines the target matrix
  69765. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  69766. */
  69767. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  69768. /**
  69769. * Stores a perspective projection for WebVR info a given matrix
  69770. * @param fov defines the field of view
  69771. * @param znear defines the near clip plane
  69772. * @param zfar defines the far clip plane
  69773. * @param result defines the target matrix
  69774. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  69775. */
  69776. static PerspectiveFovWebVRToRef(fov: {
  69777. upDegrees: number;
  69778. downDegrees: number;
  69779. leftDegrees: number;
  69780. rightDegrees: number;
  69781. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  69782. /**
  69783. * Computes a complete transformation matrix
  69784. * @param viewport defines the viewport to use
  69785. * @param world defines the world matrix
  69786. * @param view defines the view matrix
  69787. * @param projection defines the projection matrix
  69788. * @param zmin defines the near clip plane
  69789. * @param zmax defines the far clip plane
  69790. * @returns the transformation matrix
  69791. */
  69792. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  69793. /**
  69794. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  69795. * @param matrix defines the matrix to use
  69796. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  69797. */
  69798. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  69799. /**
  69800. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  69801. * @param matrix defines the matrix to use
  69802. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  69803. */
  69804. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  69805. /**
  69806. * Compute the transpose of a given matrix
  69807. * @param matrix defines the matrix to transpose
  69808. * @returns the new matrix
  69809. */
  69810. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  69811. /**
  69812. * Compute the transpose of a matrix and store it in a target matrix
  69813. * @param matrix defines the matrix to transpose
  69814. * @param result defines the target matrix
  69815. */
  69816. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  69817. /**
  69818. * Computes a reflection matrix from a plane
  69819. * @param plane defines the reflection plane
  69820. * @returns a new matrix
  69821. */
  69822. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  69823. /**
  69824. * Computes a reflection matrix from a plane
  69825. * @param plane defines the reflection plane
  69826. * @param result defines the target matrix
  69827. */
  69828. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  69829. /**
  69830. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  69831. * @param xaxis defines the value of the 1st axis
  69832. * @param yaxis defines the value of the 2nd axis
  69833. * @param zaxis defines the value of the 3rd axis
  69834. * @param result defines the target matrix
  69835. */
  69836. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  69837. /**
  69838. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  69839. * @param quat defines the quaternion to use
  69840. * @param result defines the target matrix
  69841. */
  69842. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  69843. }
  69844. /**
  69845. * @hidden
  69846. */
  69847. export class TmpVectors {
  69848. static Vector2: Vector2[];
  69849. static Vector3: Vector3[];
  69850. static Vector4: Vector4[];
  69851. static Quaternion: Quaternion[];
  69852. static Matrix: Matrix[];
  69853. }
  69854. }
  69855. declare module BABYLON {
  69856. /** Defines the cross module used constants to avoid circular dependncies */
  69857. export class Constants {
  69858. /** Defines that alpha blending is disabled */
  69859. static readonly ALPHA_DISABLE: number;
  69860. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  69861. static readonly ALPHA_ADD: number;
  69862. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  69863. static readonly ALPHA_COMBINE: number;
  69864. /** Defines that alpha blending to DEST - SRC * DEST */
  69865. static readonly ALPHA_SUBTRACT: number;
  69866. /** Defines that alpha blending to SRC * DEST */
  69867. static readonly ALPHA_MULTIPLY: number;
  69868. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  69869. static readonly ALPHA_MAXIMIZED: number;
  69870. /** Defines that alpha blending to SRC + DEST */
  69871. static readonly ALPHA_ONEONE: number;
  69872. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  69873. static readonly ALPHA_PREMULTIPLIED: number;
  69874. /**
  69875. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  69876. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  69877. */
  69878. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  69879. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  69880. static readonly ALPHA_INTERPOLATE: number;
  69881. /**
  69882. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  69883. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  69884. */
  69885. static readonly ALPHA_SCREENMODE: number;
  69886. /** Defines that the ressource is not delayed*/
  69887. static readonly DELAYLOADSTATE_NONE: number;
  69888. /** Defines that the ressource was successfully delay loaded */
  69889. static readonly DELAYLOADSTATE_LOADED: number;
  69890. /** Defines that the ressource is currently delay loading */
  69891. static readonly DELAYLOADSTATE_LOADING: number;
  69892. /** Defines that the ressource is delayed and has not started loading */
  69893. static readonly DELAYLOADSTATE_NOTLOADED: number;
  69894. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  69895. static readonly NEVER: number;
  69896. /** 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 */
  69897. static readonly ALWAYS: number;
  69898. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  69899. static readonly LESS: number;
  69900. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  69901. static readonly EQUAL: number;
  69902. /** 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 */
  69903. static readonly LEQUAL: number;
  69904. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  69905. static readonly GREATER: number;
  69906. /** 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 */
  69907. static readonly GEQUAL: number;
  69908. /** 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 */
  69909. static readonly NOTEQUAL: number;
  69910. /** Passed to stencilOperation to specify that stencil value must be kept */
  69911. static readonly KEEP: number;
  69912. /** Passed to stencilOperation to specify that stencil value must be replaced */
  69913. static readonly REPLACE: number;
  69914. /** Passed to stencilOperation to specify that stencil value must be incremented */
  69915. static readonly INCR: number;
  69916. /** Passed to stencilOperation to specify that stencil value must be decremented */
  69917. static readonly DECR: number;
  69918. /** Passed to stencilOperation to specify that stencil value must be inverted */
  69919. static readonly INVERT: number;
  69920. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  69921. static readonly INCR_WRAP: number;
  69922. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  69923. static readonly DECR_WRAP: number;
  69924. /** Texture is not repeating outside of 0..1 UVs */
  69925. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  69926. /** Texture is repeating outside of 0..1 UVs */
  69927. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  69928. /** Texture is repeating and mirrored */
  69929. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  69930. /** ALPHA */
  69931. static readonly TEXTUREFORMAT_ALPHA: number;
  69932. /** LUMINANCE */
  69933. static readonly TEXTUREFORMAT_LUMINANCE: number;
  69934. /** LUMINANCE_ALPHA */
  69935. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  69936. /** RGB */
  69937. static readonly TEXTUREFORMAT_RGB: number;
  69938. /** RGBA */
  69939. static readonly TEXTUREFORMAT_RGBA: number;
  69940. /** RED */
  69941. static readonly TEXTUREFORMAT_RED: number;
  69942. /** RED (2nd reference) */
  69943. static readonly TEXTUREFORMAT_R: number;
  69944. /** RG */
  69945. static readonly TEXTUREFORMAT_RG: number;
  69946. /** RED_INTEGER */
  69947. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  69948. /** RED_INTEGER (2nd reference) */
  69949. static readonly TEXTUREFORMAT_R_INTEGER: number;
  69950. /** RG_INTEGER */
  69951. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  69952. /** RGB_INTEGER */
  69953. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  69954. /** RGBA_INTEGER */
  69955. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  69956. /** UNSIGNED_BYTE */
  69957. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  69958. /** UNSIGNED_BYTE (2nd reference) */
  69959. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  69960. /** FLOAT */
  69961. static readonly TEXTURETYPE_FLOAT: number;
  69962. /** HALF_FLOAT */
  69963. static readonly TEXTURETYPE_HALF_FLOAT: number;
  69964. /** BYTE */
  69965. static readonly TEXTURETYPE_BYTE: number;
  69966. /** SHORT */
  69967. static readonly TEXTURETYPE_SHORT: number;
  69968. /** UNSIGNED_SHORT */
  69969. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  69970. /** INT */
  69971. static readonly TEXTURETYPE_INT: number;
  69972. /** UNSIGNED_INT */
  69973. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  69974. /** UNSIGNED_SHORT_4_4_4_4 */
  69975. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  69976. /** UNSIGNED_SHORT_5_5_5_1 */
  69977. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  69978. /** UNSIGNED_SHORT_5_6_5 */
  69979. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  69980. /** UNSIGNED_INT_2_10_10_10_REV */
  69981. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  69982. /** UNSIGNED_INT_24_8 */
  69983. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  69984. /** UNSIGNED_INT_10F_11F_11F_REV */
  69985. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  69986. /** UNSIGNED_INT_5_9_9_9_REV */
  69987. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  69988. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  69989. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  69990. /** nearest is mag = nearest and min = nearest and mip = linear */
  69991. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  69992. /** Bilinear is mag = linear and min = linear and mip = nearest */
  69993. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  69994. /** Trilinear is mag = linear and min = linear and mip = linear */
  69995. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  69996. /** nearest is mag = nearest and min = nearest and mip = linear */
  69997. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  69998. /** Bilinear is mag = linear and min = linear and mip = nearest */
  69999. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  70000. /** Trilinear is mag = linear and min = linear and mip = linear */
  70001. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  70002. /** mag = nearest and min = nearest and mip = nearest */
  70003. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  70004. /** mag = nearest and min = linear and mip = nearest */
  70005. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  70006. /** mag = nearest and min = linear and mip = linear */
  70007. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  70008. /** mag = nearest and min = linear and mip = none */
  70009. static readonly TEXTURE_NEAREST_LINEAR: number;
  70010. /** mag = nearest and min = nearest and mip = none */
  70011. static readonly TEXTURE_NEAREST_NEAREST: number;
  70012. /** mag = linear and min = nearest and mip = nearest */
  70013. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  70014. /** mag = linear and min = nearest and mip = linear */
  70015. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  70016. /** mag = linear and min = linear and mip = none */
  70017. static readonly TEXTURE_LINEAR_LINEAR: number;
  70018. /** mag = linear and min = nearest and mip = none */
  70019. static readonly TEXTURE_LINEAR_NEAREST: number;
  70020. /** Explicit coordinates mode */
  70021. static readonly TEXTURE_EXPLICIT_MODE: number;
  70022. /** Spherical coordinates mode */
  70023. static readonly TEXTURE_SPHERICAL_MODE: number;
  70024. /** Planar coordinates mode */
  70025. static readonly TEXTURE_PLANAR_MODE: number;
  70026. /** Cubic coordinates mode */
  70027. static readonly TEXTURE_CUBIC_MODE: number;
  70028. /** Projection coordinates mode */
  70029. static readonly TEXTURE_PROJECTION_MODE: number;
  70030. /** Skybox coordinates mode */
  70031. static readonly TEXTURE_SKYBOX_MODE: number;
  70032. /** Inverse Cubic coordinates mode */
  70033. static readonly TEXTURE_INVCUBIC_MODE: number;
  70034. /** Equirectangular coordinates mode */
  70035. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  70036. /** Equirectangular Fixed coordinates mode */
  70037. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  70038. /** Equirectangular Fixed Mirrored coordinates mode */
  70039. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  70040. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  70041. static readonly SCALEMODE_FLOOR: number;
  70042. /** Defines that texture rescaling will look for the nearest power of 2 size */
  70043. static readonly SCALEMODE_NEAREST: number;
  70044. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  70045. static readonly SCALEMODE_CEILING: number;
  70046. /**
  70047. * The dirty texture flag value
  70048. */
  70049. static readonly MATERIAL_TextureDirtyFlag: number;
  70050. /**
  70051. * The dirty light flag value
  70052. */
  70053. static readonly MATERIAL_LightDirtyFlag: number;
  70054. /**
  70055. * The dirty fresnel flag value
  70056. */
  70057. static readonly MATERIAL_FresnelDirtyFlag: number;
  70058. /**
  70059. * The dirty attribute flag value
  70060. */
  70061. static readonly MATERIAL_AttributesDirtyFlag: number;
  70062. /**
  70063. * The dirty misc flag value
  70064. */
  70065. static readonly MATERIAL_MiscDirtyFlag: number;
  70066. /**
  70067. * The all dirty flag value
  70068. */
  70069. static readonly MATERIAL_AllDirtyFlag: number;
  70070. /**
  70071. * Returns the triangle fill mode
  70072. */
  70073. static readonly MATERIAL_TriangleFillMode: number;
  70074. /**
  70075. * Returns the wireframe mode
  70076. */
  70077. static readonly MATERIAL_WireFrameFillMode: number;
  70078. /**
  70079. * Returns the point fill mode
  70080. */
  70081. static readonly MATERIAL_PointFillMode: number;
  70082. /**
  70083. * Returns the point list draw mode
  70084. */
  70085. static readonly MATERIAL_PointListDrawMode: number;
  70086. /**
  70087. * Returns the line list draw mode
  70088. */
  70089. static readonly MATERIAL_LineListDrawMode: number;
  70090. /**
  70091. * Returns the line loop draw mode
  70092. */
  70093. static readonly MATERIAL_LineLoopDrawMode: number;
  70094. /**
  70095. * Returns the line strip draw mode
  70096. */
  70097. static readonly MATERIAL_LineStripDrawMode: number;
  70098. /**
  70099. * Returns the triangle strip draw mode
  70100. */
  70101. static readonly MATERIAL_TriangleStripDrawMode: number;
  70102. /**
  70103. * Returns the triangle fan draw mode
  70104. */
  70105. static readonly MATERIAL_TriangleFanDrawMode: number;
  70106. /**
  70107. * Stores the clock-wise side orientation
  70108. */
  70109. static readonly MATERIAL_ClockWiseSideOrientation: number;
  70110. /**
  70111. * Stores the counter clock-wise side orientation
  70112. */
  70113. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  70114. /**
  70115. * Nothing
  70116. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70117. */
  70118. static readonly ACTION_NothingTrigger: number;
  70119. /**
  70120. * On pick
  70121. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70122. */
  70123. static readonly ACTION_OnPickTrigger: number;
  70124. /**
  70125. * On left pick
  70126. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70127. */
  70128. static readonly ACTION_OnLeftPickTrigger: number;
  70129. /**
  70130. * On right pick
  70131. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70132. */
  70133. static readonly ACTION_OnRightPickTrigger: number;
  70134. /**
  70135. * On center pick
  70136. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70137. */
  70138. static readonly ACTION_OnCenterPickTrigger: number;
  70139. /**
  70140. * On pick down
  70141. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70142. */
  70143. static readonly ACTION_OnPickDownTrigger: number;
  70144. /**
  70145. * On double pick
  70146. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70147. */
  70148. static readonly ACTION_OnDoublePickTrigger: number;
  70149. /**
  70150. * On pick up
  70151. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70152. */
  70153. static readonly ACTION_OnPickUpTrigger: number;
  70154. /**
  70155. * On pick out.
  70156. * This trigger will only be raised if you also declared a OnPickDown
  70157. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70158. */
  70159. static readonly ACTION_OnPickOutTrigger: number;
  70160. /**
  70161. * On long press
  70162. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70163. */
  70164. static readonly ACTION_OnLongPressTrigger: number;
  70165. /**
  70166. * On pointer over
  70167. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70168. */
  70169. static readonly ACTION_OnPointerOverTrigger: number;
  70170. /**
  70171. * On pointer out
  70172. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70173. */
  70174. static readonly ACTION_OnPointerOutTrigger: number;
  70175. /**
  70176. * On every frame
  70177. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70178. */
  70179. static readonly ACTION_OnEveryFrameTrigger: number;
  70180. /**
  70181. * On intersection enter
  70182. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70183. */
  70184. static readonly ACTION_OnIntersectionEnterTrigger: number;
  70185. /**
  70186. * On intersection exit
  70187. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70188. */
  70189. static readonly ACTION_OnIntersectionExitTrigger: number;
  70190. /**
  70191. * On key down
  70192. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70193. */
  70194. static readonly ACTION_OnKeyDownTrigger: number;
  70195. /**
  70196. * On key up
  70197. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70198. */
  70199. static readonly ACTION_OnKeyUpTrigger: number;
  70200. /**
  70201. * Billboard mode will only apply to Y axis
  70202. */
  70203. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  70204. /**
  70205. * Billboard mode will apply to all axes
  70206. */
  70207. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  70208. /**
  70209. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  70210. */
  70211. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  70212. /**
  70213. * Gets or sets base Assets URL
  70214. */
  70215. static PARTICLES_BaseAssetsUrl: string;
  70216. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  70217. * Test order :
  70218. * Is the bounding sphere outside the frustum ?
  70219. * If not, are the bounding box vertices outside the frustum ?
  70220. * It not, then the cullable object is in the frustum.
  70221. */
  70222. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  70223. /** Culling strategy : Bounding Sphere Only.
  70224. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  70225. * It's also less accurate than the standard because some not visible objects can still be selected.
  70226. * Test : is the bounding sphere outside the frustum ?
  70227. * If not, then the cullable object is in the frustum.
  70228. */
  70229. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  70230. /** Culling strategy : Optimistic Inclusion.
  70231. * This in an inclusion test first, then the standard exclusion test.
  70232. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  70233. * 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.
  70234. * Anyway, it's as accurate as the standard strategy.
  70235. * Test :
  70236. * Is the cullable object bounding sphere center in the frustum ?
  70237. * If not, apply the default culling strategy.
  70238. */
  70239. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  70240. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  70241. * This in an inclusion test first, then the bounding sphere only exclusion test.
  70242. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  70243. * 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.
  70244. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  70245. * Test :
  70246. * Is the cullable object bounding sphere center in the frustum ?
  70247. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  70248. */
  70249. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  70250. /**
  70251. * No logging while loading
  70252. */
  70253. static readonly SCENELOADER_NO_LOGGING: number;
  70254. /**
  70255. * Minimal logging while loading
  70256. */
  70257. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  70258. /**
  70259. * Summary logging while loading
  70260. */
  70261. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  70262. /**
  70263. * Detailled logging while loading
  70264. */
  70265. static readonly SCENELOADER_DETAILED_LOGGING: number;
  70266. }
  70267. }
  70268. declare module BABYLON {
  70269. /**
  70270. * Class used to store and describe the pipeline context associated with an effect
  70271. */
  70272. export interface IPipelineContext {
  70273. /**
  70274. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  70275. */
  70276. isAsync: boolean;
  70277. /**
  70278. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  70279. */
  70280. isReady: boolean;
  70281. /** @hidden */
  70282. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  70283. }
  70284. }
  70285. declare module BABYLON {
  70286. /** @hidden */
  70287. export interface IShaderProcessor {
  70288. attributeProcessor?: (attribute: string) => string;
  70289. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  70290. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  70291. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  70292. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  70293. lineProcessor?: (line: string, isFragment: boolean) => string;
  70294. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  70295. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  70296. }
  70297. }
  70298. declare module BABYLON {
  70299. /** @hidden */
  70300. export interface ProcessingOptions {
  70301. defines: string[];
  70302. indexParameters: any;
  70303. isFragment: boolean;
  70304. shouldUseHighPrecisionShader: boolean;
  70305. supportsUniformBuffers: boolean;
  70306. shadersRepository: string;
  70307. includesShadersStore: {
  70308. [key: string]: string;
  70309. };
  70310. processor?: IShaderProcessor;
  70311. version: string;
  70312. platformName: string;
  70313. lookForClosingBracketForUniformBuffer?: boolean;
  70314. }
  70315. }
  70316. declare module BABYLON {
  70317. /**
  70318. * Helper to manipulate strings
  70319. */
  70320. export class StringTools {
  70321. /**
  70322. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  70323. * @param str Source string
  70324. * @param suffix Suffix to search for in the source string
  70325. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  70326. */
  70327. static EndsWith(str: string, suffix: string): boolean;
  70328. /**
  70329. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  70330. * @param str Source string
  70331. * @param suffix Suffix to search for in the source string
  70332. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  70333. */
  70334. static StartsWith(str: string, suffix: string): boolean;
  70335. }
  70336. }
  70337. declare module BABYLON {
  70338. /** @hidden */
  70339. export class ShaderCodeNode {
  70340. line: string;
  70341. children: ShaderCodeNode[];
  70342. additionalDefineKey?: string;
  70343. additionalDefineValue?: string;
  70344. isValid(preprocessors: {
  70345. [key: string]: string;
  70346. }): boolean;
  70347. process(preprocessors: {
  70348. [key: string]: string;
  70349. }, options: ProcessingOptions): string;
  70350. }
  70351. }
  70352. declare module BABYLON {
  70353. /** @hidden */
  70354. export class ShaderCodeCursor {
  70355. private _lines;
  70356. lineIndex: number;
  70357. readonly currentLine: string;
  70358. readonly canRead: boolean;
  70359. lines: string[];
  70360. }
  70361. }
  70362. declare module BABYLON {
  70363. /** @hidden */
  70364. export class ShaderCodeConditionNode extends ShaderCodeNode {
  70365. process(preprocessors: {
  70366. [key: string]: string;
  70367. }, options: ProcessingOptions): string;
  70368. }
  70369. }
  70370. declare module BABYLON {
  70371. /** @hidden */
  70372. export class ShaderDefineExpression {
  70373. isTrue(preprocessors: {
  70374. [key: string]: string;
  70375. }): boolean;
  70376. }
  70377. }
  70378. declare module BABYLON {
  70379. /** @hidden */
  70380. export class ShaderCodeTestNode extends ShaderCodeNode {
  70381. testExpression: ShaderDefineExpression;
  70382. isValid(preprocessors: {
  70383. [key: string]: string;
  70384. }): boolean;
  70385. }
  70386. }
  70387. declare module BABYLON {
  70388. /** @hidden */
  70389. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  70390. define: string;
  70391. not: boolean;
  70392. constructor(define: string, not?: boolean);
  70393. isTrue(preprocessors: {
  70394. [key: string]: string;
  70395. }): boolean;
  70396. }
  70397. }
  70398. declare module BABYLON {
  70399. /** @hidden */
  70400. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  70401. leftOperand: ShaderDefineExpression;
  70402. rightOperand: ShaderDefineExpression;
  70403. isTrue(preprocessors: {
  70404. [key: string]: string;
  70405. }): boolean;
  70406. }
  70407. }
  70408. declare module BABYLON {
  70409. /** @hidden */
  70410. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  70411. leftOperand: ShaderDefineExpression;
  70412. rightOperand: ShaderDefineExpression;
  70413. isTrue(preprocessors: {
  70414. [key: string]: string;
  70415. }): boolean;
  70416. }
  70417. }
  70418. declare module BABYLON {
  70419. /** @hidden */
  70420. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  70421. define: string;
  70422. operand: string;
  70423. testValue: string;
  70424. constructor(define: string, operand: string, testValue: string);
  70425. isTrue(preprocessors: {
  70426. [key: string]: string;
  70427. }): boolean;
  70428. }
  70429. }
  70430. declare module BABYLON {
  70431. /**
  70432. * @ignore
  70433. * Application error to support additional information when loading a file
  70434. */
  70435. export class LoadFileError extends Error {
  70436. /** defines the optional web request */
  70437. request?: WebRequest | undefined;
  70438. private static _setPrototypeOf;
  70439. /**
  70440. * Creates a new LoadFileError
  70441. * @param message defines the message of the error
  70442. * @param request defines the optional web request
  70443. */
  70444. constructor(message: string,
  70445. /** defines the optional web request */
  70446. request?: WebRequest | undefined);
  70447. }
  70448. }
  70449. declare module BABYLON {
  70450. /**
  70451. * Class used to enable access to offline support
  70452. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  70453. */
  70454. export interface IOfflineProvider {
  70455. /**
  70456. * Gets a boolean indicating if scene must be saved in the database
  70457. */
  70458. enableSceneOffline: boolean;
  70459. /**
  70460. * Gets a boolean indicating if textures must be saved in the database
  70461. */
  70462. enableTexturesOffline: boolean;
  70463. /**
  70464. * Open the offline support and make it available
  70465. * @param successCallback defines the callback to call on success
  70466. * @param errorCallback defines the callback to call on error
  70467. */
  70468. open(successCallback: () => void, errorCallback: () => void): void;
  70469. /**
  70470. * Loads an image from the offline support
  70471. * @param url defines the url to load from
  70472. * @param image defines the target DOM image
  70473. */
  70474. loadImage(url: string, image: HTMLImageElement): void;
  70475. /**
  70476. * Loads a file from offline support
  70477. * @param url defines the URL to load from
  70478. * @param sceneLoaded defines a callback to call on success
  70479. * @param progressCallBack defines a callback to call when progress changed
  70480. * @param errorCallback defines a callback to call on error
  70481. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  70482. */
  70483. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  70484. }
  70485. }
  70486. declare module BABYLON {
  70487. /**
  70488. * Class used to help managing file picking and drag'n'drop
  70489. * File Storage
  70490. */
  70491. export class FilesInputStore {
  70492. /**
  70493. * List of files ready to be loaded
  70494. */
  70495. static FilesToLoad: {
  70496. [key: string]: File;
  70497. };
  70498. }
  70499. }
  70500. declare module BABYLON {
  70501. /**
  70502. * Class used to define a retry strategy when error happens while loading assets
  70503. */
  70504. export class RetryStrategy {
  70505. /**
  70506. * Function used to defines an exponential back off strategy
  70507. * @param maxRetries defines the maximum number of retries (3 by default)
  70508. * @param baseInterval defines the interval between retries
  70509. * @returns the strategy function to use
  70510. */
  70511. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  70512. }
  70513. }
  70514. declare module BABYLON {
  70515. /**
  70516. * @hidden
  70517. */
  70518. export class FileTools {
  70519. /**
  70520. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  70521. */
  70522. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  70523. /**
  70524. * Gets or sets the base URL to use to load assets
  70525. */
  70526. static BaseUrl: string;
  70527. /**
  70528. * Default behaviour for cors in the application.
  70529. * It can be a string if the expected behavior is identical in the entire app.
  70530. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  70531. */
  70532. static CorsBehavior: string | ((url: string | string[]) => string);
  70533. /**
  70534. * Gets or sets a function used to pre-process url before using them to load assets
  70535. */
  70536. static PreprocessUrl: (url: string) => string;
  70537. /**
  70538. * Removes unwanted characters from an url
  70539. * @param url defines the url to clean
  70540. * @returns the cleaned url
  70541. */
  70542. private static _CleanUrl;
  70543. /**
  70544. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  70545. * @param url define the url we are trying
  70546. * @param element define the dom element where to configure the cors policy
  70547. */
  70548. static SetCorsBehavior(url: string | string[], element: {
  70549. crossOrigin: string | null;
  70550. }): void;
  70551. /**
  70552. * Loads an image as an HTMLImageElement.
  70553. * @param input url string, ArrayBuffer, or Blob to load
  70554. * @param onLoad callback called when the image successfully loads
  70555. * @param onError callback called when the image fails to load
  70556. * @param offlineProvider offline provider for caching
  70557. * @returns the HTMLImageElement of the loaded image
  70558. */
  70559. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  70560. /**
  70561. * Loads a file
  70562. * @param fileToLoad defines the file to load
  70563. * @param callback defines the callback to call when data is loaded
  70564. * @param progressCallBack defines the callback to call during loading process
  70565. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  70566. * @returns a file request object
  70567. */
  70568. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  70569. /**
  70570. * Loads a file
  70571. * @param url url string, ArrayBuffer, or Blob to load
  70572. * @param onSuccess callback called when the file successfully loads
  70573. * @param onProgress callback called while file is loading (if the server supports this mode)
  70574. * @param offlineProvider defines the offline provider for caching
  70575. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  70576. * @param onError callback called when the file fails to load
  70577. * @returns a file request object
  70578. */
  70579. 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;
  70580. /**
  70581. * Checks if the loaded document was accessed via `file:`-Protocol.
  70582. * @returns boolean
  70583. */
  70584. static IsFileURL(): boolean;
  70585. }
  70586. }
  70587. declare module BABYLON {
  70588. /** @hidden */
  70589. export class ShaderProcessor {
  70590. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  70591. private static _ProcessPrecision;
  70592. private static _ExtractOperation;
  70593. private static _BuildSubExpression;
  70594. private static _BuildExpression;
  70595. private static _MoveCursorWithinIf;
  70596. private static _MoveCursor;
  70597. private static _EvaluatePreProcessors;
  70598. private static _PreparePreProcessors;
  70599. private static _ProcessShaderConversion;
  70600. private static _ProcessIncludes;
  70601. }
  70602. }
  70603. declare module BABYLON {
  70604. /**
  70605. * Class used to hold a RBG color
  70606. */
  70607. export class Color3 {
  70608. /**
  70609. * Defines the red component (between 0 and 1, default is 0)
  70610. */
  70611. r: number;
  70612. /**
  70613. * Defines the green component (between 0 and 1, default is 0)
  70614. */
  70615. g: number;
  70616. /**
  70617. * Defines the blue component (between 0 and 1, default is 0)
  70618. */
  70619. b: number;
  70620. /**
  70621. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  70622. * @param r defines the red component (between 0 and 1, default is 0)
  70623. * @param g defines the green component (between 0 and 1, default is 0)
  70624. * @param b defines the blue component (between 0 and 1, default is 0)
  70625. */
  70626. constructor(
  70627. /**
  70628. * Defines the red component (between 0 and 1, default is 0)
  70629. */
  70630. r?: number,
  70631. /**
  70632. * Defines the green component (between 0 and 1, default is 0)
  70633. */
  70634. g?: number,
  70635. /**
  70636. * Defines the blue component (between 0 and 1, default is 0)
  70637. */
  70638. b?: number);
  70639. /**
  70640. * Creates a string with the Color3 current values
  70641. * @returns the string representation of the Color3 object
  70642. */
  70643. toString(): string;
  70644. /**
  70645. * Returns the string "Color3"
  70646. * @returns "Color3"
  70647. */
  70648. getClassName(): string;
  70649. /**
  70650. * Compute the Color3 hash code
  70651. * @returns an unique number that can be used to hash Color3 objects
  70652. */
  70653. getHashCode(): number;
  70654. /**
  70655. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  70656. * @param array defines the array where to store the r,g,b components
  70657. * @param index defines an optional index in the target array to define where to start storing values
  70658. * @returns the current Color3 object
  70659. */
  70660. toArray(array: FloatArray, index?: number): Color3;
  70661. /**
  70662. * Returns a new Color4 object from the current Color3 and the given alpha
  70663. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  70664. * @returns a new Color4 object
  70665. */
  70666. toColor4(alpha?: number): Color4;
  70667. /**
  70668. * Returns a new array populated with 3 numeric elements : red, green and blue values
  70669. * @returns the new array
  70670. */
  70671. asArray(): number[];
  70672. /**
  70673. * Returns the luminance value
  70674. * @returns a float value
  70675. */
  70676. toLuminance(): number;
  70677. /**
  70678. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  70679. * @param otherColor defines the second operand
  70680. * @returns the new Color3 object
  70681. */
  70682. multiply(otherColor: DeepImmutable<Color3>): Color3;
  70683. /**
  70684. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  70685. * @param otherColor defines the second operand
  70686. * @param result defines the Color3 object where to store the result
  70687. * @returns the current Color3
  70688. */
  70689. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70690. /**
  70691. * Determines equality between Color3 objects
  70692. * @param otherColor defines the second operand
  70693. * @returns true if the rgb values are equal to the given ones
  70694. */
  70695. equals(otherColor: DeepImmutable<Color3>): boolean;
  70696. /**
  70697. * Determines equality between the current Color3 object and a set of r,b,g values
  70698. * @param r defines the red component to check
  70699. * @param g defines the green component to check
  70700. * @param b defines the blue component to check
  70701. * @returns true if the rgb values are equal to the given ones
  70702. */
  70703. equalsFloats(r: number, g: number, b: number): boolean;
  70704. /**
  70705. * Multiplies in place each rgb value by scale
  70706. * @param scale defines the scaling factor
  70707. * @returns the updated Color3
  70708. */
  70709. scale(scale: number): Color3;
  70710. /**
  70711. * Multiplies the rgb values by scale and stores the result into "result"
  70712. * @param scale defines the scaling factor
  70713. * @param result defines the Color3 object where to store the result
  70714. * @returns the unmodified current Color3
  70715. */
  70716. scaleToRef(scale: number, result: Color3): Color3;
  70717. /**
  70718. * Scale the current Color3 values by a factor and add the result to a given Color3
  70719. * @param scale defines the scale factor
  70720. * @param result defines color to store the result into
  70721. * @returns the unmodified current Color3
  70722. */
  70723. scaleAndAddToRef(scale: number, result: Color3): Color3;
  70724. /**
  70725. * Clamps the rgb values by the min and max values and stores the result into "result"
  70726. * @param min defines minimum clamping value (default is 0)
  70727. * @param max defines maximum clamping value (default is 1)
  70728. * @param result defines color to store the result into
  70729. * @returns the original Color3
  70730. */
  70731. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  70732. /**
  70733. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  70734. * @param otherColor defines the second operand
  70735. * @returns the new Color3
  70736. */
  70737. add(otherColor: DeepImmutable<Color3>): Color3;
  70738. /**
  70739. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  70740. * @param otherColor defines the second operand
  70741. * @param result defines Color3 object to store the result into
  70742. * @returns the unmodified current Color3
  70743. */
  70744. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70745. /**
  70746. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  70747. * @param otherColor defines the second operand
  70748. * @returns the new Color3
  70749. */
  70750. subtract(otherColor: DeepImmutable<Color3>): Color3;
  70751. /**
  70752. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  70753. * @param otherColor defines the second operand
  70754. * @param result defines Color3 object to store the result into
  70755. * @returns the unmodified current Color3
  70756. */
  70757. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70758. /**
  70759. * Copy the current object
  70760. * @returns a new Color3 copied the current one
  70761. */
  70762. clone(): Color3;
  70763. /**
  70764. * Copies the rgb values from the source in the current Color3
  70765. * @param source defines the source Color3 object
  70766. * @returns the updated Color3 object
  70767. */
  70768. copyFrom(source: DeepImmutable<Color3>): Color3;
  70769. /**
  70770. * Updates the Color3 rgb values from the given floats
  70771. * @param r defines the red component to read from
  70772. * @param g defines the green component to read from
  70773. * @param b defines the blue component to read from
  70774. * @returns the current Color3 object
  70775. */
  70776. copyFromFloats(r: number, g: number, b: number): Color3;
  70777. /**
  70778. * Updates the Color3 rgb values from the given floats
  70779. * @param r defines the red component to read from
  70780. * @param g defines the green component to read from
  70781. * @param b defines the blue component to read from
  70782. * @returns the current Color3 object
  70783. */
  70784. set(r: number, g: number, b: number): Color3;
  70785. /**
  70786. * Compute the Color3 hexadecimal code as a string
  70787. * @returns a string containing the hexadecimal representation of the Color3 object
  70788. */
  70789. toHexString(): string;
  70790. /**
  70791. * Computes a new Color3 converted from the current one to linear space
  70792. * @returns a new Color3 object
  70793. */
  70794. toLinearSpace(): Color3;
  70795. /**
  70796. * Converts current color in rgb space to HSV values
  70797. * @returns a new color3 representing the HSV values
  70798. */
  70799. toHSV(): Color3;
  70800. /**
  70801. * Converts current color in rgb space to HSV values
  70802. * @param result defines the Color3 where to store the HSV values
  70803. */
  70804. toHSVToRef(result: Color3): void;
  70805. /**
  70806. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  70807. * @param convertedColor defines the Color3 object where to store the linear space version
  70808. * @returns the unmodified Color3
  70809. */
  70810. toLinearSpaceToRef(convertedColor: Color3): Color3;
  70811. /**
  70812. * Computes a new Color3 converted from the current one to gamma space
  70813. * @returns a new Color3 object
  70814. */
  70815. toGammaSpace(): Color3;
  70816. /**
  70817. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  70818. * @param convertedColor defines the Color3 object where to store the gamma space version
  70819. * @returns the unmodified Color3
  70820. */
  70821. toGammaSpaceToRef(convertedColor: Color3): Color3;
  70822. private static _BlackReadOnly;
  70823. /**
  70824. * Convert Hue, saturation and value to a Color3 (RGB)
  70825. * @param hue defines the hue
  70826. * @param saturation defines the saturation
  70827. * @param value defines the value
  70828. * @param result defines the Color3 where to store the RGB values
  70829. */
  70830. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  70831. /**
  70832. * Creates a new Color3 from the string containing valid hexadecimal values
  70833. * @param hex defines a string containing valid hexadecimal values
  70834. * @returns a new Color3 object
  70835. */
  70836. static FromHexString(hex: string): Color3;
  70837. /**
  70838. * Creates a new Color3 from the starting index of the given array
  70839. * @param array defines the source array
  70840. * @param offset defines an offset in the source array
  70841. * @returns a new Color3 object
  70842. */
  70843. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  70844. /**
  70845. * Creates a new Color3 from integer values (< 256)
  70846. * @param r defines the red component to read from (value between 0 and 255)
  70847. * @param g defines the green component to read from (value between 0 and 255)
  70848. * @param b defines the blue component to read from (value between 0 and 255)
  70849. * @returns a new Color3 object
  70850. */
  70851. static FromInts(r: number, g: number, b: number): Color3;
  70852. /**
  70853. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70854. * @param start defines the start Color3 value
  70855. * @param end defines the end Color3 value
  70856. * @param amount defines the gradient value between start and end
  70857. * @returns a new Color3 object
  70858. */
  70859. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  70860. /**
  70861. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70862. * @param left defines the start value
  70863. * @param right defines the end value
  70864. * @param amount defines the gradient factor
  70865. * @param result defines the Color3 object where to store the result
  70866. */
  70867. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  70868. /**
  70869. * Returns a Color3 value containing a red color
  70870. * @returns a new Color3 object
  70871. */
  70872. static Red(): Color3;
  70873. /**
  70874. * Returns a Color3 value containing a green color
  70875. * @returns a new Color3 object
  70876. */
  70877. static Green(): Color3;
  70878. /**
  70879. * Returns a Color3 value containing a blue color
  70880. * @returns a new Color3 object
  70881. */
  70882. static Blue(): Color3;
  70883. /**
  70884. * Returns a Color3 value containing a black color
  70885. * @returns a new Color3 object
  70886. */
  70887. static Black(): Color3;
  70888. /**
  70889. * Gets a Color3 value containing a black color that must not be updated
  70890. */
  70891. static readonly BlackReadOnly: DeepImmutable<Color3>;
  70892. /**
  70893. * Returns a Color3 value containing a white color
  70894. * @returns a new Color3 object
  70895. */
  70896. static White(): Color3;
  70897. /**
  70898. * Returns a Color3 value containing a purple color
  70899. * @returns a new Color3 object
  70900. */
  70901. static Purple(): Color3;
  70902. /**
  70903. * Returns a Color3 value containing a magenta color
  70904. * @returns a new Color3 object
  70905. */
  70906. static Magenta(): Color3;
  70907. /**
  70908. * Returns a Color3 value containing a yellow color
  70909. * @returns a new Color3 object
  70910. */
  70911. static Yellow(): Color3;
  70912. /**
  70913. * Returns a Color3 value containing a gray color
  70914. * @returns a new Color3 object
  70915. */
  70916. static Gray(): Color3;
  70917. /**
  70918. * Returns a Color3 value containing a teal color
  70919. * @returns a new Color3 object
  70920. */
  70921. static Teal(): Color3;
  70922. /**
  70923. * Returns a Color3 value containing a random color
  70924. * @returns a new Color3 object
  70925. */
  70926. static Random(): Color3;
  70927. }
  70928. /**
  70929. * Class used to hold a RBGA color
  70930. */
  70931. export class Color4 {
  70932. /**
  70933. * Defines the red component (between 0 and 1, default is 0)
  70934. */
  70935. r: number;
  70936. /**
  70937. * Defines the green component (between 0 and 1, default is 0)
  70938. */
  70939. g: number;
  70940. /**
  70941. * Defines the blue component (between 0 and 1, default is 0)
  70942. */
  70943. b: number;
  70944. /**
  70945. * Defines the alpha component (between 0 and 1, default is 1)
  70946. */
  70947. a: number;
  70948. /**
  70949. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  70950. * @param r defines the red component (between 0 and 1, default is 0)
  70951. * @param g defines the green component (between 0 and 1, default is 0)
  70952. * @param b defines the blue component (between 0 and 1, default is 0)
  70953. * @param a defines the alpha component (between 0 and 1, default is 1)
  70954. */
  70955. constructor(
  70956. /**
  70957. * Defines the red component (between 0 and 1, default is 0)
  70958. */
  70959. r?: number,
  70960. /**
  70961. * Defines the green component (between 0 and 1, default is 0)
  70962. */
  70963. g?: number,
  70964. /**
  70965. * Defines the blue component (between 0 and 1, default is 0)
  70966. */
  70967. b?: number,
  70968. /**
  70969. * Defines the alpha component (between 0 and 1, default is 1)
  70970. */
  70971. a?: number);
  70972. /**
  70973. * Adds in place the given Color4 values to the current Color4 object
  70974. * @param right defines the second operand
  70975. * @returns the current updated Color4 object
  70976. */
  70977. addInPlace(right: DeepImmutable<Color4>): Color4;
  70978. /**
  70979. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  70980. * @returns the new array
  70981. */
  70982. asArray(): number[];
  70983. /**
  70984. * Stores from the starting index in the given array the Color4 successive values
  70985. * @param array defines the array where to store the r,g,b components
  70986. * @param index defines an optional index in the target array to define where to start storing values
  70987. * @returns the current Color4 object
  70988. */
  70989. toArray(array: number[], index?: number): Color4;
  70990. /**
  70991. * Determines equality between Color4 objects
  70992. * @param otherColor defines the second operand
  70993. * @returns true if the rgba values are equal to the given ones
  70994. */
  70995. equals(otherColor: DeepImmutable<Color4>): boolean;
  70996. /**
  70997. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  70998. * @param right defines the second operand
  70999. * @returns a new Color4 object
  71000. */
  71001. add(right: DeepImmutable<Color4>): Color4;
  71002. /**
  71003. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  71004. * @param right defines the second operand
  71005. * @returns a new Color4 object
  71006. */
  71007. subtract(right: DeepImmutable<Color4>): Color4;
  71008. /**
  71009. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  71010. * @param right defines the second operand
  71011. * @param result defines the Color4 object where to store the result
  71012. * @returns the current Color4 object
  71013. */
  71014. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  71015. /**
  71016. * Creates a new Color4 with the current Color4 values multiplied by scale
  71017. * @param scale defines the scaling factor to apply
  71018. * @returns a new Color4 object
  71019. */
  71020. scale(scale: number): Color4;
  71021. /**
  71022. * Multiplies the current Color4 values by scale and stores the result in "result"
  71023. * @param scale defines the scaling factor to apply
  71024. * @param result defines the Color4 object where to store the result
  71025. * @returns the current unmodified Color4
  71026. */
  71027. scaleToRef(scale: number, result: Color4): Color4;
  71028. /**
  71029. * Scale the current Color4 values by a factor and add the result to a given Color4
  71030. * @param scale defines the scale factor
  71031. * @param result defines the Color4 object where to store the result
  71032. * @returns the unmodified current Color4
  71033. */
  71034. scaleAndAddToRef(scale: number, result: Color4): Color4;
  71035. /**
  71036. * Clamps the rgb values by the min and max values and stores the result into "result"
  71037. * @param min defines minimum clamping value (default is 0)
  71038. * @param max defines maximum clamping value (default is 1)
  71039. * @param result defines color to store the result into.
  71040. * @returns the cuurent Color4
  71041. */
  71042. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  71043. /**
  71044. * Multipy an Color4 value by another and return a new Color4 object
  71045. * @param color defines the Color4 value to multiply by
  71046. * @returns a new Color4 object
  71047. */
  71048. multiply(color: Color4): Color4;
  71049. /**
  71050. * Multipy a Color4 value by another and push the result in a reference value
  71051. * @param color defines the Color4 value to multiply by
  71052. * @param result defines the Color4 to fill the result in
  71053. * @returns the result Color4
  71054. */
  71055. multiplyToRef(color: Color4, result: Color4): Color4;
  71056. /**
  71057. * Creates a string with the Color4 current values
  71058. * @returns the string representation of the Color4 object
  71059. */
  71060. toString(): string;
  71061. /**
  71062. * Returns the string "Color4"
  71063. * @returns "Color4"
  71064. */
  71065. getClassName(): string;
  71066. /**
  71067. * Compute the Color4 hash code
  71068. * @returns an unique number that can be used to hash Color4 objects
  71069. */
  71070. getHashCode(): number;
  71071. /**
  71072. * Creates a new Color4 copied from the current one
  71073. * @returns a new Color4 object
  71074. */
  71075. clone(): Color4;
  71076. /**
  71077. * Copies the given Color4 values into the current one
  71078. * @param source defines the source Color4 object
  71079. * @returns the current updated Color4 object
  71080. */
  71081. copyFrom(source: Color4): Color4;
  71082. /**
  71083. * Copies the given float values into the current one
  71084. * @param r defines the red component to read from
  71085. * @param g defines the green component to read from
  71086. * @param b defines the blue component to read from
  71087. * @param a defines the alpha component to read from
  71088. * @returns the current updated Color4 object
  71089. */
  71090. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  71091. /**
  71092. * Copies the given float values into the current one
  71093. * @param r defines the red component to read from
  71094. * @param g defines the green component to read from
  71095. * @param b defines the blue component to read from
  71096. * @param a defines the alpha component to read from
  71097. * @returns the current updated Color4 object
  71098. */
  71099. set(r: number, g: number, b: number, a: number): Color4;
  71100. /**
  71101. * Compute the Color4 hexadecimal code as a string
  71102. * @returns a string containing the hexadecimal representation of the Color4 object
  71103. */
  71104. toHexString(): string;
  71105. /**
  71106. * Computes a new Color4 converted from the current one to linear space
  71107. * @returns a new Color4 object
  71108. */
  71109. toLinearSpace(): Color4;
  71110. /**
  71111. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  71112. * @param convertedColor defines the Color4 object where to store the linear space version
  71113. * @returns the unmodified Color4
  71114. */
  71115. toLinearSpaceToRef(convertedColor: Color4): Color4;
  71116. /**
  71117. * Computes a new Color4 converted from the current one to gamma space
  71118. * @returns a new Color4 object
  71119. */
  71120. toGammaSpace(): Color4;
  71121. /**
  71122. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  71123. * @param convertedColor defines the Color4 object where to store the gamma space version
  71124. * @returns the unmodified Color4
  71125. */
  71126. toGammaSpaceToRef(convertedColor: Color4): Color4;
  71127. /**
  71128. * Creates a new Color4 from the string containing valid hexadecimal values
  71129. * @param hex defines a string containing valid hexadecimal values
  71130. * @returns a new Color4 object
  71131. */
  71132. static FromHexString(hex: string): Color4;
  71133. /**
  71134. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  71135. * @param left defines the start value
  71136. * @param right defines the end value
  71137. * @param amount defines the gradient factor
  71138. * @returns a new Color4 object
  71139. */
  71140. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  71141. /**
  71142. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  71143. * @param left defines the start value
  71144. * @param right defines the end value
  71145. * @param amount defines the gradient factor
  71146. * @param result defines the Color4 object where to store data
  71147. */
  71148. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  71149. /**
  71150. * Creates a new Color4 from a Color3 and an alpha value
  71151. * @param color3 defines the source Color3 to read from
  71152. * @param alpha defines the alpha component (1.0 by default)
  71153. * @returns a new Color4 object
  71154. */
  71155. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  71156. /**
  71157. * Creates a new Color4 from the starting index element of the given array
  71158. * @param array defines the source array to read from
  71159. * @param offset defines the offset in the source array
  71160. * @returns a new Color4 object
  71161. */
  71162. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  71163. /**
  71164. * Creates a new Color3 from integer values (< 256)
  71165. * @param r defines the red component to read from (value between 0 and 255)
  71166. * @param g defines the green component to read from (value between 0 and 255)
  71167. * @param b defines the blue component to read from (value between 0 and 255)
  71168. * @param a defines the alpha component to read from (value between 0 and 255)
  71169. * @returns a new Color3 object
  71170. */
  71171. static FromInts(r: number, g: number, b: number, a: number): Color4;
  71172. /**
  71173. * Check the content of a given array and convert it to an array containing RGBA data
  71174. * If the original array was already containing count * 4 values then it is returned directly
  71175. * @param colors defines the array to check
  71176. * @param count defines the number of RGBA data to expect
  71177. * @returns an array containing count * 4 values (RGBA)
  71178. */
  71179. static CheckColors4(colors: number[], count: number): number[];
  71180. }
  71181. /**
  71182. * @hidden
  71183. */
  71184. export class TmpColors {
  71185. static Color3: Color3[];
  71186. static Color4: Color4[];
  71187. }
  71188. }
  71189. declare module BABYLON {
  71190. /**
  71191. * Class representing spherical harmonics coefficients to the 3rd degree
  71192. */
  71193. export class SphericalHarmonics {
  71194. /**
  71195. * Defines whether or not the harmonics have been prescaled for rendering.
  71196. */
  71197. preScaled: boolean;
  71198. /**
  71199. * The l0,0 coefficients of the spherical harmonics
  71200. */
  71201. l00: Vector3;
  71202. /**
  71203. * The l1,-1 coefficients of the spherical harmonics
  71204. */
  71205. l1_1: Vector3;
  71206. /**
  71207. * The l1,0 coefficients of the spherical harmonics
  71208. */
  71209. l10: Vector3;
  71210. /**
  71211. * The l1,1 coefficients of the spherical harmonics
  71212. */
  71213. l11: Vector3;
  71214. /**
  71215. * The l2,-2 coefficients of the spherical harmonics
  71216. */
  71217. l2_2: Vector3;
  71218. /**
  71219. * The l2,-1 coefficients of the spherical harmonics
  71220. */
  71221. l2_1: Vector3;
  71222. /**
  71223. * The l2,0 coefficients of the spherical harmonics
  71224. */
  71225. l20: Vector3;
  71226. /**
  71227. * The l2,1 coefficients of the spherical harmonics
  71228. */
  71229. l21: Vector3;
  71230. /**
  71231. * The l2,2 coefficients of the spherical harmonics
  71232. */
  71233. l22: Vector3;
  71234. /**
  71235. * Adds a light to the spherical harmonics
  71236. * @param direction the direction of the light
  71237. * @param color the color of the light
  71238. * @param deltaSolidAngle the delta solid angle of the light
  71239. */
  71240. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  71241. /**
  71242. * Scales the spherical harmonics by the given amount
  71243. * @param scale the amount to scale
  71244. */
  71245. scaleInPlace(scale: number): void;
  71246. /**
  71247. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  71248. *
  71249. * ```
  71250. * E_lm = A_l * L_lm
  71251. * ```
  71252. *
  71253. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  71254. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  71255. * the scaling factors are given in equation 9.
  71256. */
  71257. convertIncidentRadianceToIrradiance(): void;
  71258. /**
  71259. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  71260. *
  71261. * ```
  71262. * L = (1/pi) * E * rho
  71263. * ```
  71264. *
  71265. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  71266. */
  71267. convertIrradianceToLambertianRadiance(): void;
  71268. /**
  71269. * Integrates the reconstruction coefficients directly in to the SH preventing further
  71270. * required operations at run time.
  71271. *
  71272. * This is simply done by scaling back the SH with Ylm constants parameter.
  71273. * The trigonometric part being applied by the shader at run time.
  71274. */
  71275. preScaleForRendering(): void;
  71276. /**
  71277. * Constructs a spherical harmonics from an array.
  71278. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  71279. * @returns the spherical harmonics
  71280. */
  71281. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  71282. /**
  71283. * Gets the spherical harmonics from polynomial
  71284. * @param polynomial the spherical polynomial
  71285. * @returns the spherical harmonics
  71286. */
  71287. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  71288. }
  71289. /**
  71290. * Class representing spherical polynomial coefficients to the 3rd degree
  71291. */
  71292. export class SphericalPolynomial {
  71293. private _harmonics;
  71294. /**
  71295. * The spherical harmonics used to create the polynomials.
  71296. */
  71297. readonly preScaledHarmonics: SphericalHarmonics;
  71298. /**
  71299. * The x coefficients of the spherical polynomial
  71300. */
  71301. x: Vector3;
  71302. /**
  71303. * The y coefficients of the spherical polynomial
  71304. */
  71305. y: Vector3;
  71306. /**
  71307. * The z coefficients of the spherical polynomial
  71308. */
  71309. z: Vector3;
  71310. /**
  71311. * The xx coefficients of the spherical polynomial
  71312. */
  71313. xx: Vector3;
  71314. /**
  71315. * The yy coefficients of the spherical polynomial
  71316. */
  71317. yy: Vector3;
  71318. /**
  71319. * The zz coefficients of the spherical polynomial
  71320. */
  71321. zz: Vector3;
  71322. /**
  71323. * The xy coefficients of the spherical polynomial
  71324. */
  71325. xy: Vector3;
  71326. /**
  71327. * The yz coefficients of the spherical polynomial
  71328. */
  71329. yz: Vector3;
  71330. /**
  71331. * The zx coefficients of the spherical polynomial
  71332. */
  71333. zx: Vector3;
  71334. /**
  71335. * Adds an ambient color to the spherical polynomial
  71336. * @param color the color to add
  71337. */
  71338. addAmbient(color: Color3): void;
  71339. /**
  71340. * Scales the spherical polynomial by the given amount
  71341. * @param scale the amount to scale
  71342. */
  71343. scaleInPlace(scale: number): void;
  71344. /**
  71345. * Gets the spherical polynomial from harmonics
  71346. * @param harmonics the spherical harmonics
  71347. * @returns the spherical polynomial
  71348. */
  71349. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  71350. /**
  71351. * Constructs a spherical polynomial from an array.
  71352. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  71353. * @returns the spherical polynomial
  71354. */
  71355. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  71356. }
  71357. }
  71358. declare module BABYLON {
  71359. /**
  71360. * Define options used to create a render target texture
  71361. */
  71362. export class RenderTargetCreationOptions {
  71363. /**
  71364. * Specifies is mipmaps must be generated
  71365. */
  71366. generateMipMaps?: boolean;
  71367. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  71368. generateDepthBuffer?: boolean;
  71369. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  71370. generateStencilBuffer?: boolean;
  71371. /** Defines texture type (int by default) */
  71372. type?: number;
  71373. /** Defines sampling mode (trilinear by default) */
  71374. samplingMode?: number;
  71375. /** Defines format (RGBA by default) */
  71376. format?: number;
  71377. }
  71378. }
  71379. declare module BABYLON {
  71380. /**
  71381. * @hidden
  71382. **/
  71383. export class _AlphaState {
  71384. private _isAlphaBlendDirty;
  71385. private _isBlendFunctionParametersDirty;
  71386. private _isBlendEquationParametersDirty;
  71387. private _isBlendConstantsDirty;
  71388. private _alphaBlend;
  71389. private _blendFunctionParameters;
  71390. private _blendEquationParameters;
  71391. private _blendConstants;
  71392. /**
  71393. * Initializes the state.
  71394. */
  71395. constructor();
  71396. readonly isDirty: boolean;
  71397. alphaBlend: boolean;
  71398. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  71399. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  71400. setAlphaEquationParameters(rgb: number, alpha: number): void;
  71401. reset(): void;
  71402. apply(gl: WebGLRenderingContext): void;
  71403. }
  71404. }
  71405. declare module BABYLON {
  71406. /**
  71407. * @hidden
  71408. **/
  71409. export class _DepthCullingState {
  71410. private _isDepthTestDirty;
  71411. private _isDepthMaskDirty;
  71412. private _isDepthFuncDirty;
  71413. private _isCullFaceDirty;
  71414. private _isCullDirty;
  71415. private _isZOffsetDirty;
  71416. private _isFrontFaceDirty;
  71417. private _depthTest;
  71418. private _depthMask;
  71419. private _depthFunc;
  71420. private _cull;
  71421. private _cullFace;
  71422. private _zOffset;
  71423. private _frontFace;
  71424. /**
  71425. * Initializes the state.
  71426. */
  71427. constructor();
  71428. readonly isDirty: boolean;
  71429. zOffset: number;
  71430. cullFace: Nullable<number>;
  71431. cull: Nullable<boolean>;
  71432. depthFunc: Nullable<number>;
  71433. depthMask: boolean;
  71434. depthTest: boolean;
  71435. frontFace: Nullable<number>;
  71436. reset(): void;
  71437. apply(gl: WebGLRenderingContext): void;
  71438. }
  71439. }
  71440. declare module BABYLON {
  71441. /**
  71442. * @hidden
  71443. **/
  71444. export class _StencilState {
  71445. /** 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 */
  71446. static readonly ALWAYS: number;
  71447. /** Passed to stencilOperation to specify that stencil value must be kept */
  71448. static readonly KEEP: number;
  71449. /** Passed to stencilOperation to specify that stencil value must be replaced */
  71450. static readonly REPLACE: number;
  71451. private _isStencilTestDirty;
  71452. private _isStencilMaskDirty;
  71453. private _isStencilFuncDirty;
  71454. private _isStencilOpDirty;
  71455. private _stencilTest;
  71456. private _stencilMask;
  71457. private _stencilFunc;
  71458. private _stencilFuncRef;
  71459. private _stencilFuncMask;
  71460. private _stencilOpStencilFail;
  71461. private _stencilOpDepthFail;
  71462. private _stencilOpStencilDepthPass;
  71463. readonly isDirty: boolean;
  71464. stencilFunc: number;
  71465. stencilFuncRef: number;
  71466. stencilFuncMask: number;
  71467. stencilOpStencilFail: number;
  71468. stencilOpDepthFail: number;
  71469. stencilOpStencilDepthPass: number;
  71470. stencilMask: number;
  71471. stencilTest: boolean;
  71472. constructor();
  71473. reset(): void;
  71474. apply(gl: WebGLRenderingContext): void;
  71475. }
  71476. }
  71477. declare module BABYLON {
  71478. /**
  71479. * @hidden
  71480. **/
  71481. export class _TimeToken {
  71482. _startTimeQuery: Nullable<WebGLQuery>;
  71483. _endTimeQuery: Nullable<WebGLQuery>;
  71484. _timeElapsedQuery: Nullable<WebGLQuery>;
  71485. _timeElapsedQueryEnded: boolean;
  71486. }
  71487. }
  71488. declare module BABYLON {
  71489. /**
  71490. * Class used to evalaute queries containing `and` and `or` operators
  71491. */
  71492. export class AndOrNotEvaluator {
  71493. /**
  71494. * Evaluate a query
  71495. * @param query defines the query to evaluate
  71496. * @param evaluateCallback defines the callback used to filter result
  71497. * @returns true if the query matches
  71498. */
  71499. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  71500. private static _HandleParenthesisContent;
  71501. private static _SimplifyNegation;
  71502. }
  71503. }
  71504. declare module BABYLON {
  71505. /**
  71506. * Class used to store custom tags
  71507. */
  71508. export class Tags {
  71509. /**
  71510. * Adds support for tags on the given object
  71511. * @param obj defines the object to use
  71512. */
  71513. static EnableFor(obj: any): void;
  71514. /**
  71515. * Removes tags support
  71516. * @param obj defines the object to use
  71517. */
  71518. static DisableFor(obj: any): void;
  71519. /**
  71520. * Gets a boolean indicating if the given object has tags
  71521. * @param obj defines the object to use
  71522. * @returns a boolean
  71523. */
  71524. static HasTags(obj: any): boolean;
  71525. /**
  71526. * Gets the tags available on a given object
  71527. * @param obj defines the object to use
  71528. * @param asString defines if the tags must be returned as a string instead of an array of strings
  71529. * @returns the tags
  71530. */
  71531. static GetTags(obj: any, asString?: boolean): any;
  71532. /**
  71533. * Adds tags to an object
  71534. * @param obj defines the object to use
  71535. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  71536. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  71537. */
  71538. static AddTagsTo(obj: any, tagsString: string): void;
  71539. /**
  71540. * @hidden
  71541. */
  71542. static _AddTagTo(obj: any, tag: string): void;
  71543. /**
  71544. * Removes specific tags from a specific object
  71545. * @param obj defines the object to use
  71546. * @param tagsString defines the tags to remove
  71547. */
  71548. static RemoveTagsFrom(obj: any, tagsString: string): void;
  71549. /**
  71550. * @hidden
  71551. */
  71552. static _RemoveTagFrom(obj: any, tag: string): void;
  71553. /**
  71554. * Defines if tags hosted on an object match a given query
  71555. * @param obj defines the object to use
  71556. * @param tagsQuery defines the tag query
  71557. * @returns a boolean
  71558. */
  71559. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  71560. }
  71561. }
  71562. declare module BABYLON {
  71563. /**
  71564. * Defines potential orientation for back face culling
  71565. */
  71566. export enum Orientation {
  71567. /**
  71568. * Clockwise
  71569. */
  71570. CW = 0,
  71571. /** Counter clockwise */
  71572. CCW = 1
  71573. }
  71574. /** Class used to represent a Bezier curve */
  71575. export class BezierCurve {
  71576. /**
  71577. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  71578. * @param t defines the time
  71579. * @param x1 defines the left coordinate on X axis
  71580. * @param y1 defines the left coordinate on Y axis
  71581. * @param x2 defines the right coordinate on X axis
  71582. * @param y2 defines the right coordinate on Y axis
  71583. * @returns the interpolated value
  71584. */
  71585. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  71586. }
  71587. /**
  71588. * Defines angle representation
  71589. */
  71590. export class Angle {
  71591. private _radians;
  71592. /**
  71593. * Creates an Angle object of "radians" radians (float).
  71594. * @param radians the angle in radians
  71595. */
  71596. constructor(radians: number);
  71597. /**
  71598. * Get value in degrees
  71599. * @returns the Angle value in degrees (float)
  71600. */
  71601. degrees(): number;
  71602. /**
  71603. * Get value in radians
  71604. * @returns the Angle value in radians (float)
  71605. */
  71606. radians(): number;
  71607. /**
  71608. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  71609. * @param a defines first vector
  71610. * @param b defines second vector
  71611. * @returns a new Angle
  71612. */
  71613. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  71614. /**
  71615. * Gets a new Angle object from the given float in radians
  71616. * @param radians defines the angle value in radians
  71617. * @returns a new Angle
  71618. */
  71619. static FromRadians(radians: number): Angle;
  71620. /**
  71621. * Gets a new Angle object from the given float in degrees
  71622. * @param degrees defines the angle value in degrees
  71623. * @returns a new Angle
  71624. */
  71625. static FromDegrees(degrees: number): Angle;
  71626. }
  71627. /**
  71628. * This represents an arc in a 2d space.
  71629. */
  71630. export class Arc2 {
  71631. /** Defines the start point of the arc */
  71632. startPoint: Vector2;
  71633. /** Defines the mid point of the arc */
  71634. midPoint: Vector2;
  71635. /** Defines the end point of the arc */
  71636. endPoint: Vector2;
  71637. /**
  71638. * Defines the center point of the arc.
  71639. */
  71640. centerPoint: Vector2;
  71641. /**
  71642. * Defines the radius of the arc.
  71643. */
  71644. radius: number;
  71645. /**
  71646. * Defines the angle of the arc (from mid point to end point).
  71647. */
  71648. angle: Angle;
  71649. /**
  71650. * Defines the start angle of the arc (from start point to middle point).
  71651. */
  71652. startAngle: Angle;
  71653. /**
  71654. * Defines the orientation of the arc (clock wise/counter clock wise).
  71655. */
  71656. orientation: Orientation;
  71657. /**
  71658. * Creates an Arc object from the three given points : start, middle and end.
  71659. * @param startPoint Defines the start point of the arc
  71660. * @param midPoint Defines the midlle point of the arc
  71661. * @param endPoint Defines the end point of the arc
  71662. */
  71663. constructor(
  71664. /** Defines the start point of the arc */
  71665. startPoint: Vector2,
  71666. /** Defines the mid point of the arc */
  71667. midPoint: Vector2,
  71668. /** Defines the end point of the arc */
  71669. endPoint: Vector2);
  71670. }
  71671. /**
  71672. * Represents a 2D path made up of multiple 2D points
  71673. */
  71674. export class Path2 {
  71675. private _points;
  71676. private _length;
  71677. /**
  71678. * If the path start and end point are the same
  71679. */
  71680. closed: boolean;
  71681. /**
  71682. * Creates a Path2 object from the starting 2D coordinates x and y.
  71683. * @param x the starting points x value
  71684. * @param y the starting points y value
  71685. */
  71686. constructor(x: number, y: number);
  71687. /**
  71688. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  71689. * @param x the added points x value
  71690. * @param y the added points y value
  71691. * @returns the updated Path2.
  71692. */
  71693. addLineTo(x: number, y: number): Path2;
  71694. /**
  71695. * 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.
  71696. * @param midX middle point x value
  71697. * @param midY middle point y value
  71698. * @param endX end point x value
  71699. * @param endY end point y value
  71700. * @param numberOfSegments (default: 36)
  71701. * @returns the updated Path2.
  71702. */
  71703. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  71704. /**
  71705. * Closes the Path2.
  71706. * @returns the Path2.
  71707. */
  71708. close(): Path2;
  71709. /**
  71710. * Gets the sum of the distance between each sequential point in the path
  71711. * @returns the Path2 total length (float).
  71712. */
  71713. length(): number;
  71714. /**
  71715. * Gets the points which construct the path
  71716. * @returns the Path2 internal array of points.
  71717. */
  71718. getPoints(): Vector2[];
  71719. /**
  71720. * Retreives the point at the distance aways from the starting point
  71721. * @param normalizedLengthPosition the length along the path to retreive the point from
  71722. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  71723. */
  71724. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  71725. /**
  71726. * Creates a new path starting from an x and y position
  71727. * @param x starting x value
  71728. * @param y starting y value
  71729. * @returns a new Path2 starting at the coordinates (x, y).
  71730. */
  71731. static StartingAt(x: number, y: number): Path2;
  71732. }
  71733. /**
  71734. * Represents a 3D path made up of multiple 3D points
  71735. */
  71736. export class Path3D {
  71737. /**
  71738. * an array of Vector3, the curve axis of the Path3D
  71739. */
  71740. path: Vector3[];
  71741. private _curve;
  71742. private _distances;
  71743. private _tangents;
  71744. private _normals;
  71745. private _binormals;
  71746. private _raw;
  71747. /**
  71748. * new Path3D(path, normal, raw)
  71749. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  71750. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  71751. * @param path an array of Vector3, the curve axis of the Path3D
  71752. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  71753. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  71754. */
  71755. constructor(
  71756. /**
  71757. * an array of Vector3, the curve axis of the Path3D
  71758. */
  71759. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  71760. /**
  71761. * Returns the Path3D array of successive Vector3 designing its curve.
  71762. * @returns the Path3D array of successive Vector3 designing its curve.
  71763. */
  71764. getCurve(): Vector3[];
  71765. /**
  71766. * Returns an array populated with tangent vectors on each Path3D curve point.
  71767. * @returns an array populated with tangent vectors on each Path3D curve point.
  71768. */
  71769. getTangents(): Vector3[];
  71770. /**
  71771. * Returns an array populated with normal vectors on each Path3D curve point.
  71772. * @returns an array populated with normal vectors on each Path3D curve point.
  71773. */
  71774. getNormals(): Vector3[];
  71775. /**
  71776. * Returns an array populated with binormal vectors on each Path3D curve point.
  71777. * @returns an array populated with binormal vectors on each Path3D curve point.
  71778. */
  71779. getBinormals(): Vector3[];
  71780. /**
  71781. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  71782. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  71783. */
  71784. getDistances(): number[];
  71785. /**
  71786. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  71787. * @param path path which all values are copied into the curves points
  71788. * @param firstNormal which should be projected onto the curve
  71789. * @returns the same object updated.
  71790. */
  71791. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  71792. private _compute;
  71793. private _getFirstNonNullVector;
  71794. private _getLastNonNullVector;
  71795. private _normalVector;
  71796. }
  71797. /**
  71798. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  71799. * A Curve3 is designed from a series of successive Vector3.
  71800. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  71801. */
  71802. export class Curve3 {
  71803. private _points;
  71804. private _length;
  71805. /**
  71806. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  71807. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  71808. * @param v1 (Vector3) the control point
  71809. * @param v2 (Vector3) the end point of the Quadratic Bezier
  71810. * @param nbPoints (integer) the wanted number of points in the curve
  71811. * @returns the created Curve3
  71812. */
  71813. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71814. /**
  71815. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  71816. * @param v0 (Vector3) the origin point of the Cubic Bezier
  71817. * @param v1 (Vector3) the first control point
  71818. * @param v2 (Vector3) the second control point
  71819. * @param v3 (Vector3) the end point of the Cubic Bezier
  71820. * @param nbPoints (integer) the wanted number of points in the curve
  71821. * @returns the created Curve3
  71822. */
  71823. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71824. /**
  71825. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  71826. * @param p1 (Vector3) the origin point of the Hermite Spline
  71827. * @param t1 (Vector3) the tangent vector at the origin point
  71828. * @param p2 (Vector3) the end point of the Hermite Spline
  71829. * @param t2 (Vector3) the tangent vector at the end point
  71830. * @param nbPoints (integer) the wanted number of points in the curve
  71831. * @returns the created Curve3
  71832. */
  71833. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71834. /**
  71835. * Returns a Curve3 object along a CatmullRom Spline curve :
  71836. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  71837. * @param nbPoints (integer) the wanted number of points between each curve control points
  71838. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  71839. * @returns the created Curve3
  71840. */
  71841. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  71842. /**
  71843. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  71844. * A Curve3 is designed from a series of successive Vector3.
  71845. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  71846. * @param points points which make up the curve
  71847. */
  71848. constructor(points: Vector3[]);
  71849. /**
  71850. * @returns the Curve3 stored array of successive Vector3
  71851. */
  71852. getPoints(): Vector3[];
  71853. /**
  71854. * @returns the computed length (float) of the curve.
  71855. */
  71856. length(): number;
  71857. /**
  71858. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  71859. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  71860. * curveA and curveB keep unchanged.
  71861. * @param curve the curve to continue from this curve
  71862. * @returns the newly constructed curve
  71863. */
  71864. continue(curve: DeepImmutable<Curve3>): Curve3;
  71865. private _computeLength;
  71866. }
  71867. }
  71868. declare module BABYLON {
  71869. /**
  71870. * This represents the main contract an easing function should follow.
  71871. * Easing functions are used throughout the animation system.
  71872. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71873. */
  71874. export interface IEasingFunction {
  71875. /**
  71876. * Given an input gradient between 0 and 1, this returns the corrseponding value
  71877. * of the easing function.
  71878. * The link below provides some of the most common examples of easing functions.
  71879. * @see https://easings.net/
  71880. * @param gradient Defines the value between 0 and 1 we want the easing value for
  71881. * @returns the corresponding value on the curve defined by the easing function
  71882. */
  71883. ease(gradient: number): number;
  71884. }
  71885. /**
  71886. * Base class used for every default easing function.
  71887. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71888. */
  71889. export class EasingFunction implements IEasingFunction {
  71890. /**
  71891. * Interpolation follows the mathematical formula associated with the easing function.
  71892. */
  71893. static readonly EASINGMODE_EASEIN: number;
  71894. /**
  71895. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  71896. */
  71897. static readonly EASINGMODE_EASEOUT: number;
  71898. /**
  71899. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  71900. */
  71901. static readonly EASINGMODE_EASEINOUT: number;
  71902. private _easingMode;
  71903. /**
  71904. * Sets the easing mode of the current function.
  71905. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  71906. */
  71907. setEasingMode(easingMode: number): void;
  71908. /**
  71909. * Gets the current easing mode.
  71910. * @returns the easing mode
  71911. */
  71912. getEasingMode(): number;
  71913. /**
  71914. * @hidden
  71915. */
  71916. easeInCore(gradient: number): number;
  71917. /**
  71918. * Given an input gradient between 0 and 1, this returns the corresponding value
  71919. * of the easing function.
  71920. * @param gradient Defines the value between 0 and 1 we want the easing value for
  71921. * @returns the corresponding value on the curve defined by the easing function
  71922. */
  71923. ease(gradient: number): number;
  71924. }
  71925. /**
  71926. * Easing function with a circle shape (see link below).
  71927. * @see https://easings.net/#easeInCirc
  71928. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71929. */
  71930. export class CircleEase extends EasingFunction implements IEasingFunction {
  71931. /** @hidden */
  71932. easeInCore(gradient: number): number;
  71933. }
  71934. /**
  71935. * Easing function with a ease back shape (see link below).
  71936. * @see https://easings.net/#easeInBack
  71937. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71938. */
  71939. export class BackEase extends EasingFunction implements IEasingFunction {
  71940. /** Defines the amplitude of the function */
  71941. amplitude: number;
  71942. /**
  71943. * Instantiates a back ease easing
  71944. * @see https://easings.net/#easeInBack
  71945. * @param amplitude Defines the amplitude of the function
  71946. */
  71947. constructor(
  71948. /** Defines the amplitude of the function */
  71949. amplitude?: number);
  71950. /** @hidden */
  71951. easeInCore(gradient: number): number;
  71952. }
  71953. /**
  71954. * Easing function with a bouncing shape (see link below).
  71955. * @see https://easings.net/#easeInBounce
  71956. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71957. */
  71958. export class BounceEase extends EasingFunction implements IEasingFunction {
  71959. /** Defines the number of bounces */
  71960. bounces: number;
  71961. /** Defines the amplitude of the bounce */
  71962. bounciness: number;
  71963. /**
  71964. * Instantiates a bounce easing
  71965. * @see https://easings.net/#easeInBounce
  71966. * @param bounces Defines the number of bounces
  71967. * @param bounciness Defines the amplitude of the bounce
  71968. */
  71969. constructor(
  71970. /** Defines the number of bounces */
  71971. bounces?: number,
  71972. /** Defines the amplitude of the bounce */
  71973. bounciness?: number);
  71974. /** @hidden */
  71975. easeInCore(gradient: number): number;
  71976. }
  71977. /**
  71978. * Easing function with a power of 3 shape (see link below).
  71979. * @see https://easings.net/#easeInCubic
  71980. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71981. */
  71982. export class CubicEase extends EasingFunction implements IEasingFunction {
  71983. /** @hidden */
  71984. easeInCore(gradient: number): number;
  71985. }
  71986. /**
  71987. * Easing function with an elastic shape (see link below).
  71988. * @see https://easings.net/#easeInElastic
  71989. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71990. */
  71991. export class ElasticEase extends EasingFunction implements IEasingFunction {
  71992. /** Defines the number of oscillations*/
  71993. oscillations: number;
  71994. /** Defines the amplitude of the oscillations*/
  71995. springiness: number;
  71996. /**
  71997. * Instantiates an elastic easing function
  71998. * @see https://easings.net/#easeInElastic
  71999. * @param oscillations Defines the number of oscillations
  72000. * @param springiness Defines the amplitude of the oscillations
  72001. */
  72002. constructor(
  72003. /** Defines the number of oscillations*/
  72004. oscillations?: number,
  72005. /** Defines the amplitude of the oscillations*/
  72006. springiness?: number);
  72007. /** @hidden */
  72008. easeInCore(gradient: number): number;
  72009. }
  72010. /**
  72011. * Easing function with an exponential shape (see link below).
  72012. * @see https://easings.net/#easeInExpo
  72013. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72014. */
  72015. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  72016. /** Defines the exponent of the function */
  72017. exponent: number;
  72018. /**
  72019. * Instantiates an exponential easing function
  72020. * @see https://easings.net/#easeInExpo
  72021. * @param exponent Defines the exponent of the function
  72022. */
  72023. constructor(
  72024. /** Defines the exponent of the function */
  72025. exponent?: number);
  72026. /** @hidden */
  72027. easeInCore(gradient: number): number;
  72028. }
  72029. /**
  72030. * Easing function with a power shape (see link below).
  72031. * @see https://easings.net/#easeInQuad
  72032. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72033. */
  72034. export class PowerEase extends EasingFunction implements IEasingFunction {
  72035. /** Defines the power of the function */
  72036. power: number;
  72037. /**
  72038. * Instantiates an power base easing function
  72039. * @see https://easings.net/#easeInQuad
  72040. * @param power Defines the power of the function
  72041. */
  72042. constructor(
  72043. /** Defines the power of the function */
  72044. power?: number);
  72045. /** @hidden */
  72046. easeInCore(gradient: number): number;
  72047. }
  72048. /**
  72049. * Easing function with a power of 2 shape (see link below).
  72050. * @see https://easings.net/#easeInQuad
  72051. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72052. */
  72053. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  72054. /** @hidden */
  72055. easeInCore(gradient: number): number;
  72056. }
  72057. /**
  72058. * Easing function with a power of 4 shape (see link below).
  72059. * @see https://easings.net/#easeInQuart
  72060. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72061. */
  72062. export class QuarticEase extends EasingFunction implements IEasingFunction {
  72063. /** @hidden */
  72064. easeInCore(gradient: number): number;
  72065. }
  72066. /**
  72067. * Easing function with a power of 5 shape (see link below).
  72068. * @see https://easings.net/#easeInQuint
  72069. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72070. */
  72071. export class QuinticEase extends EasingFunction implements IEasingFunction {
  72072. /** @hidden */
  72073. easeInCore(gradient: number): number;
  72074. }
  72075. /**
  72076. * Easing function with a sin shape (see link below).
  72077. * @see https://easings.net/#easeInSine
  72078. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72079. */
  72080. export class SineEase extends EasingFunction implements IEasingFunction {
  72081. /** @hidden */
  72082. easeInCore(gradient: number): number;
  72083. }
  72084. /**
  72085. * Easing function with a bezier shape (see link below).
  72086. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72087. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72088. */
  72089. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  72090. /** Defines the x component of the start tangent in the bezier curve */
  72091. x1: number;
  72092. /** Defines the y component of the start tangent in the bezier curve */
  72093. y1: number;
  72094. /** Defines the x component of the end tangent in the bezier curve */
  72095. x2: number;
  72096. /** Defines the y component of the end tangent in the bezier curve */
  72097. y2: number;
  72098. /**
  72099. * Instantiates a bezier function
  72100. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72101. * @param x1 Defines the x component of the start tangent in the bezier curve
  72102. * @param y1 Defines the y component of the start tangent in the bezier curve
  72103. * @param x2 Defines the x component of the end tangent in the bezier curve
  72104. * @param y2 Defines the y component of the end tangent in the bezier curve
  72105. */
  72106. constructor(
  72107. /** Defines the x component of the start tangent in the bezier curve */
  72108. x1?: number,
  72109. /** Defines the y component of the start tangent in the bezier curve */
  72110. y1?: number,
  72111. /** Defines the x component of the end tangent in the bezier curve */
  72112. x2?: number,
  72113. /** Defines the y component of the end tangent in the bezier curve */
  72114. y2?: number);
  72115. /** @hidden */
  72116. easeInCore(gradient: number): number;
  72117. }
  72118. }
  72119. declare module BABYLON {
  72120. /**
  72121. * Defines an interface which represents an animation key frame
  72122. */
  72123. export interface IAnimationKey {
  72124. /**
  72125. * Frame of the key frame
  72126. */
  72127. frame: number;
  72128. /**
  72129. * Value at the specifies key frame
  72130. */
  72131. value: any;
  72132. /**
  72133. * The input tangent for the cubic hermite spline
  72134. */
  72135. inTangent?: any;
  72136. /**
  72137. * The output tangent for the cubic hermite spline
  72138. */
  72139. outTangent?: any;
  72140. /**
  72141. * The animation interpolation type
  72142. */
  72143. interpolation?: AnimationKeyInterpolation;
  72144. }
  72145. /**
  72146. * Enum for the animation key frame interpolation type
  72147. */
  72148. export enum AnimationKeyInterpolation {
  72149. /**
  72150. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  72151. */
  72152. STEP = 1
  72153. }
  72154. }
  72155. declare module BABYLON {
  72156. /**
  72157. * Represents the range of an animation
  72158. */
  72159. export class AnimationRange {
  72160. /**The name of the animation range**/
  72161. name: string;
  72162. /**The starting frame of the animation */
  72163. from: number;
  72164. /**The ending frame of the animation*/
  72165. to: number;
  72166. /**
  72167. * Initializes the range of an animation
  72168. * @param name The name of the animation range
  72169. * @param from The starting frame of the animation
  72170. * @param to The ending frame of the animation
  72171. */
  72172. constructor(
  72173. /**The name of the animation range**/
  72174. name: string,
  72175. /**The starting frame of the animation */
  72176. from: number,
  72177. /**The ending frame of the animation*/
  72178. to: number);
  72179. /**
  72180. * Makes a copy of the animation range
  72181. * @returns A copy of the animation range
  72182. */
  72183. clone(): AnimationRange;
  72184. }
  72185. }
  72186. declare module BABYLON {
  72187. /**
  72188. * Composed of a frame, and an action function
  72189. */
  72190. export class AnimationEvent {
  72191. /** The frame for which the event is triggered **/
  72192. frame: number;
  72193. /** The event to perform when triggered **/
  72194. action: (currentFrame: number) => void;
  72195. /** Specifies if the event should be triggered only once**/
  72196. onlyOnce?: boolean | undefined;
  72197. /**
  72198. * Specifies if the animation event is done
  72199. */
  72200. isDone: boolean;
  72201. /**
  72202. * Initializes the animation event
  72203. * @param frame The frame for which the event is triggered
  72204. * @param action The event to perform when triggered
  72205. * @param onlyOnce Specifies if the event should be triggered only once
  72206. */
  72207. constructor(
  72208. /** The frame for which the event is triggered **/
  72209. frame: number,
  72210. /** The event to perform when triggered **/
  72211. action: (currentFrame: number) => void,
  72212. /** Specifies if the event should be triggered only once**/
  72213. onlyOnce?: boolean | undefined);
  72214. /** @hidden */
  72215. _clone(): AnimationEvent;
  72216. }
  72217. }
  72218. declare module BABYLON {
  72219. /**
  72220. * Interface used to define a behavior
  72221. */
  72222. export interface Behavior<T> {
  72223. /** gets or sets behavior's name */
  72224. name: string;
  72225. /**
  72226. * Function called when the behavior needs to be initialized (after attaching it to a target)
  72227. */
  72228. init(): void;
  72229. /**
  72230. * Called when the behavior is attached to a target
  72231. * @param target defines the target where the behavior is attached to
  72232. */
  72233. attach(target: T): void;
  72234. /**
  72235. * Called when the behavior is detached from its target
  72236. */
  72237. detach(): void;
  72238. }
  72239. /**
  72240. * Interface implemented by classes supporting behaviors
  72241. */
  72242. export interface IBehaviorAware<T> {
  72243. /**
  72244. * Attach a behavior
  72245. * @param behavior defines the behavior to attach
  72246. * @returns the current host
  72247. */
  72248. addBehavior(behavior: Behavior<T>): T;
  72249. /**
  72250. * Remove a behavior from the current object
  72251. * @param behavior defines the behavior to detach
  72252. * @returns the current host
  72253. */
  72254. removeBehavior(behavior: Behavior<T>): T;
  72255. /**
  72256. * Gets a behavior using its name to search
  72257. * @param name defines the name to search
  72258. * @returns the behavior or null if not found
  72259. */
  72260. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  72261. }
  72262. }
  72263. declare module BABYLON {
  72264. /**
  72265. * Defines an array and its length.
  72266. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  72267. */
  72268. export interface ISmartArrayLike<T> {
  72269. /**
  72270. * The data of the array.
  72271. */
  72272. data: Array<T>;
  72273. /**
  72274. * The active length of the array.
  72275. */
  72276. length: number;
  72277. }
  72278. /**
  72279. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72280. */
  72281. export class SmartArray<T> implements ISmartArrayLike<T> {
  72282. /**
  72283. * The full set of data from the array.
  72284. */
  72285. data: Array<T>;
  72286. /**
  72287. * The active length of the array.
  72288. */
  72289. length: number;
  72290. protected _id: number;
  72291. /**
  72292. * Instantiates a Smart Array.
  72293. * @param capacity defines the default capacity of the array.
  72294. */
  72295. constructor(capacity: number);
  72296. /**
  72297. * Pushes a value at the end of the active data.
  72298. * @param value defines the object to push in the array.
  72299. */
  72300. push(value: T): void;
  72301. /**
  72302. * Iterates over the active data and apply the lambda to them.
  72303. * @param func defines the action to apply on each value.
  72304. */
  72305. forEach(func: (content: T) => void): void;
  72306. /**
  72307. * Sorts the full sets of data.
  72308. * @param compareFn defines the comparison function to apply.
  72309. */
  72310. sort(compareFn: (a: T, b: T) => number): void;
  72311. /**
  72312. * Resets the active data to an empty array.
  72313. */
  72314. reset(): void;
  72315. /**
  72316. * Releases all the data from the array as well as the array.
  72317. */
  72318. dispose(): void;
  72319. /**
  72320. * Concats the active data with a given array.
  72321. * @param array defines the data to concatenate with.
  72322. */
  72323. concat(array: any): void;
  72324. /**
  72325. * Returns the position of a value in the active data.
  72326. * @param value defines the value to find the index for
  72327. * @returns the index if found in the active data otherwise -1
  72328. */
  72329. indexOf(value: T): number;
  72330. /**
  72331. * Returns whether an element is part of the active data.
  72332. * @param value defines the value to look for
  72333. * @returns true if found in the active data otherwise false
  72334. */
  72335. contains(value: T): boolean;
  72336. private static _GlobalId;
  72337. }
  72338. /**
  72339. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72340. * The data in this array can only be present once
  72341. */
  72342. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  72343. private _duplicateId;
  72344. /**
  72345. * Pushes a value at the end of the active data.
  72346. * THIS DOES NOT PREVENT DUPPLICATE DATA
  72347. * @param value defines the object to push in the array.
  72348. */
  72349. push(value: T): void;
  72350. /**
  72351. * Pushes a value at the end of the active data.
  72352. * If the data is already present, it won t be added again
  72353. * @param value defines the object to push in the array.
  72354. * @returns true if added false if it was already present
  72355. */
  72356. pushNoDuplicate(value: T): boolean;
  72357. /**
  72358. * Resets the active data to an empty array.
  72359. */
  72360. reset(): void;
  72361. /**
  72362. * Concats the active data with a given array.
  72363. * This ensures no dupplicate will be present in the result.
  72364. * @param array defines the data to concatenate with.
  72365. */
  72366. concatWithNoDuplicate(array: any): void;
  72367. }
  72368. }
  72369. declare module BABYLON {
  72370. /**
  72371. * @ignore
  72372. * This is a list of all the different input types that are available in the application.
  72373. * Fo instance: ArcRotateCameraGamepadInput...
  72374. */
  72375. export var CameraInputTypes: {};
  72376. /**
  72377. * This is the contract to implement in order to create a new input class.
  72378. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  72379. */
  72380. export interface ICameraInput<TCamera extends Camera> {
  72381. /**
  72382. * Defines the camera the input is attached to.
  72383. */
  72384. camera: Nullable<TCamera>;
  72385. /**
  72386. * Gets the class name of the current intput.
  72387. * @returns the class name
  72388. */
  72389. getClassName(): string;
  72390. /**
  72391. * Get the friendly name associated with the input class.
  72392. * @returns the input friendly name
  72393. */
  72394. getSimpleName(): string;
  72395. /**
  72396. * Attach the input controls to a specific dom element to get the input from.
  72397. * @param element Defines the element the controls should be listened from
  72398. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72399. */
  72400. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72401. /**
  72402. * Detach the current controls from the specified dom element.
  72403. * @param element Defines the element to stop listening the inputs from
  72404. */
  72405. detachControl(element: Nullable<HTMLElement>): void;
  72406. /**
  72407. * Update the current camera state depending on the inputs that have been used this frame.
  72408. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72409. */
  72410. checkInputs?: () => void;
  72411. }
  72412. /**
  72413. * Represents a map of input types to input instance or input index to input instance.
  72414. */
  72415. export interface CameraInputsMap<TCamera extends Camera> {
  72416. /**
  72417. * Accessor to the input by input type.
  72418. */
  72419. [name: string]: ICameraInput<TCamera>;
  72420. /**
  72421. * Accessor to the input by input index.
  72422. */
  72423. [idx: number]: ICameraInput<TCamera>;
  72424. }
  72425. /**
  72426. * This represents the input manager used within a camera.
  72427. * It helps dealing with all the different kind of input attached to a camera.
  72428. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72429. */
  72430. export class CameraInputsManager<TCamera extends Camera> {
  72431. /**
  72432. * Defines the list of inputs attahed to the camera.
  72433. */
  72434. attached: CameraInputsMap<TCamera>;
  72435. /**
  72436. * Defines the dom element the camera is collecting inputs from.
  72437. * This is null if the controls have not been attached.
  72438. */
  72439. attachedElement: Nullable<HTMLElement>;
  72440. /**
  72441. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72442. */
  72443. noPreventDefault: boolean;
  72444. /**
  72445. * Defined the camera the input manager belongs to.
  72446. */
  72447. camera: TCamera;
  72448. /**
  72449. * Update the current camera state depending on the inputs that have been used this frame.
  72450. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72451. */
  72452. checkInputs: () => void;
  72453. /**
  72454. * Instantiate a new Camera Input Manager.
  72455. * @param camera Defines the camera the input manager blongs to
  72456. */
  72457. constructor(camera: TCamera);
  72458. /**
  72459. * Add an input method to a camera
  72460. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72461. * @param input camera input method
  72462. */
  72463. add(input: ICameraInput<TCamera>): void;
  72464. /**
  72465. * Remove a specific input method from a camera
  72466. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  72467. * @param inputToRemove camera input method
  72468. */
  72469. remove(inputToRemove: ICameraInput<TCamera>): void;
  72470. /**
  72471. * Remove a specific input type from a camera
  72472. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  72473. * @param inputType the type of the input to remove
  72474. */
  72475. removeByType(inputType: string): void;
  72476. private _addCheckInputs;
  72477. /**
  72478. * Attach the input controls to the currently attached dom element to listen the events from.
  72479. * @param input Defines the input to attach
  72480. */
  72481. attachInput(input: ICameraInput<TCamera>): void;
  72482. /**
  72483. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  72484. * @param element Defines the dom element to collect the events from
  72485. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72486. */
  72487. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  72488. /**
  72489. * Detach the current manager inputs controls from a specific dom element.
  72490. * @param element Defines the dom element to collect the events from
  72491. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  72492. */
  72493. detachElement(element: HTMLElement, disconnect?: boolean): void;
  72494. /**
  72495. * Rebuild the dynamic inputCheck function from the current list of
  72496. * defined inputs in the manager.
  72497. */
  72498. rebuildInputCheck(): void;
  72499. /**
  72500. * Remove all attached input methods from a camera
  72501. */
  72502. clear(): void;
  72503. /**
  72504. * Serialize the current input manager attached to a camera.
  72505. * This ensures than once parsed,
  72506. * the input associated to the camera will be identical to the current ones
  72507. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  72508. */
  72509. serialize(serializedCamera: any): void;
  72510. /**
  72511. * Parses an input manager serialized JSON to restore the previous list of inputs
  72512. * and states associated to a camera.
  72513. * @param parsedCamera Defines the JSON to parse
  72514. */
  72515. parse(parsedCamera: any): void;
  72516. }
  72517. }
  72518. declare module BABYLON {
  72519. /**
  72520. * @hidden
  72521. */
  72522. export class IntersectionInfo {
  72523. bu: Nullable<number>;
  72524. bv: Nullable<number>;
  72525. distance: number;
  72526. faceId: number;
  72527. subMeshId: number;
  72528. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  72529. }
  72530. }
  72531. declare module BABYLON {
  72532. /**
  72533. * Represens a plane by the equation ax + by + cz + d = 0
  72534. */
  72535. export class Plane {
  72536. private static _TmpMatrix;
  72537. /**
  72538. * Normal of the plane (a,b,c)
  72539. */
  72540. normal: Vector3;
  72541. /**
  72542. * d component of the plane
  72543. */
  72544. d: number;
  72545. /**
  72546. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  72547. * @param a a component of the plane
  72548. * @param b b component of the plane
  72549. * @param c c component of the plane
  72550. * @param d d component of the plane
  72551. */
  72552. constructor(a: number, b: number, c: number, d: number);
  72553. /**
  72554. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  72555. */
  72556. asArray(): number[];
  72557. /**
  72558. * @returns a new plane copied from the current Plane.
  72559. */
  72560. clone(): Plane;
  72561. /**
  72562. * @returns the string "Plane".
  72563. */
  72564. getClassName(): string;
  72565. /**
  72566. * @returns the Plane hash code.
  72567. */
  72568. getHashCode(): number;
  72569. /**
  72570. * Normalize the current Plane in place.
  72571. * @returns the updated Plane.
  72572. */
  72573. normalize(): Plane;
  72574. /**
  72575. * Applies a transformation the plane and returns the result
  72576. * @param transformation the transformation matrix to be applied to the plane
  72577. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  72578. */
  72579. transform(transformation: DeepImmutable<Matrix>): Plane;
  72580. /**
  72581. * Calcualtte the dot product between the point and the plane normal
  72582. * @param point point to calculate the dot product with
  72583. * @returns the dot product (float) of the point coordinates and the plane normal.
  72584. */
  72585. dotCoordinate(point: DeepImmutable<Vector3>): number;
  72586. /**
  72587. * Updates the current Plane from the plane defined by the three given points.
  72588. * @param point1 one of the points used to contruct the plane
  72589. * @param point2 one of the points used to contruct the plane
  72590. * @param point3 one of the points used to contruct the plane
  72591. * @returns the updated Plane.
  72592. */
  72593. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  72594. /**
  72595. * Checks if the plane is facing a given direction
  72596. * @param direction the direction to check if the plane is facing
  72597. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  72598. * @returns True is the vector "direction" is the same side than the plane normal.
  72599. */
  72600. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  72601. /**
  72602. * Calculates the distance to a point
  72603. * @param point point to calculate distance to
  72604. * @returns the signed distance (float) from the given point to the Plane.
  72605. */
  72606. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  72607. /**
  72608. * Creates a plane from an array
  72609. * @param array the array to create a plane from
  72610. * @returns a new Plane from the given array.
  72611. */
  72612. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  72613. /**
  72614. * Creates a plane from three points
  72615. * @param point1 point used to create the plane
  72616. * @param point2 point used to create the plane
  72617. * @param point3 point used to create the plane
  72618. * @returns a new Plane defined by the three given points.
  72619. */
  72620. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  72621. /**
  72622. * Creates a plane from an origin point and a normal
  72623. * @param origin origin of the plane to be constructed
  72624. * @param normal normal of the plane to be constructed
  72625. * @returns a new Plane the normal vector to this plane at the given origin point.
  72626. * Note : the vector "normal" is updated because normalized.
  72627. */
  72628. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  72629. /**
  72630. * Calculates the distance from a plane and a point
  72631. * @param origin origin of the plane to be constructed
  72632. * @param normal normal of the plane to be constructed
  72633. * @param point point to calculate distance to
  72634. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  72635. */
  72636. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  72637. }
  72638. }
  72639. declare module BABYLON {
  72640. /**
  72641. * Class used to store bounding sphere information
  72642. */
  72643. export class BoundingSphere {
  72644. /**
  72645. * Gets the center of the bounding sphere in local space
  72646. */
  72647. readonly center: Vector3;
  72648. /**
  72649. * Radius of the bounding sphere in local space
  72650. */
  72651. radius: number;
  72652. /**
  72653. * Gets the center of the bounding sphere in world space
  72654. */
  72655. readonly centerWorld: Vector3;
  72656. /**
  72657. * Radius of the bounding sphere in world space
  72658. */
  72659. radiusWorld: number;
  72660. /**
  72661. * Gets the minimum vector in local space
  72662. */
  72663. readonly minimum: Vector3;
  72664. /**
  72665. * Gets the maximum vector in local space
  72666. */
  72667. readonly maximum: Vector3;
  72668. private _worldMatrix;
  72669. private static readonly TmpVector3;
  72670. /**
  72671. * Creates a new bounding sphere
  72672. * @param min defines the minimum vector (in local space)
  72673. * @param max defines the maximum vector (in local space)
  72674. * @param worldMatrix defines the new world matrix
  72675. */
  72676. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  72677. /**
  72678. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  72679. * @param min defines the new minimum vector (in local space)
  72680. * @param max defines the new maximum vector (in local space)
  72681. * @param worldMatrix defines the new world matrix
  72682. */
  72683. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  72684. /**
  72685. * Scale the current bounding sphere by applying a scale factor
  72686. * @param factor defines the scale factor to apply
  72687. * @returns the current bounding box
  72688. */
  72689. scale(factor: number): BoundingSphere;
  72690. /**
  72691. * Gets the world matrix of the bounding box
  72692. * @returns a matrix
  72693. */
  72694. getWorldMatrix(): DeepImmutable<Matrix>;
  72695. /** @hidden */
  72696. _update(worldMatrix: DeepImmutable<Matrix>): void;
  72697. /**
  72698. * Tests if the bounding sphere is intersecting the frustum planes
  72699. * @param frustumPlanes defines the frustum planes to test
  72700. * @returns true if there is an intersection
  72701. */
  72702. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72703. /**
  72704. * Tests if the bounding sphere center is in between the frustum planes.
  72705. * Used for optimistic fast inclusion.
  72706. * @param frustumPlanes defines the frustum planes to test
  72707. * @returns true if the sphere center is in between the frustum planes
  72708. */
  72709. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72710. /**
  72711. * Tests if a point is inside the bounding sphere
  72712. * @param point defines the point to test
  72713. * @returns true if the point is inside the bounding sphere
  72714. */
  72715. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  72716. /**
  72717. * Checks if two sphere intersct
  72718. * @param sphere0 sphere 0
  72719. * @param sphere1 sphere 1
  72720. * @returns true if the speres intersect
  72721. */
  72722. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  72723. }
  72724. }
  72725. declare module BABYLON {
  72726. /**
  72727. * Class used to store bounding box information
  72728. */
  72729. export class BoundingBox implements ICullable {
  72730. /**
  72731. * Gets the 8 vectors representing the bounding box in local space
  72732. */
  72733. readonly vectors: Vector3[];
  72734. /**
  72735. * Gets the center of the bounding box in local space
  72736. */
  72737. readonly center: Vector3;
  72738. /**
  72739. * Gets the center of the bounding box in world space
  72740. */
  72741. readonly centerWorld: Vector3;
  72742. /**
  72743. * Gets the extend size in local space
  72744. */
  72745. readonly extendSize: Vector3;
  72746. /**
  72747. * Gets the extend size in world space
  72748. */
  72749. readonly extendSizeWorld: Vector3;
  72750. /**
  72751. * Gets the OBB (object bounding box) directions
  72752. */
  72753. readonly directions: Vector3[];
  72754. /**
  72755. * Gets the 8 vectors representing the bounding box in world space
  72756. */
  72757. readonly vectorsWorld: Vector3[];
  72758. /**
  72759. * Gets the minimum vector in world space
  72760. */
  72761. readonly minimumWorld: Vector3;
  72762. /**
  72763. * Gets the maximum vector in world space
  72764. */
  72765. readonly maximumWorld: Vector3;
  72766. /**
  72767. * Gets the minimum vector in local space
  72768. */
  72769. readonly minimum: Vector3;
  72770. /**
  72771. * Gets the maximum vector in local space
  72772. */
  72773. readonly maximum: Vector3;
  72774. private _worldMatrix;
  72775. private static readonly TmpVector3;
  72776. /**
  72777. * @hidden
  72778. */
  72779. _tag: number;
  72780. /**
  72781. * Creates a new bounding box
  72782. * @param min defines the minimum vector (in local space)
  72783. * @param max defines the maximum vector (in local space)
  72784. * @param worldMatrix defines the new world matrix
  72785. */
  72786. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  72787. /**
  72788. * Recreates the entire bounding box from scratch as if we call the constructor in place
  72789. * @param min defines the new minimum vector (in local space)
  72790. * @param max defines the new maximum vector (in local space)
  72791. * @param worldMatrix defines the new world matrix
  72792. */
  72793. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  72794. /**
  72795. * Scale the current bounding box by applying a scale factor
  72796. * @param factor defines the scale factor to apply
  72797. * @returns the current bounding box
  72798. */
  72799. scale(factor: number): BoundingBox;
  72800. /**
  72801. * Gets the world matrix of the bounding box
  72802. * @returns a matrix
  72803. */
  72804. getWorldMatrix(): DeepImmutable<Matrix>;
  72805. /** @hidden */
  72806. _update(world: DeepImmutable<Matrix>): void;
  72807. /**
  72808. * Tests if the bounding box is intersecting the frustum planes
  72809. * @param frustumPlanes defines the frustum planes to test
  72810. * @returns true if there is an intersection
  72811. */
  72812. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72813. /**
  72814. * Tests if the bounding box is entirely inside the frustum planes
  72815. * @param frustumPlanes defines the frustum planes to test
  72816. * @returns true if there is an inclusion
  72817. */
  72818. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72819. /**
  72820. * Tests if a point is inside the bounding box
  72821. * @param point defines the point to test
  72822. * @returns true if the point is inside the bounding box
  72823. */
  72824. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  72825. /**
  72826. * Tests if the bounding box intersects with a bounding sphere
  72827. * @param sphere defines the sphere to test
  72828. * @returns true if there is an intersection
  72829. */
  72830. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  72831. /**
  72832. * Tests if the bounding box intersects with a box defined by a min and max vectors
  72833. * @param min defines the min vector to use
  72834. * @param max defines the max vector to use
  72835. * @returns true if there is an intersection
  72836. */
  72837. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  72838. /**
  72839. * Tests if two bounding boxes are intersections
  72840. * @param box0 defines the first box to test
  72841. * @param box1 defines the second box to test
  72842. * @returns true if there is an intersection
  72843. */
  72844. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  72845. /**
  72846. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  72847. * @param minPoint defines the minimum vector of the bounding box
  72848. * @param maxPoint defines the maximum vector of the bounding box
  72849. * @param sphereCenter defines the sphere center
  72850. * @param sphereRadius defines the sphere radius
  72851. * @returns true if there is an intersection
  72852. */
  72853. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  72854. /**
  72855. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  72856. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  72857. * @param frustumPlanes defines the frustum planes to test
  72858. * @return true if there is an inclusion
  72859. */
  72860. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72861. /**
  72862. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  72863. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  72864. * @param frustumPlanes defines the frustum planes to test
  72865. * @return true if there is an intersection
  72866. */
  72867. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72868. }
  72869. }
  72870. declare module BABYLON {
  72871. /** @hidden */
  72872. export class Collider {
  72873. /** Define if a collision was found */
  72874. collisionFound: boolean;
  72875. /**
  72876. * Define last intersection point in local space
  72877. */
  72878. intersectionPoint: Vector3;
  72879. /**
  72880. * Define last collided mesh
  72881. */
  72882. collidedMesh: Nullable<AbstractMesh>;
  72883. private _collisionPoint;
  72884. private _planeIntersectionPoint;
  72885. private _tempVector;
  72886. private _tempVector2;
  72887. private _tempVector3;
  72888. private _tempVector4;
  72889. private _edge;
  72890. private _baseToVertex;
  72891. private _destinationPoint;
  72892. private _slidePlaneNormal;
  72893. private _displacementVector;
  72894. /** @hidden */
  72895. _radius: Vector3;
  72896. /** @hidden */
  72897. _retry: number;
  72898. private _velocity;
  72899. private _basePoint;
  72900. private _epsilon;
  72901. /** @hidden */
  72902. _velocityWorldLength: number;
  72903. /** @hidden */
  72904. _basePointWorld: Vector3;
  72905. private _velocityWorld;
  72906. private _normalizedVelocity;
  72907. /** @hidden */
  72908. _initialVelocity: Vector3;
  72909. /** @hidden */
  72910. _initialPosition: Vector3;
  72911. private _nearestDistance;
  72912. private _collisionMask;
  72913. collisionMask: number;
  72914. /**
  72915. * Gets the plane normal used to compute the sliding response (in local space)
  72916. */
  72917. readonly slidePlaneNormal: Vector3;
  72918. /** @hidden */
  72919. _initialize(source: Vector3, dir: Vector3, e: number): void;
  72920. /** @hidden */
  72921. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  72922. /** @hidden */
  72923. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  72924. /** @hidden */
  72925. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  72926. /** @hidden */
  72927. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  72928. /** @hidden */
  72929. _getResponse(pos: Vector3, vel: Vector3): void;
  72930. }
  72931. }
  72932. declare module BABYLON {
  72933. /**
  72934. * Interface for cullable objects
  72935. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  72936. */
  72937. export interface ICullable {
  72938. /**
  72939. * Checks if the object or part of the object is in the frustum
  72940. * @param frustumPlanes Camera near/planes
  72941. * @returns true if the object is in frustum otherwise false
  72942. */
  72943. isInFrustum(frustumPlanes: Plane[]): boolean;
  72944. /**
  72945. * Checks if a cullable object (mesh...) is in the camera frustum
  72946. * Unlike isInFrustum this cheks the full bounding box
  72947. * @param frustumPlanes Camera near/planes
  72948. * @returns true if the object is in frustum otherwise false
  72949. */
  72950. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  72951. }
  72952. /**
  72953. * Info for a bounding data of a mesh
  72954. */
  72955. export class BoundingInfo implements ICullable {
  72956. /**
  72957. * Bounding box for the mesh
  72958. */
  72959. readonly boundingBox: BoundingBox;
  72960. /**
  72961. * Bounding sphere for the mesh
  72962. */
  72963. readonly boundingSphere: BoundingSphere;
  72964. private _isLocked;
  72965. private static readonly TmpVector3;
  72966. /**
  72967. * Constructs bounding info
  72968. * @param minimum min vector of the bounding box/sphere
  72969. * @param maximum max vector of the bounding box/sphere
  72970. * @param worldMatrix defines the new world matrix
  72971. */
  72972. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  72973. /**
  72974. * Recreates the entire bounding info from scratch as if we call the constructor in place
  72975. * @param min defines the new minimum vector (in local space)
  72976. * @param max defines the new maximum vector (in local space)
  72977. * @param worldMatrix defines the new world matrix
  72978. */
  72979. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  72980. /**
  72981. * min vector of the bounding box/sphere
  72982. */
  72983. readonly minimum: Vector3;
  72984. /**
  72985. * max vector of the bounding box/sphere
  72986. */
  72987. readonly maximum: Vector3;
  72988. /**
  72989. * If the info is locked and won't be updated to avoid perf overhead
  72990. */
  72991. isLocked: boolean;
  72992. /**
  72993. * Updates the bounding sphere and box
  72994. * @param world world matrix to be used to update
  72995. */
  72996. update(world: DeepImmutable<Matrix>): void;
  72997. /**
  72998. * Recreate the bounding info to be centered around a specific point given a specific extend.
  72999. * @param center New center of the bounding info
  73000. * @param extend New extend of the bounding info
  73001. * @returns the current bounding info
  73002. */
  73003. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  73004. /**
  73005. * Scale the current bounding info by applying a scale factor
  73006. * @param factor defines the scale factor to apply
  73007. * @returns the current bounding info
  73008. */
  73009. scale(factor: number): BoundingInfo;
  73010. /**
  73011. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  73012. * @param frustumPlanes defines the frustum to test
  73013. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  73014. * @returns true if the bounding info is in the frustum planes
  73015. */
  73016. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  73017. /**
  73018. * Gets the world distance between the min and max points of the bounding box
  73019. */
  73020. readonly diagonalLength: number;
  73021. /**
  73022. * Checks if a cullable object (mesh...) is in the camera frustum
  73023. * Unlike isInFrustum this cheks the full bounding box
  73024. * @param frustumPlanes Camera near/planes
  73025. * @returns true if the object is in frustum otherwise false
  73026. */
  73027. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73028. /** @hidden */
  73029. _checkCollision(collider: Collider): boolean;
  73030. /**
  73031. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  73032. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  73033. * @param point the point to check intersection with
  73034. * @returns if the point intersects
  73035. */
  73036. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73037. /**
  73038. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  73039. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  73040. * @param boundingInfo the bounding info to check intersection with
  73041. * @param precise if the intersection should be done using OBB
  73042. * @returns if the bounding info intersects
  73043. */
  73044. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  73045. }
  73046. }
  73047. declare module BABYLON {
  73048. /**
  73049. * Extracts minimum and maximum values from a list of indexed positions
  73050. * @param positions defines the positions to use
  73051. * @param indices defines the indices to the positions
  73052. * @param indexStart defines the start index
  73053. * @param indexCount defines the end index
  73054. * @param bias defines bias value to add to the result
  73055. * @return minimum and maximum values
  73056. */
  73057. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  73058. minimum: Vector3;
  73059. maximum: Vector3;
  73060. };
  73061. /**
  73062. * Extracts minimum and maximum values from a list of positions
  73063. * @param positions defines the positions to use
  73064. * @param start defines the start index in the positions array
  73065. * @param count defines the number of positions to handle
  73066. * @param bias defines bias value to add to the result
  73067. * @param stride defines the stride size to use (distance between two positions in the positions array)
  73068. * @return minimum and maximum values
  73069. */
  73070. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  73071. minimum: Vector3;
  73072. maximum: Vector3;
  73073. };
  73074. }
  73075. declare module BABYLON {
  73076. /**
  73077. * Enum that determines the text-wrapping mode to use.
  73078. */
  73079. export enum InspectableType {
  73080. /**
  73081. * Checkbox for booleans
  73082. */
  73083. Checkbox = 0,
  73084. /**
  73085. * Sliders for numbers
  73086. */
  73087. Slider = 1,
  73088. /**
  73089. * Vector3
  73090. */
  73091. Vector3 = 2,
  73092. /**
  73093. * Quaternions
  73094. */
  73095. Quaternion = 3,
  73096. /**
  73097. * Color3
  73098. */
  73099. Color3 = 4,
  73100. /**
  73101. * String
  73102. */
  73103. String = 5
  73104. }
  73105. /**
  73106. * Interface used to define custom inspectable properties.
  73107. * This interface is used by the inspector to display custom property grids
  73108. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  73109. */
  73110. export interface IInspectable {
  73111. /**
  73112. * Gets the label to display
  73113. */
  73114. label: string;
  73115. /**
  73116. * Gets the name of the property to edit
  73117. */
  73118. propertyName: string;
  73119. /**
  73120. * Gets the type of the editor to use
  73121. */
  73122. type: InspectableType;
  73123. /**
  73124. * Gets the minimum value of the property when using in "slider" mode
  73125. */
  73126. min?: number;
  73127. /**
  73128. * Gets the maximum value of the property when using in "slider" mode
  73129. */
  73130. max?: number;
  73131. /**
  73132. * Gets the setp to use when using in "slider" mode
  73133. */
  73134. step?: number;
  73135. }
  73136. }
  73137. declare module BABYLON {
  73138. /**
  73139. * Class used to provide helper for timing
  73140. */
  73141. export class TimingTools {
  73142. /**
  73143. * Polyfill for setImmediate
  73144. * @param action defines the action to execute after the current execution block
  73145. */
  73146. static SetImmediate(action: () => void): void;
  73147. }
  73148. }
  73149. declare module BABYLON {
  73150. /**
  73151. * Class used to enable instatition of objects by class name
  73152. */
  73153. export class InstantiationTools {
  73154. /**
  73155. * Use this object to register external classes like custom textures or material
  73156. * to allow the laoders to instantiate them
  73157. */
  73158. static RegisteredExternalClasses: {
  73159. [key: string]: Object;
  73160. };
  73161. /**
  73162. * Tries to instantiate a new object from a given class name
  73163. * @param className defines the class name to instantiate
  73164. * @returns the new object or null if the system was not able to do the instantiation
  73165. */
  73166. static Instantiate(className: string): any;
  73167. }
  73168. }
  73169. declare module BABYLON {
  73170. /**
  73171. * This represents the required contract to create a new type of texture loader.
  73172. */
  73173. export interface IInternalTextureLoader {
  73174. /**
  73175. * Defines wether the loader supports cascade loading the different faces.
  73176. */
  73177. supportCascades: boolean;
  73178. /**
  73179. * This returns if the loader support the current file information.
  73180. * @param extension defines the file extension of the file being loaded
  73181. * @param textureFormatInUse defines the current compressed format in use iun the engine
  73182. * @param fallback defines the fallback internal texture if any
  73183. * @param isBase64 defines whether the texture is encoded as a base64
  73184. * @param isBuffer defines whether the texture data are stored as a buffer
  73185. * @returns true if the loader can load the specified file
  73186. */
  73187. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  73188. /**
  73189. * Transform the url before loading if required.
  73190. * @param rootUrl the url of the texture
  73191. * @param textureFormatInUse defines the current compressed format in use iun the engine
  73192. * @returns the transformed texture
  73193. */
  73194. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  73195. /**
  73196. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  73197. * @param rootUrl the url of the texture
  73198. * @param textureFormatInUse defines the current compressed format in use iun the engine
  73199. * @returns the fallback texture
  73200. */
  73201. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  73202. /**
  73203. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  73204. * @param data contains the texture data
  73205. * @param texture defines the BabylonJS internal texture
  73206. * @param createPolynomials will be true if polynomials have been requested
  73207. * @param onLoad defines the callback to trigger once the texture is ready
  73208. * @param onError defines the callback to trigger in case of error
  73209. */
  73210. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  73211. /**
  73212. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  73213. * @param data contains the texture data
  73214. * @param texture defines the BabylonJS internal texture
  73215. * @param callback defines the method to call once ready to upload
  73216. */
  73217. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  73218. }
  73219. }
  73220. declare module BABYLON {
  73221. interface Engine {
  73222. /**
  73223. * Creates a depth stencil cube texture.
  73224. * This is only available in WebGL 2.
  73225. * @param size The size of face edge in the cube texture.
  73226. * @param options The options defining the cube texture.
  73227. * @returns The cube texture
  73228. */
  73229. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  73230. /**
  73231. * Creates a cube texture
  73232. * @param rootUrl defines the url where the files to load is located
  73233. * @param scene defines the current scene
  73234. * @param files defines the list of files to load (1 per face)
  73235. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  73236. * @param onLoad defines an optional callback raised when the texture is loaded
  73237. * @param onError defines an optional callback raised if there is an issue to load the texture
  73238. * @param format defines the format of the data
  73239. * @param forcedExtension defines the extension to use to pick the right loader
  73240. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  73241. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  73242. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  73243. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  73244. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  73245. * @returns the cube texture as an InternalTexture
  73246. */
  73247. 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;
  73248. /**
  73249. * Creates a cube texture
  73250. * @param rootUrl defines the url where the files to load is located
  73251. * @param scene defines the current scene
  73252. * @param files defines the list of files to load (1 per face)
  73253. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  73254. * @param onLoad defines an optional callback raised when the texture is loaded
  73255. * @param onError defines an optional callback raised if there is an issue to load the texture
  73256. * @param format defines the format of the data
  73257. * @param forcedExtension defines the extension to use to pick the right loader
  73258. * @returns the cube texture as an InternalTexture
  73259. */
  73260. 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;
  73261. /**
  73262. * Creates a cube texture
  73263. * @param rootUrl defines the url where the files to load is located
  73264. * @param scene defines the current scene
  73265. * @param files defines the list of files to load (1 per face)
  73266. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  73267. * @param onLoad defines an optional callback raised when the texture is loaded
  73268. * @param onError defines an optional callback raised if there is an issue to load the texture
  73269. * @param format defines the format of the data
  73270. * @param forcedExtension defines the extension to use to pick the right loader
  73271. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  73272. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  73273. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  73274. * @returns the cube texture as an InternalTexture
  73275. */
  73276. 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;
  73277. /** @hidden */
  73278. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  73279. /** @hidden */
  73280. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  73281. /** @hidden */
  73282. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  73283. /** @hidden */
  73284. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  73285. }
  73286. }
  73287. declare module BABYLON {
  73288. /**
  73289. * Class for creating a cube texture
  73290. */
  73291. export class CubeTexture extends BaseTexture {
  73292. private _delayedOnLoad;
  73293. /**
  73294. * The url of the texture
  73295. */
  73296. url: string;
  73297. /**
  73298. * Gets or sets the center of the bounding box associated with the cube texture.
  73299. * It must define where the camera used to render the texture was set
  73300. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  73301. */
  73302. boundingBoxPosition: Vector3;
  73303. private _boundingBoxSize;
  73304. /**
  73305. * Gets or sets the size of the bounding box associated with the cube texture
  73306. * When defined, the cubemap will switch to local mode
  73307. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  73308. * @example https://www.babylonjs-playground.com/#RNASML
  73309. */
  73310. /**
  73311. * Returns the bounding box size
  73312. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  73313. */
  73314. boundingBoxSize: Vector3;
  73315. protected _rotationY: number;
  73316. /**
  73317. * Sets texture matrix rotation angle around Y axis in radians.
  73318. */
  73319. /**
  73320. * Gets texture matrix rotation angle around Y axis radians.
  73321. */
  73322. rotationY: number;
  73323. /**
  73324. * Are mip maps generated for this texture or not.
  73325. */
  73326. readonly noMipmap: boolean;
  73327. private _noMipmap;
  73328. private _files;
  73329. private _extensions;
  73330. private _textureMatrix;
  73331. private _format;
  73332. private _createPolynomials;
  73333. /** @hidden */
  73334. _prefiltered: boolean;
  73335. /**
  73336. * Creates a cube texture from an array of image urls
  73337. * @param files defines an array of image urls
  73338. * @param scene defines the hosting scene
  73339. * @param noMipmap specifies if mip maps are not used
  73340. * @returns a cube texture
  73341. */
  73342. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  73343. /**
  73344. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  73345. * @param url defines the url of the prefiltered texture
  73346. * @param scene defines the scene the texture is attached to
  73347. * @param forcedExtension defines the extension of the file if different from the url
  73348. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  73349. * @return the prefiltered texture
  73350. */
  73351. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  73352. /**
  73353. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  73354. * as prefiltered data.
  73355. * @param rootUrl defines the url of the texture or the root name of the six images
  73356. * @param scene defines the scene the texture is attached to
  73357. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  73358. * @param noMipmap defines if mipmaps should be created or not
  73359. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  73360. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  73361. * @param onError defines a callback triggered in case of error during load
  73362. * @param format defines the internal format to use for the texture once loaded
  73363. * @param prefiltered defines whether or not the texture is created from prefiltered data
  73364. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  73365. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  73366. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  73367. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  73368. * @return the cube texture
  73369. */
  73370. 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);
  73371. /**
  73372. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  73373. */
  73374. readonly isPrefiltered: boolean;
  73375. /**
  73376. * Get the current class name of the texture useful for serialization or dynamic coding.
  73377. * @returns "CubeTexture"
  73378. */
  73379. getClassName(): string;
  73380. /**
  73381. * Update the url (and optional buffer) of this texture if url was null during construction.
  73382. * @param url the url of the texture
  73383. * @param forcedExtension defines the extension to use
  73384. * @param onLoad callback called when the texture is loaded (defaults to null)
  73385. */
  73386. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  73387. /**
  73388. * Delays loading of the cube texture
  73389. * @param forcedExtension defines the extension to use
  73390. */
  73391. delayLoad(forcedExtension?: string): void;
  73392. /**
  73393. * Returns the reflection texture matrix
  73394. * @returns the reflection texture matrix
  73395. */
  73396. getReflectionTextureMatrix(): Matrix;
  73397. /**
  73398. * Sets the reflection texture matrix
  73399. * @param value Reflection texture matrix
  73400. */
  73401. setReflectionTextureMatrix(value: Matrix): void;
  73402. /**
  73403. * Parses text to create a cube texture
  73404. * @param parsedTexture define the serialized text to read from
  73405. * @param scene defines the hosting scene
  73406. * @param rootUrl defines the root url of the cube texture
  73407. * @returns a cube texture
  73408. */
  73409. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  73410. /**
  73411. * Makes a clone, or deep copy, of the cube texture
  73412. * @returns a new cube texture
  73413. */
  73414. clone(): CubeTexture;
  73415. }
  73416. }
  73417. declare module BABYLON {
  73418. /**
  73419. * Manages the defines for the Material
  73420. */
  73421. export class MaterialDefines {
  73422. /** @hidden */
  73423. protected _keys: string[];
  73424. private _isDirty;
  73425. /** @hidden */
  73426. _renderId: number;
  73427. /** @hidden */
  73428. _areLightsDirty: boolean;
  73429. /** @hidden */
  73430. _areLightsDisposed: boolean;
  73431. /** @hidden */
  73432. _areAttributesDirty: boolean;
  73433. /** @hidden */
  73434. _areTexturesDirty: boolean;
  73435. /** @hidden */
  73436. _areFresnelDirty: boolean;
  73437. /** @hidden */
  73438. _areMiscDirty: boolean;
  73439. /** @hidden */
  73440. _areImageProcessingDirty: boolean;
  73441. /** @hidden */
  73442. _normals: boolean;
  73443. /** @hidden */
  73444. _uvs: boolean;
  73445. /** @hidden */
  73446. _needNormals: boolean;
  73447. /** @hidden */
  73448. _needUVs: boolean;
  73449. [id: string]: any;
  73450. /**
  73451. * Specifies if the material needs to be re-calculated
  73452. */
  73453. readonly isDirty: boolean;
  73454. /**
  73455. * Marks the material to indicate that it has been re-calculated
  73456. */
  73457. markAsProcessed(): void;
  73458. /**
  73459. * Marks the material to indicate that it needs to be re-calculated
  73460. */
  73461. markAsUnprocessed(): void;
  73462. /**
  73463. * Marks the material to indicate all of its defines need to be re-calculated
  73464. */
  73465. markAllAsDirty(): void;
  73466. /**
  73467. * Marks the material to indicate that image processing needs to be re-calculated
  73468. */
  73469. markAsImageProcessingDirty(): void;
  73470. /**
  73471. * Marks the material to indicate the lights need to be re-calculated
  73472. * @param disposed Defines whether the light is dirty due to dispose or not
  73473. */
  73474. markAsLightDirty(disposed?: boolean): void;
  73475. /**
  73476. * Marks the attribute state as changed
  73477. */
  73478. markAsAttributesDirty(): void;
  73479. /**
  73480. * Marks the texture state as changed
  73481. */
  73482. markAsTexturesDirty(): void;
  73483. /**
  73484. * Marks the fresnel state as changed
  73485. */
  73486. markAsFresnelDirty(): void;
  73487. /**
  73488. * Marks the misc state as changed
  73489. */
  73490. markAsMiscDirty(): void;
  73491. /**
  73492. * Rebuilds the material defines
  73493. */
  73494. rebuild(): void;
  73495. /**
  73496. * Specifies if two material defines are equal
  73497. * @param other - A material define instance to compare to
  73498. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  73499. */
  73500. isEqual(other: MaterialDefines): boolean;
  73501. /**
  73502. * Clones this instance's defines to another instance
  73503. * @param other - material defines to clone values to
  73504. */
  73505. cloneTo(other: MaterialDefines): void;
  73506. /**
  73507. * Resets the material define values
  73508. */
  73509. reset(): void;
  73510. /**
  73511. * Converts the material define values to a string
  73512. * @returns - String of material define information
  73513. */
  73514. toString(): string;
  73515. }
  73516. }
  73517. declare module BABYLON {
  73518. /**
  73519. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  73520. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  73521. * 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;
  73522. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  73523. */
  73524. export class ColorCurves {
  73525. private _dirty;
  73526. private _tempColor;
  73527. private _globalCurve;
  73528. private _highlightsCurve;
  73529. private _midtonesCurve;
  73530. private _shadowsCurve;
  73531. private _positiveCurve;
  73532. private _negativeCurve;
  73533. private _globalHue;
  73534. private _globalDensity;
  73535. private _globalSaturation;
  73536. private _globalExposure;
  73537. /**
  73538. * Gets the global Hue value.
  73539. * 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).
  73540. */
  73541. /**
  73542. * Sets the global Hue value.
  73543. * 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).
  73544. */
  73545. globalHue: number;
  73546. /**
  73547. * Gets the global Density value.
  73548. * 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.
  73549. * Values less than zero provide a filter of opposite hue.
  73550. */
  73551. /**
  73552. * Sets the global Density value.
  73553. * 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.
  73554. * Values less than zero provide a filter of opposite hue.
  73555. */
  73556. globalDensity: number;
  73557. /**
  73558. * Gets the global Saturation value.
  73559. * 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.
  73560. */
  73561. /**
  73562. * Sets the global Saturation value.
  73563. * 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.
  73564. */
  73565. globalSaturation: number;
  73566. /**
  73567. * Gets the global Exposure value.
  73568. * 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.
  73569. */
  73570. /**
  73571. * Sets the global Exposure value.
  73572. * 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.
  73573. */
  73574. globalExposure: number;
  73575. private _highlightsHue;
  73576. private _highlightsDensity;
  73577. private _highlightsSaturation;
  73578. private _highlightsExposure;
  73579. /**
  73580. * Gets the highlights Hue value.
  73581. * 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).
  73582. */
  73583. /**
  73584. * Sets the highlights Hue value.
  73585. * 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).
  73586. */
  73587. highlightsHue: number;
  73588. /**
  73589. * Gets the highlights Density value.
  73590. * 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.
  73591. * Values less than zero provide a filter of opposite hue.
  73592. */
  73593. /**
  73594. * Sets the highlights Density value.
  73595. * 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.
  73596. * Values less than zero provide a filter of opposite hue.
  73597. */
  73598. highlightsDensity: number;
  73599. /**
  73600. * Gets the highlights Saturation value.
  73601. * 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.
  73602. */
  73603. /**
  73604. * Sets the highlights Saturation value.
  73605. * 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.
  73606. */
  73607. highlightsSaturation: number;
  73608. /**
  73609. * Gets the highlights Exposure value.
  73610. * 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.
  73611. */
  73612. /**
  73613. * Sets the highlights Exposure value.
  73614. * 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.
  73615. */
  73616. highlightsExposure: number;
  73617. private _midtonesHue;
  73618. private _midtonesDensity;
  73619. private _midtonesSaturation;
  73620. private _midtonesExposure;
  73621. /**
  73622. * Gets the midtones Hue value.
  73623. * 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).
  73624. */
  73625. /**
  73626. * Sets the midtones Hue value.
  73627. * 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).
  73628. */
  73629. midtonesHue: number;
  73630. /**
  73631. * Gets the midtones Density value.
  73632. * 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.
  73633. * Values less than zero provide a filter of opposite hue.
  73634. */
  73635. /**
  73636. * Sets the midtones Density value.
  73637. * 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.
  73638. * Values less than zero provide a filter of opposite hue.
  73639. */
  73640. midtonesDensity: number;
  73641. /**
  73642. * Gets the midtones Saturation value.
  73643. * 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.
  73644. */
  73645. /**
  73646. * Sets the midtones Saturation value.
  73647. * 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.
  73648. */
  73649. midtonesSaturation: number;
  73650. /**
  73651. * Gets the midtones Exposure value.
  73652. * 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.
  73653. */
  73654. /**
  73655. * Sets the midtones Exposure value.
  73656. * 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.
  73657. */
  73658. midtonesExposure: number;
  73659. private _shadowsHue;
  73660. private _shadowsDensity;
  73661. private _shadowsSaturation;
  73662. private _shadowsExposure;
  73663. /**
  73664. * Gets the shadows Hue value.
  73665. * 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).
  73666. */
  73667. /**
  73668. * Sets the shadows Hue value.
  73669. * 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).
  73670. */
  73671. shadowsHue: number;
  73672. /**
  73673. * Gets the shadows Density value.
  73674. * 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.
  73675. * Values less than zero provide a filter of opposite hue.
  73676. */
  73677. /**
  73678. * Sets the shadows Density value.
  73679. * 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.
  73680. * Values less than zero provide a filter of opposite hue.
  73681. */
  73682. shadowsDensity: number;
  73683. /**
  73684. * Gets the shadows Saturation value.
  73685. * 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.
  73686. */
  73687. /**
  73688. * Sets the shadows Saturation value.
  73689. * 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.
  73690. */
  73691. shadowsSaturation: number;
  73692. /**
  73693. * Gets the shadows Exposure value.
  73694. * 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.
  73695. */
  73696. /**
  73697. * Sets the shadows Exposure value.
  73698. * 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.
  73699. */
  73700. shadowsExposure: number;
  73701. /**
  73702. * Returns the class name
  73703. * @returns The class name
  73704. */
  73705. getClassName(): string;
  73706. /**
  73707. * Binds the color curves to the shader.
  73708. * @param colorCurves The color curve to bind
  73709. * @param effect The effect to bind to
  73710. * @param positiveUniform The positive uniform shader parameter
  73711. * @param neutralUniform The neutral uniform shader parameter
  73712. * @param negativeUniform The negative uniform shader parameter
  73713. */
  73714. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  73715. /**
  73716. * Prepare the list of uniforms associated with the ColorCurves effects.
  73717. * @param uniformsList The list of uniforms used in the effect
  73718. */
  73719. static PrepareUniforms(uniformsList: string[]): void;
  73720. /**
  73721. * Returns color grading data based on a hue, density, saturation and exposure value.
  73722. * @param filterHue The hue of the color filter.
  73723. * @param filterDensity The density of the color filter.
  73724. * @param saturation The saturation.
  73725. * @param exposure The exposure.
  73726. * @param result The result data container.
  73727. */
  73728. private getColorGradingDataToRef;
  73729. /**
  73730. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  73731. * @param value The input slider value in range [-100,100].
  73732. * @returns Adjusted value.
  73733. */
  73734. private static applyColorGradingSliderNonlinear;
  73735. /**
  73736. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  73737. * @param hue The hue (H) input.
  73738. * @param saturation The saturation (S) input.
  73739. * @param brightness The brightness (B) input.
  73740. * @result An RGBA color represented as Vector4.
  73741. */
  73742. private static fromHSBToRef;
  73743. /**
  73744. * Returns a value clamped between min and max
  73745. * @param value The value to clamp
  73746. * @param min The minimum of value
  73747. * @param max The maximum of value
  73748. * @returns The clamped value.
  73749. */
  73750. private static clamp;
  73751. /**
  73752. * Clones the current color curve instance.
  73753. * @return The cloned curves
  73754. */
  73755. clone(): ColorCurves;
  73756. /**
  73757. * Serializes the current color curve instance to a json representation.
  73758. * @return a JSON representation
  73759. */
  73760. serialize(): any;
  73761. /**
  73762. * Parses the color curve from a json representation.
  73763. * @param source the JSON source to parse
  73764. * @return The parsed curves
  73765. */
  73766. static Parse(source: any): ColorCurves;
  73767. }
  73768. }
  73769. declare module BABYLON {
  73770. /**
  73771. * Interface to follow in your material defines to integrate easily the
  73772. * Image proccessing functions.
  73773. * @hidden
  73774. */
  73775. export interface IImageProcessingConfigurationDefines {
  73776. IMAGEPROCESSING: boolean;
  73777. VIGNETTE: boolean;
  73778. VIGNETTEBLENDMODEMULTIPLY: boolean;
  73779. VIGNETTEBLENDMODEOPAQUE: boolean;
  73780. TONEMAPPING: boolean;
  73781. TONEMAPPING_ACES: boolean;
  73782. CONTRAST: boolean;
  73783. EXPOSURE: boolean;
  73784. COLORCURVES: boolean;
  73785. COLORGRADING: boolean;
  73786. COLORGRADING3D: boolean;
  73787. SAMPLER3DGREENDEPTH: boolean;
  73788. SAMPLER3DBGRMAP: boolean;
  73789. IMAGEPROCESSINGPOSTPROCESS: boolean;
  73790. }
  73791. /**
  73792. * @hidden
  73793. */
  73794. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  73795. IMAGEPROCESSING: boolean;
  73796. VIGNETTE: boolean;
  73797. VIGNETTEBLENDMODEMULTIPLY: boolean;
  73798. VIGNETTEBLENDMODEOPAQUE: boolean;
  73799. TONEMAPPING: boolean;
  73800. TONEMAPPING_ACES: boolean;
  73801. CONTRAST: boolean;
  73802. COLORCURVES: boolean;
  73803. COLORGRADING: boolean;
  73804. COLORGRADING3D: boolean;
  73805. SAMPLER3DGREENDEPTH: boolean;
  73806. SAMPLER3DBGRMAP: boolean;
  73807. IMAGEPROCESSINGPOSTPROCESS: boolean;
  73808. EXPOSURE: boolean;
  73809. constructor();
  73810. }
  73811. /**
  73812. * This groups together the common properties used for image processing either in direct forward pass
  73813. * or through post processing effect depending on the use of the image processing pipeline in your scene
  73814. * or not.
  73815. */
  73816. export class ImageProcessingConfiguration {
  73817. /**
  73818. * Default tone mapping applied in BabylonJS.
  73819. */
  73820. static readonly TONEMAPPING_STANDARD: number;
  73821. /**
  73822. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  73823. * to other engines rendering to increase portability.
  73824. */
  73825. static readonly TONEMAPPING_ACES: number;
  73826. /**
  73827. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  73828. */
  73829. colorCurves: Nullable<ColorCurves>;
  73830. private _colorCurvesEnabled;
  73831. /**
  73832. * Gets wether the color curves effect is enabled.
  73833. */
  73834. /**
  73835. * Sets wether the color curves effect is enabled.
  73836. */
  73837. colorCurvesEnabled: boolean;
  73838. private _colorGradingTexture;
  73839. /**
  73840. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  73841. */
  73842. /**
  73843. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  73844. */
  73845. colorGradingTexture: Nullable<BaseTexture>;
  73846. private _colorGradingEnabled;
  73847. /**
  73848. * Gets wether the color grading effect is enabled.
  73849. */
  73850. /**
  73851. * Sets wether the color grading effect is enabled.
  73852. */
  73853. colorGradingEnabled: boolean;
  73854. private _colorGradingWithGreenDepth;
  73855. /**
  73856. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  73857. */
  73858. /**
  73859. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  73860. */
  73861. colorGradingWithGreenDepth: boolean;
  73862. private _colorGradingBGR;
  73863. /**
  73864. * Gets wether the color grading texture contains BGR values.
  73865. */
  73866. /**
  73867. * Sets wether the color grading texture contains BGR values.
  73868. */
  73869. colorGradingBGR: boolean;
  73870. /** @hidden */
  73871. _exposure: number;
  73872. /**
  73873. * Gets the Exposure used in the effect.
  73874. */
  73875. /**
  73876. * Sets the Exposure used in the effect.
  73877. */
  73878. exposure: number;
  73879. private _toneMappingEnabled;
  73880. /**
  73881. * Gets wether the tone mapping effect is enabled.
  73882. */
  73883. /**
  73884. * Sets wether the tone mapping effect is enabled.
  73885. */
  73886. toneMappingEnabled: boolean;
  73887. private _toneMappingType;
  73888. /**
  73889. * Gets the type of tone mapping effect.
  73890. */
  73891. /**
  73892. * Sets the type of tone mapping effect used in BabylonJS.
  73893. */
  73894. toneMappingType: number;
  73895. protected _contrast: number;
  73896. /**
  73897. * Gets the contrast used in the effect.
  73898. */
  73899. /**
  73900. * Sets the contrast used in the effect.
  73901. */
  73902. contrast: number;
  73903. /**
  73904. * Vignette stretch size.
  73905. */
  73906. vignetteStretch: number;
  73907. /**
  73908. * Vignette centre X Offset.
  73909. */
  73910. vignetteCentreX: number;
  73911. /**
  73912. * Vignette centre Y Offset.
  73913. */
  73914. vignetteCentreY: number;
  73915. /**
  73916. * Vignette weight or intensity of the vignette effect.
  73917. */
  73918. vignetteWeight: number;
  73919. /**
  73920. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  73921. * if vignetteEnabled is set to true.
  73922. */
  73923. vignetteColor: Color4;
  73924. /**
  73925. * Camera field of view used by the Vignette effect.
  73926. */
  73927. vignetteCameraFov: number;
  73928. private _vignetteBlendMode;
  73929. /**
  73930. * Gets the vignette blend mode allowing different kind of effect.
  73931. */
  73932. /**
  73933. * Sets the vignette blend mode allowing different kind of effect.
  73934. */
  73935. vignetteBlendMode: number;
  73936. private _vignetteEnabled;
  73937. /**
  73938. * Gets wether the vignette effect is enabled.
  73939. */
  73940. /**
  73941. * Sets wether the vignette effect is enabled.
  73942. */
  73943. vignetteEnabled: boolean;
  73944. private _applyByPostProcess;
  73945. /**
  73946. * Gets wether the image processing is applied through a post process or not.
  73947. */
  73948. /**
  73949. * Sets wether the image processing is applied through a post process or not.
  73950. */
  73951. applyByPostProcess: boolean;
  73952. private _isEnabled;
  73953. /**
  73954. * Gets wether the image processing is enabled or not.
  73955. */
  73956. /**
  73957. * Sets wether the image processing is enabled or not.
  73958. */
  73959. isEnabled: boolean;
  73960. /**
  73961. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  73962. */
  73963. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  73964. /**
  73965. * Method called each time the image processing information changes requires to recompile the effect.
  73966. */
  73967. protected _updateParameters(): void;
  73968. /**
  73969. * Gets the current class name.
  73970. * @return "ImageProcessingConfiguration"
  73971. */
  73972. getClassName(): string;
  73973. /**
  73974. * Prepare the list of uniforms associated with the Image Processing effects.
  73975. * @param uniforms The list of uniforms used in the effect
  73976. * @param defines the list of defines currently in use
  73977. */
  73978. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  73979. /**
  73980. * Prepare the list of samplers associated with the Image Processing effects.
  73981. * @param samplersList The list of uniforms used in the effect
  73982. * @param defines the list of defines currently in use
  73983. */
  73984. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  73985. /**
  73986. * Prepare the list of defines associated to the shader.
  73987. * @param defines the list of defines to complete
  73988. * @param forPostProcess Define if we are currently in post process mode or not
  73989. */
  73990. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  73991. /**
  73992. * Returns true if all the image processing information are ready.
  73993. * @returns True if ready, otherwise, false
  73994. */
  73995. isReady(): boolean;
  73996. /**
  73997. * Binds the image processing to the shader.
  73998. * @param effect The effect to bind to
  73999. * @param aspectRatio Define the current aspect ratio of the effect
  74000. */
  74001. bind(effect: Effect, aspectRatio?: number): void;
  74002. /**
  74003. * Clones the current image processing instance.
  74004. * @return The cloned image processing
  74005. */
  74006. clone(): ImageProcessingConfiguration;
  74007. /**
  74008. * Serializes the current image processing instance to a json representation.
  74009. * @return a JSON representation
  74010. */
  74011. serialize(): any;
  74012. /**
  74013. * Parses the image processing from a json representation.
  74014. * @param source the JSON source to parse
  74015. * @return The parsed image processing
  74016. */
  74017. static Parse(source: any): ImageProcessingConfiguration;
  74018. private static _VIGNETTEMODE_MULTIPLY;
  74019. private static _VIGNETTEMODE_OPAQUE;
  74020. /**
  74021. * Used to apply the vignette as a mix with the pixel color.
  74022. */
  74023. static readonly VIGNETTEMODE_MULTIPLY: number;
  74024. /**
  74025. * Used to apply the vignette as a replacement of the pixel color.
  74026. */
  74027. static readonly VIGNETTEMODE_OPAQUE: number;
  74028. }
  74029. }
  74030. declare module BABYLON {
  74031. /** @hidden */
  74032. export var postprocessVertexShader: {
  74033. name: string;
  74034. shader: string;
  74035. };
  74036. }
  74037. declare module BABYLON {
  74038. /** Defines supported spaces */
  74039. export enum Space {
  74040. /** Local (object) space */
  74041. LOCAL = 0,
  74042. /** World space */
  74043. WORLD = 1,
  74044. /** Bone space */
  74045. BONE = 2
  74046. }
  74047. /** Defines the 3 main axes */
  74048. export class Axis {
  74049. /** X axis */
  74050. static X: Vector3;
  74051. /** Y axis */
  74052. static Y: Vector3;
  74053. /** Z axis */
  74054. static Z: Vector3;
  74055. }
  74056. }
  74057. declare module BABYLON {
  74058. /**
  74059. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  74060. * This is the base of the follow, arc rotate cameras and Free camera
  74061. * @see http://doc.babylonjs.com/features/cameras
  74062. */
  74063. export class TargetCamera extends Camera {
  74064. private static _RigCamTransformMatrix;
  74065. private static _TargetTransformMatrix;
  74066. private static _TargetFocalPoint;
  74067. /**
  74068. * Define the current direction the camera is moving to
  74069. */
  74070. cameraDirection: Vector3;
  74071. /**
  74072. * Define the current rotation the camera is rotating to
  74073. */
  74074. cameraRotation: Vector2;
  74075. /**
  74076. * When set, the up vector of the camera will be updated by the rotation of the camera
  74077. */
  74078. updateUpVectorFromRotation: boolean;
  74079. private _tmpQuaternion;
  74080. /**
  74081. * Define the current rotation of the camera
  74082. */
  74083. rotation: Vector3;
  74084. /**
  74085. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  74086. */
  74087. rotationQuaternion: Quaternion;
  74088. /**
  74089. * Define the current speed of the camera
  74090. */
  74091. speed: number;
  74092. /**
  74093. * Add cconstraint to the camera to prevent it to move freely in all directions and
  74094. * around all axis.
  74095. */
  74096. noRotationConstraint: boolean;
  74097. /**
  74098. * Define the current target of the camera as an object or a position.
  74099. */
  74100. lockedTarget: any;
  74101. /** @hidden */
  74102. _currentTarget: Vector3;
  74103. /** @hidden */
  74104. _initialFocalDistance: number;
  74105. /** @hidden */
  74106. _viewMatrix: Matrix;
  74107. /** @hidden */
  74108. _camMatrix: Matrix;
  74109. /** @hidden */
  74110. _cameraTransformMatrix: Matrix;
  74111. /** @hidden */
  74112. _cameraRotationMatrix: Matrix;
  74113. /** @hidden */
  74114. _referencePoint: Vector3;
  74115. /** @hidden */
  74116. _transformedReferencePoint: Vector3;
  74117. protected _globalCurrentTarget: Vector3;
  74118. protected _globalCurrentUpVector: Vector3;
  74119. /** @hidden */
  74120. _reset: () => void;
  74121. private _defaultUp;
  74122. /**
  74123. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  74124. * This is the base of the follow, arc rotate cameras and Free camera
  74125. * @see http://doc.babylonjs.com/features/cameras
  74126. * @param name Defines the name of the camera in the scene
  74127. * @param position Defines the start position of the camera in the scene
  74128. * @param scene Defines the scene the camera belongs to
  74129. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  74130. */
  74131. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  74132. /**
  74133. * Gets the position in front of the camera at a given distance.
  74134. * @param distance The distance from the camera we want the position to be
  74135. * @returns the position
  74136. */
  74137. getFrontPosition(distance: number): Vector3;
  74138. /** @hidden */
  74139. _getLockedTargetPosition(): Nullable<Vector3>;
  74140. private _storedPosition;
  74141. private _storedRotation;
  74142. private _storedRotationQuaternion;
  74143. /**
  74144. * Store current camera state of the camera (fov, position, rotation, etc..)
  74145. * @returns the camera
  74146. */
  74147. storeState(): Camera;
  74148. /**
  74149. * Restored camera state. You must call storeState() first
  74150. * @returns whether it was successful or not
  74151. * @hidden
  74152. */
  74153. _restoreStateValues(): boolean;
  74154. /** @hidden */
  74155. _initCache(): void;
  74156. /** @hidden */
  74157. _updateCache(ignoreParentClass?: boolean): void;
  74158. /** @hidden */
  74159. _isSynchronizedViewMatrix(): boolean;
  74160. /** @hidden */
  74161. _computeLocalCameraSpeed(): number;
  74162. /**
  74163. * Defines the target the camera should look at.
  74164. * @param target Defines the new target as a Vector or a mesh
  74165. */
  74166. setTarget(target: Vector3): void;
  74167. /**
  74168. * Return the current target position of the camera. This value is expressed in local space.
  74169. * @returns the target position
  74170. */
  74171. getTarget(): Vector3;
  74172. /** @hidden */
  74173. _decideIfNeedsToMove(): boolean;
  74174. /** @hidden */
  74175. _updatePosition(): void;
  74176. /** @hidden */
  74177. _checkInputs(): void;
  74178. protected _updateCameraRotationMatrix(): void;
  74179. /**
  74180. * 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)
  74181. * @returns the current camera
  74182. */
  74183. private _rotateUpVectorWithCameraRotationMatrix;
  74184. private _cachedRotationZ;
  74185. private _cachedQuaternionRotationZ;
  74186. /** @hidden */
  74187. _getViewMatrix(): Matrix;
  74188. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  74189. /**
  74190. * @hidden
  74191. */
  74192. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  74193. /**
  74194. * @hidden
  74195. */
  74196. _updateRigCameras(): void;
  74197. private _getRigCamPositionAndTarget;
  74198. /**
  74199. * Gets the current object class name.
  74200. * @return the class name
  74201. */
  74202. getClassName(): string;
  74203. }
  74204. }
  74205. declare module BABYLON {
  74206. /**
  74207. * Gather the list of keyboard event types as constants.
  74208. */
  74209. export class KeyboardEventTypes {
  74210. /**
  74211. * The keydown event is fired when a key becomes active (pressed).
  74212. */
  74213. static readonly KEYDOWN: number;
  74214. /**
  74215. * The keyup event is fired when a key has been released.
  74216. */
  74217. static readonly KEYUP: number;
  74218. }
  74219. /**
  74220. * This class is used to store keyboard related info for the onKeyboardObservable event.
  74221. */
  74222. export class KeyboardInfo {
  74223. /**
  74224. * Defines the type of event (KeyboardEventTypes)
  74225. */
  74226. type: number;
  74227. /**
  74228. * Defines the related dom event
  74229. */
  74230. event: KeyboardEvent;
  74231. /**
  74232. * Instantiates a new keyboard info.
  74233. * This class is used to store keyboard related info for the onKeyboardObservable event.
  74234. * @param type Defines the type of event (KeyboardEventTypes)
  74235. * @param event Defines the related dom event
  74236. */
  74237. constructor(
  74238. /**
  74239. * Defines the type of event (KeyboardEventTypes)
  74240. */
  74241. type: number,
  74242. /**
  74243. * Defines the related dom event
  74244. */
  74245. event: KeyboardEvent);
  74246. }
  74247. /**
  74248. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  74249. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  74250. */
  74251. export class KeyboardInfoPre extends KeyboardInfo {
  74252. /**
  74253. * Defines the type of event (KeyboardEventTypes)
  74254. */
  74255. type: number;
  74256. /**
  74257. * Defines the related dom event
  74258. */
  74259. event: KeyboardEvent;
  74260. /**
  74261. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  74262. */
  74263. skipOnPointerObservable: boolean;
  74264. /**
  74265. * Instantiates a new keyboard pre info.
  74266. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  74267. * @param type Defines the type of event (KeyboardEventTypes)
  74268. * @param event Defines the related dom event
  74269. */
  74270. constructor(
  74271. /**
  74272. * Defines the type of event (KeyboardEventTypes)
  74273. */
  74274. type: number,
  74275. /**
  74276. * Defines the related dom event
  74277. */
  74278. event: KeyboardEvent);
  74279. }
  74280. }
  74281. declare module BABYLON {
  74282. /**
  74283. * Manage the keyboard inputs to control the movement of a free camera.
  74284. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74285. */
  74286. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  74287. /**
  74288. * Defines the camera the input is attached to.
  74289. */
  74290. camera: FreeCamera;
  74291. /**
  74292. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  74293. */
  74294. keysUp: number[];
  74295. /**
  74296. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  74297. */
  74298. keysDown: number[];
  74299. /**
  74300. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  74301. */
  74302. keysLeft: number[];
  74303. /**
  74304. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  74305. */
  74306. keysRight: number[];
  74307. private _keys;
  74308. private _onCanvasBlurObserver;
  74309. private _onKeyboardObserver;
  74310. private _engine;
  74311. private _scene;
  74312. /**
  74313. * Attach the input controls to a specific dom element to get the input from.
  74314. * @param element Defines the element the controls should be listened from
  74315. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74316. */
  74317. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  74318. /**
  74319. * Detach the current controls from the specified dom element.
  74320. * @param element Defines the element to stop listening the inputs from
  74321. */
  74322. detachControl(element: Nullable<HTMLElement>): void;
  74323. /**
  74324. * Update the current camera state depending on the inputs that have been used this frame.
  74325. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  74326. */
  74327. checkInputs(): void;
  74328. /**
  74329. * Gets the class name of the current intput.
  74330. * @returns the class name
  74331. */
  74332. getClassName(): string;
  74333. /** @hidden */
  74334. _onLostFocus(): void;
  74335. /**
  74336. * Get the friendly name associated with the input class.
  74337. * @returns the input friendly name
  74338. */
  74339. getSimpleName(): string;
  74340. }
  74341. }
  74342. declare module BABYLON {
  74343. /**
  74344. * Interface describing all the common properties and methods a shadow light needs to implement.
  74345. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  74346. * as well as binding the different shadow properties to the effects.
  74347. */
  74348. export interface IShadowLight extends Light {
  74349. /**
  74350. * The light id in the scene (used in scene.findLighById for instance)
  74351. */
  74352. id: string;
  74353. /**
  74354. * The position the shdow will be casted from.
  74355. */
  74356. position: Vector3;
  74357. /**
  74358. * In 2d mode (needCube being false), the direction used to cast the shadow.
  74359. */
  74360. direction: Vector3;
  74361. /**
  74362. * The transformed position. Position of the light in world space taking parenting in account.
  74363. */
  74364. transformedPosition: Vector3;
  74365. /**
  74366. * The transformed direction. Direction of the light in world space taking parenting in account.
  74367. */
  74368. transformedDirection: Vector3;
  74369. /**
  74370. * The friendly name of the light in the scene.
  74371. */
  74372. name: string;
  74373. /**
  74374. * Defines the shadow projection clipping minimum z value.
  74375. */
  74376. shadowMinZ: number;
  74377. /**
  74378. * Defines the shadow projection clipping maximum z value.
  74379. */
  74380. shadowMaxZ: number;
  74381. /**
  74382. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  74383. * @returns true if the information has been computed, false if it does not need to (no parenting)
  74384. */
  74385. computeTransformedInformation(): boolean;
  74386. /**
  74387. * Gets the scene the light belongs to.
  74388. * @returns The scene
  74389. */
  74390. getScene(): Scene;
  74391. /**
  74392. * Callback defining a custom Projection Matrix Builder.
  74393. * This can be used to override the default projection matrix computation.
  74394. */
  74395. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  74396. /**
  74397. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  74398. * @param matrix The materix to updated with the projection information
  74399. * @param viewMatrix The transform matrix of the light
  74400. * @param renderList The list of mesh to render in the map
  74401. * @returns The current light
  74402. */
  74403. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  74404. /**
  74405. * Gets the current depth scale used in ESM.
  74406. * @returns The scale
  74407. */
  74408. getDepthScale(): number;
  74409. /**
  74410. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  74411. * @returns true if a cube texture needs to be use
  74412. */
  74413. needCube(): boolean;
  74414. /**
  74415. * Detects if the projection matrix requires to be recomputed this frame.
  74416. * @returns true if it requires to be recomputed otherwise, false.
  74417. */
  74418. needProjectionMatrixCompute(): boolean;
  74419. /**
  74420. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  74421. */
  74422. forceProjectionMatrixCompute(): void;
  74423. /**
  74424. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  74425. * @param faceIndex The index of the face we are computed the direction to generate shadow
  74426. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  74427. */
  74428. getShadowDirection(faceIndex?: number): Vector3;
  74429. /**
  74430. * Gets the minZ used for shadow according to both the scene and the light.
  74431. * @param activeCamera The camera we are returning the min for
  74432. * @returns the depth min z
  74433. */
  74434. getDepthMinZ(activeCamera: Camera): number;
  74435. /**
  74436. * Gets the maxZ used for shadow according to both the scene and the light.
  74437. * @param activeCamera The camera we are returning the max for
  74438. * @returns the depth max z
  74439. */
  74440. getDepthMaxZ(activeCamera: Camera): number;
  74441. }
  74442. /**
  74443. * Base implementation IShadowLight
  74444. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  74445. */
  74446. export abstract class ShadowLight extends Light implements IShadowLight {
  74447. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  74448. protected _position: Vector3;
  74449. protected _setPosition(value: Vector3): void;
  74450. /**
  74451. * Sets the position the shadow will be casted from. Also use as the light position for both
  74452. * point and spot lights.
  74453. */
  74454. /**
  74455. * Sets the position the shadow will be casted from. Also use as the light position for both
  74456. * point and spot lights.
  74457. */
  74458. position: Vector3;
  74459. protected _direction: Vector3;
  74460. protected _setDirection(value: Vector3): void;
  74461. /**
  74462. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  74463. * Also use as the light direction on spot and directional lights.
  74464. */
  74465. /**
  74466. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  74467. * Also use as the light direction on spot and directional lights.
  74468. */
  74469. direction: Vector3;
  74470. private _shadowMinZ;
  74471. /**
  74472. * Gets the shadow projection clipping minimum z value.
  74473. */
  74474. /**
  74475. * Sets the shadow projection clipping minimum z value.
  74476. */
  74477. shadowMinZ: number;
  74478. private _shadowMaxZ;
  74479. /**
  74480. * Sets the shadow projection clipping maximum z value.
  74481. */
  74482. /**
  74483. * Gets the shadow projection clipping maximum z value.
  74484. */
  74485. shadowMaxZ: number;
  74486. /**
  74487. * Callback defining a custom Projection Matrix Builder.
  74488. * This can be used to override the default projection matrix computation.
  74489. */
  74490. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  74491. /**
  74492. * The transformed position. Position of the light in world space taking parenting in account.
  74493. */
  74494. transformedPosition: Vector3;
  74495. /**
  74496. * The transformed direction. Direction of the light in world space taking parenting in account.
  74497. */
  74498. transformedDirection: Vector3;
  74499. private _needProjectionMatrixCompute;
  74500. /**
  74501. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  74502. * @returns true if the information has been computed, false if it does not need to (no parenting)
  74503. */
  74504. computeTransformedInformation(): boolean;
  74505. /**
  74506. * Return the depth scale used for the shadow map.
  74507. * @returns the depth scale.
  74508. */
  74509. getDepthScale(): number;
  74510. /**
  74511. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  74512. * @param faceIndex The index of the face we are computed the direction to generate shadow
  74513. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  74514. */
  74515. getShadowDirection(faceIndex?: number): Vector3;
  74516. /**
  74517. * Returns the ShadowLight absolute position in the World.
  74518. * @returns the position vector in world space
  74519. */
  74520. getAbsolutePosition(): Vector3;
  74521. /**
  74522. * Sets the ShadowLight direction toward the passed target.
  74523. * @param target The point to target in local space
  74524. * @returns the updated ShadowLight direction
  74525. */
  74526. setDirectionToTarget(target: Vector3): Vector3;
  74527. /**
  74528. * Returns the light rotation in euler definition.
  74529. * @returns the x y z rotation in local space.
  74530. */
  74531. getRotation(): Vector3;
  74532. /**
  74533. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  74534. * @returns true if a cube texture needs to be use
  74535. */
  74536. needCube(): boolean;
  74537. /**
  74538. * Detects if the projection matrix requires to be recomputed this frame.
  74539. * @returns true if it requires to be recomputed otherwise, false.
  74540. */
  74541. needProjectionMatrixCompute(): boolean;
  74542. /**
  74543. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  74544. */
  74545. forceProjectionMatrixCompute(): void;
  74546. /** @hidden */
  74547. _initCache(): void;
  74548. /** @hidden */
  74549. _isSynchronized(): boolean;
  74550. /**
  74551. * Computes the world matrix of the node
  74552. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  74553. * @returns the world matrix
  74554. */
  74555. computeWorldMatrix(force?: boolean): Matrix;
  74556. /**
  74557. * Gets the minZ used for shadow according to both the scene and the light.
  74558. * @param activeCamera The camera we are returning the min for
  74559. * @returns the depth min z
  74560. */
  74561. getDepthMinZ(activeCamera: Camera): number;
  74562. /**
  74563. * Gets the maxZ used for shadow according to both the scene and the light.
  74564. * @param activeCamera The camera we are returning the max for
  74565. * @returns the depth max z
  74566. */
  74567. getDepthMaxZ(activeCamera: Camera): number;
  74568. /**
  74569. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  74570. * @param matrix The materix to updated with the projection information
  74571. * @param viewMatrix The transform matrix of the light
  74572. * @param renderList The list of mesh to render in the map
  74573. * @returns The current light
  74574. */
  74575. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  74576. }
  74577. }
  74578. declare module BABYLON {
  74579. /**
  74580. * "Static Class" containing the most commonly used helper while dealing with material for
  74581. * rendering purpose.
  74582. *
  74583. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  74584. *
  74585. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  74586. */
  74587. export class MaterialHelper {
  74588. /**
  74589. * Bind the current view position to an effect.
  74590. * @param effect The effect to be bound
  74591. * @param scene The scene the eyes position is used from
  74592. */
  74593. static BindEyePosition(effect: Effect, scene: Scene): void;
  74594. /**
  74595. * Helps preparing the defines values about the UVs in used in the effect.
  74596. * UVs are shared as much as we can accross channels in the shaders.
  74597. * @param texture The texture we are preparing the UVs for
  74598. * @param defines The defines to update
  74599. * @param key The channel key "diffuse", "specular"... used in the shader
  74600. */
  74601. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  74602. /**
  74603. * Binds a texture matrix value to its corrsponding uniform
  74604. * @param texture The texture to bind the matrix for
  74605. * @param uniformBuffer The uniform buffer receivin the data
  74606. * @param key The channel key "diffuse", "specular"... used in the shader
  74607. */
  74608. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  74609. /**
  74610. * Gets the current status of the fog (should it be enabled?)
  74611. * @param mesh defines the mesh to evaluate for fog support
  74612. * @param scene defines the hosting scene
  74613. * @returns true if fog must be enabled
  74614. */
  74615. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  74616. /**
  74617. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  74618. * @param mesh defines the current mesh
  74619. * @param scene defines the current scene
  74620. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  74621. * @param pointsCloud defines if point cloud rendering has to be turned on
  74622. * @param fogEnabled defines if fog has to be turned on
  74623. * @param alphaTest defines if alpha testing has to be turned on
  74624. * @param defines defines the current list of defines
  74625. */
  74626. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  74627. /**
  74628. * Helper used to prepare the list of defines associated with frame values for shader compilation
  74629. * @param scene defines the current scene
  74630. * @param engine defines the current engine
  74631. * @param defines specifies the list of active defines
  74632. * @param useInstances defines if instances have to be turned on
  74633. * @param useClipPlane defines if clip plane have to be turned on
  74634. */
  74635. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  74636. /**
  74637. * Prepares the defines for bones
  74638. * @param mesh The mesh containing the geometry data we will draw
  74639. * @param defines The defines to update
  74640. */
  74641. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  74642. /**
  74643. * Prepares the defines for morph targets
  74644. * @param mesh The mesh containing the geometry data we will draw
  74645. * @param defines The defines to update
  74646. */
  74647. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  74648. /**
  74649. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  74650. * @param mesh The mesh containing the geometry data we will draw
  74651. * @param defines The defines to update
  74652. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  74653. * @param useBones Precise whether bones should be used or not (override mesh info)
  74654. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  74655. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  74656. * @returns false if defines are considered not dirty and have not been checked
  74657. */
  74658. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  74659. /**
  74660. * Prepares the defines related to multiview
  74661. * @param scene The scene we are intending to draw
  74662. * @param defines The defines to update
  74663. */
  74664. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  74665. /**
  74666. * Prepares the defines related to the light information passed in parameter
  74667. * @param scene The scene we are intending to draw
  74668. * @param mesh The mesh the effect is compiling for
  74669. * @param light The light the effect is compiling for
  74670. * @param lightIndex The index of the light
  74671. * @param defines The defines to update
  74672. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  74673. * @param state Defines the current state regarding what is needed (normals, etc...)
  74674. */
  74675. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  74676. needNormals: boolean;
  74677. needRebuild: boolean;
  74678. shadowEnabled: boolean;
  74679. specularEnabled: boolean;
  74680. lightmapMode: boolean;
  74681. }): void;
  74682. /**
  74683. * Prepares the defines related to the light information passed in parameter
  74684. * @param scene The scene we are intending to draw
  74685. * @param mesh The mesh the effect is compiling for
  74686. * @param defines The defines to update
  74687. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  74688. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  74689. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  74690. * @returns true if normals will be required for the rest of the effect
  74691. */
  74692. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  74693. /**
  74694. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  74695. * @param lightIndex defines the light index
  74696. * @param uniformsList The uniform list
  74697. * @param samplersList The sampler list
  74698. * @param projectedLightTexture defines if projected texture must be used
  74699. * @param uniformBuffersList defines an optional list of uniform buffers
  74700. */
  74701. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  74702. /**
  74703. * Prepares the uniforms and samplers list to be used in the effect
  74704. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  74705. * @param samplersList The sampler list
  74706. * @param defines The defines helping in the list generation
  74707. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  74708. */
  74709. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  74710. /**
  74711. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  74712. * @param defines The defines to update while falling back
  74713. * @param fallbacks The authorized effect fallbacks
  74714. * @param maxSimultaneousLights The maximum number of lights allowed
  74715. * @param rank the current rank of the Effect
  74716. * @returns The newly affected rank
  74717. */
  74718. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  74719. private static _TmpMorphInfluencers;
  74720. /**
  74721. * Prepares the list of attributes required for morph targets according to the effect defines.
  74722. * @param attribs The current list of supported attribs
  74723. * @param mesh The mesh to prepare the morph targets attributes for
  74724. * @param influencers The number of influencers
  74725. */
  74726. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  74727. /**
  74728. * Prepares the list of attributes required for morph targets according to the effect defines.
  74729. * @param attribs The current list of supported attribs
  74730. * @param mesh The mesh to prepare the morph targets attributes for
  74731. * @param defines The current Defines of the effect
  74732. */
  74733. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  74734. /**
  74735. * Prepares the list of attributes required for bones according to the effect defines.
  74736. * @param attribs The current list of supported attribs
  74737. * @param mesh The mesh to prepare the bones attributes for
  74738. * @param defines The current Defines of the effect
  74739. * @param fallbacks The current efffect fallback strategy
  74740. */
  74741. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  74742. /**
  74743. * Check and prepare the list of attributes required for instances according to the effect defines.
  74744. * @param attribs The current list of supported attribs
  74745. * @param defines The current MaterialDefines of the effect
  74746. */
  74747. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  74748. /**
  74749. * Add the list of attributes required for instances to the attribs array.
  74750. * @param attribs The current list of supported attribs
  74751. */
  74752. static PushAttributesForInstances(attribs: string[]): void;
  74753. /**
  74754. * Binds the light shadow information to the effect for the given mesh.
  74755. * @param light The light containing the generator
  74756. * @param scene The scene the lights belongs to
  74757. * @param mesh The mesh we are binding the information to render
  74758. * @param lightIndex The light index in the effect used to render the mesh
  74759. * @param effect The effect we are binding the data to
  74760. */
  74761. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  74762. /**
  74763. * Binds the light information to the effect.
  74764. * @param light The light containing the generator
  74765. * @param effect The effect we are binding the data to
  74766. * @param lightIndex The light index in the effect used to render
  74767. */
  74768. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  74769. /**
  74770. * Binds the lights information from the scene to the effect for the given mesh.
  74771. * @param light Light to bind
  74772. * @param lightIndex Light index
  74773. * @param scene The scene where the light belongs to
  74774. * @param mesh The mesh we are binding the information to render
  74775. * @param effect The effect we are binding the data to
  74776. * @param useSpecular Defines if specular is supported
  74777. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  74778. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  74779. */
  74780. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  74781. /**
  74782. * Binds the lights information from the scene to the effect for the given mesh.
  74783. * @param scene The scene the lights belongs to
  74784. * @param mesh The mesh we are binding the information to render
  74785. * @param effect The effect we are binding the data to
  74786. * @param defines The generated defines for the effect
  74787. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  74788. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  74789. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  74790. */
  74791. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  74792. private static _tempFogColor;
  74793. /**
  74794. * Binds the fog information from the scene to the effect for the given mesh.
  74795. * @param scene The scene the lights belongs to
  74796. * @param mesh The mesh we are binding the information to render
  74797. * @param effect The effect we are binding the data to
  74798. * @param linearSpace Defines if the fog effect is applied in linear space
  74799. */
  74800. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  74801. /**
  74802. * Binds the bones information from the mesh to the effect.
  74803. * @param mesh The mesh we are binding the information to render
  74804. * @param effect The effect we are binding the data to
  74805. */
  74806. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  74807. /**
  74808. * Binds the morph targets information from the mesh to the effect.
  74809. * @param abstractMesh The mesh we are binding the information to render
  74810. * @param effect The effect we are binding the data to
  74811. */
  74812. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  74813. /**
  74814. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  74815. * @param defines The generated defines used in the effect
  74816. * @param effect The effect we are binding the data to
  74817. * @param scene The scene we are willing to render with logarithmic scale for
  74818. */
  74819. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  74820. /**
  74821. * Binds the clip plane information from the scene to the effect.
  74822. * @param scene The scene the clip plane information are extracted from
  74823. * @param effect The effect we are binding the data to
  74824. */
  74825. static BindClipPlane(effect: Effect, scene: Scene): void;
  74826. }
  74827. }
  74828. declare module BABYLON {
  74829. /** @hidden */
  74830. export var packingFunctions: {
  74831. name: string;
  74832. shader: string;
  74833. };
  74834. }
  74835. declare module BABYLON {
  74836. /** @hidden */
  74837. export var shadowMapPixelShader: {
  74838. name: string;
  74839. shader: string;
  74840. };
  74841. }
  74842. declare module BABYLON {
  74843. /** @hidden */
  74844. export var bonesDeclaration: {
  74845. name: string;
  74846. shader: string;
  74847. };
  74848. }
  74849. declare module BABYLON {
  74850. /** @hidden */
  74851. export var morphTargetsVertexGlobalDeclaration: {
  74852. name: string;
  74853. shader: string;
  74854. };
  74855. }
  74856. declare module BABYLON {
  74857. /** @hidden */
  74858. export var morphTargetsVertexDeclaration: {
  74859. name: string;
  74860. shader: string;
  74861. };
  74862. }
  74863. declare module BABYLON {
  74864. /** @hidden */
  74865. export var instancesDeclaration: {
  74866. name: string;
  74867. shader: string;
  74868. };
  74869. }
  74870. declare module BABYLON {
  74871. /** @hidden */
  74872. export var helperFunctions: {
  74873. name: string;
  74874. shader: string;
  74875. };
  74876. }
  74877. declare module BABYLON {
  74878. /** @hidden */
  74879. export var morphTargetsVertex: {
  74880. name: string;
  74881. shader: string;
  74882. };
  74883. }
  74884. declare module BABYLON {
  74885. /** @hidden */
  74886. export var instancesVertex: {
  74887. name: string;
  74888. shader: string;
  74889. };
  74890. }
  74891. declare module BABYLON {
  74892. /** @hidden */
  74893. export var bonesVertex: {
  74894. name: string;
  74895. shader: string;
  74896. };
  74897. }
  74898. declare module BABYLON {
  74899. /** @hidden */
  74900. export var shadowMapVertexShader: {
  74901. name: string;
  74902. shader: string;
  74903. };
  74904. }
  74905. declare module BABYLON {
  74906. /** @hidden */
  74907. export var depthBoxBlurPixelShader: {
  74908. name: string;
  74909. shader: string;
  74910. };
  74911. }
  74912. declare module BABYLON {
  74913. /**
  74914. * Defines the options associated with the creation of a custom shader for a shadow generator.
  74915. */
  74916. export interface ICustomShaderOptions {
  74917. /**
  74918. * Gets or sets the custom shader name to use
  74919. */
  74920. shaderName: string;
  74921. /**
  74922. * The list of attribute names used in the shader
  74923. */
  74924. attributes?: string[];
  74925. /**
  74926. * The list of unifrom names used in the shader
  74927. */
  74928. uniforms?: string[];
  74929. /**
  74930. * The list of sampler names used in the shader
  74931. */
  74932. samplers?: string[];
  74933. /**
  74934. * The list of defines used in the shader
  74935. */
  74936. defines?: string[];
  74937. }
  74938. /**
  74939. * Interface to implement to create a shadow generator compatible with BJS.
  74940. */
  74941. export interface IShadowGenerator {
  74942. /**
  74943. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  74944. * @returns The render target texture if present otherwise, null
  74945. */
  74946. getShadowMap(): Nullable<RenderTargetTexture>;
  74947. /**
  74948. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  74949. * @returns The render target texture if the shadow map is present otherwise, null
  74950. */
  74951. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  74952. /**
  74953. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  74954. * @param subMesh The submesh we want to render in the shadow map
  74955. * @param useInstances Defines wether will draw in the map using instances
  74956. * @returns true if ready otherwise, false
  74957. */
  74958. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  74959. /**
  74960. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  74961. * @param defines Defines of the material we want to update
  74962. * @param lightIndex Index of the light in the enabled light list of the material
  74963. */
  74964. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  74965. /**
  74966. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  74967. * defined in the generator but impacting the effect).
  74968. * It implies the unifroms available on the materials are the standard BJS ones.
  74969. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  74970. * @param effect The effect we are binfing the information for
  74971. */
  74972. bindShadowLight(lightIndex: string, effect: Effect): void;
  74973. /**
  74974. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  74975. * (eq to shadow prjection matrix * light transform matrix)
  74976. * @returns The transform matrix used to create the shadow map
  74977. */
  74978. getTransformMatrix(): Matrix;
  74979. /**
  74980. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  74981. * Cube and 2D textures for instance.
  74982. */
  74983. recreateShadowMap(): void;
  74984. /**
  74985. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74986. * @param onCompiled Callback triggered at the and of the effects compilation
  74987. * @param options Sets of optional options forcing the compilation with different modes
  74988. */
  74989. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  74990. useInstances: boolean;
  74991. }>): void;
  74992. /**
  74993. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74994. * @param options Sets of optional options forcing the compilation with different modes
  74995. * @returns A promise that resolves when the compilation completes
  74996. */
  74997. forceCompilationAsync(options?: Partial<{
  74998. useInstances: boolean;
  74999. }>): Promise<void>;
  75000. /**
  75001. * Serializes the shadow generator setup to a json object.
  75002. * @returns The serialized JSON object
  75003. */
  75004. serialize(): any;
  75005. /**
  75006. * Disposes the Shadow map and related Textures and effects.
  75007. */
  75008. dispose(): void;
  75009. }
  75010. /**
  75011. * Default implementation IShadowGenerator.
  75012. * This is the main object responsible of generating shadows in the framework.
  75013. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  75014. */
  75015. export class ShadowGenerator implements IShadowGenerator {
  75016. /**
  75017. * Shadow generator mode None: no filtering applied.
  75018. */
  75019. static readonly FILTER_NONE: number;
  75020. /**
  75021. * Shadow generator mode ESM: Exponential Shadow Mapping.
  75022. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  75023. */
  75024. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  75025. /**
  75026. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  75027. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  75028. */
  75029. static readonly FILTER_POISSONSAMPLING: number;
  75030. /**
  75031. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  75032. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  75033. */
  75034. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  75035. /**
  75036. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  75037. * edge artifacts on steep falloff.
  75038. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  75039. */
  75040. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  75041. /**
  75042. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  75043. * edge artifacts on steep falloff.
  75044. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  75045. */
  75046. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  75047. /**
  75048. * Shadow generator mode PCF: Percentage Closer Filtering
  75049. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  75050. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  75051. */
  75052. static readonly FILTER_PCF: number;
  75053. /**
  75054. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  75055. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  75056. * Contact Hardening
  75057. */
  75058. static readonly FILTER_PCSS: number;
  75059. /**
  75060. * Reserved for PCF and PCSS
  75061. * Highest Quality.
  75062. *
  75063. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  75064. *
  75065. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  75066. */
  75067. static readonly QUALITY_HIGH: number;
  75068. /**
  75069. * Reserved for PCF and PCSS
  75070. * Good tradeoff for quality/perf cross devices
  75071. *
  75072. * Execute PCF on a 3*3 kernel.
  75073. *
  75074. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  75075. */
  75076. static readonly QUALITY_MEDIUM: number;
  75077. /**
  75078. * Reserved for PCF and PCSS
  75079. * The lowest quality but the fastest.
  75080. *
  75081. * Execute PCF on a 1*1 kernel.
  75082. *
  75083. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  75084. */
  75085. static readonly QUALITY_LOW: number;
  75086. /** Gets or sets the custom shader name to use */
  75087. customShaderOptions: ICustomShaderOptions;
  75088. /**
  75089. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  75090. */
  75091. onBeforeShadowMapRenderObservable: Observable<Effect>;
  75092. /**
  75093. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  75094. */
  75095. onAfterShadowMapRenderObservable: Observable<Effect>;
  75096. /**
  75097. * Observable triggered before a mesh is rendered in the shadow map.
  75098. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  75099. */
  75100. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  75101. /**
  75102. * Observable triggered after a mesh is rendered in the shadow map.
  75103. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  75104. */
  75105. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  75106. private _bias;
  75107. /**
  75108. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  75109. */
  75110. /**
  75111. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  75112. */
  75113. bias: number;
  75114. private _normalBias;
  75115. /**
  75116. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  75117. */
  75118. /**
  75119. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  75120. */
  75121. normalBias: number;
  75122. private _blurBoxOffset;
  75123. /**
  75124. * Gets the blur box offset: offset applied during the blur pass.
  75125. * Only useful if useKernelBlur = false
  75126. */
  75127. /**
  75128. * Sets the blur box offset: offset applied during the blur pass.
  75129. * Only useful if useKernelBlur = false
  75130. */
  75131. blurBoxOffset: number;
  75132. private _blurScale;
  75133. /**
  75134. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  75135. * 2 means half of the size.
  75136. */
  75137. /**
  75138. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  75139. * 2 means half of the size.
  75140. */
  75141. blurScale: number;
  75142. private _blurKernel;
  75143. /**
  75144. * Gets the blur kernel: kernel size of the blur pass.
  75145. * Only useful if useKernelBlur = true
  75146. */
  75147. /**
  75148. * Sets the blur kernel: kernel size of the blur pass.
  75149. * Only useful if useKernelBlur = true
  75150. */
  75151. blurKernel: number;
  75152. private _useKernelBlur;
  75153. /**
  75154. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  75155. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  75156. */
  75157. /**
  75158. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  75159. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  75160. */
  75161. useKernelBlur: boolean;
  75162. private _depthScale;
  75163. /**
  75164. * Gets the depth scale used in ESM mode.
  75165. */
  75166. /**
  75167. * Sets the depth scale used in ESM mode.
  75168. * This can override the scale stored on the light.
  75169. */
  75170. depthScale: number;
  75171. private _filter;
  75172. /**
  75173. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  75174. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  75175. */
  75176. /**
  75177. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  75178. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  75179. */
  75180. filter: number;
  75181. /**
  75182. * Gets if the current filter is set to Poisson Sampling.
  75183. */
  75184. /**
  75185. * Sets the current filter to Poisson Sampling.
  75186. */
  75187. usePoissonSampling: boolean;
  75188. /**
  75189. * Gets if the current filter is set to ESM.
  75190. */
  75191. /**
  75192. * Sets the current filter is to ESM.
  75193. */
  75194. useExponentialShadowMap: boolean;
  75195. /**
  75196. * Gets if the current filter is set to filtered ESM.
  75197. */
  75198. /**
  75199. * Gets if the current filter is set to filtered ESM.
  75200. */
  75201. useBlurExponentialShadowMap: boolean;
  75202. /**
  75203. * Gets if the current filter is set to "close ESM" (using the inverse of the
  75204. * exponential to prevent steep falloff artifacts).
  75205. */
  75206. /**
  75207. * Sets the current filter to "close ESM" (using the inverse of the
  75208. * exponential to prevent steep falloff artifacts).
  75209. */
  75210. useCloseExponentialShadowMap: boolean;
  75211. /**
  75212. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  75213. * exponential to prevent steep falloff artifacts).
  75214. */
  75215. /**
  75216. * Sets the current filter to filtered "close ESM" (using the inverse of the
  75217. * exponential to prevent steep falloff artifacts).
  75218. */
  75219. useBlurCloseExponentialShadowMap: boolean;
  75220. /**
  75221. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  75222. */
  75223. /**
  75224. * Sets the current filter to "PCF" (percentage closer filtering).
  75225. */
  75226. usePercentageCloserFiltering: boolean;
  75227. private _filteringQuality;
  75228. /**
  75229. * Gets the PCF or PCSS Quality.
  75230. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  75231. */
  75232. /**
  75233. * Sets the PCF or PCSS Quality.
  75234. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  75235. */
  75236. filteringQuality: number;
  75237. /**
  75238. * Gets if the current filter is set to "PCSS" (contact hardening).
  75239. */
  75240. /**
  75241. * Sets the current filter to "PCSS" (contact hardening).
  75242. */
  75243. useContactHardeningShadow: boolean;
  75244. private _contactHardeningLightSizeUVRatio;
  75245. /**
  75246. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  75247. * Using a ratio helps keeping shape stability independently of the map size.
  75248. *
  75249. * It does not account for the light projection as it was having too much
  75250. * instability during the light setup or during light position changes.
  75251. *
  75252. * Only valid if useContactHardeningShadow is true.
  75253. */
  75254. /**
  75255. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  75256. * Using a ratio helps keeping shape stability independently of the map size.
  75257. *
  75258. * It does not account for the light projection as it was having too much
  75259. * instability during the light setup or during light position changes.
  75260. *
  75261. * Only valid if useContactHardeningShadow is true.
  75262. */
  75263. contactHardeningLightSizeUVRatio: number;
  75264. private _darkness;
  75265. /** Gets or sets the actual darkness of a shadow */
  75266. darkness: number;
  75267. /**
  75268. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  75269. * 0 means strongest and 1 would means no shadow.
  75270. * @returns the darkness.
  75271. */
  75272. getDarkness(): number;
  75273. /**
  75274. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  75275. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  75276. * @returns the shadow generator allowing fluent coding.
  75277. */
  75278. setDarkness(darkness: number): ShadowGenerator;
  75279. private _transparencyShadow;
  75280. /** Gets or sets the ability to have transparent shadow */
  75281. transparencyShadow: boolean;
  75282. /**
  75283. * Sets the ability to have transparent shadow (boolean).
  75284. * @param transparent True if transparent else False
  75285. * @returns the shadow generator allowing fluent coding
  75286. */
  75287. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  75288. private _shadowMap;
  75289. private _shadowMap2;
  75290. /**
  75291. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  75292. * @returns The render target texture if present otherwise, null
  75293. */
  75294. getShadowMap(): Nullable<RenderTargetTexture>;
  75295. /**
  75296. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  75297. * @returns The render target texture if the shadow map is present otherwise, null
  75298. */
  75299. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  75300. /**
  75301. * Gets the class name of that object
  75302. * @returns "ShadowGenerator"
  75303. */
  75304. getClassName(): string;
  75305. /**
  75306. * Helper function to add a mesh and its descendants to the list of shadow casters.
  75307. * @param mesh Mesh to add
  75308. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  75309. * @returns the Shadow Generator itself
  75310. */
  75311. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  75312. /**
  75313. * Helper function to remove a mesh and its descendants from the list of shadow casters
  75314. * @param mesh Mesh to remove
  75315. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  75316. * @returns the Shadow Generator itself
  75317. */
  75318. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  75319. /**
  75320. * Controls the extent to which the shadows fade out at the edge of the frustum
  75321. * Used only by directionals and spots
  75322. */
  75323. frustumEdgeFalloff: number;
  75324. private _light;
  75325. /**
  75326. * Returns the associated light object.
  75327. * @returns the light generating the shadow
  75328. */
  75329. getLight(): IShadowLight;
  75330. /**
  75331. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  75332. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  75333. * It might on the other hand introduce peter panning.
  75334. */
  75335. forceBackFacesOnly: boolean;
  75336. private _scene;
  75337. private _lightDirection;
  75338. private _effect;
  75339. private _viewMatrix;
  75340. private _projectionMatrix;
  75341. private _transformMatrix;
  75342. private _cachedPosition;
  75343. private _cachedDirection;
  75344. private _cachedDefines;
  75345. private _currentRenderID;
  75346. private _boxBlurPostprocess;
  75347. private _kernelBlurXPostprocess;
  75348. private _kernelBlurYPostprocess;
  75349. private _blurPostProcesses;
  75350. private _mapSize;
  75351. private _currentFaceIndex;
  75352. private _currentFaceIndexCache;
  75353. private _textureType;
  75354. private _defaultTextureMatrix;
  75355. /** @hidden */
  75356. static _SceneComponentInitialization: (scene: Scene) => void;
  75357. /**
  75358. * Creates a ShadowGenerator object.
  75359. * A ShadowGenerator is the required tool to use the shadows.
  75360. * Each light casting shadows needs to use its own ShadowGenerator.
  75361. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  75362. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  75363. * @param light The light object generating the shadows.
  75364. * @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.
  75365. */
  75366. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  75367. private _initializeGenerator;
  75368. private _initializeShadowMap;
  75369. private _initializeBlurRTTAndPostProcesses;
  75370. private _renderForShadowMap;
  75371. private _renderSubMeshForShadowMap;
  75372. private _applyFilterValues;
  75373. /**
  75374. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  75375. * @param onCompiled Callback triggered at the and of the effects compilation
  75376. * @param options Sets of optional options forcing the compilation with different modes
  75377. */
  75378. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  75379. useInstances: boolean;
  75380. }>): void;
  75381. /**
  75382. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  75383. * @param options Sets of optional options forcing the compilation with different modes
  75384. * @returns A promise that resolves when the compilation completes
  75385. */
  75386. forceCompilationAsync(options?: Partial<{
  75387. useInstances: boolean;
  75388. }>): Promise<void>;
  75389. /**
  75390. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  75391. * @param subMesh The submesh we want to render in the shadow map
  75392. * @param useInstances Defines wether will draw in the map using instances
  75393. * @returns true if ready otherwise, false
  75394. */
  75395. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  75396. /**
  75397. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  75398. * @param defines Defines of the material we want to update
  75399. * @param lightIndex Index of the light in the enabled light list of the material
  75400. */
  75401. prepareDefines(defines: any, lightIndex: number): void;
  75402. /**
  75403. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  75404. * defined in the generator but impacting the effect).
  75405. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  75406. * @param effect The effect we are binfing the information for
  75407. */
  75408. bindShadowLight(lightIndex: string, effect: Effect): void;
  75409. /**
  75410. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  75411. * (eq to shadow prjection matrix * light transform matrix)
  75412. * @returns The transform matrix used to create the shadow map
  75413. */
  75414. getTransformMatrix(): Matrix;
  75415. /**
  75416. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  75417. * Cube and 2D textures for instance.
  75418. */
  75419. recreateShadowMap(): void;
  75420. private _disposeBlurPostProcesses;
  75421. private _disposeRTTandPostProcesses;
  75422. /**
  75423. * Disposes the ShadowGenerator.
  75424. * Returns nothing.
  75425. */
  75426. dispose(): void;
  75427. /**
  75428. * Serializes the shadow generator setup to a json object.
  75429. * @returns The serialized JSON object
  75430. */
  75431. serialize(): any;
  75432. /**
  75433. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  75434. * @param parsedShadowGenerator The JSON object to parse
  75435. * @param scene The scene to create the shadow map for
  75436. * @returns The parsed shadow generator
  75437. */
  75438. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  75439. }
  75440. }
  75441. declare module BABYLON {
  75442. /**
  75443. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  75444. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  75445. * 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.
  75446. */
  75447. export abstract class Light extends Node {
  75448. /**
  75449. * Falloff Default: light is falling off following the material specification:
  75450. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  75451. */
  75452. static readonly FALLOFF_DEFAULT: number;
  75453. /**
  75454. * Falloff Physical: light is falling off following the inverse squared distance law.
  75455. */
  75456. static readonly FALLOFF_PHYSICAL: number;
  75457. /**
  75458. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  75459. * to enhance interoperability with other engines.
  75460. */
  75461. static readonly FALLOFF_GLTF: number;
  75462. /**
  75463. * Falloff Standard: light is falling off like in the standard material
  75464. * to enhance interoperability with other materials.
  75465. */
  75466. static readonly FALLOFF_STANDARD: number;
  75467. /**
  75468. * If every light affecting the material is in this lightmapMode,
  75469. * material.lightmapTexture adds or multiplies
  75470. * (depends on material.useLightmapAsShadowmap)
  75471. * after every other light calculations.
  75472. */
  75473. static readonly LIGHTMAP_DEFAULT: number;
  75474. /**
  75475. * material.lightmapTexture as only diffuse lighting from this light
  75476. * adds only specular lighting from this light
  75477. * adds dynamic shadows
  75478. */
  75479. static readonly LIGHTMAP_SPECULAR: number;
  75480. /**
  75481. * material.lightmapTexture as only lighting
  75482. * no light calculation from this light
  75483. * only adds dynamic shadows from this light
  75484. */
  75485. static readonly LIGHTMAP_SHADOWSONLY: number;
  75486. /**
  75487. * Each light type uses the default quantity according to its type:
  75488. * point/spot lights use luminous intensity
  75489. * directional lights use illuminance
  75490. */
  75491. static readonly INTENSITYMODE_AUTOMATIC: number;
  75492. /**
  75493. * lumen (lm)
  75494. */
  75495. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  75496. /**
  75497. * candela (lm/sr)
  75498. */
  75499. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  75500. /**
  75501. * lux (lm/m^2)
  75502. */
  75503. static readonly INTENSITYMODE_ILLUMINANCE: number;
  75504. /**
  75505. * nit (cd/m^2)
  75506. */
  75507. static readonly INTENSITYMODE_LUMINANCE: number;
  75508. /**
  75509. * Light type const id of the point light.
  75510. */
  75511. static readonly LIGHTTYPEID_POINTLIGHT: number;
  75512. /**
  75513. * Light type const id of the directional light.
  75514. */
  75515. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  75516. /**
  75517. * Light type const id of the spot light.
  75518. */
  75519. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  75520. /**
  75521. * Light type const id of the hemispheric light.
  75522. */
  75523. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  75524. /**
  75525. * Diffuse gives the basic color to an object.
  75526. */
  75527. diffuse: Color3;
  75528. /**
  75529. * Specular produces a highlight color on an object.
  75530. * Note: This is note affecting PBR materials.
  75531. */
  75532. specular: Color3;
  75533. /**
  75534. * Defines the falloff type for this light. This lets overrriding how punctual light are
  75535. * falling off base on range or angle.
  75536. * This can be set to any values in Light.FALLOFF_x.
  75537. *
  75538. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  75539. * other types of materials.
  75540. */
  75541. falloffType: number;
  75542. /**
  75543. * Strength of the light.
  75544. * Note: By default it is define in the framework own unit.
  75545. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  75546. */
  75547. intensity: number;
  75548. private _range;
  75549. protected _inverseSquaredRange: number;
  75550. /**
  75551. * Defines how far from the source the light is impacting in scene units.
  75552. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  75553. */
  75554. /**
  75555. * Defines how far from the source the light is impacting in scene units.
  75556. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  75557. */
  75558. range: number;
  75559. /**
  75560. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  75561. * of light.
  75562. */
  75563. private _photometricScale;
  75564. private _intensityMode;
  75565. /**
  75566. * Gets the photometric scale used to interpret the intensity.
  75567. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  75568. */
  75569. /**
  75570. * Sets the photometric scale used to interpret the intensity.
  75571. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  75572. */
  75573. intensityMode: number;
  75574. private _radius;
  75575. /**
  75576. * Gets the light radius used by PBR Materials to simulate soft area lights.
  75577. */
  75578. /**
  75579. * sets the light radius used by PBR Materials to simulate soft area lights.
  75580. */
  75581. radius: number;
  75582. private _renderPriority;
  75583. /**
  75584. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  75585. * exceeding the number allowed of the materials.
  75586. */
  75587. renderPriority: number;
  75588. private _shadowEnabled;
  75589. /**
  75590. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  75591. * the current shadow generator.
  75592. */
  75593. /**
  75594. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  75595. * the current shadow generator.
  75596. */
  75597. shadowEnabled: boolean;
  75598. private _includedOnlyMeshes;
  75599. /**
  75600. * Gets the only meshes impacted by this light.
  75601. */
  75602. /**
  75603. * Sets the only meshes impacted by this light.
  75604. */
  75605. includedOnlyMeshes: AbstractMesh[];
  75606. private _excludedMeshes;
  75607. /**
  75608. * Gets the meshes not impacted by this light.
  75609. */
  75610. /**
  75611. * Sets the meshes not impacted by this light.
  75612. */
  75613. excludedMeshes: AbstractMesh[];
  75614. private _excludeWithLayerMask;
  75615. /**
  75616. * Gets the layer id use to find what meshes are not impacted by the light.
  75617. * Inactive if 0
  75618. */
  75619. /**
  75620. * Sets the layer id use to find what meshes are not impacted by the light.
  75621. * Inactive if 0
  75622. */
  75623. excludeWithLayerMask: number;
  75624. private _includeOnlyWithLayerMask;
  75625. /**
  75626. * Gets the layer id use to find what meshes are impacted by the light.
  75627. * Inactive if 0
  75628. */
  75629. /**
  75630. * Sets the layer id use to find what meshes are impacted by the light.
  75631. * Inactive if 0
  75632. */
  75633. includeOnlyWithLayerMask: number;
  75634. private _lightmapMode;
  75635. /**
  75636. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  75637. */
  75638. /**
  75639. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  75640. */
  75641. lightmapMode: number;
  75642. /**
  75643. * Shadow generator associted to the light.
  75644. * @hidden Internal use only.
  75645. */
  75646. _shadowGenerator: Nullable<IShadowGenerator>;
  75647. /**
  75648. * @hidden Internal use only.
  75649. */
  75650. _excludedMeshesIds: string[];
  75651. /**
  75652. * @hidden Internal use only.
  75653. */
  75654. _includedOnlyMeshesIds: string[];
  75655. /**
  75656. * The current light unifom buffer.
  75657. * @hidden Internal use only.
  75658. */
  75659. _uniformBuffer: UniformBuffer;
  75660. /**
  75661. * Creates a Light object in the scene.
  75662. * Documentation : https://doc.babylonjs.com/babylon101/lights
  75663. * @param name The firendly name of the light
  75664. * @param scene The scene the light belongs too
  75665. */
  75666. constructor(name: string, scene: Scene);
  75667. protected abstract _buildUniformLayout(): void;
  75668. /**
  75669. * Sets the passed Effect "effect" with the Light information.
  75670. * @param effect The effect to update
  75671. * @param lightIndex The index of the light in the effect to update
  75672. * @returns The light
  75673. */
  75674. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  75675. /**
  75676. * Sets the passed Effect "effect" with the Light information.
  75677. * @param effect The effect to update
  75678. * @param lightDataUniformName The uniform used to store light data (position or direction)
  75679. * @returns The light
  75680. */
  75681. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  75682. /**
  75683. * Returns the string "Light".
  75684. * @returns the class name
  75685. */
  75686. getClassName(): string;
  75687. /** @hidden */
  75688. readonly _isLight: boolean;
  75689. /**
  75690. * Converts the light information to a readable string for debug purpose.
  75691. * @param fullDetails Supports for multiple levels of logging within scene loading
  75692. * @returns the human readable light info
  75693. */
  75694. toString(fullDetails?: boolean): string;
  75695. /** @hidden */
  75696. protected _syncParentEnabledState(): void;
  75697. /**
  75698. * Set the enabled state of this node.
  75699. * @param value - the new enabled state
  75700. */
  75701. setEnabled(value: boolean): void;
  75702. /**
  75703. * Returns the Light associated shadow generator if any.
  75704. * @return the associated shadow generator.
  75705. */
  75706. getShadowGenerator(): Nullable<IShadowGenerator>;
  75707. /**
  75708. * Returns a Vector3, the absolute light position in the World.
  75709. * @returns the world space position of the light
  75710. */
  75711. getAbsolutePosition(): Vector3;
  75712. /**
  75713. * Specifies if the light will affect the passed mesh.
  75714. * @param mesh The mesh to test against the light
  75715. * @return true the mesh is affected otherwise, false.
  75716. */
  75717. canAffectMesh(mesh: AbstractMesh): boolean;
  75718. /**
  75719. * Sort function to order lights for rendering.
  75720. * @param a First Light object to compare to second.
  75721. * @param b Second Light object to compare first.
  75722. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  75723. */
  75724. static CompareLightsPriority(a: Light, b: Light): number;
  75725. /**
  75726. * Releases resources associated with this node.
  75727. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  75728. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  75729. */
  75730. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  75731. /**
  75732. * Returns the light type ID (integer).
  75733. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  75734. */
  75735. getTypeID(): number;
  75736. /**
  75737. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  75738. * @returns the scaled intensity in intensity mode unit
  75739. */
  75740. getScaledIntensity(): number;
  75741. /**
  75742. * Returns a new Light object, named "name", from the current one.
  75743. * @param name The name of the cloned light
  75744. * @returns the new created light
  75745. */
  75746. clone(name: string): Nullable<Light>;
  75747. /**
  75748. * Serializes the current light into a Serialization object.
  75749. * @returns the serialized object.
  75750. */
  75751. serialize(): any;
  75752. /**
  75753. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  75754. * This new light is named "name" and added to the passed scene.
  75755. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  75756. * @param name The friendly name of the light
  75757. * @param scene The scene the new light will belong to
  75758. * @returns the constructor function
  75759. */
  75760. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  75761. /**
  75762. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  75763. * @param parsedLight The JSON representation of the light
  75764. * @param scene The scene to create the parsed light in
  75765. * @returns the created light after parsing
  75766. */
  75767. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  75768. private _hookArrayForExcluded;
  75769. private _hookArrayForIncludedOnly;
  75770. private _resyncMeshes;
  75771. /**
  75772. * Forces the meshes to update their light related information in their rendering used effects
  75773. * @hidden Internal Use Only
  75774. */
  75775. _markMeshesAsLightDirty(): void;
  75776. /**
  75777. * Recomputes the cached photometric scale if needed.
  75778. */
  75779. private _computePhotometricScale;
  75780. /**
  75781. * Returns the Photometric Scale according to the light type and intensity mode.
  75782. */
  75783. private _getPhotometricScale;
  75784. /**
  75785. * Reorder the light in the scene according to their defined priority.
  75786. * @hidden Internal Use Only
  75787. */
  75788. _reorderLightsInScene(): void;
  75789. /**
  75790. * Prepares the list of defines specific to the light type.
  75791. * @param defines the list of defines
  75792. * @param lightIndex defines the index of the light for the effect
  75793. */
  75794. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  75795. }
  75796. }
  75797. declare module BABYLON {
  75798. /**
  75799. * Interface used to define Action
  75800. */
  75801. export interface IAction {
  75802. /**
  75803. * Trigger for the action
  75804. */
  75805. trigger: number;
  75806. /** Options of the trigger */
  75807. triggerOptions: any;
  75808. /**
  75809. * Gets the trigger parameters
  75810. * @returns the trigger parameters
  75811. */
  75812. getTriggerParameter(): any;
  75813. /**
  75814. * Internal only - executes current action event
  75815. * @hidden
  75816. */
  75817. _executeCurrent(evt?: ActionEvent): void;
  75818. /**
  75819. * Serialize placeholder for child classes
  75820. * @param parent of child
  75821. * @returns the serialized object
  75822. */
  75823. serialize(parent: any): any;
  75824. /**
  75825. * Internal only
  75826. * @hidden
  75827. */
  75828. _prepare(): void;
  75829. /**
  75830. * Internal only - manager for action
  75831. * @hidden
  75832. */
  75833. _actionManager: AbstractActionManager;
  75834. /**
  75835. * Adds action to chain of actions, may be a DoNothingAction
  75836. * @param action defines the next action to execute
  75837. * @returns The action passed in
  75838. * @see https://www.babylonjs-playground.com/#1T30HR#0
  75839. */
  75840. then(action: IAction): IAction;
  75841. }
  75842. /**
  75843. * The action to be carried out following a trigger
  75844. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  75845. */
  75846. export class Action implements IAction {
  75847. /** the trigger, with or without parameters, for the action */
  75848. triggerOptions: any;
  75849. /**
  75850. * Trigger for the action
  75851. */
  75852. trigger: number;
  75853. /**
  75854. * Internal only - manager for action
  75855. * @hidden
  75856. */
  75857. _actionManager: ActionManager;
  75858. private _nextActiveAction;
  75859. private _child;
  75860. private _condition?;
  75861. private _triggerParameter;
  75862. /**
  75863. * An event triggered prior to action being executed.
  75864. */
  75865. onBeforeExecuteObservable: Observable<Action>;
  75866. /**
  75867. * Creates a new Action
  75868. * @param triggerOptions the trigger, with or without parameters, for the action
  75869. * @param condition an optional determinant of action
  75870. */
  75871. constructor(
  75872. /** the trigger, with or without parameters, for the action */
  75873. triggerOptions: any, condition?: Condition);
  75874. /**
  75875. * Internal only
  75876. * @hidden
  75877. */
  75878. _prepare(): void;
  75879. /**
  75880. * Gets the trigger parameters
  75881. * @returns the trigger parameters
  75882. */
  75883. getTriggerParameter(): any;
  75884. /**
  75885. * Internal only - executes current action event
  75886. * @hidden
  75887. */
  75888. _executeCurrent(evt?: ActionEvent): void;
  75889. /**
  75890. * Execute placeholder for child classes
  75891. * @param evt optional action event
  75892. */
  75893. execute(evt?: ActionEvent): void;
  75894. /**
  75895. * Skips to next active action
  75896. */
  75897. skipToNextActiveAction(): void;
  75898. /**
  75899. * Adds action to chain of actions, may be a DoNothingAction
  75900. * @param action defines the next action to execute
  75901. * @returns The action passed in
  75902. * @see https://www.babylonjs-playground.com/#1T30HR#0
  75903. */
  75904. then(action: Action): Action;
  75905. /**
  75906. * Internal only
  75907. * @hidden
  75908. */
  75909. _getProperty(propertyPath: string): string;
  75910. /**
  75911. * Internal only
  75912. * @hidden
  75913. */
  75914. _getEffectiveTarget(target: any, propertyPath: string): any;
  75915. /**
  75916. * Serialize placeholder for child classes
  75917. * @param parent of child
  75918. * @returns the serialized object
  75919. */
  75920. serialize(parent: any): any;
  75921. /**
  75922. * Internal only called by serialize
  75923. * @hidden
  75924. */
  75925. protected _serialize(serializedAction: any, parent?: any): any;
  75926. /**
  75927. * Internal only
  75928. * @hidden
  75929. */
  75930. static _SerializeValueAsString: (value: any) => string;
  75931. /**
  75932. * Internal only
  75933. * @hidden
  75934. */
  75935. static _GetTargetProperty: (target: Node | Scene) => {
  75936. name: string;
  75937. targetType: string;
  75938. value: string;
  75939. };
  75940. }
  75941. }
  75942. declare module BABYLON {
  75943. /**
  75944. * A Condition applied to an Action
  75945. */
  75946. export class Condition {
  75947. /**
  75948. * Internal only - manager for action
  75949. * @hidden
  75950. */
  75951. _actionManager: ActionManager;
  75952. /**
  75953. * Internal only
  75954. * @hidden
  75955. */
  75956. _evaluationId: number;
  75957. /**
  75958. * Internal only
  75959. * @hidden
  75960. */
  75961. _currentResult: boolean;
  75962. /**
  75963. * Creates a new Condition
  75964. * @param actionManager the manager of the action the condition is applied to
  75965. */
  75966. constructor(actionManager: ActionManager);
  75967. /**
  75968. * Check if the current condition is valid
  75969. * @returns a boolean
  75970. */
  75971. isValid(): boolean;
  75972. /**
  75973. * Internal only
  75974. * @hidden
  75975. */
  75976. _getProperty(propertyPath: string): string;
  75977. /**
  75978. * Internal only
  75979. * @hidden
  75980. */
  75981. _getEffectiveTarget(target: any, propertyPath: string): any;
  75982. /**
  75983. * Serialize placeholder for child classes
  75984. * @returns the serialized object
  75985. */
  75986. serialize(): any;
  75987. /**
  75988. * Internal only
  75989. * @hidden
  75990. */
  75991. protected _serialize(serializedCondition: any): any;
  75992. }
  75993. /**
  75994. * Defines specific conditional operators as extensions of Condition
  75995. */
  75996. export class ValueCondition extends Condition {
  75997. /** path to specify the property of the target the conditional operator uses */
  75998. propertyPath: string;
  75999. /** the value compared by the conditional operator against the current value of the property */
  76000. value: any;
  76001. /** the conditional operator, default ValueCondition.IsEqual */
  76002. operator: number;
  76003. /**
  76004. * Internal only
  76005. * @hidden
  76006. */
  76007. private static _IsEqual;
  76008. /**
  76009. * Internal only
  76010. * @hidden
  76011. */
  76012. private static _IsDifferent;
  76013. /**
  76014. * Internal only
  76015. * @hidden
  76016. */
  76017. private static _IsGreater;
  76018. /**
  76019. * Internal only
  76020. * @hidden
  76021. */
  76022. private static _IsLesser;
  76023. /**
  76024. * returns the number for IsEqual
  76025. */
  76026. static readonly IsEqual: number;
  76027. /**
  76028. * Returns the number for IsDifferent
  76029. */
  76030. static readonly IsDifferent: number;
  76031. /**
  76032. * Returns the number for IsGreater
  76033. */
  76034. static readonly IsGreater: number;
  76035. /**
  76036. * Returns the number for IsLesser
  76037. */
  76038. static readonly IsLesser: number;
  76039. /**
  76040. * Internal only The action manager for the condition
  76041. * @hidden
  76042. */
  76043. _actionManager: ActionManager;
  76044. /**
  76045. * Internal only
  76046. * @hidden
  76047. */
  76048. private _target;
  76049. /**
  76050. * Internal only
  76051. * @hidden
  76052. */
  76053. private _effectiveTarget;
  76054. /**
  76055. * Internal only
  76056. * @hidden
  76057. */
  76058. private _property;
  76059. /**
  76060. * Creates a new ValueCondition
  76061. * @param actionManager manager for the action the condition applies to
  76062. * @param target for the action
  76063. * @param propertyPath path to specify the property of the target the conditional operator uses
  76064. * @param value the value compared by the conditional operator against the current value of the property
  76065. * @param operator the conditional operator, default ValueCondition.IsEqual
  76066. */
  76067. constructor(actionManager: ActionManager, target: any,
  76068. /** path to specify the property of the target the conditional operator uses */
  76069. propertyPath: string,
  76070. /** the value compared by the conditional operator against the current value of the property */
  76071. value: any,
  76072. /** the conditional operator, default ValueCondition.IsEqual */
  76073. operator?: number);
  76074. /**
  76075. * Compares the given value with the property value for the specified conditional operator
  76076. * @returns the result of the comparison
  76077. */
  76078. isValid(): boolean;
  76079. /**
  76080. * Serialize the ValueCondition into a JSON compatible object
  76081. * @returns serialization object
  76082. */
  76083. serialize(): any;
  76084. /**
  76085. * Gets the name of the conditional operator for the ValueCondition
  76086. * @param operator the conditional operator
  76087. * @returns the name
  76088. */
  76089. static GetOperatorName(operator: number): string;
  76090. }
  76091. /**
  76092. * Defines a predicate condition as an extension of Condition
  76093. */
  76094. export class PredicateCondition extends Condition {
  76095. /** defines the predicate function used to validate the condition */
  76096. predicate: () => boolean;
  76097. /**
  76098. * Internal only - manager for action
  76099. * @hidden
  76100. */
  76101. _actionManager: ActionManager;
  76102. /**
  76103. * Creates a new PredicateCondition
  76104. * @param actionManager manager for the action the condition applies to
  76105. * @param predicate defines the predicate function used to validate the condition
  76106. */
  76107. constructor(actionManager: ActionManager,
  76108. /** defines the predicate function used to validate the condition */
  76109. predicate: () => boolean);
  76110. /**
  76111. * @returns the validity of the predicate condition
  76112. */
  76113. isValid(): boolean;
  76114. }
  76115. /**
  76116. * Defines a state condition as an extension of Condition
  76117. */
  76118. export class StateCondition extends Condition {
  76119. /** Value to compare with target state */
  76120. value: string;
  76121. /**
  76122. * Internal only - manager for action
  76123. * @hidden
  76124. */
  76125. _actionManager: ActionManager;
  76126. /**
  76127. * Internal only
  76128. * @hidden
  76129. */
  76130. private _target;
  76131. /**
  76132. * Creates a new StateCondition
  76133. * @param actionManager manager for the action the condition applies to
  76134. * @param target of the condition
  76135. * @param value to compare with target state
  76136. */
  76137. constructor(actionManager: ActionManager, target: any,
  76138. /** Value to compare with target state */
  76139. value: string);
  76140. /**
  76141. * Gets a boolean indicating if the current condition is met
  76142. * @returns the validity of the state
  76143. */
  76144. isValid(): boolean;
  76145. /**
  76146. * Serialize the StateCondition into a JSON compatible object
  76147. * @returns serialization object
  76148. */
  76149. serialize(): any;
  76150. }
  76151. }
  76152. declare module BABYLON {
  76153. /**
  76154. * This defines an action responsible to toggle a boolean once triggered.
  76155. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76156. */
  76157. export class SwitchBooleanAction extends Action {
  76158. /**
  76159. * The path to the boolean property in the target object
  76160. */
  76161. propertyPath: string;
  76162. private _target;
  76163. private _effectiveTarget;
  76164. private _property;
  76165. /**
  76166. * Instantiate the action
  76167. * @param triggerOptions defines the trigger options
  76168. * @param target defines the object containing the boolean
  76169. * @param propertyPath defines the path to the boolean property in the target object
  76170. * @param condition defines the trigger related conditions
  76171. */
  76172. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  76173. /** @hidden */
  76174. _prepare(): void;
  76175. /**
  76176. * Execute the action toggle the boolean value.
  76177. */
  76178. execute(): void;
  76179. /**
  76180. * Serializes the actions and its related information.
  76181. * @param parent defines the object to serialize in
  76182. * @returns the serialized object
  76183. */
  76184. serialize(parent: any): any;
  76185. }
  76186. /**
  76187. * This defines an action responsible to set a the state field of the target
  76188. * to a desired value once triggered.
  76189. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76190. */
  76191. export class SetStateAction extends Action {
  76192. /**
  76193. * The value to store in the state field.
  76194. */
  76195. value: string;
  76196. private _target;
  76197. /**
  76198. * Instantiate the action
  76199. * @param triggerOptions defines the trigger options
  76200. * @param target defines the object containing the state property
  76201. * @param value defines the value to store in the state field
  76202. * @param condition defines the trigger related conditions
  76203. */
  76204. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  76205. /**
  76206. * Execute the action and store the value on the target state property.
  76207. */
  76208. execute(): void;
  76209. /**
  76210. * Serializes the actions and its related information.
  76211. * @param parent defines the object to serialize in
  76212. * @returns the serialized object
  76213. */
  76214. serialize(parent: any): any;
  76215. }
  76216. /**
  76217. * This defines an action responsible to set a property of the target
  76218. * to a desired value once triggered.
  76219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76220. */
  76221. export class SetValueAction extends Action {
  76222. /**
  76223. * The path of the property to set in the target.
  76224. */
  76225. propertyPath: string;
  76226. /**
  76227. * The value to set in the property
  76228. */
  76229. value: any;
  76230. private _target;
  76231. private _effectiveTarget;
  76232. private _property;
  76233. /**
  76234. * Instantiate the action
  76235. * @param triggerOptions defines the trigger options
  76236. * @param target defines the object containing the property
  76237. * @param propertyPath defines the path of the property to set in the target
  76238. * @param value defines the value to set in the property
  76239. * @param condition defines the trigger related conditions
  76240. */
  76241. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  76242. /** @hidden */
  76243. _prepare(): void;
  76244. /**
  76245. * Execute the action and set the targetted property to the desired value.
  76246. */
  76247. execute(): void;
  76248. /**
  76249. * Serializes the actions and its related information.
  76250. * @param parent defines the object to serialize in
  76251. * @returns the serialized object
  76252. */
  76253. serialize(parent: any): any;
  76254. }
  76255. /**
  76256. * This defines an action responsible to increment the target value
  76257. * to a desired value once triggered.
  76258. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76259. */
  76260. export class IncrementValueAction extends Action {
  76261. /**
  76262. * The path of the property to increment in the target.
  76263. */
  76264. propertyPath: string;
  76265. /**
  76266. * The value we should increment the property by.
  76267. */
  76268. value: any;
  76269. private _target;
  76270. private _effectiveTarget;
  76271. private _property;
  76272. /**
  76273. * Instantiate the action
  76274. * @param triggerOptions defines the trigger options
  76275. * @param target defines the object containing the property
  76276. * @param propertyPath defines the path of the property to increment in the target
  76277. * @param value defines the value value we should increment the property by
  76278. * @param condition defines the trigger related conditions
  76279. */
  76280. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  76281. /** @hidden */
  76282. _prepare(): void;
  76283. /**
  76284. * Execute the action and increment the target of the value amount.
  76285. */
  76286. execute(): void;
  76287. /**
  76288. * Serializes the actions and its related information.
  76289. * @param parent defines the object to serialize in
  76290. * @returns the serialized object
  76291. */
  76292. serialize(parent: any): any;
  76293. }
  76294. /**
  76295. * This defines an action responsible to start an animation once triggered.
  76296. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76297. */
  76298. export class PlayAnimationAction extends Action {
  76299. /**
  76300. * Where the animation should start (animation frame)
  76301. */
  76302. from: number;
  76303. /**
  76304. * Where the animation should stop (animation frame)
  76305. */
  76306. to: number;
  76307. /**
  76308. * Define if the animation should loop or stop after the first play.
  76309. */
  76310. loop?: boolean;
  76311. private _target;
  76312. /**
  76313. * Instantiate the action
  76314. * @param triggerOptions defines the trigger options
  76315. * @param target defines the target animation or animation name
  76316. * @param from defines from where the animation should start (animation frame)
  76317. * @param end defines where the animation should stop (animation frame)
  76318. * @param loop defines if the animation should loop or stop after the first play
  76319. * @param condition defines the trigger related conditions
  76320. */
  76321. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  76322. /** @hidden */
  76323. _prepare(): void;
  76324. /**
  76325. * Execute the action and play the animation.
  76326. */
  76327. execute(): void;
  76328. /**
  76329. * Serializes the actions and its related information.
  76330. * @param parent defines the object to serialize in
  76331. * @returns the serialized object
  76332. */
  76333. serialize(parent: any): any;
  76334. }
  76335. /**
  76336. * This defines an action responsible to stop an animation once triggered.
  76337. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76338. */
  76339. export class StopAnimationAction extends Action {
  76340. private _target;
  76341. /**
  76342. * Instantiate the action
  76343. * @param triggerOptions defines the trigger options
  76344. * @param target defines the target animation or animation name
  76345. * @param condition defines the trigger related conditions
  76346. */
  76347. constructor(triggerOptions: any, target: any, condition?: Condition);
  76348. /** @hidden */
  76349. _prepare(): void;
  76350. /**
  76351. * Execute the action and stop the animation.
  76352. */
  76353. execute(): void;
  76354. /**
  76355. * Serializes the actions and its related information.
  76356. * @param parent defines the object to serialize in
  76357. * @returns the serialized object
  76358. */
  76359. serialize(parent: any): any;
  76360. }
  76361. /**
  76362. * This defines an action responsible that does nothing once triggered.
  76363. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76364. */
  76365. export class DoNothingAction extends Action {
  76366. /**
  76367. * Instantiate the action
  76368. * @param triggerOptions defines the trigger options
  76369. * @param condition defines the trigger related conditions
  76370. */
  76371. constructor(triggerOptions?: any, condition?: Condition);
  76372. /**
  76373. * Execute the action and do nothing.
  76374. */
  76375. execute(): void;
  76376. /**
  76377. * Serializes the actions and its related information.
  76378. * @param parent defines the object to serialize in
  76379. * @returns the serialized object
  76380. */
  76381. serialize(parent: any): any;
  76382. }
  76383. /**
  76384. * This defines an action responsible to trigger several actions once triggered.
  76385. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76386. */
  76387. export class CombineAction extends Action {
  76388. /**
  76389. * The list of aggregated animations to run.
  76390. */
  76391. children: Action[];
  76392. /**
  76393. * Instantiate the action
  76394. * @param triggerOptions defines the trigger options
  76395. * @param children defines the list of aggregated animations to run
  76396. * @param condition defines the trigger related conditions
  76397. */
  76398. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  76399. /** @hidden */
  76400. _prepare(): void;
  76401. /**
  76402. * Execute the action and executes all the aggregated actions.
  76403. */
  76404. execute(evt: ActionEvent): void;
  76405. /**
  76406. * Serializes the actions and its related information.
  76407. * @param parent defines the object to serialize in
  76408. * @returns the serialized object
  76409. */
  76410. serialize(parent: any): any;
  76411. }
  76412. /**
  76413. * This defines an action responsible to run code (external event) once triggered.
  76414. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76415. */
  76416. export class ExecuteCodeAction extends Action {
  76417. /**
  76418. * The callback function to run.
  76419. */
  76420. func: (evt: ActionEvent) => void;
  76421. /**
  76422. * Instantiate the action
  76423. * @param triggerOptions defines the trigger options
  76424. * @param func defines the callback function to run
  76425. * @param condition defines the trigger related conditions
  76426. */
  76427. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  76428. /**
  76429. * Execute the action and run the attached code.
  76430. */
  76431. execute(evt: ActionEvent): void;
  76432. }
  76433. /**
  76434. * This defines an action responsible to set the parent property of the target once triggered.
  76435. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76436. */
  76437. export class SetParentAction extends Action {
  76438. private _parent;
  76439. private _target;
  76440. /**
  76441. * Instantiate the action
  76442. * @param triggerOptions defines the trigger options
  76443. * @param target defines the target containing the parent property
  76444. * @param parent defines from where the animation should start (animation frame)
  76445. * @param condition defines the trigger related conditions
  76446. */
  76447. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  76448. /** @hidden */
  76449. _prepare(): void;
  76450. /**
  76451. * Execute the action and set the parent property.
  76452. */
  76453. execute(): void;
  76454. /**
  76455. * Serializes the actions and its related information.
  76456. * @param parent defines the object to serialize in
  76457. * @returns the serialized object
  76458. */
  76459. serialize(parent: any): any;
  76460. }
  76461. }
  76462. declare module BABYLON {
  76463. /**
  76464. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  76465. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  76466. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76467. */
  76468. export class ActionManager extends AbstractActionManager {
  76469. /**
  76470. * Nothing
  76471. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76472. */
  76473. static readonly NothingTrigger: number;
  76474. /**
  76475. * On pick
  76476. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76477. */
  76478. static readonly OnPickTrigger: number;
  76479. /**
  76480. * On left pick
  76481. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76482. */
  76483. static readonly OnLeftPickTrigger: number;
  76484. /**
  76485. * On right pick
  76486. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76487. */
  76488. static readonly OnRightPickTrigger: number;
  76489. /**
  76490. * On center pick
  76491. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76492. */
  76493. static readonly OnCenterPickTrigger: number;
  76494. /**
  76495. * On pick down
  76496. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76497. */
  76498. static readonly OnPickDownTrigger: number;
  76499. /**
  76500. * On double pick
  76501. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76502. */
  76503. static readonly OnDoublePickTrigger: number;
  76504. /**
  76505. * On pick up
  76506. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76507. */
  76508. static readonly OnPickUpTrigger: number;
  76509. /**
  76510. * On pick out.
  76511. * This trigger will only be raised if you also declared a OnPickDown
  76512. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76513. */
  76514. static readonly OnPickOutTrigger: number;
  76515. /**
  76516. * On long press
  76517. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76518. */
  76519. static readonly OnLongPressTrigger: number;
  76520. /**
  76521. * On pointer over
  76522. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76523. */
  76524. static readonly OnPointerOverTrigger: number;
  76525. /**
  76526. * On pointer out
  76527. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76528. */
  76529. static readonly OnPointerOutTrigger: number;
  76530. /**
  76531. * On every frame
  76532. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76533. */
  76534. static readonly OnEveryFrameTrigger: number;
  76535. /**
  76536. * On intersection enter
  76537. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76538. */
  76539. static readonly OnIntersectionEnterTrigger: number;
  76540. /**
  76541. * On intersection exit
  76542. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76543. */
  76544. static readonly OnIntersectionExitTrigger: number;
  76545. /**
  76546. * On key down
  76547. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76548. */
  76549. static readonly OnKeyDownTrigger: number;
  76550. /**
  76551. * On key up
  76552. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76553. */
  76554. static readonly OnKeyUpTrigger: number;
  76555. private _scene;
  76556. /**
  76557. * Creates a new action manager
  76558. * @param scene defines the hosting scene
  76559. */
  76560. constructor(scene: Scene);
  76561. /**
  76562. * Releases all associated resources
  76563. */
  76564. dispose(): void;
  76565. /**
  76566. * Gets hosting scene
  76567. * @returns the hosting scene
  76568. */
  76569. getScene(): Scene;
  76570. /**
  76571. * Does this action manager handles actions of any of the given triggers
  76572. * @param triggers defines the triggers to be tested
  76573. * @return a boolean indicating whether one (or more) of the triggers is handled
  76574. */
  76575. hasSpecificTriggers(triggers: number[]): boolean;
  76576. /**
  76577. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  76578. * speed.
  76579. * @param triggerA defines the trigger to be tested
  76580. * @param triggerB defines the trigger to be tested
  76581. * @return a boolean indicating whether one (or more) of the triggers is handled
  76582. */
  76583. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  76584. /**
  76585. * Does this action manager handles actions of a given trigger
  76586. * @param trigger defines the trigger to be tested
  76587. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  76588. * @return whether the trigger is handled
  76589. */
  76590. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  76591. /**
  76592. * Does this action manager has pointer triggers
  76593. */
  76594. readonly hasPointerTriggers: boolean;
  76595. /**
  76596. * Does this action manager has pick triggers
  76597. */
  76598. readonly hasPickTriggers: boolean;
  76599. /**
  76600. * Registers an action to this action manager
  76601. * @param action defines the action to be registered
  76602. * @return the action amended (prepared) after registration
  76603. */
  76604. registerAction(action: IAction): Nullable<IAction>;
  76605. /**
  76606. * Unregisters an action to this action manager
  76607. * @param action defines the action to be unregistered
  76608. * @return a boolean indicating whether the action has been unregistered
  76609. */
  76610. unregisterAction(action: IAction): Boolean;
  76611. /**
  76612. * Process a specific trigger
  76613. * @param trigger defines the trigger to process
  76614. * @param evt defines the event details to be processed
  76615. */
  76616. processTrigger(trigger: number, evt?: IActionEvent): void;
  76617. /** @hidden */
  76618. _getEffectiveTarget(target: any, propertyPath: string): any;
  76619. /** @hidden */
  76620. _getProperty(propertyPath: string): string;
  76621. /**
  76622. * Serialize this manager to a JSON object
  76623. * @param name defines the property name to store this manager
  76624. * @returns a JSON representation of this manager
  76625. */
  76626. serialize(name: string): any;
  76627. /**
  76628. * Creates a new ActionManager from a JSON data
  76629. * @param parsedActions defines the JSON data to read from
  76630. * @param object defines the hosting mesh
  76631. * @param scene defines the hosting scene
  76632. */
  76633. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  76634. /**
  76635. * Get a trigger name by index
  76636. * @param trigger defines the trigger index
  76637. * @returns a trigger name
  76638. */
  76639. static GetTriggerName(trigger: number): string;
  76640. }
  76641. }
  76642. declare module BABYLON {
  76643. /**
  76644. * Class representing a ray with position and direction
  76645. */
  76646. export class Ray {
  76647. /** origin point */
  76648. origin: Vector3;
  76649. /** direction */
  76650. direction: Vector3;
  76651. /** length of the ray */
  76652. length: number;
  76653. private static readonly TmpVector3;
  76654. private _tmpRay;
  76655. /**
  76656. * Creates a new ray
  76657. * @param origin origin point
  76658. * @param direction direction
  76659. * @param length length of the ray
  76660. */
  76661. constructor(
  76662. /** origin point */
  76663. origin: Vector3,
  76664. /** direction */
  76665. direction: Vector3,
  76666. /** length of the ray */
  76667. length?: number);
  76668. /**
  76669. * Checks if the ray intersects a box
  76670. * @param minimum bound of the box
  76671. * @param maximum bound of the box
  76672. * @param intersectionTreshold extra extend to be added to the box in all direction
  76673. * @returns if the box was hit
  76674. */
  76675. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  76676. /**
  76677. * Checks if the ray intersects a box
  76678. * @param box the bounding box to check
  76679. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  76680. * @returns if the box was hit
  76681. */
  76682. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  76683. /**
  76684. * If the ray hits a sphere
  76685. * @param sphere the bounding sphere to check
  76686. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  76687. * @returns true if it hits the sphere
  76688. */
  76689. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  76690. /**
  76691. * If the ray hits a triange
  76692. * @param vertex0 triangle vertex
  76693. * @param vertex1 triangle vertex
  76694. * @param vertex2 triangle vertex
  76695. * @returns intersection information if hit
  76696. */
  76697. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  76698. /**
  76699. * Checks if ray intersects a plane
  76700. * @param plane the plane to check
  76701. * @returns the distance away it was hit
  76702. */
  76703. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  76704. /**
  76705. * Calculate the intercept of a ray on a given axis
  76706. * @param axis to check 'x' | 'y' | 'z'
  76707. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  76708. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  76709. */
  76710. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  76711. /**
  76712. * Checks if ray intersects a mesh
  76713. * @param mesh the mesh to check
  76714. * @param fastCheck if only the bounding box should checked
  76715. * @returns picking info of the intersecton
  76716. */
  76717. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  76718. /**
  76719. * Checks if ray intersects a mesh
  76720. * @param meshes the meshes to check
  76721. * @param fastCheck if only the bounding box should checked
  76722. * @param results array to store result in
  76723. * @returns Array of picking infos
  76724. */
  76725. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  76726. private _comparePickingInfo;
  76727. private static smallnum;
  76728. private static rayl;
  76729. /**
  76730. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  76731. * @param sega the first point of the segment to test the intersection against
  76732. * @param segb the second point of the segment to test the intersection against
  76733. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  76734. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  76735. */
  76736. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  76737. /**
  76738. * Update the ray from viewport position
  76739. * @param x position
  76740. * @param y y position
  76741. * @param viewportWidth viewport width
  76742. * @param viewportHeight viewport height
  76743. * @param world world matrix
  76744. * @param view view matrix
  76745. * @param projection projection matrix
  76746. * @returns this ray updated
  76747. */
  76748. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  76749. /**
  76750. * Creates a ray with origin and direction of 0,0,0
  76751. * @returns the new ray
  76752. */
  76753. static Zero(): Ray;
  76754. /**
  76755. * Creates a new ray from screen space and viewport
  76756. * @param x position
  76757. * @param y y position
  76758. * @param viewportWidth viewport width
  76759. * @param viewportHeight viewport height
  76760. * @param world world matrix
  76761. * @param view view matrix
  76762. * @param projection projection matrix
  76763. * @returns new ray
  76764. */
  76765. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  76766. /**
  76767. * 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
  76768. * transformed to the given world matrix.
  76769. * @param origin The origin point
  76770. * @param end The end point
  76771. * @param world a matrix to transform the ray to. Default is the identity matrix.
  76772. * @returns the new ray
  76773. */
  76774. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  76775. /**
  76776. * Transforms a ray by a matrix
  76777. * @param ray ray to transform
  76778. * @param matrix matrix to apply
  76779. * @returns the resulting new ray
  76780. */
  76781. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  76782. /**
  76783. * Transforms a ray by a matrix
  76784. * @param ray ray to transform
  76785. * @param matrix matrix to apply
  76786. * @param result ray to store result in
  76787. */
  76788. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  76789. /**
  76790. * Unproject a ray from screen space to object space
  76791. * @param sourceX defines the screen space x coordinate to use
  76792. * @param sourceY defines the screen space y coordinate to use
  76793. * @param viewportWidth defines the current width of the viewport
  76794. * @param viewportHeight defines the current height of the viewport
  76795. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76796. * @param view defines the view matrix to use
  76797. * @param projection defines the projection matrix to use
  76798. */
  76799. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  76800. }
  76801. /**
  76802. * Type used to define predicate used to select faces when a mesh intersection is detected
  76803. */
  76804. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  76805. interface Scene {
  76806. /** @hidden */
  76807. _tempPickingRay: Nullable<Ray>;
  76808. /** @hidden */
  76809. _cachedRayForTransform: Ray;
  76810. /** @hidden */
  76811. _pickWithRayInverseMatrix: Matrix;
  76812. /** @hidden */
  76813. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  76814. /** @hidden */
  76815. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  76816. }
  76817. }
  76818. declare module BABYLON {
  76819. /**
  76820. * Groups all the scene component constants in one place to ease maintenance.
  76821. * @hidden
  76822. */
  76823. export class SceneComponentConstants {
  76824. static readonly NAME_EFFECTLAYER: string;
  76825. static readonly NAME_LAYER: string;
  76826. static readonly NAME_LENSFLARESYSTEM: string;
  76827. static readonly NAME_BOUNDINGBOXRENDERER: string;
  76828. static readonly NAME_PARTICLESYSTEM: string;
  76829. static readonly NAME_GAMEPAD: string;
  76830. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  76831. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  76832. static readonly NAME_DEPTHRENDERER: string;
  76833. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  76834. static readonly NAME_SPRITE: string;
  76835. static readonly NAME_OUTLINERENDERER: string;
  76836. static readonly NAME_PROCEDURALTEXTURE: string;
  76837. static readonly NAME_SHADOWGENERATOR: string;
  76838. static readonly NAME_OCTREE: string;
  76839. static readonly NAME_PHYSICSENGINE: string;
  76840. static readonly NAME_AUDIO: string;
  76841. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  76842. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  76843. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  76844. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  76845. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  76846. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  76847. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  76848. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  76849. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  76850. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  76851. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  76852. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  76853. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  76854. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  76855. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  76856. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  76857. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  76858. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  76859. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  76860. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  76861. static readonly STEP_AFTERRENDER_AUDIO: number;
  76862. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  76863. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  76864. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  76865. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  76866. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  76867. static readonly STEP_POINTERMOVE_SPRITE: number;
  76868. static readonly STEP_POINTERDOWN_SPRITE: number;
  76869. static readonly STEP_POINTERUP_SPRITE: number;
  76870. }
  76871. /**
  76872. * This represents a scene component.
  76873. *
  76874. * This is used to decouple the dependency the scene is having on the different workloads like
  76875. * layers, post processes...
  76876. */
  76877. export interface ISceneComponent {
  76878. /**
  76879. * The name of the component. Each component must have a unique name.
  76880. */
  76881. name: string;
  76882. /**
  76883. * The scene the component belongs to.
  76884. */
  76885. scene: Scene;
  76886. /**
  76887. * Register the component to one instance of a scene.
  76888. */
  76889. register(): void;
  76890. /**
  76891. * Rebuilds the elements related to this component in case of
  76892. * context lost for instance.
  76893. */
  76894. rebuild(): void;
  76895. /**
  76896. * Disposes the component and the associated ressources.
  76897. */
  76898. dispose(): void;
  76899. }
  76900. /**
  76901. * This represents a SERIALIZABLE scene component.
  76902. *
  76903. * This extends Scene Component to add Serialization methods on top.
  76904. */
  76905. export interface ISceneSerializableComponent extends ISceneComponent {
  76906. /**
  76907. * Adds all the elements from the container to the scene
  76908. * @param container the container holding the elements
  76909. */
  76910. addFromContainer(container: AbstractScene): void;
  76911. /**
  76912. * Removes all the elements in the container from the scene
  76913. * @param container contains the elements to remove
  76914. * @param dispose if the removed element should be disposed (default: false)
  76915. */
  76916. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  76917. /**
  76918. * Serializes the component data to the specified json object
  76919. * @param serializationObject The object to serialize to
  76920. */
  76921. serialize(serializationObject: any): void;
  76922. }
  76923. /**
  76924. * Strong typing of a Mesh related stage step action
  76925. */
  76926. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  76927. /**
  76928. * Strong typing of a Evaluate Sub Mesh related stage step action
  76929. */
  76930. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  76931. /**
  76932. * Strong typing of a Active Mesh related stage step action
  76933. */
  76934. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  76935. /**
  76936. * Strong typing of a Camera related stage step action
  76937. */
  76938. export type CameraStageAction = (camera: Camera) => void;
  76939. /**
  76940. * Strong typing of a Camera Frame buffer related stage step action
  76941. */
  76942. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  76943. /**
  76944. * Strong typing of a Render Target related stage step action
  76945. */
  76946. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  76947. /**
  76948. * Strong typing of a RenderingGroup related stage step action
  76949. */
  76950. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  76951. /**
  76952. * Strong typing of a Mesh Render related stage step action
  76953. */
  76954. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  76955. /**
  76956. * Strong typing of a simple stage step action
  76957. */
  76958. export type SimpleStageAction = () => void;
  76959. /**
  76960. * Strong typing of a render target action.
  76961. */
  76962. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  76963. /**
  76964. * Strong typing of a pointer move action.
  76965. */
  76966. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  76967. /**
  76968. * Strong typing of a pointer up/down action.
  76969. */
  76970. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  76971. /**
  76972. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  76973. * @hidden
  76974. */
  76975. export class Stage<T extends Function> extends Array<{
  76976. index: number;
  76977. component: ISceneComponent;
  76978. action: T;
  76979. }> {
  76980. /**
  76981. * Hide ctor from the rest of the world.
  76982. * @param items The items to add.
  76983. */
  76984. private constructor();
  76985. /**
  76986. * Creates a new Stage.
  76987. * @returns A new instance of a Stage
  76988. */
  76989. static Create<T extends Function>(): Stage<T>;
  76990. /**
  76991. * Registers a step in an ordered way in the targeted stage.
  76992. * @param index Defines the position to register the step in
  76993. * @param component Defines the component attached to the step
  76994. * @param action Defines the action to launch during the step
  76995. */
  76996. registerStep(index: number, component: ISceneComponent, action: T): void;
  76997. /**
  76998. * Clears all the steps from the stage.
  76999. */
  77000. clear(): void;
  77001. }
  77002. }
  77003. declare module BABYLON {
  77004. interface Scene {
  77005. /** @hidden */
  77006. _pointerOverSprite: Nullable<Sprite>;
  77007. /** @hidden */
  77008. _pickedDownSprite: Nullable<Sprite>;
  77009. /** @hidden */
  77010. _tempSpritePickingRay: Nullable<Ray>;
  77011. /**
  77012. * All of the sprite managers added to this scene
  77013. * @see http://doc.babylonjs.com/babylon101/sprites
  77014. */
  77015. spriteManagers: Array<ISpriteManager>;
  77016. /**
  77017. * An event triggered when sprites rendering is about to start
  77018. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  77019. */
  77020. onBeforeSpritesRenderingObservable: Observable<Scene>;
  77021. /**
  77022. * An event triggered when sprites rendering is done
  77023. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  77024. */
  77025. onAfterSpritesRenderingObservable: Observable<Scene>;
  77026. /** @hidden */
  77027. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  77028. /** Launch a ray to try to pick a sprite in the scene
  77029. * @param x position on screen
  77030. * @param y position on screen
  77031. * @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
  77032. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  77033. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  77034. * @returns a PickingInfo
  77035. */
  77036. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  77037. /** Use the given ray to pick a sprite in the scene
  77038. * @param ray The ray (in world space) to use to pick meshes
  77039. * @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
  77040. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  77041. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  77042. * @returns a PickingInfo
  77043. */
  77044. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  77045. /** @hidden */
  77046. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  77047. /** Launch a ray to try to pick sprites in the scene
  77048. * @param x position on screen
  77049. * @param y position on screen
  77050. * @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
  77051. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  77052. * @returns a PickingInfo array
  77053. */
  77054. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  77055. /** Use the given ray to pick sprites in the scene
  77056. * @param ray The ray (in world space) to use to pick meshes
  77057. * @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
  77058. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  77059. * @returns a PickingInfo array
  77060. */
  77061. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  77062. /**
  77063. * Force the sprite under the pointer
  77064. * @param sprite defines the sprite to use
  77065. */
  77066. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  77067. /**
  77068. * Gets the sprite under the pointer
  77069. * @returns a Sprite or null if no sprite is under the pointer
  77070. */
  77071. getPointerOverSprite(): Nullable<Sprite>;
  77072. }
  77073. /**
  77074. * Defines the sprite scene component responsible to manage sprites
  77075. * in a given scene.
  77076. */
  77077. export class SpriteSceneComponent implements ISceneComponent {
  77078. /**
  77079. * The component name helpfull to identify the component in the list of scene components.
  77080. */
  77081. readonly name: string;
  77082. /**
  77083. * The scene the component belongs to.
  77084. */
  77085. scene: Scene;
  77086. /** @hidden */
  77087. private _spritePredicate;
  77088. /**
  77089. * Creates a new instance of the component for the given scene
  77090. * @param scene Defines the scene to register the component in
  77091. */
  77092. constructor(scene: Scene);
  77093. /**
  77094. * Registers the component in a given scene
  77095. */
  77096. register(): void;
  77097. /**
  77098. * Rebuilds the elements related to this component in case of
  77099. * context lost for instance.
  77100. */
  77101. rebuild(): void;
  77102. /**
  77103. * Disposes the component and the associated ressources.
  77104. */
  77105. dispose(): void;
  77106. private _pickSpriteButKeepRay;
  77107. private _pointerMove;
  77108. private _pointerDown;
  77109. private _pointerUp;
  77110. }
  77111. }
  77112. declare module BABYLON {
  77113. /** @hidden */
  77114. export var fogFragmentDeclaration: {
  77115. name: string;
  77116. shader: string;
  77117. };
  77118. }
  77119. declare module BABYLON {
  77120. /** @hidden */
  77121. export var fogFragment: {
  77122. name: string;
  77123. shader: string;
  77124. };
  77125. }
  77126. declare module BABYLON {
  77127. /** @hidden */
  77128. export var spritesPixelShader: {
  77129. name: string;
  77130. shader: string;
  77131. };
  77132. }
  77133. declare module BABYLON {
  77134. /** @hidden */
  77135. export var fogVertexDeclaration: {
  77136. name: string;
  77137. shader: string;
  77138. };
  77139. }
  77140. declare module BABYLON {
  77141. /** @hidden */
  77142. export var spritesVertexShader: {
  77143. name: string;
  77144. shader: string;
  77145. };
  77146. }
  77147. declare module BABYLON {
  77148. /**
  77149. * Defines the minimum interface to fullfil in order to be a sprite manager.
  77150. */
  77151. export interface ISpriteManager extends IDisposable {
  77152. /**
  77153. * Restricts the camera to viewing objects with the same layerMask.
  77154. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  77155. */
  77156. layerMask: number;
  77157. /**
  77158. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  77159. */
  77160. isPickable: boolean;
  77161. /**
  77162. * Specifies the rendering group id for this mesh (0 by default)
  77163. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  77164. */
  77165. renderingGroupId: number;
  77166. /**
  77167. * Defines the list of sprites managed by the manager.
  77168. */
  77169. sprites: Array<Sprite>;
  77170. /**
  77171. * Tests the intersection of a sprite with a specific ray.
  77172. * @param ray The ray we are sending to test the collision
  77173. * @param camera The camera space we are sending rays in
  77174. * @param predicate A predicate allowing excluding sprites from the list of object to test
  77175. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  77176. * @returns picking info or null.
  77177. */
  77178. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  77179. /**
  77180. * Intersects the sprites with a ray
  77181. * @param ray defines the ray to intersect with
  77182. * @param camera defines the current active camera
  77183. * @param predicate defines a predicate used to select candidate sprites
  77184. * @returns null if no hit or a PickingInfo array
  77185. */
  77186. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  77187. /**
  77188. * Renders the list of sprites on screen.
  77189. */
  77190. render(): void;
  77191. }
  77192. /**
  77193. * Class used to manage multiple sprites on the same spritesheet
  77194. * @see http://doc.babylonjs.com/babylon101/sprites
  77195. */
  77196. export class SpriteManager implements ISpriteManager {
  77197. /** defines the manager's name */
  77198. name: string;
  77199. /** Gets the list of sprites */
  77200. sprites: Sprite[];
  77201. /** Gets or sets the rendering group id (0 by default) */
  77202. renderingGroupId: number;
  77203. /** Gets or sets camera layer mask */
  77204. layerMask: number;
  77205. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  77206. fogEnabled: boolean;
  77207. /** Gets or sets a boolean indicating if the sprites are pickable */
  77208. isPickable: boolean;
  77209. /** Defines the default width of a cell in the spritesheet */
  77210. cellWidth: number;
  77211. /** Defines the default height of a cell in the spritesheet */
  77212. cellHeight: number;
  77213. /** Associative array from JSON sprite data file */
  77214. private _cellData;
  77215. /** Array of sprite names from JSON sprite data file */
  77216. private _spriteMap;
  77217. /** True when packed cell data from JSON file is ready*/
  77218. private _packedAndReady;
  77219. /**
  77220. * An event triggered when the manager is disposed.
  77221. */
  77222. onDisposeObservable: Observable<SpriteManager>;
  77223. private _onDisposeObserver;
  77224. /**
  77225. * Callback called when the manager is disposed
  77226. */
  77227. onDispose: () => void;
  77228. private _capacity;
  77229. private _fromPacked;
  77230. private _spriteTexture;
  77231. private _epsilon;
  77232. private _scene;
  77233. private _vertexData;
  77234. private _buffer;
  77235. private _vertexBuffers;
  77236. private _indexBuffer;
  77237. private _effectBase;
  77238. private _effectFog;
  77239. /**
  77240. * Gets or sets the spritesheet texture
  77241. */
  77242. texture: Texture;
  77243. /**
  77244. * Creates a new sprite manager
  77245. * @param name defines the manager's name
  77246. * @param imgUrl defines the sprite sheet url
  77247. * @param capacity defines the maximum allowed number of sprites
  77248. * @param cellSize defines the size of a sprite cell
  77249. * @param scene defines the hosting scene
  77250. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  77251. * @param samplingMode defines the smapling mode to use with spritesheet
  77252. * @param fromPacked set to false; do not alter
  77253. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  77254. */
  77255. constructor(
  77256. /** defines the manager's name */
  77257. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  77258. private _makePacked;
  77259. private _appendSpriteVertex;
  77260. /**
  77261. * Intersects the sprites with a ray
  77262. * @param ray defines the ray to intersect with
  77263. * @param camera defines the current active camera
  77264. * @param predicate defines a predicate used to select candidate sprites
  77265. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  77266. * @returns null if no hit or a PickingInfo
  77267. */
  77268. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  77269. /**
  77270. * Intersects the sprites with a ray
  77271. * @param ray defines the ray to intersect with
  77272. * @param camera defines the current active camera
  77273. * @param predicate defines a predicate used to select candidate sprites
  77274. * @returns null if no hit or a PickingInfo array
  77275. */
  77276. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  77277. /**
  77278. * Render all child sprites
  77279. */
  77280. render(): void;
  77281. /**
  77282. * Release associated resources
  77283. */
  77284. dispose(): void;
  77285. }
  77286. }
  77287. declare module BABYLON {
  77288. /**
  77289. * Class used to represent a sprite
  77290. * @see http://doc.babylonjs.com/babylon101/sprites
  77291. */
  77292. export class Sprite {
  77293. /** defines the name */
  77294. name: string;
  77295. /** Gets or sets the current world position */
  77296. position: Vector3;
  77297. /** Gets or sets the main color */
  77298. color: Color4;
  77299. /** Gets or sets the width */
  77300. width: number;
  77301. /** Gets or sets the height */
  77302. height: number;
  77303. /** Gets or sets rotation angle */
  77304. angle: number;
  77305. /** Gets or sets the cell index in the sprite sheet */
  77306. cellIndex: number;
  77307. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  77308. cellRef: string;
  77309. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  77310. invertU: number;
  77311. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  77312. invertV: number;
  77313. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  77314. disposeWhenFinishedAnimating: boolean;
  77315. /** Gets the list of attached animations */
  77316. animations: Animation[];
  77317. /** Gets or sets a boolean indicating if the sprite can be picked */
  77318. isPickable: boolean;
  77319. /**
  77320. * Gets or sets the associated action manager
  77321. */
  77322. actionManager: Nullable<ActionManager>;
  77323. private _animationStarted;
  77324. private _loopAnimation;
  77325. private _fromIndex;
  77326. private _toIndex;
  77327. private _delay;
  77328. private _direction;
  77329. private _manager;
  77330. private _time;
  77331. private _onAnimationEnd;
  77332. /**
  77333. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  77334. */
  77335. isVisible: boolean;
  77336. /**
  77337. * Gets or sets the sprite size
  77338. */
  77339. size: number;
  77340. /**
  77341. * Creates a new Sprite
  77342. * @param name defines the name
  77343. * @param manager defines the manager
  77344. */
  77345. constructor(
  77346. /** defines the name */
  77347. name: string, manager: ISpriteManager);
  77348. /**
  77349. * Starts an animation
  77350. * @param from defines the initial key
  77351. * @param to defines the end key
  77352. * @param loop defines if the animation must loop
  77353. * @param delay defines the start delay (in ms)
  77354. * @param onAnimationEnd defines a callback to call when animation ends
  77355. */
  77356. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  77357. /** Stops current animation (if any) */
  77358. stopAnimation(): void;
  77359. /** @hidden */
  77360. _animate(deltaTime: number): void;
  77361. /** Release associated resources */
  77362. dispose(): void;
  77363. }
  77364. }
  77365. declare module BABYLON {
  77366. /**
  77367. * Information about the result of picking within a scene
  77368. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  77369. */
  77370. export class PickingInfo {
  77371. /** @hidden */
  77372. _pickingUnavailable: boolean;
  77373. /**
  77374. * If the pick collided with an object
  77375. */
  77376. hit: boolean;
  77377. /**
  77378. * Distance away where the pick collided
  77379. */
  77380. distance: number;
  77381. /**
  77382. * The location of pick collision
  77383. */
  77384. pickedPoint: Nullable<Vector3>;
  77385. /**
  77386. * The mesh corresponding the the pick collision
  77387. */
  77388. pickedMesh: Nullable<AbstractMesh>;
  77389. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  77390. bu: number;
  77391. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  77392. bv: number;
  77393. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  77394. faceId: number;
  77395. /** Id of the the submesh that was picked */
  77396. subMeshId: number;
  77397. /** If a sprite was picked, this will be the sprite the pick collided with */
  77398. pickedSprite: Nullable<Sprite>;
  77399. /**
  77400. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  77401. */
  77402. originMesh: Nullable<AbstractMesh>;
  77403. /**
  77404. * The ray that was used to perform the picking.
  77405. */
  77406. ray: Nullable<Ray>;
  77407. /**
  77408. * Gets the normal correspodning to the face the pick collided with
  77409. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  77410. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  77411. * @returns The normal correspodning to the face the pick collided with
  77412. */
  77413. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  77414. /**
  77415. * Gets the texture coordinates of where the pick occured
  77416. * @returns the vector containing the coordnates of the texture
  77417. */
  77418. getTextureCoordinates(): Nullable<Vector2>;
  77419. }
  77420. }
  77421. declare module BABYLON {
  77422. /**
  77423. * Gather the list of pointer event types as constants.
  77424. */
  77425. export class PointerEventTypes {
  77426. /**
  77427. * 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.
  77428. */
  77429. static readonly POINTERDOWN: number;
  77430. /**
  77431. * The pointerup event is fired when a pointer is no longer active.
  77432. */
  77433. static readonly POINTERUP: number;
  77434. /**
  77435. * The pointermove event is fired when a pointer changes coordinates.
  77436. */
  77437. static readonly POINTERMOVE: number;
  77438. /**
  77439. * The pointerwheel event is fired when a mouse wheel has been rotated.
  77440. */
  77441. static readonly POINTERWHEEL: number;
  77442. /**
  77443. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  77444. */
  77445. static readonly POINTERPICK: number;
  77446. /**
  77447. * The pointertap event is fired when a the object has been touched and released without drag.
  77448. */
  77449. static readonly POINTERTAP: number;
  77450. /**
  77451. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  77452. */
  77453. static readonly POINTERDOUBLETAP: number;
  77454. }
  77455. /**
  77456. * Base class of pointer info types.
  77457. */
  77458. export class PointerInfoBase {
  77459. /**
  77460. * Defines the type of event (PointerEventTypes)
  77461. */
  77462. type: number;
  77463. /**
  77464. * Defines the related dom event
  77465. */
  77466. event: PointerEvent | MouseWheelEvent;
  77467. /**
  77468. * Instantiates the base class of pointers info.
  77469. * @param type Defines the type of event (PointerEventTypes)
  77470. * @param event Defines the related dom event
  77471. */
  77472. constructor(
  77473. /**
  77474. * Defines the type of event (PointerEventTypes)
  77475. */
  77476. type: number,
  77477. /**
  77478. * Defines the related dom event
  77479. */
  77480. event: PointerEvent | MouseWheelEvent);
  77481. }
  77482. /**
  77483. * This class is used to store pointer related info for the onPrePointerObservable event.
  77484. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  77485. */
  77486. export class PointerInfoPre extends PointerInfoBase {
  77487. /**
  77488. * Ray from a pointer if availible (eg. 6dof controller)
  77489. */
  77490. ray: Nullable<Ray>;
  77491. /**
  77492. * Defines the local position of the pointer on the canvas.
  77493. */
  77494. localPosition: Vector2;
  77495. /**
  77496. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  77497. */
  77498. skipOnPointerObservable: boolean;
  77499. /**
  77500. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  77501. * @param type Defines the type of event (PointerEventTypes)
  77502. * @param event Defines the related dom event
  77503. * @param localX Defines the local x coordinates of the pointer when the event occured
  77504. * @param localY Defines the local y coordinates of the pointer when the event occured
  77505. */
  77506. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  77507. }
  77508. /**
  77509. * This type contains all the data related to a pointer event in Babylon.js.
  77510. * 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.
  77511. */
  77512. export class PointerInfo extends PointerInfoBase {
  77513. /**
  77514. * Defines the picking info associated to the info (if any)\
  77515. */
  77516. pickInfo: Nullable<PickingInfo>;
  77517. /**
  77518. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  77519. * @param type Defines the type of event (PointerEventTypes)
  77520. * @param event Defines the related dom event
  77521. * @param pickInfo Defines the picking info associated to the info (if any)\
  77522. */
  77523. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  77524. /**
  77525. * Defines the picking info associated to the info (if any)\
  77526. */
  77527. pickInfo: Nullable<PickingInfo>);
  77528. }
  77529. /**
  77530. * Data relating to a touch event on the screen.
  77531. */
  77532. export interface PointerTouch {
  77533. /**
  77534. * X coordinate of touch.
  77535. */
  77536. x: number;
  77537. /**
  77538. * Y coordinate of touch.
  77539. */
  77540. y: number;
  77541. /**
  77542. * Id of touch. Unique for each finger.
  77543. */
  77544. pointerId: number;
  77545. /**
  77546. * Event type passed from DOM.
  77547. */
  77548. type: any;
  77549. }
  77550. }
  77551. declare module BABYLON {
  77552. /**
  77553. * Manage the mouse inputs to control the movement of a free camera.
  77554. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77555. */
  77556. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  77557. /**
  77558. * Define if touch is enabled in the mouse input
  77559. */
  77560. touchEnabled: boolean;
  77561. /**
  77562. * Defines the camera the input is attached to.
  77563. */
  77564. camera: FreeCamera;
  77565. /**
  77566. * Defines the buttons associated with the input to handle camera move.
  77567. */
  77568. buttons: number[];
  77569. /**
  77570. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  77571. */
  77572. angularSensibility: number;
  77573. private _pointerInput;
  77574. private _onMouseMove;
  77575. private _observer;
  77576. private previousPosition;
  77577. /**
  77578. * Observable for when a pointer move event occurs containing the move offset
  77579. */
  77580. onPointerMovedObservable: Observable<{
  77581. offsetX: number;
  77582. offsetY: number;
  77583. }>;
  77584. /**
  77585. * @hidden
  77586. * If the camera should be rotated automatically based on pointer movement
  77587. */
  77588. _allowCameraRotation: boolean;
  77589. /**
  77590. * Manage the mouse inputs to control the movement of a free camera.
  77591. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77592. * @param touchEnabled Defines if touch is enabled or not
  77593. */
  77594. constructor(
  77595. /**
  77596. * Define if touch is enabled in the mouse input
  77597. */
  77598. touchEnabled?: boolean);
  77599. /**
  77600. * Attach the input controls to a specific dom element to get the input from.
  77601. * @param element Defines the element the controls should be listened from
  77602. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77603. */
  77604. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  77605. /**
  77606. * Called on JS contextmenu event.
  77607. * Override this method to provide functionality.
  77608. */
  77609. protected onContextMenu(evt: PointerEvent): void;
  77610. /**
  77611. * Detach the current controls from the specified dom element.
  77612. * @param element Defines the element to stop listening the inputs from
  77613. */
  77614. detachControl(element: Nullable<HTMLElement>): void;
  77615. /**
  77616. * Gets the class name of the current intput.
  77617. * @returns the class name
  77618. */
  77619. getClassName(): string;
  77620. /**
  77621. * Get the friendly name associated with the input class.
  77622. * @returns the input friendly name
  77623. */
  77624. getSimpleName(): string;
  77625. }
  77626. }
  77627. declare module BABYLON {
  77628. /**
  77629. * Manage the touch inputs to control the movement of a free camera.
  77630. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77631. */
  77632. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  77633. /**
  77634. * Defines the camera the input is attached to.
  77635. */
  77636. camera: FreeCamera;
  77637. /**
  77638. * Defines the touch sensibility for rotation.
  77639. * The higher the faster.
  77640. */
  77641. touchAngularSensibility: number;
  77642. /**
  77643. * Defines the touch sensibility for move.
  77644. * The higher the faster.
  77645. */
  77646. touchMoveSensibility: number;
  77647. private _offsetX;
  77648. private _offsetY;
  77649. private _pointerPressed;
  77650. private _pointerInput;
  77651. private _observer;
  77652. private _onLostFocus;
  77653. /**
  77654. * Attach the input controls to a specific dom element to get the input from.
  77655. * @param element Defines the element the controls should be listened from
  77656. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77657. */
  77658. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  77659. /**
  77660. * Detach the current controls from the specified dom element.
  77661. * @param element Defines the element to stop listening the inputs from
  77662. */
  77663. detachControl(element: Nullable<HTMLElement>): void;
  77664. /**
  77665. * Update the current camera state depending on the inputs that have been used this frame.
  77666. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  77667. */
  77668. checkInputs(): void;
  77669. /**
  77670. * Gets the class name of the current intput.
  77671. * @returns the class name
  77672. */
  77673. getClassName(): string;
  77674. /**
  77675. * Get the friendly name associated with the input class.
  77676. * @returns the input friendly name
  77677. */
  77678. getSimpleName(): string;
  77679. }
  77680. }
  77681. declare module BABYLON {
  77682. /**
  77683. * Default Inputs manager for the FreeCamera.
  77684. * It groups all the default supported inputs for ease of use.
  77685. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77686. */
  77687. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  77688. /**
  77689. * @hidden
  77690. */
  77691. _mouseInput: Nullable<FreeCameraMouseInput>;
  77692. /**
  77693. * Instantiates a new FreeCameraInputsManager.
  77694. * @param camera Defines the camera the inputs belong to
  77695. */
  77696. constructor(camera: FreeCamera);
  77697. /**
  77698. * Add keyboard input support to the input manager.
  77699. * @returns the current input manager
  77700. */
  77701. addKeyboard(): FreeCameraInputsManager;
  77702. /**
  77703. * Add mouse input support to the input manager.
  77704. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  77705. * @returns the current input manager
  77706. */
  77707. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  77708. /**
  77709. * Removes the mouse input support from the manager
  77710. * @returns the current input manager
  77711. */
  77712. removeMouse(): FreeCameraInputsManager;
  77713. /**
  77714. * Add touch input support to the input manager.
  77715. * @returns the current input manager
  77716. */
  77717. addTouch(): FreeCameraInputsManager;
  77718. /**
  77719. * Remove all attached input methods from a camera
  77720. */
  77721. clear(): void;
  77722. }
  77723. }
  77724. declare module BABYLON {
  77725. /**
  77726. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  77727. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  77728. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  77729. */
  77730. export class FreeCamera extends TargetCamera {
  77731. /**
  77732. * Define the collision ellipsoid of the camera.
  77733. * This is helpful to simulate a camera body like the player body around the camera
  77734. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  77735. */
  77736. ellipsoid: Vector3;
  77737. /**
  77738. * Define an offset for the position of the ellipsoid around the camera.
  77739. * This can be helpful to determine the center of the body near the gravity center of the body
  77740. * instead of its head.
  77741. */
  77742. ellipsoidOffset: Vector3;
  77743. /**
  77744. * Enable or disable collisions of the camera with the rest of the scene objects.
  77745. */
  77746. checkCollisions: boolean;
  77747. /**
  77748. * Enable or disable gravity on the camera.
  77749. */
  77750. applyGravity: boolean;
  77751. /**
  77752. * Define the input manager associated to the camera.
  77753. */
  77754. inputs: FreeCameraInputsManager;
  77755. /**
  77756. * Gets the input sensibility for a mouse input. (default is 2000.0)
  77757. * Higher values reduce sensitivity.
  77758. */
  77759. /**
  77760. * Sets the input sensibility for a mouse input. (default is 2000.0)
  77761. * Higher values reduce sensitivity.
  77762. */
  77763. angularSensibility: number;
  77764. /**
  77765. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  77766. */
  77767. keysUp: number[];
  77768. /**
  77769. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  77770. */
  77771. keysDown: number[];
  77772. /**
  77773. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  77774. */
  77775. keysLeft: number[];
  77776. /**
  77777. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  77778. */
  77779. keysRight: number[];
  77780. /**
  77781. * Event raised when the camera collide with a mesh in the scene.
  77782. */
  77783. onCollide: (collidedMesh: AbstractMesh) => void;
  77784. private _collider;
  77785. private _needMoveForGravity;
  77786. private _oldPosition;
  77787. private _diffPosition;
  77788. private _newPosition;
  77789. /** @hidden */
  77790. _localDirection: Vector3;
  77791. /** @hidden */
  77792. _transformedDirection: Vector3;
  77793. /**
  77794. * Instantiates a Free Camera.
  77795. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  77796. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  77797. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  77798. * @param name Define the name of the camera in the scene
  77799. * @param position Define the start position of the camera in the scene
  77800. * @param scene Define the scene the camera belongs to
  77801. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  77802. */
  77803. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  77804. /**
  77805. * Attached controls to the current camera.
  77806. * @param element Defines the element the controls should be listened from
  77807. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77808. */
  77809. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  77810. /**
  77811. * Detach the current controls from the camera.
  77812. * The camera will stop reacting to inputs.
  77813. * @param element Defines the element to stop listening the inputs from
  77814. */
  77815. detachControl(element: HTMLElement): void;
  77816. private _collisionMask;
  77817. /**
  77818. * Define a collision mask to limit the list of object the camera can collide with
  77819. */
  77820. collisionMask: number;
  77821. /** @hidden */
  77822. _collideWithWorld(displacement: Vector3): void;
  77823. private _onCollisionPositionChange;
  77824. /** @hidden */
  77825. _checkInputs(): void;
  77826. /** @hidden */
  77827. _decideIfNeedsToMove(): boolean;
  77828. /** @hidden */
  77829. _updatePosition(): void;
  77830. /**
  77831. * Destroy the camera and release the current resources hold by it.
  77832. */
  77833. dispose(): void;
  77834. /**
  77835. * Gets the current object class name.
  77836. * @return the class name
  77837. */
  77838. getClassName(): string;
  77839. }
  77840. }
  77841. declare module BABYLON {
  77842. /**
  77843. * Represents a gamepad control stick position
  77844. */
  77845. export class StickValues {
  77846. /**
  77847. * The x component of the control stick
  77848. */
  77849. x: number;
  77850. /**
  77851. * The y component of the control stick
  77852. */
  77853. y: number;
  77854. /**
  77855. * Initializes the gamepad x and y control stick values
  77856. * @param x The x component of the gamepad control stick value
  77857. * @param y The y component of the gamepad control stick value
  77858. */
  77859. constructor(
  77860. /**
  77861. * The x component of the control stick
  77862. */
  77863. x: number,
  77864. /**
  77865. * The y component of the control stick
  77866. */
  77867. y: number);
  77868. }
  77869. /**
  77870. * An interface which manages callbacks for gamepad button changes
  77871. */
  77872. export interface GamepadButtonChanges {
  77873. /**
  77874. * Called when a gamepad has been changed
  77875. */
  77876. changed: boolean;
  77877. /**
  77878. * Called when a gamepad press event has been triggered
  77879. */
  77880. pressChanged: boolean;
  77881. /**
  77882. * Called when a touch event has been triggered
  77883. */
  77884. touchChanged: boolean;
  77885. /**
  77886. * Called when a value has changed
  77887. */
  77888. valueChanged: boolean;
  77889. }
  77890. /**
  77891. * Represents a gamepad
  77892. */
  77893. export class Gamepad {
  77894. /**
  77895. * The id of the gamepad
  77896. */
  77897. id: string;
  77898. /**
  77899. * The index of the gamepad
  77900. */
  77901. index: number;
  77902. /**
  77903. * The browser gamepad
  77904. */
  77905. browserGamepad: any;
  77906. /**
  77907. * Specifies what type of gamepad this represents
  77908. */
  77909. type: number;
  77910. private _leftStick;
  77911. private _rightStick;
  77912. /** @hidden */
  77913. _isConnected: boolean;
  77914. private _leftStickAxisX;
  77915. private _leftStickAxisY;
  77916. private _rightStickAxisX;
  77917. private _rightStickAxisY;
  77918. /**
  77919. * Triggered when the left control stick has been changed
  77920. */
  77921. private _onleftstickchanged;
  77922. /**
  77923. * Triggered when the right control stick has been changed
  77924. */
  77925. private _onrightstickchanged;
  77926. /**
  77927. * Represents a gamepad controller
  77928. */
  77929. static GAMEPAD: number;
  77930. /**
  77931. * Represents a generic controller
  77932. */
  77933. static GENERIC: number;
  77934. /**
  77935. * Represents an XBox controller
  77936. */
  77937. static XBOX: number;
  77938. /**
  77939. * Represents a pose-enabled controller
  77940. */
  77941. static POSE_ENABLED: number;
  77942. /**
  77943. * Represents an Dual Shock controller
  77944. */
  77945. static DUALSHOCK: number;
  77946. /**
  77947. * Specifies whether the left control stick should be Y-inverted
  77948. */
  77949. protected _invertLeftStickY: boolean;
  77950. /**
  77951. * Specifies if the gamepad has been connected
  77952. */
  77953. readonly isConnected: boolean;
  77954. /**
  77955. * Initializes the gamepad
  77956. * @param id The id of the gamepad
  77957. * @param index The index of the gamepad
  77958. * @param browserGamepad The browser gamepad
  77959. * @param leftStickX The x component of the left joystick
  77960. * @param leftStickY The y component of the left joystick
  77961. * @param rightStickX The x component of the right joystick
  77962. * @param rightStickY The y component of the right joystick
  77963. */
  77964. constructor(
  77965. /**
  77966. * The id of the gamepad
  77967. */
  77968. id: string,
  77969. /**
  77970. * The index of the gamepad
  77971. */
  77972. index: number,
  77973. /**
  77974. * The browser gamepad
  77975. */
  77976. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  77977. /**
  77978. * Callback triggered when the left joystick has changed
  77979. * @param callback
  77980. */
  77981. onleftstickchanged(callback: (values: StickValues) => void): void;
  77982. /**
  77983. * Callback triggered when the right joystick has changed
  77984. * @param callback
  77985. */
  77986. onrightstickchanged(callback: (values: StickValues) => void): void;
  77987. /**
  77988. * Gets the left joystick
  77989. */
  77990. /**
  77991. * Sets the left joystick values
  77992. */
  77993. leftStick: StickValues;
  77994. /**
  77995. * Gets the right joystick
  77996. */
  77997. /**
  77998. * Sets the right joystick value
  77999. */
  78000. rightStick: StickValues;
  78001. /**
  78002. * Updates the gamepad joystick positions
  78003. */
  78004. update(): void;
  78005. /**
  78006. * Disposes the gamepad
  78007. */
  78008. dispose(): void;
  78009. }
  78010. /**
  78011. * Represents a generic gamepad
  78012. */
  78013. export class GenericPad extends Gamepad {
  78014. private _buttons;
  78015. private _onbuttondown;
  78016. private _onbuttonup;
  78017. /**
  78018. * Observable triggered when a button has been pressed
  78019. */
  78020. onButtonDownObservable: Observable<number>;
  78021. /**
  78022. * Observable triggered when a button has been released
  78023. */
  78024. onButtonUpObservable: Observable<number>;
  78025. /**
  78026. * Callback triggered when a button has been pressed
  78027. * @param callback Called when a button has been pressed
  78028. */
  78029. onbuttondown(callback: (buttonPressed: number) => void): void;
  78030. /**
  78031. * Callback triggered when a button has been released
  78032. * @param callback Called when a button has been released
  78033. */
  78034. onbuttonup(callback: (buttonReleased: number) => void): void;
  78035. /**
  78036. * Initializes the generic gamepad
  78037. * @param id The id of the generic gamepad
  78038. * @param index The index of the generic gamepad
  78039. * @param browserGamepad The browser gamepad
  78040. */
  78041. constructor(id: string, index: number, browserGamepad: any);
  78042. private _setButtonValue;
  78043. /**
  78044. * Updates the generic gamepad
  78045. */
  78046. update(): void;
  78047. /**
  78048. * Disposes the generic gamepad
  78049. */
  78050. dispose(): void;
  78051. }
  78052. }
  78053. declare module BABYLON {
  78054. interface Engine {
  78055. /**
  78056. * Creates a raw texture
  78057. * @param data defines the data to store in the texture
  78058. * @param width defines the width of the texture
  78059. * @param height defines the height of the texture
  78060. * @param format defines the format of the data
  78061. * @param generateMipMaps defines if the engine should generate the mip levels
  78062. * @param invertY defines if data must be stored with Y axis inverted
  78063. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  78064. * @param compression defines the compression used (null by default)
  78065. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78066. * @returns the raw texture inside an InternalTexture
  78067. */
  78068. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  78069. /**
  78070. * Update a raw texture
  78071. * @param texture defines the texture to update
  78072. * @param data defines the data to store in the texture
  78073. * @param format defines the format of the data
  78074. * @param invertY defines if data must be stored with Y axis inverted
  78075. */
  78076. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78077. /**
  78078. * Update a raw texture
  78079. * @param texture defines the texture to update
  78080. * @param data defines the data to store in the texture
  78081. * @param format defines the format of the data
  78082. * @param invertY defines if data must be stored with Y axis inverted
  78083. * @param compression defines the compression used (null by default)
  78084. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78085. */
  78086. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  78087. /**
  78088. * Creates a new raw cube texture
  78089. * @param data defines the array of data to use to create each face
  78090. * @param size defines the size of the textures
  78091. * @param format defines the format of the data
  78092. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78093. * @param generateMipMaps defines if the engine should generate the mip levels
  78094. * @param invertY defines if data must be stored with Y axis inverted
  78095. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78096. * @param compression defines the compression used (null by default)
  78097. * @returns the cube texture as an InternalTexture
  78098. */
  78099. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  78100. /**
  78101. * Update a raw cube texture
  78102. * @param texture defines the texture to udpdate
  78103. * @param data defines the data to store
  78104. * @param format defines the data format
  78105. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78106. * @param invertY defines if data must be stored with Y axis inverted
  78107. */
  78108. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  78109. /**
  78110. * Update a raw cube texture
  78111. * @param texture defines the texture to udpdate
  78112. * @param data defines the data to store
  78113. * @param format defines the data format
  78114. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78115. * @param invertY defines if data must be stored with Y axis inverted
  78116. * @param compression defines the compression used (null by default)
  78117. */
  78118. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  78119. /**
  78120. * Update a raw cube texture
  78121. * @param texture defines the texture to udpdate
  78122. * @param data defines the data to store
  78123. * @param format defines the data format
  78124. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78125. * @param invertY defines if data must be stored with Y axis inverted
  78126. * @param compression defines the compression used (null by default)
  78127. * @param level defines which level of the texture to update
  78128. */
  78129. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  78130. /**
  78131. * Creates a new raw cube texture from a specified url
  78132. * @param url defines the url where the data is located
  78133. * @param scene defines the current scene
  78134. * @param size defines the size of the textures
  78135. * @param format defines the format of the data
  78136. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78137. * @param noMipmap defines if the engine should avoid generating the mip levels
  78138. * @param callback defines a callback used to extract texture data from loaded data
  78139. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78140. * @param onLoad defines a callback called when texture is loaded
  78141. * @param onError defines a callback called if there is an error
  78142. * @returns the cube texture as an InternalTexture
  78143. */
  78144. 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;
  78145. /**
  78146. * Creates a new raw cube texture from a specified url
  78147. * @param url defines the url where the data is located
  78148. * @param scene defines the current scene
  78149. * @param size defines the size of the textures
  78150. * @param format defines the format of the data
  78151. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78152. * @param noMipmap defines if the engine should avoid generating the mip levels
  78153. * @param callback defines a callback used to extract texture data from loaded data
  78154. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78155. * @param onLoad defines a callback called when texture is loaded
  78156. * @param onError defines a callback called if there is an error
  78157. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78158. * @param invertY defines if data must be stored with Y axis inverted
  78159. * @returns the cube texture as an InternalTexture
  78160. */
  78161. 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;
  78162. /**
  78163. * Creates a new raw 3D texture
  78164. * @param data defines the data used to create the texture
  78165. * @param width defines the width of the texture
  78166. * @param height defines the height of the texture
  78167. * @param depth defines the depth of the texture
  78168. * @param format defines the format of the texture
  78169. * @param generateMipMaps defines if the engine must generate mip levels
  78170. * @param invertY defines if data must be stored with Y axis inverted
  78171. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78172. * @param compression defines the compressed used (can be null)
  78173. * @param textureType defines the compressed used (can be null)
  78174. * @returns a new raw 3D texture (stored in an InternalTexture)
  78175. */
  78176. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  78177. /**
  78178. * Update a raw 3D texture
  78179. * @param texture defines the texture to update
  78180. * @param data defines the data to store
  78181. * @param format defines the data format
  78182. * @param invertY defines if data must be stored with Y axis inverted
  78183. */
  78184. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78185. /**
  78186. * Update a raw 3D texture
  78187. * @param texture defines the texture to update
  78188. * @param data defines the data to store
  78189. * @param format defines the data format
  78190. * @param invertY defines if data must be stored with Y axis inverted
  78191. * @param compression defines the used compression (can be null)
  78192. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  78193. */
  78194. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  78195. }
  78196. }
  78197. declare module BABYLON {
  78198. /**
  78199. * Raw texture can help creating a texture directly from an array of data.
  78200. * This can be super useful if you either get the data from an uncompressed source or
  78201. * if you wish to create your texture pixel by pixel.
  78202. */
  78203. export class RawTexture extends Texture {
  78204. /**
  78205. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78206. */
  78207. format: number;
  78208. private _engine;
  78209. /**
  78210. * Instantiates a new RawTexture.
  78211. * Raw texture can help creating a texture directly from an array of data.
  78212. * This can be super useful if you either get the data from an uncompressed source or
  78213. * if you wish to create your texture pixel by pixel.
  78214. * @param data define the array of data to use to create the texture
  78215. * @param width define the width of the texture
  78216. * @param height define the height of the texture
  78217. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78218. * @param scene define the scene the texture belongs to
  78219. * @param generateMipMaps define whether mip maps should be generated or not
  78220. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78221. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78222. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78223. */
  78224. constructor(data: ArrayBufferView, width: number, height: number,
  78225. /**
  78226. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78227. */
  78228. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  78229. /**
  78230. * Updates the texture underlying data.
  78231. * @param data Define the new data of the texture
  78232. */
  78233. update(data: ArrayBufferView): void;
  78234. /**
  78235. * Creates a luminance texture from some data.
  78236. * @param data Define the texture data
  78237. * @param width Define the width of the texture
  78238. * @param height Define the height of the texture
  78239. * @param scene Define the scene the texture belongs to
  78240. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78241. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78242. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78243. * @returns the luminance texture
  78244. */
  78245. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78246. /**
  78247. * Creates a luminance alpha texture from some data.
  78248. * @param data Define the texture data
  78249. * @param width Define the width of the texture
  78250. * @param height Define the height of the texture
  78251. * @param scene Define the scene the texture belongs to
  78252. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78253. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78254. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78255. * @returns the luminance alpha texture
  78256. */
  78257. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78258. /**
  78259. * Creates an alpha texture from some data.
  78260. * @param data Define the texture data
  78261. * @param width Define the width of the texture
  78262. * @param height Define the height of the texture
  78263. * @param scene Define the scene the texture belongs to
  78264. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78265. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78266. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78267. * @returns the alpha texture
  78268. */
  78269. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78270. /**
  78271. * Creates a RGB texture from some data.
  78272. * @param data Define the texture data
  78273. * @param width Define the width of the texture
  78274. * @param height Define the height of the texture
  78275. * @param scene Define the scene the texture belongs to
  78276. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78277. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78278. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78279. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78280. * @returns the RGB alpha texture
  78281. */
  78282. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78283. /**
  78284. * Creates a RGBA texture from some data.
  78285. * @param data Define the texture data
  78286. * @param width Define the width of the texture
  78287. * @param height Define the height of the texture
  78288. * @param scene Define the scene the texture belongs to
  78289. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78290. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78291. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78292. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78293. * @returns the RGBA texture
  78294. */
  78295. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78296. /**
  78297. * Creates a R texture from some data.
  78298. * @param data Define the texture data
  78299. * @param width Define the width of the texture
  78300. * @param height Define the height of the texture
  78301. * @param scene Define the scene the texture belongs to
  78302. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78303. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78304. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78305. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78306. * @returns the R texture
  78307. */
  78308. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78309. }
  78310. }
  78311. declare module BABYLON {
  78312. /**
  78313. * Interface for the size containing width and height
  78314. */
  78315. export interface ISize {
  78316. /**
  78317. * Width
  78318. */
  78319. width: number;
  78320. /**
  78321. * Heighht
  78322. */
  78323. height: number;
  78324. }
  78325. /**
  78326. * Size containing widht and height
  78327. */
  78328. export class Size implements ISize {
  78329. /**
  78330. * Width
  78331. */
  78332. width: number;
  78333. /**
  78334. * Height
  78335. */
  78336. height: number;
  78337. /**
  78338. * Creates a Size object from the given width and height (floats).
  78339. * @param width width of the new size
  78340. * @param height height of the new size
  78341. */
  78342. constructor(width: number, height: number);
  78343. /**
  78344. * Returns a string with the Size width and height
  78345. * @returns a string with the Size width and height
  78346. */
  78347. toString(): string;
  78348. /**
  78349. * "Size"
  78350. * @returns the string "Size"
  78351. */
  78352. getClassName(): string;
  78353. /**
  78354. * Returns the Size hash code.
  78355. * @returns a hash code for a unique width and height
  78356. */
  78357. getHashCode(): number;
  78358. /**
  78359. * Updates the current size from the given one.
  78360. * @param src the given size
  78361. */
  78362. copyFrom(src: Size): void;
  78363. /**
  78364. * Updates in place the current Size from the given floats.
  78365. * @param width width of the new size
  78366. * @param height height of the new size
  78367. * @returns the updated Size.
  78368. */
  78369. copyFromFloats(width: number, height: number): Size;
  78370. /**
  78371. * Updates in place the current Size from the given floats.
  78372. * @param width width to set
  78373. * @param height height to set
  78374. * @returns the updated Size.
  78375. */
  78376. set(width: number, height: number): Size;
  78377. /**
  78378. * Multiplies the width and height by numbers
  78379. * @param w factor to multiple the width by
  78380. * @param h factor to multiple the height by
  78381. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  78382. */
  78383. multiplyByFloats(w: number, h: number): Size;
  78384. /**
  78385. * Clones the size
  78386. * @returns a new Size copied from the given one.
  78387. */
  78388. clone(): Size;
  78389. /**
  78390. * True if the current Size and the given one width and height are strictly equal.
  78391. * @param other the other size to compare against
  78392. * @returns True if the current Size and the given one width and height are strictly equal.
  78393. */
  78394. equals(other: Size): boolean;
  78395. /**
  78396. * The surface of the Size : width * height (float).
  78397. */
  78398. readonly surface: number;
  78399. /**
  78400. * Create a new size of zero
  78401. * @returns a new Size set to (0.0, 0.0)
  78402. */
  78403. static Zero(): Size;
  78404. /**
  78405. * Sums the width and height of two sizes
  78406. * @param otherSize size to add to this size
  78407. * @returns a new Size set as the addition result of the current Size and the given one.
  78408. */
  78409. add(otherSize: Size): Size;
  78410. /**
  78411. * Subtracts the width and height of two
  78412. * @param otherSize size to subtract to this size
  78413. * @returns a new Size set as the subtraction result of the given one from the current Size.
  78414. */
  78415. subtract(otherSize: Size): Size;
  78416. /**
  78417. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  78418. * @param start starting size to lerp between
  78419. * @param end end size to lerp between
  78420. * @param amount amount to lerp between the start and end values
  78421. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  78422. */
  78423. static Lerp(start: Size, end: Size, amount: number): Size;
  78424. }
  78425. }
  78426. declare module BABYLON {
  78427. /**
  78428. * Defines a runtime animation
  78429. */
  78430. export class RuntimeAnimation {
  78431. private _events;
  78432. /**
  78433. * The current frame of the runtime animation
  78434. */
  78435. private _currentFrame;
  78436. /**
  78437. * The animation used by the runtime animation
  78438. */
  78439. private _animation;
  78440. /**
  78441. * The target of the runtime animation
  78442. */
  78443. private _target;
  78444. /**
  78445. * The initiating animatable
  78446. */
  78447. private _host;
  78448. /**
  78449. * The original value of the runtime animation
  78450. */
  78451. private _originalValue;
  78452. /**
  78453. * The original blend value of the runtime animation
  78454. */
  78455. private _originalBlendValue;
  78456. /**
  78457. * The offsets cache of the runtime animation
  78458. */
  78459. private _offsetsCache;
  78460. /**
  78461. * The high limits cache of the runtime animation
  78462. */
  78463. private _highLimitsCache;
  78464. /**
  78465. * Specifies if the runtime animation has been stopped
  78466. */
  78467. private _stopped;
  78468. /**
  78469. * The blending factor of the runtime animation
  78470. */
  78471. private _blendingFactor;
  78472. /**
  78473. * The BabylonJS scene
  78474. */
  78475. private _scene;
  78476. /**
  78477. * The current value of the runtime animation
  78478. */
  78479. private _currentValue;
  78480. /** @hidden */
  78481. _animationState: _IAnimationState;
  78482. /**
  78483. * The active target of the runtime animation
  78484. */
  78485. private _activeTargets;
  78486. private _currentActiveTarget;
  78487. private _directTarget;
  78488. /**
  78489. * The target path of the runtime animation
  78490. */
  78491. private _targetPath;
  78492. /**
  78493. * The weight of the runtime animation
  78494. */
  78495. private _weight;
  78496. /**
  78497. * The ratio offset of the runtime animation
  78498. */
  78499. private _ratioOffset;
  78500. /**
  78501. * The previous delay of the runtime animation
  78502. */
  78503. private _previousDelay;
  78504. /**
  78505. * The previous ratio of the runtime animation
  78506. */
  78507. private _previousRatio;
  78508. private _enableBlending;
  78509. private _keys;
  78510. private _minFrame;
  78511. private _maxFrame;
  78512. private _minValue;
  78513. private _maxValue;
  78514. private _targetIsArray;
  78515. /**
  78516. * Gets the current frame of the runtime animation
  78517. */
  78518. readonly currentFrame: number;
  78519. /**
  78520. * Gets the weight of the runtime animation
  78521. */
  78522. readonly weight: number;
  78523. /**
  78524. * Gets the current value of the runtime animation
  78525. */
  78526. readonly currentValue: any;
  78527. /**
  78528. * Gets the target path of the runtime animation
  78529. */
  78530. readonly targetPath: string;
  78531. /**
  78532. * Gets the actual target of the runtime animation
  78533. */
  78534. readonly target: any;
  78535. /** @hidden */
  78536. _onLoop: () => void;
  78537. /**
  78538. * Create a new RuntimeAnimation object
  78539. * @param target defines the target of the animation
  78540. * @param animation defines the source animation object
  78541. * @param scene defines the hosting scene
  78542. * @param host defines the initiating Animatable
  78543. */
  78544. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  78545. private _preparePath;
  78546. /**
  78547. * Gets the animation from the runtime animation
  78548. */
  78549. readonly animation: Animation;
  78550. /**
  78551. * Resets the runtime animation to the beginning
  78552. * @param restoreOriginal defines whether to restore the target property to the original value
  78553. */
  78554. reset(restoreOriginal?: boolean): void;
  78555. /**
  78556. * Specifies if the runtime animation is stopped
  78557. * @returns Boolean specifying if the runtime animation is stopped
  78558. */
  78559. isStopped(): boolean;
  78560. /**
  78561. * Disposes of the runtime animation
  78562. */
  78563. dispose(): void;
  78564. /**
  78565. * Apply the interpolated value to the target
  78566. * @param currentValue defines the value computed by the animation
  78567. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  78568. */
  78569. setValue(currentValue: any, weight: number): void;
  78570. private _getOriginalValues;
  78571. private _setValue;
  78572. /**
  78573. * Gets the loop pmode of the runtime animation
  78574. * @returns Loop Mode
  78575. */
  78576. private _getCorrectLoopMode;
  78577. /**
  78578. * Move the current animation to a given frame
  78579. * @param frame defines the frame to move to
  78580. */
  78581. goToFrame(frame: number): void;
  78582. /**
  78583. * @hidden Internal use only
  78584. */
  78585. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  78586. /**
  78587. * Execute the current animation
  78588. * @param delay defines the delay to add to the current frame
  78589. * @param from defines the lower bound of the animation range
  78590. * @param to defines the upper bound of the animation range
  78591. * @param loop defines if the current animation must loop
  78592. * @param speedRatio defines the current speed ratio
  78593. * @param weight defines the weight of the animation (default is -1 so no weight)
  78594. * @param onLoop optional callback called when animation loops
  78595. * @returns a boolean indicating if the animation is running
  78596. */
  78597. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  78598. }
  78599. }
  78600. declare module BABYLON {
  78601. /**
  78602. * Class used to store an actual running animation
  78603. */
  78604. export class Animatable {
  78605. /** defines the target object */
  78606. target: any;
  78607. /** defines the starting frame number (default is 0) */
  78608. fromFrame: number;
  78609. /** defines the ending frame number (default is 100) */
  78610. toFrame: number;
  78611. /** defines if the animation must loop (default is false) */
  78612. loopAnimation: boolean;
  78613. /** defines a callback to call when animation ends if it is not looping */
  78614. onAnimationEnd?: (() => void) | null | undefined;
  78615. /** defines a callback to call when animation loops */
  78616. onAnimationLoop?: (() => void) | null | undefined;
  78617. private _localDelayOffset;
  78618. private _pausedDelay;
  78619. private _runtimeAnimations;
  78620. private _paused;
  78621. private _scene;
  78622. private _speedRatio;
  78623. private _weight;
  78624. private _syncRoot;
  78625. /**
  78626. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  78627. * This will only apply for non looping animation (default is true)
  78628. */
  78629. disposeOnEnd: boolean;
  78630. /**
  78631. * Gets a boolean indicating if the animation has started
  78632. */
  78633. animationStarted: boolean;
  78634. /**
  78635. * Observer raised when the animation ends
  78636. */
  78637. onAnimationEndObservable: Observable<Animatable>;
  78638. /**
  78639. * Observer raised when the animation loops
  78640. */
  78641. onAnimationLoopObservable: Observable<Animatable>;
  78642. /**
  78643. * Gets the root Animatable used to synchronize and normalize animations
  78644. */
  78645. readonly syncRoot: Nullable<Animatable>;
  78646. /**
  78647. * Gets the current frame of the first RuntimeAnimation
  78648. * Used to synchronize Animatables
  78649. */
  78650. readonly masterFrame: number;
  78651. /**
  78652. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  78653. */
  78654. weight: number;
  78655. /**
  78656. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  78657. */
  78658. speedRatio: number;
  78659. /**
  78660. * Creates a new Animatable
  78661. * @param scene defines the hosting scene
  78662. * @param target defines the target object
  78663. * @param fromFrame defines the starting frame number (default is 0)
  78664. * @param toFrame defines the ending frame number (default is 100)
  78665. * @param loopAnimation defines if the animation must loop (default is false)
  78666. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  78667. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  78668. * @param animations defines a group of animation to add to the new Animatable
  78669. * @param onAnimationLoop defines a callback to call when animation loops
  78670. */
  78671. constructor(scene: Scene,
  78672. /** defines the target object */
  78673. target: any,
  78674. /** defines the starting frame number (default is 0) */
  78675. fromFrame?: number,
  78676. /** defines the ending frame number (default is 100) */
  78677. toFrame?: number,
  78678. /** defines if the animation must loop (default is false) */
  78679. loopAnimation?: boolean, speedRatio?: number,
  78680. /** defines a callback to call when animation ends if it is not looping */
  78681. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  78682. /** defines a callback to call when animation loops */
  78683. onAnimationLoop?: (() => void) | null | undefined);
  78684. /**
  78685. * Synchronize and normalize current Animatable with a source Animatable
  78686. * This is useful when using animation weights and when animations are not of the same length
  78687. * @param root defines the root Animatable to synchronize with
  78688. * @returns the current Animatable
  78689. */
  78690. syncWith(root: Animatable): Animatable;
  78691. /**
  78692. * Gets the list of runtime animations
  78693. * @returns an array of RuntimeAnimation
  78694. */
  78695. getAnimations(): RuntimeAnimation[];
  78696. /**
  78697. * Adds more animations to the current animatable
  78698. * @param target defines the target of the animations
  78699. * @param animations defines the new animations to add
  78700. */
  78701. appendAnimations(target: any, animations: Animation[]): void;
  78702. /**
  78703. * Gets the source animation for a specific property
  78704. * @param property defines the propertyu to look for
  78705. * @returns null or the source animation for the given property
  78706. */
  78707. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  78708. /**
  78709. * Gets the runtime animation for a specific property
  78710. * @param property defines the propertyu to look for
  78711. * @returns null or the runtime animation for the given property
  78712. */
  78713. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  78714. /**
  78715. * Resets the animatable to its original state
  78716. */
  78717. reset(): void;
  78718. /**
  78719. * Allows the animatable to blend with current running animations
  78720. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78721. * @param blendingSpeed defines the blending speed to use
  78722. */
  78723. enableBlending(blendingSpeed: number): void;
  78724. /**
  78725. * Disable animation blending
  78726. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78727. */
  78728. disableBlending(): void;
  78729. /**
  78730. * Jump directly to a given frame
  78731. * @param frame defines the frame to jump to
  78732. */
  78733. goToFrame(frame: number): void;
  78734. /**
  78735. * Pause the animation
  78736. */
  78737. pause(): void;
  78738. /**
  78739. * Restart the animation
  78740. */
  78741. restart(): void;
  78742. private _raiseOnAnimationEnd;
  78743. /**
  78744. * Stop and delete the current animation
  78745. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  78746. * @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)
  78747. */
  78748. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  78749. /**
  78750. * Wait asynchronously for the animation to end
  78751. * @returns a promise which will be fullfilled when the animation ends
  78752. */
  78753. waitAsync(): Promise<Animatable>;
  78754. /** @hidden */
  78755. _animate(delay: number): boolean;
  78756. }
  78757. interface Scene {
  78758. /** @hidden */
  78759. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  78760. /** @hidden */
  78761. _processLateAnimationBindingsForMatrices(holder: {
  78762. totalWeight: number;
  78763. animations: RuntimeAnimation[];
  78764. originalValue: Matrix;
  78765. }): any;
  78766. /** @hidden */
  78767. _processLateAnimationBindingsForQuaternions(holder: {
  78768. totalWeight: number;
  78769. animations: RuntimeAnimation[];
  78770. originalValue: Quaternion;
  78771. }, refQuaternion: Quaternion): Quaternion;
  78772. /** @hidden */
  78773. _processLateAnimationBindings(): void;
  78774. /**
  78775. * Will start the animation sequence of a given target
  78776. * @param target defines the target
  78777. * @param from defines from which frame should animation start
  78778. * @param to defines until which frame should animation run.
  78779. * @param weight defines the weight to apply to the animation (1.0 by default)
  78780. * @param loop defines if the animation loops
  78781. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78782. * @param onAnimationEnd defines the function to be executed when the animation ends
  78783. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78784. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78785. * @param onAnimationLoop defines the callback to call when an animation loops
  78786. * @returns the animatable object created for this animation
  78787. */
  78788. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78789. /**
  78790. * Will start the animation sequence of a given target
  78791. * @param target defines the target
  78792. * @param from defines from which frame should animation start
  78793. * @param to defines until which frame should animation run.
  78794. * @param loop defines if the animation loops
  78795. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78796. * @param onAnimationEnd defines the function to be executed when the animation ends
  78797. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78798. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78799. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  78800. * @param onAnimationLoop defines the callback to call when an animation loops
  78801. * @returns the animatable object created for this animation
  78802. */
  78803. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78804. /**
  78805. * Will start the animation sequence of a given target and its hierarchy
  78806. * @param target defines the target
  78807. * @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.
  78808. * @param from defines from which frame should animation start
  78809. * @param to defines until which frame should animation run.
  78810. * @param loop defines if the animation loops
  78811. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78812. * @param onAnimationEnd defines the function to be executed when the animation ends
  78813. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78814. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78815. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78816. * @param onAnimationLoop defines the callback to call when an animation loops
  78817. * @returns the list of created animatables
  78818. */
  78819. 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[];
  78820. /**
  78821. * Begin a new animation on a given node
  78822. * @param target defines the target where the animation will take place
  78823. * @param animations defines the list of animations to start
  78824. * @param from defines the initial value
  78825. * @param to defines the final value
  78826. * @param loop defines if you want animation to loop (off by default)
  78827. * @param speedRatio defines the speed ratio to apply to all animations
  78828. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78829. * @param onAnimationLoop defines the callback to call when an animation loops
  78830. * @returns the list of created animatables
  78831. */
  78832. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  78833. /**
  78834. * Begin a new animation on a given node and its hierarchy
  78835. * @param target defines the root node where the animation will take place
  78836. * @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.
  78837. * @param animations defines the list of animations to start
  78838. * @param from defines the initial value
  78839. * @param to defines the final value
  78840. * @param loop defines if you want animation to loop (off by default)
  78841. * @param speedRatio defines the speed ratio to apply to all animations
  78842. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78843. * @param onAnimationLoop defines the callback to call when an animation loops
  78844. * @returns the list of animatables created for all nodes
  78845. */
  78846. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  78847. /**
  78848. * Gets the animatable associated with a specific target
  78849. * @param target defines the target of the animatable
  78850. * @returns the required animatable if found
  78851. */
  78852. getAnimatableByTarget(target: any): Nullable<Animatable>;
  78853. /**
  78854. * Gets all animatables associated with a given target
  78855. * @param target defines the target to look animatables for
  78856. * @returns an array of Animatables
  78857. */
  78858. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  78859. /**
  78860. * Stops and removes all animations that have been applied to the scene
  78861. */
  78862. stopAllAnimations(): void;
  78863. }
  78864. interface Bone {
  78865. /**
  78866. * Copy an animation range from another bone
  78867. * @param source defines the source bone
  78868. * @param rangeName defines the range name to copy
  78869. * @param frameOffset defines the frame offset
  78870. * @param rescaleAsRequired defines if rescaling must be applied if required
  78871. * @param skelDimensionsRatio defines the scaling ratio
  78872. * @returns true if operation was successful
  78873. */
  78874. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  78875. }
  78876. }
  78877. declare module BABYLON {
  78878. /**
  78879. * Class used to override all child animations of a given target
  78880. */
  78881. export class AnimationPropertiesOverride {
  78882. /**
  78883. * Gets or sets a value indicating if animation blending must be used
  78884. */
  78885. enableBlending: boolean;
  78886. /**
  78887. * Gets or sets the blending speed to use when enableBlending is true
  78888. */
  78889. blendingSpeed: number;
  78890. /**
  78891. * Gets or sets the default loop mode to use
  78892. */
  78893. loopMode: number;
  78894. }
  78895. }
  78896. declare module BABYLON {
  78897. /**
  78898. * Class used to handle skinning animations
  78899. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  78900. */
  78901. export class Skeleton implements IAnimatable {
  78902. /** defines the skeleton name */
  78903. name: string;
  78904. /** defines the skeleton Id */
  78905. id: string;
  78906. /**
  78907. * Defines the list of child bones
  78908. */
  78909. bones: Bone[];
  78910. /**
  78911. * Defines an estimate of the dimension of the skeleton at rest
  78912. */
  78913. dimensionsAtRest: Vector3;
  78914. /**
  78915. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  78916. */
  78917. needInitialSkinMatrix: boolean;
  78918. /**
  78919. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  78920. */
  78921. overrideMesh: Nullable<AbstractMesh>;
  78922. /**
  78923. * Gets the list of animations attached to this skeleton
  78924. */
  78925. animations: Array<Animation>;
  78926. private _scene;
  78927. private _isDirty;
  78928. private _transformMatrices;
  78929. private _transformMatrixTexture;
  78930. private _meshesWithPoseMatrix;
  78931. private _animatables;
  78932. private _identity;
  78933. private _synchronizedWithMesh;
  78934. private _ranges;
  78935. private _lastAbsoluteTransformsUpdateId;
  78936. private _canUseTextureForBones;
  78937. private _uniqueId;
  78938. /** @hidden */
  78939. _numBonesWithLinkedTransformNode: number;
  78940. /** @hidden */
  78941. _hasWaitingData: Nullable<boolean>;
  78942. /**
  78943. * Specifies if the skeleton should be serialized
  78944. */
  78945. doNotSerialize: boolean;
  78946. private _useTextureToStoreBoneMatrices;
  78947. /**
  78948. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  78949. * Please note that this option is not available if the hardware does not support it
  78950. */
  78951. useTextureToStoreBoneMatrices: boolean;
  78952. private _animationPropertiesOverride;
  78953. /**
  78954. * Gets or sets the animation properties override
  78955. */
  78956. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  78957. /**
  78958. * List of inspectable custom properties (used by the Inspector)
  78959. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78960. */
  78961. inspectableCustomProperties: IInspectable[];
  78962. /**
  78963. * An observable triggered before computing the skeleton's matrices
  78964. */
  78965. onBeforeComputeObservable: Observable<Skeleton>;
  78966. /**
  78967. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  78968. */
  78969. readonly isUsingTextureForMatrices: boolean;
  78970. /**
  78971. * Gets the unique ID of this skeleton
  78972. */
  78973. readonly uniqueId: number;
  78974. /**
  78975. * Creates a new skeleton
  78976. * @param name defines the skeleton name
  78977. * @param id defines the skeleton Id
  78978. * @param scene defines the hosting scene
  78979. */
  78980. constructor(
  78981. /** defines the skeleton name */
  78982. name: string,
  78983. /** defines the skeleton Id */
  78984. id: string, scene: Scene);
  78985. /**
  78986. * Gets the current object class name.
  78987. * @return the class name
  78988. */
  78989. getClassName(): string;
  78990. /**
  78991. * Returns an array containing the root bones
  78992. * @returns an array containing the root bones
  78993. */
  78994. getChildren(): Array<Bone>;
  78995. /**
  78996. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  78997. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  78998. * @returns a Float32Array containing matrices data
  78999. */
  79000. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  79001. /**
  79002. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  79003. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  79004. * @returns a raw texture containing the data
  79005. */
  79006. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  79007. /**
  79008. * Gets the current hosting scene
  79009. * @returns a scene object
  79010. */
  79011. getScene(): Scene;
  79012. /**
  79013. * Gets a string representing the current skeleton data
  79014. * @param fullDetails defines a boolean indicating if we want a verbose version
  79015. * @returns a string representing the current skeleton data
  79016. */
  79017. toString(fullDetails?: boolean): string;
  79018. /**
  79019. * Get bone's index searching by name
  79020. * @param name defines bone's name to search for
  79021. * @return the indice of the bone. Returns -1 if not found
  79022. */
  79023. getBoneIndexByName(name: string): number;
  79024. /**
  79025. * Creater a new animation range
  79026. * @param name defines the name of the range
  79027. * @param from defines the start key
  79028. * @param to defines the end key
  79029. */
  79030. createAnimationRange(name: string, from: number, to: number): void;
  79031. /**
  79032. * Delete a specific animation range
  79033. * @param name defines the name of the range
  79034. * @param deleteFrames defines if frames must be removed as well
  79035. */
  79036. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  79037. /**
  79038. * Gets a specific animation range
  79039. * @param name defines the name of the range to look for
  79040. * @returns the requested animation range or null if not found
  79041. */
  79042. getAnimationRange(name: string): Nullable<AnimationRange>;
  79043. /**
  79044. * Gets the list of all animation ranges defined on this skeleton
  79045. * @returns an array
  79046. */
  79047. getAnimationRanges(): Nullable<AnimationRange>[];
  79048. /**
  79049. * Copy animation range from a source skeleton.
  79050. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  79051. * @param source defines the source skeleton
  79052. * @param name defines the name of the range to copy
  79053. * @param rescaleAsRequired defines if rescaling must be applied if required
  79054. * @returns true if operation was successful
  79055. */
  79056. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  79057. /**
  79058. * Forces the skeleton to go to rest pose
  79059. */
  79060. returnToRest(): void;
  79061. private _getHighestAnimationFrame;
  79062. /**
  79063. * Begin a specific animation range
  79064. * @param name defines the name of the range to start
  79065. * @param loop defines if looping must be turned on (false by default)
  79066. * @param speedRatio defines the speed ratio to apply (1 by default)
  79067. * @param onAnimationEnd defines a callback which will be called when animation will end
  79068. * @returns a new animatable
  79069. */
  79070. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  79071. /** @hidden */
  79072. _markAsDirty(): void;
  79073. /** @hidden */
  79074. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79075. /** @hidden */
  79076. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79077. private _computeTransformMatrices;
  79078. /**
  79079. * Build all resources required to render a skeleton
  79080. */
  79081. prepare(): void;
  79082. /**
  79083. * Gets the list of animatables currently running for this skeleton
  79084. * @returns an array of animatables
  79085. */
  79086. getAnimatables(): IAnimatable[];
  79087. /**
  79088. * Clone the current skeleton
  79089. * @param name defines the name of the new skeleton
  79090. * @param id defines the id of the new skeleton
  79091. * @returns the new skeleton
  79092. */
  79093. clone(name: string, id: string): Skeleton;
  79094. /**
  79095. * Enable animation blending for this skeleton
  79096. * @param blendingSpeed defines the blending speed to apply
  79097. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79098. */
  79099. enableBlending(blendingSpeed?: number): void;
  79100. /**
  79101. * Releases all resources associated with the current skeleton
  79102. */
  79103. dispose(): void;
  79104. /**
  79105. * Serialize the skeleton in a JSON object
  79106. * @returns a JSON object
  79107. */
  79108. serialize(): any;
  79109. /**
  79110. * Creates a new skeleton from serialized data
  79111. * @param parsedSkeleton defines the serialized data
  79112. * @param scene defines the hosting scene
  79113. * @returns a new skeleton
  79114. */
  79115. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  79116. /**
  79117. * Compute all node absolute transforms
  79118. * @param forceUpdate defines if computation must be done even if cache is up to date
  79119. */
  79120. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  79121. /**
  79122. * Gets the root pose matrix
  79123. * @returns a matrix
  79124. */
  79125. getPoseMatrix(): Nullable<Matrix>;
  79126. /**
  79127. * Sorts bones per internal index
  79128. */
  79129. sortBones(): void;
  79130. private _sortBones;
  79131. }
  79132. }
  79133. declare module BABYLON {
  79134. /**
  79135. * Class used to store bone information
  79136. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79137. */
  79138. export class Bone extends Node {
  79139. /**
  79140. * defines the bone name
  79141. */
  79142. name: string;
  79143. private static _tmpVecs;
  79144. private static _tmpQuat;
  79145. private static _tmpMats;
  79146. /**
  79147. * Gets the list of child bones
  79148. */
  79149. children: Bone[];
  79150. /** Gets the animations associated with this bone */
  79151. animations: Animation[];
  79152. /**
  79153. * Gets or sets bone length
  79154. */
  79155. length: number;
  79156. /**
  79157. * @hidden Internal only
  79158. * Set this value to map this bone to a different index in the transform matrices
  79159. * Set this value to -1 to exclude the bone from the transform matrices
  79160. */
  79161. _index: Nullable<number>;
  79162. private _skeleton;
  79163. private _localMatrix;
  79164. private _restPose;
  79165. private _baseMatrix;
  79166. private _absoluteTransform;
  79167. private _invertedAbsoluteTransform;
  79168. private _parent;
  79169. private _scalingDeterminant;
  79170. private _worldTransform;
  79171. private _localScaling;
  79172. private _localRotation;
  79173. private _localPosition;
  79174. private _needToDecompose;
  79175. private _needToCompose;
  79176. /** @hidden */
  79177. _linkedTransformNode: Nullable<TransformNode>;
  79178. /** @hidden */
  79179. _waitingTransformNodeId: Nullable<string>;
  79180. /** @hidden */
  79181. /** @hidden */
  79182. _matrix: Matrix;
  79183. /**
  79184. * Create a new bone
  79185. * @param name defines the bone name
  79186. * @param skeleton defines the parent skeleton
  79187. * @param parentBone defines the parent (can be null if the bone is the root)
  79188. * @param localMatrix defines the local matrix
  79189. * @param restPose defines the rest pose matrix
  79190. * @param baseMatrix defines the base matrix
  79191. * @param index defines index of the bone in the hiearchy
  79192. */
  79193. constructor(
  79194. /**
  79195. * defines the bone name
  79196. */
  79197. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  79198. /**
  79199. * Gets the current object class name.
  79200. * @return the class name
  79201. */
  79202. getClassName(): string;
  79203. /**
  79204. * Gets the parent skeleton
  79205. * @returns a skeleton
  79206. */
  79207. getSkeleton(): Skeleton;
  79208. /**
  79209. * Gets parent bone
  79210. * @returns a bone or null if the bone is the root of the bone hierarchy
  79211. */
  79212. getParent(): Nullable<Bone>;
  79213. /**
  79214. * Returns an array containing the root bones
  79215. * @returns an array containing the root bones
  79216. */
  79217. getChildren(): Array<Bone>;
  79218. /**
  79219. * Sets the parent bone
  79220. * @param parent defines the parent (can be null if the bone is the root)
  79221. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  79222. */
  79223. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  79224. /**
  79225. * Gets the local matrix
  79226. * @returns a matrix
  79227. */
  79228. getLocalMatrix(): Matrix;
  79229. /**
  79230. * Gets the base matrix (initial matrix which remains unchanged)
  79231. * @returns a matrix
  79232. */
  79233. getBaseMatrix(): Matrix;
  79234. /**
  79235. * Gets the rest pose matrix
  79236. * @returns a matrix
  79237. */
  79238. getRestPose(): Matrix;
  79239. /**
  79240. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  79241. */
  79242. getWorldMatrix(): Matrix;
  79243. /**
  79244. * Sets the local matrix to rest pose matrix
  79245. */
  79246. returnToRest(): void;
  79247. /**
  79248. * Gets the inverse of the absolute transform matrix.
  79249. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  79250. * @returns a matrix
  79251. */
  79252. getInvertedAbsoluteTransform(): Matrix;
  79253. /**
  79254. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  79255. * @returns a matrix
  79256. */
  79257. getAbsoluteTransform(): Matrix;
  79258. /**
  79259. * Links with the given transform node.
  79260. * The local matrix of this bone is copied from the transform node every frame.
  79261. * @param transformNode defines the transform node to link to
  79262. */
  79263. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  79264. /**
  79265. * Gets the node used to drive the bone's transformation
  79266. * @returns a transform node or null
  79267. */
  79268. getTransformNode(): Nullable<TransformNode>;
  79269. /** Gets or sets current position (in local space) */
  79270. position: Vector3;
  79271. /** Gets or sets current rotation (in local space) */
  79272. rotation: Vector3;
  79273. /** Gets or sets current rotation quaternion (in local space) */
  79274. rotationQuaternion: Quaternion;
  79275. /** Gets or sets current scaling (in local space) */
  79276. scaling: Vector3;
  79277. /**
  79278. * Gets the animation properties override
  79279. */
  79280. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79281. private _decompose;
  79282. private _compose;
  79283. /**
  79284. * Update the base and local matrices
  79285. * @param matrix defines the new base or local matrix
  79286. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  79287. * @param updateLocalMatrix defines if the local matrix should be updated
  79288. */
  79289. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  79290. /** @hidden */
  79291. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  79292. /**
  79293. * Flag the bone as dirty (Forcing it to update everything)
  79294. */
  79295. markAsDirty(): void;
  79296. /** @hidden */
  79297. _markAsDirtyAndCompose(): void;
  79298. private _markAsDirtyAndDecompose;
  79299. /**
  79300. * Translate the bone in local or world space
  79301. * @param vec The amount to translate the bone
  79302. * @param space The space that the translation is in
  79303. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79304. */
  79305. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  79306. /**
  79307. * Set the postion of the bone in local or world space
  79308. * @param position The position to set the bone
  79309. * @param space The space that the position is in
  79310. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79311. */
  79312. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  79313. /**
  79314. * Set the absolute position of the bone (world space)
  79315. * @param position The position to set the bone
  79316. * @param mesh The mesh that this bone is attached to
  79317. */
  79318. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  79319. /**
  79320. * Scale the bone on the x, y and z axes (in local space)
  79321. * @param x The amount to scale the bone on the x axis
  79322. * @param y The amount to scale the bone on the y axis
  79323. * @param z The amount to scale the bone on the z axis
  79324. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  79325. */
  79326. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  79327. /**
  79328. * Set the bone scaling in local space
  79329. * @param scale defines the scaling vector
  79330. */
  79331. setScale(scale: Vector3): void;
  79332. /**
  79333. * Gets the current scaling in local space
  79334. * @returns the current scaling vector
  79335. */
  79336. getScale(): Vector3;
  79337. /**
  79338. * Gets the current scaling in local space and stores it in a target vector
  79339. * @param result defines the target vector
  79340. */
  79341. getScaleToRef(result: Vector3): void;
  79342. /**
  79343. * Set the yaw, pitch, and roll of the bone in local or world space
  79344. * @param yaw The rotation of the bone on the y axis
  79345. * @param pitch The rotation of the bone on the x axis
  79346. * @param roll The rotation of the bone on the z axis
  79347. * @param space The space that the axes of rotation are in
  79348. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79349. */
  79350. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  79351. /**
  79352. * Add a rotation to the bone on an axis in local or world space
  79353. * @param axis The axis to rotate the bone on
  79354. * @param amount The amount to rotate the bone
  79355. * @param space The space that the axis is in
  79356. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79357. */
  79358. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  79359. /**
  79360. * Set the rotation of the bone to a particular axis angle in local or world space
  79361. * @param axis The axis to rotate the bone on
  79362. * @param angle The angle that the bone should be rotated to
  79363. * @param space The space that the axis is in
  79364. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79365. */
  79366. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  79367. /**
  79368. * Set the euler rotation of the bone in local of world space
  79369. * @param rotation The euler rotation that the bone should be set to
  79370. * @param space The space that the rotation is in
  79371. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79372. */
  79373. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  79374. /**
  79375. * Set the quaternion rotation of the bone in local of world space
  79376. * @param quat The quaternion rotation that the bone should be set to
  79377. * @param space The space that the rotation is in
  79378. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79379. */
  79380. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  79381. /**
  79382. * Set the rotation matrix of the bone in local of world space
  79383. * @param rotMat The rotation matrix that the bone should be set to
  79384. * @param space The space that the rotation is in
  79385. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79386. */
  79387. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  79388. private _rotateWithMatrix;
  79389. private _getNegativeRotationToRef;
  79390. /**
  79391. * Get the position of the bone in local or world space
  79392. * @param space The space that the returned position is in
  79393. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79394. * @returns The position of the bone
  79395. */
  79396. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  79397. /**
  79398. * Copy the position of the bone to a vector3 in local or world space
  79399. * @param space The space that the returned position is in
  79400. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79401. * @param result The vector3 to copy the position to
  79402. */
  79403. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  79404. /**
  79405. * Get the absolute position of the bone (world space)
  79406. * @param mesh The mesh that this bone is attached to
  79407. * @returns The absolute position of the bone
  79408. */
  79409. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  79410. /**
  79411. * Copy the absolute position of the bone (world space) to the result param
  79412. * @param mesh The mesh that this bone is attached to
  79413. * @param result The vector3 to copy the absolute position to
  79414. */
  79415. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  79416. /**
  79417. * Compute the absolute transforms of this bone and its children
  79418. */
  79419. computeAbsoluteTransforms(): void;
  79420. /**
  79421. * Get the world direction from an axis that is in the local space of the bone
  79422. * @param localAxis The local direction that is used to compute the world direction
  79423. * @param mesh The mesh that this bone is attached to
  79424. * @returns The world direction
  79425. */
  79426. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  79427. /**
  79428. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  79429. * @param localAxis The local direction that is used to compute the world direction
  79430. * @param mesh The mesh that this bone is attached to
  79431. * @param result The vector3 that the world direction will be copied to
  79432. */
  79433. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79434. /**
  79435. * Get the euler rotation of the bone in local or world space
  79436. * @param space The space that the rotation should be in
  79437. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79438. * @returns The euler rotation
  79439. */
  79440. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  79441. /**
  79442. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  79443. * @param space The space that the rotation should be in
  79444. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79445. * @param result The vector3 that the rotation should be copied to
  79446. */
  79447. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79448. /**
  79449. * Get the quaternion rotation of the bone in either local or world space
  79450. * @param space The space that the rotation should be in
  79451. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79452. * @returns The quaternion rotation
  79453. */
  79454. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  79455. /**
  79456. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  79457. * @param space The space that the rotation should be in
  79458. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79459. * @param result The quaternion that the rotation should be copied to
  79460. */
  79461. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  79462. /**
  79463. * Get the rotation matrix of the bone in local or world space
  79464. * @param space The space that the rotation should be in
  79465. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79466. * @returns The rotation matrix
  79467. */
  79468. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  79469. /**
  79470. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  79471. * @param space The space that the rotation should be in
  79472. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79473. * @param result The quaternion that the rotation should be copied to
  79474. */
  79475. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  79476. /**
  79477. * Get the world position of a point that is in the local space of the bone
  79478. * @param position The local position
  79479. * @param mesh The mesh that this bone is attached to
  79480. * @returns The world position
  79481. */
  79482. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  79483. /**
  79484. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  79485. * @param position The local position
  79486. * @param mesh The mesh that this bone is attached to
  79487. * @param result The vector3 that the world position should be copied to
  79488. */
  79489. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79490. /**
  79491. * Get the local position of a point that is in world space
  79492. * @param position The world position
  79493. * @param mesh The mesh that this bone is attached to
  79494. * @returns The local position
  79495. */
  79496. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  79497. /**
  79498. * Get the local position of a point that is in world space and copy it to the result param
  79499. * @param position The world position
  79500. * @param mesh The mesh that this bone is attached to
  79501. * @param result The vector3 that the local position should be copied to
  79502. */
  79503. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79504. }
  79505. }
  79506. declare module BABYLON {
  79507. /**
  79508. * 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.
  79509. * @see https://doc.babylonjs.com/how_to/transformnode
  79510. */
  79511. export class TransformNode extends Node {
  79512. /**
  79513. * Object will not rotate to face the camera
  79514. */
  79515. static BILLBOARDMODE_NONE: number;
  79516. /**
  79517. * Object will rotate to face the camera but only on the x axis
  79518. */
  79519. static BILLBOARDMODE_X: number;
  79520. /**
  79521. * Object will rotate to face the camera but only on the y axis
  79522. */
  79523. static BILLBOARDMODE_Y: number;
  79524. /**
  79525. * Object will rotate to face the camera but only on the z axis
  79526. */
  79527. static BILLBOARDMODE_Z: number;
  79528. /**
  79529. * Object will rotate to face the camera
  79530. */
  79531. static BILLBOARDMODE_ALL: number;
  79532. /**
  79533. * Object will rotate to face the camera's position instead of orientation
  79534. */
  79535. static BILLBOARDMODE_USE_POSITION: number;
  79536. private _forward;
  79537. private _forwardInverted;
  79538. private _up;
  79539. private _right;
  79540. private _rightInverted;
  79541. private _position;
  79542. private _rotation;
  79543. private _rotationQuaternion;
  79544. protected _scaling: Vector3;
  79545. protected _isDirty: boolean;
  79546. private _transformToBoneReferal;
  79547. private _isAbsoluteSynced;
  79548. private _billboardMode;
  79549. /**
  79550. * Gets or sets the billboard mode. Default is 0.
  79551. *
  79552. * | Value | Type | Description |
  79553. * | --- | --- | --- |
  79554. * | 0 | BILLBOARDMODE_NONE | |
  79555. * | 1 | BILLBOARDMODE_X | |
  79556. * | 2 | BILLBOARDMODE_Y | |
  79557. * | 4 | BILLBOARDMODE_Z | |
  79558. * | 7 | BILLBOARDMODE_ALL | |
  79559. *
  79560. */
  79561. billboardMode: number;
  79562. private _preserveParentRotationForBillboard;
  79563. /**
  79564. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  79565. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  79566. */
  79567. preserveParentRotationForBillboard: boolean;
  79568. /**
  79569. * 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
  79570. */
  79571. scalingDeterminant: number;
  79572. private _infiniteDistance;
  79573. /**
  79574. * Gets or sets the distance of the object to max, often used by skybox
  79575. */
  79576. infiniteDistance: boolean;
  79577. /**
  79578. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  79579. * By default the system will update normals to compensate
  79580. */
  79581. ignoreNonUniformScaling: boolean;
  79582. /**
  79583. * 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
  79584. */
  79585. reIntegrateRotationIntoRotationQuaternion: boolean;
  79586. /** @hidden */
  79587. _poseMatrix: Nullable<Matrix>;
  79588. /** @hidden */
  79589. _localMatrix: Matrix;
  79590. private _usePivotMatrix;
  79591. private _absolutePosition;
  79592. private _absoluteScaling;
  79593. private _absoluteRotationQuaternion;
  79594. private _pivotMatrix;
  79595. private _pivotMatrixInverse;
  79596. protected _postMultiplyPivotMatrix: boolean;
  79597. protected _isWorldMatrixFrozen: boolean;
  79598. /** @hidden */
  79599. _indexInSceneTransformNodesArray: number;
  79600. /**
  79601. * An event triggered after the world matrix is updated
  79602. */
  79603. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  79604. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  79605. /**
  79606. * Gets a string identifying the name of the class
  79607. * @returns "TransformNode" string
  79608. */
  79609. getClassName(): string;
  79610. /**
  79611. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  79612. */
  79613. position: Vector3;
  79614. /**
  79615. * 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)).
  79616. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  79617. */
  79618. rotation: Vector3;
  79619. /**
  79620. * 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)).
  79621. */
  79622. scaling: Vector3;
  79623. /**
  79624. * 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).
  79625. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  79626. */
  79627. rotationQuaternion: Nullable<Quaternion>;
  79628. /**
  79629. * The forward direction of that transform in world space.
  79630. */
  79631. readonly forward: Vector3;
  79632. /**
  79633. * The up direction of that transform in world space.
  79634. */
  79635. readonly up: Vector3;
  79636. /**
  79637. * The right direction of that transform in world space.
  79638. */
  79639. readonly right: Vector3;
  79640. /**
  79641. * Copies the parameter passed Matrix into the mesh Pose matrix.
  79642. * @param matrix the matrix to copy the pose from
  79643. * @returns this TransformNode.
  79644. */
  79645. updatePoseMatrix(matrix: Matrix): TransformNode;
  79646. /**
  79647. * Returns the mesh Pose matrix.
  79648. * @returns the pose matrix
  79649. */
  79650. getPoseMatrix(): Matrix;
  79651. /** @hidden */
  79652. _isSynchronized(): boolean;
  79653. /** @hidden */
  79654. _initCache(): void;
  79655. /**
  79656. * Flag the transform node as dirty (Forcing it to update everything)
  79657. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  79658. * @returns this transform node
  79659. */
  79660. markAsDirty(property: string): TransformNode;
  79661. /**
  79662. * Returns the current mesh absolute position.
  79663. * Returns a Vector3.
  79664. */
  79665. readonly absolutePosition: Vector3;
  79666. /**
  79667. * Returns the current mesh absolute scaling.
  79668. * Returns a Vector3.
  79669. */
  79670. readonly absoluteScaling: Vector3;
  79671. /**
  79672. * Returns the current mesh absolute rotation.
  79673. * Returns a Quaternion.
  79674. */
  79675. readonly absoluteRotationQuaternion: Quaternion;
  79676. /**
  79677. * Sets a new matrix to apply before all other transformation
  79678. * @param matrix defines the transform matrix
  79679. * @returns the current TransformNode
  79680. */
  79681. setPreTransformMatrix(matrix: Matrix): TransformNode;
  79682. /**
  79683. * Sets a new pivot matrix to the current node
  79684. * @param matrix defines the new pivot matrix to use
  79685. * @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
  79686. * @returns the current TransformNode
  79687. */
  79688. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  79689. /**
  79690. * Returns the mesh pivot matrix.
  79691. * Default : Identity.
  79692. * @returns the matrix
  79693. */
  79694. getPivotMatrix(): Matrix;
  79695. /**
  79696. * Instantiate (when possible) or clone that node with its hierarchy
  79697. * @param newParent defines the new parent to use for the instance (or clone)
  79698. * @returns an instance (or a clone) of the current node with its hiearchy
  79699. */
  79700. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  79701. /**
  79702. * Prevents the World matrix to be computed any longer
  79703. * @param newWorldMatrix defines an optional matrix to use as world matrix
  79704. * @returns the TransformNode.
  79705. */
  79706. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  79707. /**
  79708. * Allows back the World matrix computation.
  79709. * @returns the TransformNode.
  79710. */
  79711. unfreezeWorldMatrix(): this;
  79712. /**
  79713. * True if the World matrix has been frozen.
  79714. */
  79715. readonly isWorldMatrixFrozen: boolean;
  79716. /**
  79717. * Retuns the mesh absolute position in the World.
  79718. * @returns a Vector3.
  79719. */
  79720. getAbsolutePosition(): Vector3;
  79721. /**
  79722. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  79723. * @param absolutePosition the absolute position to set
  79724. * @returns the TransformNode.
  79725. */
  79726. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  79727. /**
  79728. * Sets the mesh position in its local space.
  79729. * @param vector3 the position to set in localspace
  79730. * @returns the TransformNode.
  79731. */
  79732. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  79733. /**
  79734. * Returns the mesh position in the local space from the current World matrix values.
  79735. * @returns a new Vector3.
  79736. */
  79737. getPositionExpressedInLocalSpace(): Vector3;
  79738. /**
  79739. * Translates the mesh along the passed Vector3 in its local space.
  79740. * @param vector3 the distance to translate in localspace
  79741. * @returns the TransformNode.
  79742. */
  79743. locallyTranslate(vector3: Vector3): TransformNode;
  79744. private static _lookAtVectorCache;
  79745. /**
  79746. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  79747. * @param targetPoint the position (must be in same space as current mesh) to look at
  79748. * @param yawCor optional yaw (y-axis) correction in radians
  79749. * @param pitchCor optional pitch (x-axis) correction in radians
  79750. * @param rollCor optional roll (z-axis) correction in radians
  79751. * @param space the choosen space of the target
  79752. * @returns the TransformNode.
  79753. */
  79754. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  79755. /**
  79756. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  79757. * This Vector3 is expressed in the World space.
  79758. * @param localAxis axis to rotate
  79759. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  79760. */
  79761. getDirection(localAxis: Vector3): Vector3;
  79762. /**
  79763. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  79764. * localAxis is expressed in the mesh local space.
  79765. * result is computed in the Wordl space from the mesh World matrix.
  79766. * @param localAxis axis to rotate
  79767. * @param result the resulting transformnode
  79768. * @returns this TransformNode.
  79769. */
  79770. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  79771. /**
  79772. * Sets this transform node rotation to the given local axis.
  79773. * @param localAxis the axis in local space
  79774. * @param yawCor optional yaw (y-axis) correction in radians
  79775. * @param pitchCor optional pitch (x-axis) correction in radians
  79776. * @param rollCor optional roll (z-axis) correction in radians
  79777. * @returns this TransformNode
  79778. */
  79779. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  79780. /**
  79781. * Sets a new pivot point to the current node
  79782. * @param point defines the new pivot point to use
  79783. * @param space defines if the point is in world or local space (local by default)
  79784. * @returns the current TransformNode
  79785. */
  79786. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  79787. /**
  79788. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  79789. * @returns the pivot point
  79790. */
  79791. getPivotPoint(): Vector3;
  79792. /**
  79793. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  79794. * @param result the vector3 to store the result
  79795. * @returns this TransformNode.
  79796. */
  79797. getPivotPointToRef(result: Vector3): TransformNode;
  79798. /**
  79799. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  79800. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  79801. */
  79802. getAbsolutePivotPoint(): Vector3;
  79803. /**
  79804. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  79805. * @param result vector3 to store the result
  79806. * @returns this TransformNode.
  79807. */
  79808. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  79809. /**
  79810. * Defines the passed node as the parent of the current node.
  79811. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  79812. * @see https://doc.babylonjs.com/how_to/parenting
  79813. * @param node the node ot set as the parent
  79814. * @returns this TransformNode.
  79815. */
  79816. setParent(node: Nullable<Node>): TransformNode;
  79817. private _nonUniformScaling;
  79818. /**
  79819. * True if the scaling property of this object is non uniform eg. (1,2,1)
  79820. */
  79821. readonly nonUniformScaling: boolean;
  79822. /** @hidden */
  79823. _updateNonUniformScalingState(value: boolean): boolean;
  79824. /**
  79825. * Attach the current TransformNode to another TransformNode associated with a bone
  79826. * @param bone Bone affecting the TransformNode
  79827. * @param affectedTransformNode TransformNode associated with the bone
  79828. * @returns this object
  79829. */
  79830. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  79831. /**
  79832. * Detach the transform node if its associated with a bone
  79833. * @returns this object
  79834. */
  79835. detachFromBone(): TransformNode;
  79836. private static _rotationAxisCache;
  79837. /**
  79838. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  79839. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  79840. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  79841. * The passed axis is also normalized.
  79842. * @param axis the axis to rotate around
  79843. * @param amount the amount to rotate in radians
  79844. * @param space Space to rotate in (Default: local)
  79845. * @returns the TransformNode.
  79846. */
  79847. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  79848. /**
  79849. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  79850. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  79851. * The passed axis is also normalized. .
  79852. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  79853. * @param point the point to rotate around
  79854. * @param axis the axis to rotate around
  79855. * @param amount the amount to rotate in radians
  79856. * @returns the TransformNode
  79857. */
  79858. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  79859. /**
  79860. * Translates the mesh along the axis vector for the passed distance in the given space.
  79861. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  79862. * @param axis the axis to translate in
  79863. * @param distance the distance to translate
  79864. * @param space Space to rotate in (Default: local)
  79865. * @returns the TransformNode.
  79866. */
  79867. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  79868. /**
  79869. * Adds a rotation step to the mesh current rotation.
  79870. * x, y, z are Euler angles expressed in radians.
  79871. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  79872. * This means this rotation is made in the mesh local space only.
  79873. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  79874. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  79875. * ```javascript
  79876. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  79877. * ```
  79878. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  79879. * 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.
  79880. * @param x Rotation to add
  79881. * @param y Rotation to add
  79882. * @param z Rotation to add
  79883. * @returns the TransformNode.
  79884. */
  79885. addRotation(x: number, y: number, z: number): TransformNode;
  79886. /**
  79887. * @hidden
  79888. */
  79889. protected _getEffectiveParent(): Nullable<Node>;
  79890. /**
  79891. * Computes the world matrix of the node
  79892. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  79893. * @returns the world matrix
  79894. */
  79895. computeWorldMatrix(force?: boolean): Matrix;
  79896. protected _afterComputeWorldMatrix(): void;
  79897. /**
  79898. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  79899. * @param func callback function to add
  79900. *
  79901. * @returns the TransformNode.
  79902. */
  79903. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  79904. /**
  79905. * Removes a registered callback function.
  79906. * @param func callback function to remove
  79907. * @returns the TransformNode.
  79908. */
  79909. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  79910. /**
  79911. * Gets the position of the current mesh in camera space
  79912. * @param camera defines the camera to use
  79913. * @returns a position
  79914. */
  79915. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  79916. /**
  79917. * Returns the distance from the mesh to the active camera
  79918. * @param camera defines the camera to use
  79919. * @returns the distance
  79920. */
  79921. getDistanceToCamera(camera?: Nullable<Camera>): number;
  79922. /**
  79923. * Clone the current transform node
  79924. * @param name Name of the new clone
  79925. * @param newParent New parent for the clone
  79926. * @param doNotCloneChildren Do not clone children hierarchy
  79927. * @returns the new transform node
  79928. */
  79929. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  79930. /**
  79931. * Serializes the objects information.
  79932. * @param currentSerializationObject defines the object to serialize in
  79933. * @returns the serialized object
  79934. */
  79935. serialize(currentSerializationObject?: any): any;
  79936. /**
  79937. * Returns a new TransformNode object parsed from the source provided.
  79938. * @param parsedTransformNode is the source.
  79939. * @param scene the scne the object belongs to
  79940. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  79941. * @returns a new TransformNode object parsed from the source provided.
  79942. */
  79943. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  79944. /**
  79945. * Get all child-transformNodes of this node
  79946. * @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
  79947. * @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
  79948. * @returns an array of TransformNode
  79949. */
  79950. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  79951. /**
  79952. * Releases resources associated with this transform node.
  79953. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  79954. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  79955. */
  79956. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  79957. /**
  79958. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  79959. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  79960. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  79961. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  79962. * @returns the current mesh
  79963. */
  79964. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  79965. private _syncAbsoluteScalingAndRotation;
  79966. }
  79967. }
  79968. declare module BABYLON {
  79969. /**
  79970. * Defines the types of pose enabled controllers that are supported
  79971. */
  79972. export enum PoseEnabledControllerType {
  79973. /**
  79974. * HTC Vive
  79975. */
  79976. VIVE = 0,
  79977. /**
  79978. * Oculus Rift
  79979. */
  79980. OCULUS = 1,
  79981. /**
  79982. * Windows mixed reality
  79983. */
  79984. WINDOWS = 2,
  79985. /**
  79986. * Samsung gear VR
  79987. */
  79988. GEAR_VR = 3,
  79989. /**
  79990. * Google Daydream
  79991. */
  79992. DAYDREAM = 4,
  79993. /**
  79994. * Generic
  79995. */
  79996. GENERIC = 5
  79997. }
  79998. /**
  79999. * Defines the MutableGamepadButton interface for the state of a gamepad button
  80000. */
  80001. export interface MutableGamepadButton {
  80002. /**
  80003. * Value of the button/trigger
  80004. */
  80005. value: number;
  80006. /**
  80007. * If the button/trigger is currently touched
  80008. */
  80009. touched: boolean;
  80010. /**
  80011. * If the button/trigger is currently pressed
  80012. */
  80013. pressed: boolean;
  80014. }
  80015. /**
  80016. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  80017. * @hidden
  80018. */
  80019. export interface ExtendedGamepadButton extends GamepadButton {
  80020. /**
  80021. * If the button/trigger is currently pressed
  80022. */
  80023. readonly pressed: boolean;
  80024. /**
  80025. * If the button/trigger is currently touched
  80026. */
  80027. readonly touched: boolean;
  80028. /**
  80029. * Value of the button/trigger
  80030. */
  80031. readonly value: number;
  80032. }
  80033. /** @hidden */
  80034. export interface _GamePadFactory {
  80035. /**
  80036. * Returns wether or not the current gamepad can be created for this type of controller.
  80037. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  80038. * @returns true if it can be created, otherwise false
  80039. */
  80040. canCreate(gamepadInfo: any): boolean;
  80041. /**
  80042. * Creates a new instance of the Gamepad.
  80043. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  80044. * @returns the new gamepad instance
  80045. */
  80046. create(gamepadInfo: any): Gamepad;
  80047. }
  80048. /**
  80049. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  80050. */
  80051. export class PoseEnabledControllerHelper {
  80052. /** @hidden */
  80053. static _ControllerFactories: _GamePadFactory[];
  80054. /** @hidden */
  80055. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  80056. /**
  80057. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  80058. * @param vrGamepad the gamepad to initialized
  80059. * @returns a vr controller of the type the gamepad identified as
  80060. */
  80061. static InitiateController(vrGamepad: any): Gamepad;
  80062. }
  80063. /**
  80064. * Defines the PoseEnabledController object that contains state of a vr capable controller
  80065. */
  80066. export class PoseEnabledController extends Gamepad implements PoseControlled {
  80067. /**
  80068. * If the controller is used in a webXR session
  80069. */
  80070. isXR: boolean;
  80071. private _deviceRoomPosition;
  80072. private _deviceRoomRotationQuaternion;
  80073. /**
  80074. * The device position in babylon space
  80075. */
  80076. devicePosition: Vector3;
  80077. /**
  80078. * The device rotation in babylon space
  80079. */
  80080. deviceRotationQuaternion: Quaternion;
  80081. /**
  80082. * The scale factor of the device in babylon space
  80083. */
  80084. deviceScaleFactor: number;
  80085. /**
  80086. * (Likely devicePosition should be used instead) The device position in its room space
  80087. */
  80088. position: Vector3;
  80089. /**
  80090. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  80091. */
  80092. rotationQuaternion: Quaternion;
  80093. /**
  80094. * The type of controller (Eg. Windows mixed reality)
  80095. */
  80096. controllerType: PoseEnabledControllerType;
  80097. protected _calculatedPosition: Vector3;
  80098. private _calculatedRotation;
  80099. /**
  80100. * The raw pose from the device
  80101. */
  80102. rawPose: DevicePose;
  80103. private _trackPosition;
  80104. private _maxRotationDistFromHeadset;
  80105. private _draggedRoomRotation;
  80106. /**
  80107. * @hidden
  80108. */
  80109. _disableTrackPosition(fixedPosition: Vector3): void;
  80110. /**
  80111. * Internal, the mesh attached to the controller
  80112. * @hidden
  80113. */
  80114. _mesh: Nullable<AbstractMesh>;
  80115. private _poseControlledCamera;
  80116. private _leftHandSystemQuaternion;
  80117. /**
  80118. * Internal, matrix used to convert room space to babylon space
  80119. * @hidden
  80120. */
  80121. _deviceToWorld: Matrix;
  80122. /**
  80123. * Node to be used when casting a ray from the controller
  80124. * @hidden
  80125. */
  80126. _pointingPoseNode: Nullable<TransformNode>;
  80127. /**
  80128. * Name of the child mesh that can be used to cast a ray from the controller
  80129. */
  80130. static readonly POINTING_POSE: string;
  80131. /**
  80132. * Creates a new PoseEnabledController from a gamepad
  80133. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  80134. */
  80135. constructor(browserGamepad: any);
  80136. private _workingMatrix;
  80137. /**
  80138. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  80139. */
  80140. update(): void;
  80141. /**
  80142. * Updates only the pose device and mesh without doing any button event checking
  80143. */
  80144. protected _updatePoseAndMesh(): void;
  80145. /**
  80146. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  80147. * @param poseData raw pose fromthe device
  80148. */
  80149. updateFromDevice(poseData: DevicePose): void;
  80150. /**
  80151. * @hidden
  80152. */
  80153. _meshAttachedObservable: Observable<AbstractMesh>;
  80154. /**
  80155. * Attaches a mesh to the controller
  80156. * @param mesh the mesh to be attached
  80157. */
  80158. attachToMesh(mesh: AbstractMesh): void;
  80159. /**
  80160. * Attaches the controllers mesh to a camera
  80161. * @param camera the camera the mesh should be attached to
  80162. */
  80163. attachToPoseControlledCamera(camera: TargetCamera): void;
  80164. /**
  80165. * Disposes of the controller
  80166. */
  80167. dispose(): void;
  80168. /**
  80169. * The mesh that is attached to the controller
  80170. */
  80171. readonly mesh: Nullable<AbstractMesh>;
  80172. /**
  80173. * Gets the ray of the controller in the direction the controller is pointing
  80174. * @param length the length the resulting ray should be
  80175. * @returns a ray in the direction the controller is pointing
  80176. */
  80177. getForwardRay(length?: number): Ray;
  80178. }
  80179. }
  80180. declare module BABYLON {
  80181. /**
  80182. * Defines the WebVRController object that represents controllers tracked in 3D space
  80183. */
  80184. export abstract class WebVRController extends PoseEnabledController {
  80185. /**
  80186. * Internal, the default controller model for the controller
  80187. */
  80188. protected _defaultModel: AbstractMesh;
  80189. /**
  80190. * Fired when the trigger state has changed
  80191. */
  80192. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  80193. /**
  80194. * Fired when the main button state has changed
  80195. */
  80196. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  80197. /**
  80198. * Fired when the secondary button state has changed
  80199. */
  80200. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  80201. /**
  80202. * Fired when the pad state has changed
  80203. */
  80204. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  80205. /**
  80206. * Fired when controllers stick values have changed
  80207. */
  80208. onPadValuesChangedObservable: Observable<StickValues>;
  80209. /**
  80210. * Array of button availible on the controller
  80211. */
  80212. protected _buttons: Array<MutableGamepadButton>;
  80213. private _onButtonStateChange;
  80214. /**
  80215. * Fired when a controller button's state has changed
  80216. * @param callback the callback containing the button that was modified
  80217. */
  80218. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  80219. /**
  80220. * X and Y axis corresponding to the controllers joystick
  80221. */
  80222. pad: StickValues;
  80223. /**
  80224. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  80225. */
  80226. hand: string;
  80227. /**
  80228. * The default controller model for the controller
  80229. */
  80230. readonly defaultModel: AbstractMesh;
  80231. /**
  80232. * Creates a new WebVRController from a gamepad
  80233. * @param vrGamepad the gamepad that the WebVRController should be created from
  80234. */
  80235. constructor(vrGamepad: any);
  80236. /**
  80237. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  80238. */
  80239. update(): void;
  80240. /**
  80241. * Function to be called when a button is modified
  80242. */
  80243. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  80244. /**
  80245. * Loads a mesh and attaches it to the controller
  80246. * @param scene the scene the mesh should be added to
  80247. * @param meshLoaded callback for when the mesh has been loaded
  80248. */
  80249. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  80250. private _setButtonValue;
  80251. private _changes;
  80252. private _checkChanges;
  80253. /**
  80254. * Disposes of th webVRCOntroller
  80255. */
  80256. dispose(): void;
  80257. }
  80258. }
  80259. declare module BABYLON {
  80260. /**
  80261. * The HemisphericLight simulates the ambient environment light,
  80262. * so the passed direction is the light reflection direction, not the incoming direction.
  80263. */
  80264. export class HemisphericLight extends Light {
  80265. /**
  80266. * The groundColor is the light in the opposite direction to the one specified during creation.
  80267. * 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.
  80268. */
  80269. groundColor: Color3;
  80270. /**
  80271. * The light reflection direction, not the incoming direction.
  80272. */
  80273. direction: Vector3;
  80274. /**
  80275. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  80276. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  80277. * The HemisphericLight can't cast shadows.
  80278. * Documentation : https://doc.babylonjs.com/babylon101/lights
  80279. * @param name The friendly name of the light
  80280. * @param direction The direction of the light reflection
  80281. * @param scene The scene the light belongs to
  80282. */
  80283. constructor(name: string, direction: Vector3, scene: Scene);
  80284. protected _buildUniformLayout(): void;
  80285. /**
  80286. * Returns the string "HemisphericLight".
  80287. * @return The class name
  80288. */
  80289. getClassName(): string;
  80290. /**
  80291. * Sets the HemisphericLight direction towards the passed target (Vector3).
  80292. * Returns the updated direction.
  80293. * @param target The target the direction should point to
  80294. * @return The computed direction
  80295. */
  80296. setDirectionToTarget(target: Vector3): Vector3;
  80297. /**
  80298. * Returns the shadow generator associated to the light.
  80299. * @returns Always null for hemispheric lights because it does not support shadows.
  80300. */
  80301. getShadowGenerator(): Nullable<IShadowGenerator>;
  80302. /**
  80303. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  80304. * @param effect The effect to update
  80305. * @param lightIndex The index of the light in the effect to update
  80306. * @returns The hemispheric light
  80307. */
  80308. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  80309. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  80310. /**
  80311. * Computes the world matrix of the node
  80312. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  80313. * @param useWasUpdatedFlag defines a reserved property
  80314. * @returns the world matrix
  80315. */
  80316. computeWorldMatrix(): Matrix;
  80317. /**
  80318. * Returns the integer 3.
  80319. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  80320. */
  80321. getTypeID(): number;
  80322. /**
  80323. * Prepares the list of defines specific to the light type.
  80324. * @param defines the list of defines
  80325. * @param lightIndex defines the index of the light for the effect
  80326. */
  80327. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  80328. }
  80329. }
  80330. declare module BABYLON {
  80331. /** @hidden */
  80332. export var vrMultiviewToSingleviewPixelShader: {
  80333. name: string;
  80334. shader: string;
  80335. };
  80336. }
  80337. declare module BABYLON {
  80338. /**
  80339. * Renders to multiple views with a single draw call
  80340. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  80341. */
  80342. export class MultiviewRenderTarget extends RenderTargetTexture {
  80343. /**
  80344. * Creates a multiview render target
  80345. * @param scene scene used with the render target
  80346. * @param size the size of the render target (used for each view)
  80347. */
  80348. constructor(scene: Scene, size?: number | {
  80349. width: number;
  80350. height: number;
  80351. } | {
  80352. ratio: number;
  80353. });
  80354. /**
  80355. * @hidden
  80356. * @param faceIndex the face index, if its a cube texture
  80357. */
  80358. _bindFrameBuffer(faceIndex?: number): void;
  80359. /**
  80360. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  80361. * @returns the view count
  80362. */
  80363. getViewCount(): number;
  80364. }
  80365. }
  80366. declare module BABYLON {
  80367. /**
  80368. * Represents a camera frustum
  80369. */
  80370. export class Frustum {
  80371. /**
  80372. * Gets the planes representing the frustum
  80373. * @param transform matrix to be applied to the returned planes
  80374. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  80375. */
  80376. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  80377. /**
  80378. * Gets the near frustum plane transformed by the transform matrix
  80379. * @param transform transformation matrix to be applied to the resulting frustum plane
  80380. * @param frustumPlane the resuling frustum plane
  80381. */
  80382. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80383. /**
  80384. * Gets the far frustum plane transformed by the transform matrix
  80385. * @param transform transformation matrix to be applied to the resulting frustum plane
  80386. * @param frustumPlane the resuling frustum plane
  80387. */
  80388. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80389. /**
  80390. * Gets the left frustum plane transformed by the transform matrix
  80391. * @param transform transformation matrix to be applied to the resulting frustum plane
  80392. * @param frustumPlane the resuling frustum plane
  80393. */
  80394. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80395. /**
  80396. * Gets the right frustum plane transformed by the transform matrix
  80397. * @param transform transformation matrix to be applied to the resulting frustum plane
  80398. * @param frustumPlane the resuling frustum plane
  80399. */
  80400. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80401. /**
  80402. * Gets the top frustum plane transformed by the transform matrix
  80403. * @param transform transformation matrix to be applied to the resulting frustum plane
  80404. * @param frustumPlane the resuling frustum plane
  80405. */
  80406. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80407. /**
  80408. * Gets the bottom frustum plane transformed by the transform matrix
  80409. * @param transform transformation matrix to be applied to the resulting frustum plane
  80410. * @param frustumPlane the resuling frustum plane
  80411. */
  80412. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80413. /**
  80414. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  80415. * @param transform transformation matrix to be applied to the resulting frustum planes
  80416. * @param frustumPlanes the resuling frustum planes
  80417. */
  80418. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  80419. }
  80420. }
  80421. declare module BABYLON {
  80422. interface Engine {
  80423. /**
  80424. * Creates a new multiview render target
  80425. * @param width defines the width of the texture
  80426. * @param height defines the height of the texture
  80427. * @returns the created multiview texture
  80428. */
  80429. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  80430. /**
  80431. * Binds a multiview framebuffer to be drawn to
  80432. * @param multiviewTexture texture to bind
  80433. */
  80434. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  80435. }
  80436. interface Camera {
  80437. /**
  80438. * @hidden
  80439. * 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)
  80440. */
  80441. _useMultiviewToSingleView: boolean;
  80442. /**
  80443. * @hidden
  80444. * 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)
  80445. */
  80446. _multiviewTexture: Nullable<RenderTargetTexture>;
  80447. /**
  80448. * @hidden
  80449. * ensures the multiview texture of the camera exists and has the specified width/height
  80450. * @param width height to set on the multiview texture
  80451. * @param height width to set on the multiview texture
  80452. */
  80453. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  80454. }
  80455. interface Scene {
  80456. /** @hidden */
  80457. _transformMatrixR: Matrix;
  80458. /** @hidden */
  80459. _multiviewSceneUbo: Nullable<UniformBuffer>;
  80460. /** @hidden */
  80461. _createMultiviewUbo(): void;
  80462. /** @hidden */
  80463. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  80464. /** @hidden */
  80465. _renderMultiviewToSingleView(camera: Camera): void;
  80466. }
  80467. }
  80468. declare module BABYLON {
  80469. /**
  80470. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  80471. * This will not be used for webXR as it supports displaying texture arrays directly
  80472. */
  80473. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  80474. /**
  80475. * Initializes a VRMultiviewToSingleview
  80476. * @param name name of the post process
  80477. * @param camera camera to be applied to
  80478. * @param scaleFactor scaling factor to the size of the output texture
  80479. */
  80480. constructor(name: string, camera: Camera, scaleFactor: number);
  80481. }
  80482. }
  80483. declare module BABYLON {
  80484. interface Engine {
  80485. /** @hidden */
  80486. _vrDisplay: any;
  80487. /** @hidden */
  80488. _vrSupported: boolean;
  80489. /** @hidden */
  80490. _oldSize: Size;
  80491. /** @hidden */
  80492. _oldHardwareScaleFactor: number;
  80493. /** @hidden */
  80494. _vrExclusivePointerMode: boolean;
  80495. /** @hidden */
  80496. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  80497. /** @hidden */
  80498. _onVRDisplayPointerRestricted: () => void;
  80499. /** @hidden */
  80500. _onVRDisplayPointerUnrestricted: () => void;
  80501. /** @hidden */
  80502. _onVrDisplayConnect: Nullable<(display: any) => void>;
  80503. /** @hidden */
  80504. _onVrDisplayDisconnect: Nullable<() => void>;
  80505. /** @hidden */
  80506. _onVrDisplayPresentChange: Nullable<() => void>;
  80507. /**
  80508. * Observable signaled when VR display mode changes
  80509. */
  80510. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  80511. /**
  80512. * Observable signaled when VR request present is complete
  80513. */
  80514. onVRRequestPresentComplete: Observable<boolean>;
  80515. /**
  80516. * Observable signaled when VR request present starts
  80517. */
  80518. onVRRequestPresentStart: Observable<Engine>;
  80519. /**
  80520. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  80521. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  80522. */
  80523. isInVRExclusivePointerMode: boolean;
  80524. /**
  80525. * Gets a boolean indicating if a webVR device was detected
  80526. * @returns true if a webVR device was detected
  80527. */
  80528. isVRDevicePresent(): boolean;
  80529. /**
  80530. * Gets the current webVR device
  80531. * @returns the current webVR device (or null)
  80532. */
  80533. getVRDevice(): any;
  80534. /**
  80535. * Initializes a webVR display and starts listening to display change events
  80536. * The onVRDisplayChangedObservable will be notified upon these changes
  80537. * @returns A promise containing a VRDisplay and if vr is supported
  80538. */
  80539. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  80540. /** @hidden */
  80541. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  80542. /**
  80543. * Call this function to switch to webVR mode
  80544. * Will do nothing if webVR is not supported or if there is no webVR device
  80545. * @see http://doc.babylonjs.com/how_to/webvr_camera
  80546. */
  80547. enableVR(): void;
  80548. /** @hidden */
  80549. _onVRFullScreenTriggered(): void;
  80550. }
  80551. }
  80552. declare module BABYLON {
  80553. /**
  80554. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  80555. * IMPORTANT!! The data is right-hand data.
  80556. * @export
  80557. * @interface DevicePose
  80558. */
  80559. export interface DevicePose {
  80560. /**
  80561. * The position of the device, values in array are [x,y,z].
  80562. */
  80563. readonly position: Nullable<Float32Array>;
  80564. /**
  80565. * The linearVelocity of the device, values in array are [x,y,z].
  80566. */
  80567. readonly linearVelocity: Nullable<Float32Array>;
  80568. /**
  80569. * The linearAcceleration of the device, values in array are [x,y,z].
  80570. */
  80571. readonly linearAcceleration: Nullable<Float32Array>;
  80572. /**
  80573. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  80574. */
  80575. readonly orientation: Nullable<Float32Array>;
  80576. /**
  80577. * The angularVelocity of the device, values in array are [x,y,z].
  80578. */
  80579. readonly angularVelocity: Nullable<Float32Array>;
  80580. /**
  80581. * The angularAcceleration of the device, values in array are [x,y,z].
  80582. */
  80583. readonly angularAcceleration: Nullable<Float32Array>;
  80584. }
  80585. /**
  80586. * Interface representing a pose controlled object in Babylon.
  80587. * A pose controlled object has both regular pose values as well as pose values
  80588. * from an external device such as a VR head mounted display
  80589. */
  80590. export interface PoseControlled {
  80591. /**
  80592. * The position of the object in babylon space.
  80593. */
  80594. position: Vector3;
  80595. /**
  80596. * The rotation quaternion of the object in babylon space.
  80597. */
  80598. rotationQuaternion: Quaternion;
  80599. /**
  80600. * The position of the device in babylon space.
  80601. */
  80602. devicePosition?: Vector3;
  80603. /**
  80604. * The rotation quaternion of the device in babylon space.
  80605. */
  80606. deviceRotationQuaternion: Quaternion;
  80607. /**
  80608. * The raw pose coming from the device.
  80609. */
  80610. rawPose: Nullable<DevicePose>;
  80611. /**
  80612. * The scale of the device to be used when translating from device space to babylon space.
  80613. */
  80614. deviceScaleFactor: number;
  80615. /**
  80616. * Updates the poseControlled values based on the input device pose.
  80617. * @param poseData the pose data to update the object with
  80618. */
  80619. updateFromDevice(poseData: DevicePose): void;
  80620. }
  80621. /**
  80622. * Set of options to customize the webVRCamera
  80623. */
  80624. export interface WebVROptions {
  80625. /**
  80626. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  80627. */
  80628. trackPosition?: boolean;
  80629. /**
  80630. * Sets the scale of the vrDevice in babylon space. (default: 1)
  80631. */
  80632. positionScale?: number;
  80633. /**
  80634. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  80635. */
  80636. displayName?: string;
  80637. /**
  80638. * Should the native controller meshes be initialized. (default: true)
  80639. */
  80640. controllerMeshes?: boolean;
  80641. /**
  80642. * Creating a default HemiLight only on controllers. (default: true)
  80643. */
  80644. defaultLightingOnControllers?: boolean;
  80645. /**
  80646. * If you don't want to use the default VR button of the helper. (default: false)
  80647. */
  80648. useCustomVRButton?: boolean;
  80649. /**
  80650. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  80651. */
  80652. customVRButton?: HTMLButtonElement;
  80653. /**
  80654. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  80655. */
  80656. rayLength?: number;
  80657. /**
  80658. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  80659. */
  80660. defaultHeight?: number;
  80661. /**
  80662. * If multiview should be used if availible (default: false)
  80663. */
  80664. useMultiview?: boolean;
  80665. }
  80666. /**
  80667. * This represents a WebVR camera.
  80668. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  80669. * @example http://doc.babylonjs.com/how_to/webvr_camera
  80670. */
  80671. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  80672. private webVROptions;
  80673. /**
  80674. * @hidden
  80675. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  80676. */
  80677. _vrDevice: any;
  80678. /**
  80679. * The rawPose of the vrDevice.
  80680. */
  80681. rawPose: Nullable<DevicePose>;
  80682. private _onVREnabled;
  80683. private _specsVersion;
  80684. private _attached;
  80685. private _frameData;
  80686. protected _descendants: Array<Node>;
  80687. private _deviceRoomPosition;
  80688. /** @hidden */
  80689. _deviceRoomRotationQuaternion: Quaternion;
  80690. private _standingMatrix;
  80691. /**
  80692. * Represents device position in babylon space.
  80693. */
  80694. devicePosition: Vector3;
  80695. /**
  80696. * Represents device rotation in babylon space.
  80697. */
  80698. deviceRotationQuaternion: Quaternion;
  80699. /**
  80700. * The scale of the device to be used when translating from device space to babylon space.
  80701. */
  80702. deviceScaleFactor: number;
  80703. private _deviceToWorld;
  80704. private _worldToDevice;
  80705. /**
  80706. * References to the webVR controllers for the vrDevice.
  80707. */
  80708. controllers: Array<WebVRController>;
  80709. /**
  80710. * Emits an event when a controller is attached.
  80711. */
  80712. onControllersAttachedObservable: Observable<WebVRController[]>;
  80713. /**
  80714. * Emits an event when a controller's mesh has been loaded;
  80715. */
  80716. onControllerMeshLoadedObservable: Observable<WebVRController>;
  80717. /**
  80718. * Emits an event when the HMD's pose has been updated.
  80719. */
  80720. onPoseUpdatedFromDeviceObservable: Observable<any>;
  80721. private _poseSet;
  80722. /**
  80723. * If the rig cameras be used as parent instead of this camera.
  80724. */
  80725. rigParenting: boolean;
  80726. private _lightOnControllers;
  80727. private _defaultHeight?;
  80728. /**
  80729. * Instantiates a WebVRFreeCamera.
  80730. * @param name The name of the WebVRFreeCamera
  80731. * @param position The starting anchor position for the camera
  80732. * @param scene The scene the camera belongs to
  80733. * @param webVROptions a set of customizable options for the webVRCamera
  80734. */
  80735. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  80736. /**
  80737. * Gets the device distance from the ground in meters.
  80738. * @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.
  80739. */
  80740. deviceDistanceToRoomGround(): number;
  80741. /**
  80742. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80743. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  80744. */
  80745. useStandingMatrix(callback?: (bool: boolean) => void): void;
  80746. /**
  80747. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80748. * @returns A promise with a boolean set to if the standing matrix is supported.
  80749. */
  80750. useStandingMatrixAsync(): Promise<boolean>;
  80751. /**
  80752. * Disposes the camera
  80753. */
  80754. dispose(): void;
  80755. /**
  80756. * Gets a vrController by name.
  80757. * @param name The name of the controller to retreive
  80758. * @returns the controller matching the name specified or null if not found
  80759. */
  80760. getControllerByName(name: string): Nullable<WebVRController>;
  80761. private _leftController;
  80762. /**
  80763. * The controller corresponding to the users left hand.
  80764. */
  80765. readonly leftController: Nullable<WebVRController>;
  80766. private _rightController;
  80767. /**
  80768. * The controller corresponding to the users right hand.
  80769. */
  80770. readonly rightController: Nullable<WebVRController>;
  80771. /**
  80772. * Casts a ray forward from the vrCamera's gaze.
  80773. * @param length Length of the ray (default: 100)
  80774. * @returns the ray corresponding to the gaze
  80775. */
  80776. getForwardRay(length?: number): Ray;
  80777. /**
  80778. * @hidden
  80779. * Updates the camera based on device's frame data
  80780. */
  80781. _checkInputs(): void;
  80782. /**
  80783. * Updates the poseControlled values based on the input device pose.
  80784. * @param poseData Pose coming from the device
  80785. */
  80786. updateFromDevice(poseData: DevicePose): void;
  80787. private _htmlElementAttached;
  80788. private _detachIfAttached;
  80789. /**
  80790. * WebVR's attach control will start broadcasting frames to the device.
  80791. * Note that in certain browsers (chrome for example) this function must be called
  80792. * within a user-interaction callback. Example:
  80793. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  80794. *
  80795. * @param element html element to attach the vrDevice to
  80796. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  80797. */
  80798. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80799. /**
  80800. * Detaches the camera from the html element and disables VR
  80801. *
  80802. * @param element html element to detach from
  80803. */
  80804. detachControl(element: HTMLElement): void;
  80805. /**
  80806. * @returns the name of this class
  80807. */
  80808. getClassName(): string;
  80809. /**
  80810. * Calls resetPose on the vrDisplay
  80811. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  80812. */
  80813. resetToCurrentRotation(): void;
  80814. /**
  80815. * @hidden
  80816. * Updates the rig cameras (left and right eye)
  80817. */
  80818. _updateRigCameras(): void;
  80819. private _workingVector;
  80820. private _oneVector;
  80821. private _workingMatrix;
  80822. private updateCacheCalled;
  80823. private _correctPositionIfNotTrackPosition;
  80824. /**
  80825. * @hidden
  80826. * Updates the cached values of the camera
  80827. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  80828. */
  80829. _updateCache(ignoreParentClass?: boolean): void;
  80830. /**
  80831. * @hidden
  80832. * Get current device position in babylon world
  80833. */
  80834. _computeDevicePosition(): void;
  80835. /**
  80836. * Updates the current device position and rotation in the babylon world
  80837. */
  80838. update(): void;
  80839. /**
  80840. * @hidden
  80841. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  80842. * @returns an identity matrix
  80843. */
  80844. _getViewMatrix(): Matrix;
  80845. private _tmpMatrix;
  80846. /**
  80847. * This function is called by the two RIG cameras.
  80848. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  80849. * @hidden
  80850. */
  80851. _getWebVRViewMatrix(): Matrix;
  80852. /** @hidden */
  80853. _getWebVRProjectionMatrix(): Matrix;
  80854. private _onGamepadConnectedObserver;
  80855. private _onGamepadDisconnectedObserver;
  80856. private _updateCacheWhenTrackingDisabledObserver;
  80857. /**
  80858. * Initializes the controllers and their meshes
  80859. */
  80860. initControllers(): void;
  80861. }
  80862. }
  80863. declare module BABYLON {
  80864. /**
  80865. * Size options for a post process
  80866. */
  80867. export type PostProcessOptions = {
  80868. width: number;
  80869. height: number;
  80870. };
  80871. /**
  80872. * PostProcess can be used to apply a shader to a texture after it has been rendered
  80873. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  80874. */
  80875. export class PostProcess {
  80876. /** Name of the PostProcess. */
  80877. name: string;
  80878. /**
  80879. * Gets or sets the unique id of the post process
  80880. */
  80881. uniqueId: number;
  80882. /**
  80883. * Width of the texture to apply the post process on
  80884. */
  80885. width: number;
  80886. /**
  80887. * Height of the texture to apply the post process on
  80888. */
  80889. height: number;
  80890. /**
  80891. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  80892. * @hidden
  80893. */
  80894. _outputTexture: Nullable<InternalTexture>;
  80895. /**
  80896. * Sampling mode used by the shader
  80897. * See https://doc.babylonjs.com/classes/3.1/texture
  80898. */
  80899. renderTargetSamplingMode: number;
  80900. /**
  80901. * Clear color to use when screen clearing
  80902. */
  80903. clearColor: Color4;
  80904. /**
  80905. * If the buffer needs to be cleared before applying the post process. (default: true)
  80906. * Should be set to false if shader will overwrite all previous pixels.
  80907. */
  80908. autoClear: boolean;
  80909. /**
  80910. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  80911. */
  80912. alphaMode: number;
  80913. /**
  80914. * Sets the setAlphaBlendConstants of the babylon engine
  80915. */
  80916. alphaConstants: Color4;
  80917. /**
  80918. * Animations to be used for the post processing
  80919. */
  80920. animations: Animation[];
  80921. /**
  80922. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  80923. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  80924. */
  80925. enablePixelPerfectMode: boolean;
  80926. /**
  80927. * Force the postprocess to be applied without taking in account viewport
  80928. */
  80929. forceFullscreenViewport: boolean;
  80930. /**
  80931. * List of inspectable custom properties (used by the Inspector)
  80932. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80933. */
  80934. inspectableCustomProperties: IInspectable[];
  80935. /**
  80936. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  80937. *
  80938. * | Value | Type | Description |
  80939. * | ----- | ----------------------------------- | ----------- |
  80940. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  80941. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  80942. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  80943. *
  80944. */
  80945. scaleMode: number;
  80946. /**
  80947. * Force textures to be a power of two (default: false)
  80948. */
  80949. alwaysForcePOT: boolean;
  80950. private _samples;
  80951. /**
  80952. * Number of sample textures (default: 1)
  80953. */
  80954. samples: number;
  80955. /**
  80956. * Modify the scale of the post process to be the same as the viewport (default: false)
  80957. */
  80958. adaptScaleToCurrentViewport: boolean;
  80959. private _camera;
  80960. private _scene;
  80961. private _engine;
  80962. private _options;
  80963. private _reusable;
  80964. private _textureType;
  80965. /**
  80966. * Smart array of input and output textures for the post process.
  80967. * @hidden
  80968. */
  80969. _textures: SmartArray<InternalTexture>;
  80970. /**
  80971. * The index in _textures that corresponds to the output texture.
  80972. * @hidden
  80973. */
  80974. _currentRenderTextureInd: number;
  80975. private _effect;
  80976. private _samplers;
  80977. private _fragmentUrl;
  80978. private _vertexUrl;
  80979. private _parameters;
  80980. private _scaleRatio;
  80981. protected _indexParameters: any;
  80982. private _shareOutputWithPostProcess;
  80983. private _texelSize;
  80984. private _forcedOutputTexture;
  80985. /**
  80986. * Returns the fragment url or shader name used in the post process.
  80987. * @returns the fragment url or name in the shader store.
  80988. */
  80989. getEffectName(): string;
  80990. /**
  80991. * An event triggered when the postprocess is activated.
  80992. */
  80993. onActivateObservable: Observable<Camera>;
  80994. private _onActivateObserver;
  80995. /**
  80996. * A function that is added to the onActivateObservable
  80997. */
  80998. onActivate: Nullable<(camera: Camera) => void>;
  80999. /**
  81000. * An event triggered when the postprocess changes its size.
  81001. */
  81002. onSizeChangedObservable: Observable<PostProcess>;
  81003. private _onSizeChangedObserver;
  81004. /**
  81005. * A function that is added to the onSizeChangedObservable
  81006. */
  81007. onSizeChanged: (postProcess: PostProcess) => void;
  81008. /**
  81009. * An event triggered when the postprocess applies its effect.
  81010. */
  81011. onApplyObservable: Observable<Effect>;
  81012. private _onApplyObserver;
  81013. /**
  81014. * A function that is added to the onApplyObservable
  81015. */
  81016. onApply: (effect: Effect) => void;
  81017. /**
  81018. * An event triggered before rendering the postprocess
  81019. */
  81020. onBeforeRenderObservable: Observable<Effect>;
  81021. private _onBeforeRenderObserver;
  81022. /**
  81023. * A function that is added to the onBeforeRenderObservable
  81024. */
  81025. onBeforeRender: (effect: Effect) => void;
  81026. /**
  81027. * An event triggered after rendering the postprocess
  81028. */
  81029. onAfterRenderObservable: Observable<Effect>;
  81030. private _onAfterRenderObserver;
  81031. /**
  81032. * A function that is added to the onAfterRenderObservable
  81033. */
  81034. onAfterRender: (efect: Effect) => void;
  81035. /**
  81036. * 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
  81037. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  81038. */
  81039. inputTexture: InternalTexture;
  81040. /**
  81041. * Gets the camera which post process is applied to.
  81042. * @returns The camera the post process is applied to.
  81043. */
  81044. getCamera(): Camera;
  81045. /**
  81046. * Gets the texel size of the postprocess.
  81047. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  81048. */
  81049. readonly texelSize: Vector2;
  81050. /**
  81051. * Creates a new instance PostProcess
  81052. * @param name The name of the PostProcess.
  81053. * @param fragmentUrl The url of the fragment shader to be used.
  81054. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  81055. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  81056. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  81057. * @param camera The camera to apply the render pass to.
  81058. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  81059. * @param engine The engine which the post process will be applied. (default: current engine)
  81060. * @param reusable If the post process can be reused on the same frame. (default: false)
  81061. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  81062. * @param textureType Type of textures used when performing the post process. (default: 0)
  81063. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  81064. * @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
  81065. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  81066. */
  81067. constructor(
  81068. /** Name of the PostProcess. */
  81069. 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);
  81070. /**
  81071. * Gets a string idenfifying the name of the class
  81072. * @returns "PostProcess" string
  81073. */
  81074. getClassName(): string;
  81075. /**
  81076. * Gets the engine which this post process belongs to.
  81077. * @returns The engine the post process was enabled with.
  81078. */
  81079. getEngine(): Engine;
  81080. /**
  81081. * The effect that is created when initializing the post process.
  81082. * @returns The created effect corresponding the the postprocess.
  81083. */
  81084. getEffect(): Effect;
  81085. /**
  81086. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  81087. * @param postProcess The post process to share the output with.
  81088. * @returns This post process.
  81089. */
  81090. shareOutputWith(postProcess: PostProcess): PostProcess;
  81091. /**
  81092. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  81093. * This should be called if the post process that shares output with this post process is disabled/disposed.
  81094. */
  81095. useOwnOutput(): void;
  81096. /**
  81097. * Updates the effect with the current post process compile time values and recompiles the shader.
  81098. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  81099. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  81100. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  81101. * @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
  81102. * @param onCompiled Called when the shader has been compiled.
  81103. * @param onError Called if there is an error when compiling a shader.
  81104. */
  81105. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81106. /**
  81107. * The post process is reusable if it can be used multiple times within one frame.
  81108. * @returns If the post process is reusable
  81109. */
  81110. isReusable(): boolean;
  81111. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  81112. markTextureDirty(): void;
  81113. /**
  81114. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  81115. * 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.
  81116. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  81117. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  81118. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  81119. * @returns The target texture that was bound to be written to.
  81120. */
  81121. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  81122. /**
  81123. * If the post process is supported.
  81124. */
  81125. readonly isSupported: boolean;
  81126. /**
  81127. * The aspect ratio of the output texture.
  81128. */
  81129. readonly aspectRatio: number;
  81130. /**
  81131. * Get a value indicating if the post-process is ready to be used
  81132. * @returns true if the post-process is ready (shader is compiled)
  81133. */
  81134. isReady(): boolean;
  81135. /**
  81136. * Binds all textures and uniforms to the shader, this will be run on every pass.
  81137. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  81138. */
  81139. apply(): Nullable<Effect>;
  81140. private _disposeTextures;
  81141. /**
  81142. * Disposes the post process.
  81143. * @param camera The camera to dispose the post process on.
  81144. */
  81145. dispose(camera?: Camera): void;
  81146. }
  81147. }
  81148. declare module BABYLON {
  81149. /** @hidden */
  81150. export var kernelBlurVaryingDeclaration: {
  81151. name: string;
  81152. shader: string;
  81153. };
  81154. }
  81155. declare module BABYLON {
  81156. /** @hidden */
  81157. export var kernelBlurFragment: {
  81158. name: string;
  81159. shader: string;
  81160. };
  81161. }
  81162. declare module BABYLON {
  81163. /** @hidden */
  81164. export var kernelBlurFragment2: {
  81165. name: string;
  81166. shader: string;
  81167. };
  81168. }
  81169. declare module BABYLON {
  81170. /** @hidden */
  81171. export var kernelBlurPixelShader: {
  81172. name: string;
  81173. shader: string;
  81174. };
  81175. }
  81176. declare module BABYLON {
  81177. /** @hidden */
  81178. export var kernelBlurVertex: {
  81179. name: string;
  81180. shader: string;
  81181. };
  81182. }
  81183. declare module BABYLON {
  81184. /** @hidden */
  81185. export var kernelBlurVertexShader: {
  81186. name: string;
  81187. shader: string;
  81188. };
  81189. }
  81190. declare module BABYLON {
  81191. /**
  81192. * The Blur Post Process which blurs an image based on a kernel and direction.
  81193. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  81194. */
  81195. export class BlurPostProcess extends PostProcess {
  81196. /** The direction in which to blur the image. */
  81197. direction: Vector2;
  81198. private blockCompilation;
  81199. protected _kernel: number;
  81200. protected _idealKernel: number;
  81201. protected _packedFloat: boolean;
  81202. private _staticDefines;
  81203. /**
  81204. * Sets the length in pixels of the blur sample region
  81205. */
  81206. /**
  81207. * Gets the length in pixels of the blur sample region
  81208. */
  81209. kernel: number;
  81210. /**
  81211. * Sets wether or not the blur needs to unpack/repack floats
  81212. */
  81213. /**
  81214. * Gets wether or not the blur is unpacking/repacking floats
  81215. */
  81216. packedFloat: boolean;
  81217. /**
  81218. * Creates a new instance BlurPostProcess
  81219. * @param name The name of the effect.
  81220. * @param direction The direction in which to blur the image.
  81221. * @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.
  81222. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  81223. * @param camera The camera to apply the render pass to.
  81224. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  81225. * @param engine The engine which the post process will be applied. (default: current engine)
  81226. * @param reusable If the post process can be reused on the same frame. (default: false)
  81227. * @param textureType Type of textures used when performing the post process. (default: 0)
  81228. * @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)
  81229. */
  81230. constructor(name: string,
  81231. /** The direction in which to blur the image. */
  81232. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  81233. /**
  81234. * Updates the effect with the current post process compile time values and recompiles the shader.
  81235. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  81236. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  81237. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  81238. * @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
  81239. * @param onCompiled Called when the shader has been compiled.
  81240. * @param onError Called if there is an error when compiling a shader.
  81241. */
  81242. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81243. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81244. /**
  81245. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  81246. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  81247. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  81248. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  81249. * The gaps between physical kernels are compensated for in the weighting of the samples
  81250. * @param idealKernel Ideal blur kernel.
  81251. * @return Nearest best kernel.
  81252. */
  81253. protected _nearestBestKernel(idealKernel: number): number;
  81254. /**
  81255. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  81256. * @param x The point on the Gaussian distribution to sample.
  81257. * @return the value of the Gaussian function at x.
  81258. */
  81259. protected _gaussianWeight(x: number): number;
  81260. /**
  81261. * Generates a string that can be used as a floating point number in GLSL.
  81262. * @param x Value to print.
  81263. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  81264. * @return GLSL float string.
  81265. */
  81266. protected _glslFloat(x: number, decimalFigures?: number): string;
  81267. }
  81268. }
  81269. declare module BABYLON {
  81270. /**
  81271. * Mirror texture can be used to simulate the view from a mirror in a scene.
  81272. * It will dynamically be rendered every frame to adapt to the camera point of view.
  81273. * You can then easily use it as a reflectionTexture on a flat surface.
  81274. * In case the surface is not a plane, please consider relying on reflection probes.
  81275. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81276. */
  81277. export class MirrorTexture extends RenderTargetTexture {
  81278. private scene;
  81279. /**
  81280. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  81281. * 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.
  81282. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81283. */
  81284. mirrorPlane: Plane;
  81285. /**
  81286. * Define the blur ratio used to blur the reflection if needed.
  81287. */
  81288. blurRatio: number;
  81289. /**
  81290. * Define the adaptive blur kernel used to blur the reflection if needed.
  81291. * This will autocompute the closest best match for the `blurKernel`
  81292. */
  81293. adaptiveBlurKernel: number;
  81294. /**
  81295. * Define the blur kernel used to blur the reflection if needed.
  81296. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81297. */
  81298. blurKernel: number;
  81299. /**
  81300. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  81301. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81302. */
  81303. blurKernelX: number;
  81304. /**
  81305. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  81306. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81307. */
  81308. blurKernelY: number;
  81309. private _autoComputeBlurKernel;
  81310. protected _onRatioRescale(): void;
  81311. private _updateGammaSpace;
  81312. private _imageProcessingConfigChangeObserver;
  81313. private _transformMatrix;
  81314. private _mirrorMatrix;
  81315. private _savedViewMatrix;
  81316. private _blurX;
  81317. private _blurY;
  81318. private _adaptiveBlurKernel;
  81319. private _blurKernelX;
  81320. private _blurKernelY;
  81321. private _blurRatio;
  81322. /**
  81323. * Instantiates a Mirror Texture.
  81324. * Mirror texture can be used to simulate the view from a mirror in a scene.
  81325. * It will dynamically be rendered every frame to adapt to the camera point of view.
  81326. * You can then easily use it as a reflectionTexture on a flat surface.
  81327. * In case the surface is not a plane, please consider relying on reflection probes.
  81328. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81329. * @param name
  81330. * @param size
  81331. * @param scene
  81332. * @param generateMipMaps
  81333. * @param type
  81334. * @param samplingMode
  81335. * @param generateDepthBuffer
  81336. */
  81337. constructor(name: string, size: number | {
  81338. width: number;
  81339. height: number;
  81340. } | {
  81341. ratio: number;
  81342. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  81343. private _preparePostProcesses;
  81344. /**
  81345. * Clone the mirror texture.
  81346. * @returns the cloned texture
  81347. */
  81348. clone(): MirrorTexture;
  81349. /**
  81350. * Serialize the texture to a JSON representation you could use in Parse later on
  81351. * @returns the serialized JSON representation
  81352. */
  81353. serialize(): any;
  81354. /**
  81355. * Dispose the texture and release its associated resources.
  81356. */
  81357. dispose(): void;
  81358. }
  81359. }
  81360. declare module BABYLON {
  81361. /**
  81362. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  81363. * @see http://doc.babylonjs.com/babylon101/materials#texture
  81364. */
  81365. export class Texture extends BaseTexture {
  81366. /**
  81367. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  81368. */
  81369. static SerializeBuffers: boolean;
  81370. /** @hidden */
  81371. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  81372. /** @hidden */
  81373. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  81374. /** @hidden */
  81375. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  81376. /** nearest is mag = nearest and min = nearest and mip = linear */
  81377. static readonly NEAREST_SAMPLINGMODE: number;
  81378. /** nearest is mag = nearest and min = nearest and mip = linear */
  81379. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  81380. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81381. static readonly BILINEAR_SAMPLINGMODE: number;
  81382. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81383. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  81384. /** Trilinear is mag = linear and min = linear and mip = linear */
  81385. static readonly TRILINEAR_SAMPLINGMODE: number;
  81386. /** Trilinear is mag = linear and min = linear and mip = linear */
  81387. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  81388. /** mag = nearest and min = nearest and mip = nearest */
  81389. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  81390. /** mag = nearest and min = linear and mip = nearest */
  81391. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  81392. /** mag = nearest and min = linear and mip = linear */
  81393. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  81394. /** mag = nearest and min = linear and mip = none */
  81395. static readonly NEAREST_LINEAR: number;
  81396. /** mag = nearest and min = nearest and mip = none */
  81397. static readonly NEAREST_NEAREST: number;
  81398. /** mag = linear and min = nearest and mip = nearest */
  81399. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  81400. /** mag = linear and min = nearest and mip = linear */
  81401. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  81402. /** mag = linear and min = linear and mip = none */
  81403. static readonly LINEAR_LINEAR: number;
  81404. /** mag = linear and min = nearest and mip = none */
  81405. static readonly LINEAR_NEAREST: number;
  81406. /** Explicit coordinates mode */
  81407. static readonly EXPLICIT_MODE: number;
  81408. /** Spherical coordinates mode */
  81409. static readonly SPHERICAL_MODE: number;
  81410. /** Planar coordinates mode */
  81411. static readonly PLANAR_MODE: number;
  81412. /** Cubic coordinates mode */
  81413. static readonly CUBIC_MODE: number;
  81414. /** Projection coordinates mode */
  81415. static readonly PROJECTION_MODE: number;
  81416. /** Inverse Cubic coordinates mode */
  81417. static readonly SKYBOX_MODE: number;
  81418. /** Inverse Cubic coordinates mode */
  81419. static readonly INVCUBIC_MODE: number;
  81420. /** Equirectangular coordinates mode */
  81421. static readonly EQUIRECTANGULAR_MODE: number;
  81422. /** Equirectangular Fixed coordinates mode */
  81423. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  81424. /** Equirectangular Fixed Mirrored coordinates mode */
  81425. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  81426. /** Texture is not repeating outside of 0..1 UVs */
  81427. static readonly CLAMP_ADDRESSMODE: number;
  81428. /** Texture is repeating outside of 0..1 UVs */
  81429. static readonly WRAP_ADDRESSMODE: number;
  81430. /** Texture is repeating and mirrored */
  81431. static readonly MIRROR_ADDRESSMODE: number;
  81432. /**
  81433. * 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
  81434. */
  81435. static UseSerializedUrlIfAny: boolean;
  81436. /**
  81437. * Define the url of the texture.
  81438. */
  81439. url: Nullable<string>;
  81440. /**
  81441. * Define an offset on the texture to offset the u coordinates of the UVs
  81442. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  81443. */
  81444. uOffset: number;
  81445. /**
  81446. * Define an offset on the texture to offset the v coordinates of the UVs
  81447. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  81448. */
  81449. vOffset: number;
  81450. /**
  81451. * Define an offset on the texture to scale the u coordinates of the UVs
  81452. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81453. */
  81454. uScale: number;
  81455. /**
  81456. * Define an offset on the texture to scale the v coordinates of the UVs
  81457. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81458. */
  81459. vScale: number;
  81460. /**
  81461. * Define an offset on the texture to rotate around the u coordinates of the UVs
  81462. * @see http://doc.babylonjs.com/how_to/more_materials
  81463. */
  81464. uAng: number;
  81465. /**
  81466. * Define an offset on the texture to rotate around the v coordinates of the UVs
  81467. * @see http://doc.babylonjs.com/how_to/more_materials
  81468. */
  81469. vAng: number;
  81470. /**
  81471. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  81472. * @see http://doc.babylonjs.com/how_to/more_materials
  81473. */
  81474. wAng: number;
  81475. /**
  81476. * Defines the center of rotation (U)
  81477. */
  81478. uRotationCenter: number;
  81479. /**
  81480. * Defines the center of rotation (V)
  81481. */
  81482. vRotationCenter: number;
  81483. /**
  81484. * Defines the center of rotation (W)
  81485. */
  81486. wRotationCenter: number;
  81487. /**
  81488. * Are mip maps generated for this texture or not.
  81489. */
  81490. readonly noMipmap: boolean;
  81491. /**
  81492. * List of inspectable custom properties (used by the Inspector)
  81493. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81494. */
  81495. inspectableCustomProperties: Nullable<IInspectable[]>;
  81496. private _noMipmap;
  81497. /** @hidden */
  81498. _invertY: boolean;
  81499. private _rowGenerationMatrix;
  81500. private _cachedTextureMatrix;
  81501. private _projectionModeMatrix;
  81502. private _t0;
  81503. private _t1;
  81504. private _t2;
  81505. private _cachedUOffset;
  81506. private _cachedVOffset;
  81507. private _cachedUScale;
  81508. private _cachedVScale;
  81509. private _cachedUAng;
  81510. private _cachedVAng;
  81511. private _cachedWAng;
  81512. private _cachedProjectionMatrixId;
  81513. private _cachedCoordinatesMode;
  81514. /** @hidden */
  81515. protected _initialSamplingMode: number;
  81516. /** @hidden */
  81517. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  81518. private _deleteBuffer;
  81519. protected _format: Nullable<number>;
  81520. private _delayedOnLoad;
  81521. private _delayedOnError;
  81522. /**
  81523. * Observable triggered once the texture has been loaded.
  81524. */
  81525. onLoadObservable: Observable<Texture>;
  81526. protected _isBlocking: boolean;
  81527. /**
  81528. * Is the texture preventing material to render while loading.
  81529. * If false, a default texture will be used instead of the loading one during the preparation step.
  81530. */
  81531. isBlocking: boolean;
  81532. /**
  81533. * Get the current sampling mode associated with the texture.
  81534. */
  81535. readonly samplingMode: number;
  81536. /**
  81537. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  81538. */
  81539. readonly invertY: boolean;
  81540. /**
  81541. * Instantiates a new texture.
  81542. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  81543. * @see http://doc.babylonjs.com/babylon101/materials#texture
  81544. * @param url define the url of the picture to load as a texture
  81545. * @param scene define the scene or engine the texture will belong to
  81546. * @param noMipmap define if the texture will require mip maps or not
  81547. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81548. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81549. * @param onLoad define a callback triggered when the texture has been loaded
  81550. * @param onError define a callback triggered when an error occurred during the loading session
  81551. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81552. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81553. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81554. */
  81555. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  81556. /**
  81557. * Update the url (and optional buffer) of this texture if url was null during construction.
  81558. * @param url the url of the texture
  81559. * @param buffer the buffer of the texture (defaults to null)
  81560. * @param onLoad callback called when the texture is loaded (defaults to null)
  81561. */
  81562. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  81563. /**
  81564. * Finish the loading sequence of a texture flagged as delayed load.
  81565. * @hidden
  81566. */
  81567. delayLoad(): void;
  81568. private _prepareRowForTextureGeneration;
  81569. /**
  81570. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  81571. * @returns the transform matrix of the texture.
  81572. */
  81573. getTextureMatrix(): Matrix;
  81574. /**
  81575. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  81576. * @returns The reflection texture transform
  81577. */
  81578. getReflectionTextureMatrix(): Matrix;
  81579. /**
  81580. * Clones the texture.
  81581. * @returns the cloned texture
  81582. */
  81583. clone(): Texture;
  81584. /**
  81585. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  81586. * @returns The JSON representation of the texture
  81587. */
  81588. serialize(): any;
  81589. /**
  81590. * Get the current class name of the texture useful for serialization or dynamic coding.
  81591. * @returns "Texture"
  81592. */
  81593. getClassName(): string;
  81594. /**
  81595. * Dispose the texture and release its associated resources.
  81596. */
  81597. dispose(): void;
  81598. /**
  81599. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  81600. * @param parsedTexture Define the JSON representation of the texture
  81601. * @param scene Define the scene the parsed texture should be instantiated in
  81602. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  81603. * @returns The parsed texture if successful
  81604. */
  81605. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  81606. /**
  81607. * Creates a texture from its base 64 representation.
  81608. * @param data Define the base64 payload without the data: prefix
  81609. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81610. * @param scene Define the scene the texture should belong to
  81611. * @param noMipmap Forces the texture to not create mip map information if true
  81612. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81613. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81614. * @param onLoad define a callback triggered when the texture has been loaded
  81615. * @param onError define a callback triggered when an error occurred during the loading session
  81616. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81617. * @returns the created texture
  81618. */
  81619. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  81620. /**
  81621. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  81622. * @param data Define the base64 payload without the data: prefix
  81623. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81624. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81625. * @param scene Define the scene the texture should belong to
  81626. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81627. * @param noMipmap Forces the texture to not create mip map information if true
  81628. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81629. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81630. * @param onLoad define a callback triggered when the texture has been loaded
  81631. * @param onError define a callback triggered when an error occurred during the loading session
  81632. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81633. * @returns the created texture
  81634. */
  81635. 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;
  81636. }
  81637. }
  81638. declare module BABYLON {
  81639. /**
  81640. * PostProcessManager is used to manage one or more post processes or post process pipelines
  81641. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  81642. */
  81643. export class PostProcessManager {
  81644. private _scene;
  81645. private _indexBuffer;
  81646. private _vertexBuffers;
  81647. /**
  81648. * Creates a new instance PostProcess
  81649. * @param scene The scene that the post process is associated with.
  81650. */
  81651. constructor(scene: Scene);
  81652. private _prepareBuffers;
  81653. private _buildIndexBuffer;
  81654. /**
  81655. * Rebuilds the vertex buffers of the manager.
  81656. * @hidden
  81657. */
  81658. _rebuild(): void;
  81659. /**
  81660. * Prepares a frame to be run through a post process.
  81661. * @param sourceTexture The input texture to the post procesess. (default: null)
  81662. * @param postProcesses An array of post processes to be run. (default: null)
  81663. * @returns True if the post processes were able to be run.
  81664. * @hidden
  81665. */
  81666. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  81667. /**
  81668. * Manually render a set of post processes to a texture.
  81669. * @param postProcesses An array of post processes to be run.
  81670. * @param targetTexture The target texture to render to.
  81671. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  81672. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  81673. * @param lodLevel defines which lod of the texture to render to
  81674. */
  81675. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  81676. /**
  81677. * Finalize the result of the output of the postprocesses.
  81678. * @param doNotPresent If true the result will not be displayed to the screen.
  81679. * @param targetTexture The target texture to render to.
  81680. * @param faceIndex The index of the face to bind the target texture to.
  81681. * @param postProcesses The array of post processes to render.
  81682. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  81683. * @hidden
  81684. */
  81685. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  81686. /**
  81687. * Disposes of the post process manager.
  81688. */
  81689. dispose(): void;
  81690. }
  81691. }
  81692. declare module BABYLON {
  81693. /** Interface used by value gradients (color, factor, ...) */
  81694. export interface IValueGradient {
  81695. /**
  81696. * Gets or sets the gradient value (between 0 and 1)
  81697. */
  81698. gradient: number;
  81699. }
  81700. /** Class used to store color4 gradient */
  81701. export class ColorGradient implements IValueGradient {
  81702. /**
  81703. * Gets or sets the gradient value (between 0 and 1)
  81704. */
  81705. gradient: number;
  81706. /**
  81707. * Gets or sets first associated color
  81708. */
  81709. color1: Color4;
  81710. /**
  81711. * Gets or sets second associated color
  81712. */
  81713. color2?: Color4;
  81714. /**
  81715. * Will get a color picked randomly between color1 and color2.
  81716. * If color2 is undefined then color1 will be used
  81717. * @param result defines the target Color4 to store the result in
  81718. */
  81719. getColorToRef(result: Color4): void;
  81720. }
  81721. /** Class used to store color 3 gradient */
  81722. export class Color3Gradient implements IValueGradient {
  81723. /**
  81724. * Gets or sets the gradient value (between 0 and 1)
  81725. */
  81726. gradient: number;
  81727. /**
  81728. * Gets or sets the associated color
  81729. */
  81730. color: Color3;
  81731. }
  81732. /** Class used to store factor gradient */
  81733. export class FactorGradient implements IValueGradient {
  81734. /**
  81735. * Gets or sets the gradient value (between 0 and 1)
  81736. */
  81737. gradient: number;
  81738. /**
  81739. * Gets or sets first associated factor
  81740. */
  81741. factor1: number;
  81742. /**
  81743. * Gets or sets second associated factor
  81744. */
  81745. factor2?: number;
  81746. /**
  81747. * Will get a number picked randomly between factor1 and factor2.
  81748. * If factor2 is undefined then factor1 will be used
  81749. * @returns the picked number
  81750. */
  81751. getFactor(): number;
  81752. }
  81753. /**
  81754. * Helper used to simplify some generic gradient tasks
  81755. */
  81756. export class GradientHelper {
  81757. /**
  81758. * Gets the current gradient from an array of IValueGradient
  81759. * @param ratio defines the current ratio to get
  81760. * @param gradients defines the array of IValueGradient
  81761. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  81762. */
  81763. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  81764. }
  81765. }
  81766. declare module BABYLON {
  81767. /**
  81768. * A class extending Texture allowing drawing on a texture
  81769. * @see http://doc.babylonjs.com/how_to/dynamictexture
  81770. */
  81771. export class DynamicTexture extends Texture {
  81772. private _generateMipMaps;
  81773. private _canvas;
  81774. private _context;
  81775. private _engine;
  81776. /**
  81777. * Creates a DynamicTexture
  81778. * @param name defines the name of the texture
  81779. * @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
  81780. * @param scene defines the scene where you want the texture
  81781. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  81782. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  81783. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  81784. */
  81785. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  81786. /**
  81787. * Get the current class name of the texture useful for serialization or dynamic coding.
  81788. * @returns "DynamicTexture"
  81789. */
  81790. getClassName(): string;
  81791. /**
  81792. * Gets the current state of canRescale
  81793. */
  81794. readonly canRescale: boolean;
  81795. private _recreate;
  81796. /**
  81797. * Scales the texture
  81798. * @param ratio the scale factor to apply to both width and height
  81799. */
  81800. scale(ratio: number): void;
  81801. /**
  81802. * Resizes the texture
  81803. * @param width the new width
  81804. * @param height the new height
  81805. */
  81806. scaleTo(width: number, height: number): void;
  81807. /**
  81808. * Gets the context of the canvas used by the texture
  81809. * @returns the canvas context of the dynamic texture
  81810. */
  81811. getContext(): CanvasRenderingContext2D;
  81812. /**
  81813. * Clears the texture
  81814. */
  81815. clear(): void;
  81816. /**
  81817. * Updates the texture
  81818. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  81819. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  81820. */
  81821. update(invertY?: boolean, premulAlpha?: boolean): void;
  81822. /**
  81823. * Draws text onto the texture
  81824. * @param text defines the text to be drawn
  81825. * @param x defines the placement of the text from the left
  81826. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  81827. * @param font defines the font to be used with font-style, font-size, font-name
  81828. * @param color defines the color used for the text
  81829. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  81830. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  81831. * @param update defines whether texture is immediately update (default is true)
  81832. */
  81833. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  81834. /**
  81835. * Clones the texture
  81836. * @returns the clone of the texture.
  81837. */
  81838. clone(): DynamicTexture;
  81839. /**
  81840. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  81841. * @returns a serialized dynamic texture object
  81842. */
  81843. serialize(): any;
  81844. /** @hidden */
  81845. _rebuild(): void;
  81846. }
  81847. }
  81848. declare module BABYLON {
  81849. interface AbstractScene {
  81850. /**
  81851. * The list of procedural textures added to the scene
  81852. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81853. */
  81854. proceduralTextures: Array<ProceduralTexture>;
  81855. }
  81856. /**
  81857. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  81858. * in a given scene.
  81859. */
  81860. export class ProceduralTextureSceneComponent implements ISceneComponent {
  81861. /**
  81862. * The component name helpfull to identify the component in the list of scene components.
  81863. */
  81864. readonly name: string;
  81865. /**
  81866. * The scene the component belongs to.
  81867. */
  81868. scene: Scene;
  81869. /**
  81870. * Creates a new instance of the component for the given scene
  81871. * @param scene Defines the scene to register the component in
  81872. */
  81873. constructor(scene: Scene);
  81874. /**
  81875. * Registers the component in a given scene
  81876. */
  81877. register(): void;
  81878. /**
  81879. * Rebuilds the elements related to this component in case of
  81880. * context lost for instance.
  81881. */
  81882. rebuild(): void;
  81883. /**
  81884. * Disposes the component and the associated ressources.
  81885. */
  81886. dispose(): void;
  81887. private _beforeClear;
  81888. }
  81889. }
  81890. declare module BABYLON {
  81891. interface Engine {
  81892. /**
  81893. * Creates a new render target cube texture
  81894. * @param size defines the size of the texture
  81895. * @param options defines the options used to create the texture
  81896. * @returns a new render target cube texture stored in an InternalTexture
  81897. */
  81898. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  81899. }
  81900. }
  81901. declare module BABYLON {
  81902. /** @hidden */
  81903. export var proceduralVertexShader: {
  81904. name: string;
  81905. shader: string;
  81906. };
  81907. }
  81908. declare module BABYLON {
  81909. /**
  81910. * 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.
  81911. * This is the base class of any Procedural texture and contains most of the shareable code.
  81912. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81913. */
  81914. export class ProceduralTexture extends Texture {
  81915. isCube: boolean;
  81916. /**
  81917. * Define if the texture is enabled or not (disabled texture will not render)
  81918. */
  81919. isEnabled: boolean;
  81920. /**
  81921. * Define if the texture must be cleared before rendering (default is true)
  81922. */
  81923. autoClear: boolean;
  81924. /**
  81925. * Callback called when the texture is generated
  81926. */
  81927. onGenerated: () => void;
  81928. /**
  81929. * Event raised when the texture is generated
  81930. */
  81931. onGeneratedObservable: Observable<ProceduralTexture>;
  81932. /** @hidden */
  81933. _generateMipMaps: boolean;
  81934. /** @hidden **/
  81935. _effect: Effect;
  81936. /** @hidden */
  81937. _textures: {
  81938. [key: string]: Texture;
  81939. };
  81940. private _size;
  81941. private _currentRefreshId;
  81942. private _refreshRate;
  81943. private _vertexBuffers;
  81944. private _indexBuffer;
  81945. private _uniforms;
  81946. private _samplers;
  81947. private _fragment;
  81948. private _floats;
  81949. private _ints;
  81950. private _floatsArrays;
  81951. private _colors3;
  81952. private _colors4;
  81953. private _vectors2;
  81954. private _vectors3;
  81955. private _matrices;
  81956. private _fallbackTexture;
  81957. private _fallbackTextureUsed;
  81958. private _engine;
  81959. private _cachedDefines;
  81960. private _contentUpdateId;
  81961. private _contentData;
  81962. /**
  81963. * Instantiates a new procedural texture.
  81964. * 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.
  81965. * This is the base class of any Procedural texture and contains most of the shareable code.
  81966. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81967. * @param name Define the name of the texture
  81968. * @param size Define the size of the texture to create
  81969. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  81970. * @param scene Define the scene the texture belongs to
  81971. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  81972. * @param generateMipMaps Define if the texture should creates mip maps or not
  81973. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  81974. */
  81975. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  81976. /**
  81977. * The effect that is created when initializing the post process.
  81978. * @returns The created effect corresponding the the postprocess.
  81979. */
  81980. getEffect(): Effect;
  81981. /**
  81982. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  81983. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  81984. */
  81985. getContent(): Nullable<ArrayBufferView>;
  81986. private _createIndexBuffer;
  81987. /** @hidden */
  81988. _rebuild(): void;
  81989. /**
  81990. * Resets the texture in order to recreate its associated resources.
  81991. * This can be called in case of context loss
  81992. */
  81993. reset(): void;
  81994. protected _getDefines(): string;
  81995. /**
  81996. * Is the texture ready to be used ? (rendered at least once)
  81997. * @returns true if ready, otherwise, false.
  81998. */
  81999. isReady(): boolean;
  82000. /**
  82001. * Resets the refresh counter of the texture and start bak from scratch.
  82002. * Could be useful to regenerate the texture if it is setup to render only once.
  82003. */
  82004. resetRefreshCounter(): void;
  82005. /**
  82006. * Set the fragment shader to use in order to render the texture.
  82007. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  82008. */
  82009. setFragment(fragment: any): void;
  82010. /**
  82011. * Define the refresh rate of the texture or the rendering frequency.
  82012. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  82013. */
  82014. refreshRate: number;
  82015. /** @hidden */
  82016. _shouldRender(): boolean;
  82017. /**
  82018. * Get the size the texture is rendering at.
  82019. * @returns the size (texture is always squared)
  82020. */
  82021. getRenderSize(): number;
  82022. /**
  82023. * Resize the texture to new value.
  82024. * @param size Define the new size the texture should have
  82025. * @param generateMipMaps Define whether the new texture should create mip maps
  82026. */
  82027. resize(size: number, generateMipMaps: boolean): void;
  82028. private _checkUniform;
  82029. /**
  82030. * Set a texture in the shader program used to render.
  82031. * @param name Define the name of the uniform samplers as defined in the shader
  82032. * @param texture Define the texture to bind to this sampler
  82033. * @return the texture itself allowing "fluent" like uniform updates
  82034. */
  82035. setTexture(name: string, texture: Texture): ProceduralTexture;
  82036. /**
  82037. * Set a float in the shader.
  82038. * @param name Define the name of the uniform as defined in the shader
  82039. * @param value Define the value to give to the uniform
  82040. * @return the texture itself allowing "fluent" like uniform updates
  82041. */
  82042. setFloat(name: string, value: number): ProceduralTexture;
  82043. /**
  82044. * Set a int in the shader.
  82045. * @param name Define the name of the uniform as defined in the shader
  82046. * @param value Define the value to give to the uniform
  82047. * @return the texture itself allowing "fluent" like uniform updates
  82048. */
  82049. setInt(name: string, value: number): ProceduralTexture;
  82050. /**
  82051. * Set an array of floats in the shader.
  82052. * @param name Define the name of the uniform as defined in the shader
  82053. * @param value Define the value to give to the uniform
  82054. * @return the texture itself allowing "fluent" like uniform updates
  82055. */
  82056. setFloats(name: string, value: number[]): ProceduralTexture;
  82057. /**
  82058. * Set a vec3 in the shader from a Color3.
  82059. * @param name Define the name of the uniform as defined in the shader
  82060. * @param value Define the value to give to the uniform
  82061. * @return the texture itself allowing "fluent" like uniform updates
  82062. */
  82063. setColor3(name: string, value: Color3): ProceduralTexture;
  82064. /**
  82065. * Set a vec4 in the shader from a Color4.
  82066. * @param name Define the name of the uniform as defined in the shader
  82067. * @param value Define the value to give to the uniform
  82068. * @return the texture itself allowing "fluent" like uniform updates
  82069. */
  82070. setColor4(name: string, value: Color4): ProceduralTexture;
  82071. /**
  82072. * Set a vec2 in the shader from a Vector2.
  82073. * @param name Define the name of the uniform as defined in the shader
  82074. * @param value Define the value to give to the uniform
  82075. * @return the texture itself allowing "fluent" like uniform updates
  82076. */
  82077. setVector2(name: string, value: Vector2): ProceduralTexture;
  82078. /**
  82079. * Set a vec3 in the shader from a Vector3.
  82080. * @param name Define the name of the uniform as defined in the shader
  82081. * @param value Define the value to give to the uniform
  82082. * @return the texture itself allowing "fluent" like uniform updates
  82083. */
  82084. setVector3(name: string, value: Vector3): ProceduralTexture;
  82085. /**
  82086. * Set a mat4 in the shader from a MAtrix.
  82087. * @param name Define the name of the uniform as defined in the shader
  82088. * @param value Define the value to give to the uniform
  82089. * @return the texture itself allowing "fluent" like uniform updates
  82090. */
  82091. setMatrix(name: string, value: Matrix): ProceduralTexture;
  82092. /**
  82093. * Render the texture to its associated render target.
  82094. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  82095. */
  82096. render(useCameraPostProcess?: boolean): void;
  82097. /**
  82098. * Clone the texture.
  82099. * @returns the cloned texture
  82100. */
  82101. clone(): ProceduralTexture;
  82102. /**
  82103. * Dispose the texture and release its asoociated resources.
  82104. */
  82105. dispose(): void;
  82106. }
  82107. }
  82108. declare module BABYLON {
  82109. /**
  82110. * This represents the base class for particle system in Babylon.
  82111. * 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.
  82112. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  82113. * @example https://doc.babylonjs.com/babylon101/particles
  82114. */
  82115. export class BaseParticleSystem {
  82116. /**
  82117. * Source color is added to the destination color without alpha affecting the result
  82118. */
  82119. static BLENDMODE_ONEONE: number;
  82120. /**
  82121. * Blend current color and particle color using particle’s alpha
  82122. */
  82123. static BLENDMODE_STANDARD: number;
  82124. /**
  82125. * Add current color and particle color multiplied by particle’s alpha
  82126. */
  82127. static BLENDMODE_ADD: number;
  82128. /**
  82129. * Multiply current color with particle color
  82130. */
  82131. static BLENDMODE_MULTIPLY: number;
  82132. /**
  82133. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  82134. */
  82135. static BLENDMODE_MULTIPLYADD: number;
  82136. /**
  82137. * List of animations used by the particle system.
  82138. */
  82139. animations: Animation[];
  82140. /**
  82141. * The id of the Particle system.
  82142. */
  82143. id: string;
  82144. /**
  82145. * The friendly name of the Particle system.
  82146. */
  82147. name: string;
  82148. /**
  82149. * The rendering group used by the Particle system to chose when to render.
  82150. */
  82151. renderingGroupId: number;
  82152. /**
  82153. * The emitter represents the Mesh or position we are attaching the particle system to.
  82154. */
  82155. emitter: Nullable<AbstractMesh | Vector3>;
  82156. /**
  82157. * The maximum number of particles to emit per frame
  82158. */
  82159. emitRate: number;
  82160. /**
  82161. * If you want to launch only a few particles at once, that can be done, as well.
  82162. */
  82163. manualEmitCount: number;
  82164. /**
  82165. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  82166. */
  82167. updateSpeed: number;
  82168. /**
  82169. * The amount of time the particle system is running (depends of the overall update speed).
  82170. */
  82171. targetStopDuration: number;
  82172. /**
  82173. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  82174. */
  82175. disposeOnStop: boolean;
  82176. /**
  82177. * Minimum power of emitting particles.
  82178. */
  82179. minEmitPower: number;
  82180. /**
  82181. * Maximum power of emitting particles.
  82182. */
  82183. maxEmitPower: number;
  82184. /**
  82185. * Minimum life time of emitting particles.
  82186. */
  82187. minLifeTime: number;
  82188. /**
  82189. * Maximum life time of emitting particles.
  82190. */
  82191. maxLifeTime: number;
  82192. /**
  82193. * Minimum Size of emitting particles.
  82194. */
  82195. minSize: number;
  82196. /**
  82197. * Maximum Size of emitting particles.
  82198. */
  82199. maxSize: number;
  82200. /**
  82201. * Minimum scale of emitting particles on X axis.
  82202. */
  82203. minScaleX: number;
  82204. /**
  82205. * Maximum scale of emitting particles on X axis.
  82206. */
  82207. maxScaleX: number;
  82208. /**
  82209. * Minimum scale of emitting particles on Y axis.
  82210. */
  82211. minScaleY: number;
  82212. /**
  82213. * Maximum scale of emitting particles on Y axis.
  82214. */
  82215. maxScaleY: number;
  82216. /**
  82217. * Gets or sets the minimal initial rotation in radians.
  82218. */
  82219. minInitialRotation: number;
  82220. /**
  82221. * Gets or sets the maximal initial rotation in radians.
  82222. */
  82223. maxInitialRotation: number;
  82224. /**
  82225. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  82226. */
  82227. minAngularSpeed: number;
  82228. /**
  82229. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  82230. */
  82231. maxAngularSpeed: number;
  82232. /**
  82233. * The texture used to render each particle. (this can be a spritesheet)
  82234. */
  82235. particleTexture: Nullable<Texture>;
  82236. /**
  82237. * The layer mask we are rendering the particles through.
  82238. */
  82239. layerMask: number;
  82240. /**
  82241. * This can help using your own shader to render the particle system.
  82242. * The according effect will be created
  82243. */
  82244. customShader: any;
  82245. /**
  82246. * By default particle system starts as soon as they are created. This prevents the
  82247. * automatic start to happen and let you decide when to start emitting particles.
  82248. */
  82249. preventAutoStart: boolean;
  82250. private _noiseTexture;
  82251. /**
  82252. * Gets or sets a texture used to add random noise to particle positions
  82253. */
  82254. noiseTexture: Nullable<ProceduralTexture>;
  82255. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  82256. noiseStrength: Vector3;
  82257. /**
  82258. * Callback triggered when the particle animation is ending.
  82259. */
  82260. onAnimationEnd: Nullable<() => void>;
  82261. /**
  82262. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  82263. */
  82264. blendMode: number;
  82265. /**
  82266. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  82267. * to override the particles.
  82268. */
  82269. forceDepthWrite: boolean;
  82270. /** 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 */
  82271. preWarmCycles: number;
  82272. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  82273. preWarmStepOffset: number;
  82274. /**
  82275. * 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)
  82276. */
  82277. spriteCellChangeSpeed: number;
  82278. /**
  82279. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  82280. */
  82281. startSpriteCellID: number;
  82282. /**
  82283. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  82284. */
  82285. endSpriteCellID: number;
  82286. /**
  82287. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  82288. */
  82289. spriteCellWidth: number;
  82290. /**
  82291. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  82292. */
  82293. spriteCellHeight: number;
  82294. /**
  82295. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  82296. */
  82297. spriteRandomStartCell: boolean;
  82298. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  82299. translationPivot: Vector2;
  82300. /** @hidden */
  82301. protected _isAnimationSheetEnabled: boolean;
  82302. /**
  82303. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  82304. */
  82305. beginAnimationOnStart: boolean;
  82306. /**
  82307. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  82308. */
  82309. beginAnimationFrom: number;
  82310. /**
  82311. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  82312. */
  82313. beginAnimationTo: number;
  82314. /**
  82315. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  82316. */
  82317. beginAnimationLoop: boolean;
  82318. /**
  82319. * Gets or sets a world offset applied to all particles
  82320. */
  82321. worldOffset: Vector3;
  82322. /**
  82323. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  82324. */
  82325. isAnimationSheetEnabled: boolean;
  82326. /**
  82327. * Get hosting scene
  82328. * @returns the scene
  82329. */
  82330. getScene(): Scene;
  82331. /**
  82332. * You can use gravity if you want to give an orientation to your particles.
  82333. */
  82334. gravity: Vector3;
  82335. protected _colorGradients: Nullable<Array<ColorGradient>>;
  82336. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  82337. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  82338. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  82339. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  82340. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  82341. protected _dragGradients: Nullable<Array<FactorGradient>>;
  82342. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  82343. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  82344. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  82345. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  82346. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  82347. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  82348. /**
  82349. * Defines the delay in milliseconds before starting the system (0 by default)
  82350. */
  82351. startDelay: number;
  82352. /**
  82353. * Gets the current list of drag gradients.
  82354. * You must use addDragGradient and removeDragGradient to udpate this list
  82355. * @returns the list of drag gradients
  82356. */
  82357. getDragGradients(): Nullable<Array<FactorGradient>>;
  82358. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  82359. limitVelocityDamping: number;
  82360. /**
  82361. * Gets the current list of limit velocity gradients.
  82362. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  82363. * @returns the list of limit velocity gradients
  82364. */
  82365. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  82366. /**
  82367. * Gets the current list of color gradients.
  82368. * You must use addColorGradient and removeColorGradient to udpate this list
  82369. * @returns the list of color gradients
  82370. */
  82371. getColorGradients(): Nullable<Array<ColorGradient>>;
  82372. /**
  82373. * Gets the current list of size gradients.
  82374. * You must use addSizeGradient and removeSizeGradient to udpate this list
  82375. * @returns the list of size gradients
  82376. */
  82377. getSizeGradients(): Nullable<Array<FactorGradient>>;
  82378. /**
  82379. * Gets the current list of color remap gradients.
  82380. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  82381. * @returns the list of color remap gradients
  82382. */
  82383. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  82384. /**
  82385. * Gets the current list of alpha remap gradients.
  82386. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  82387. * @returns the list of alpha remap gradients
  82388. */
  82389. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  82390. /**
  82391. * Gets the current list of life time gradients.
  82392. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  82393. * @returns the list of life time gradients
  82394. */
  82395. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  82396. /**
  82397. * Gets the current list of angular speed gradients.
  82398. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  82399. * @returns the list of angular speed gradients
  82400. */
  82401. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  82402. /**
  82403. * Gets the current list of velocity gradients.
  82404. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  82405. * @returns the list of velocity gradients
  82406. */
  82407. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  82408. /**
  82409. * Gets the current list of start size gradients.
  82410. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  82411. * @returns the list of start size gradients
  82412. */
  82413. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  82414. /**
  82415. * Gets the current list of emit rate gradients.
  82416. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  82417. * @returns the list of emit rate gradients
  82418. */
  82419. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  82420. /**
  82421. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82422. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82423. */
  82424. direction1: Vector3;
  82425. /**
  82426. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82427. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82428. */
  82429. direction2: Vector3;
  82430. /**
  82431. * 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.
  82432. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82433. */
  82434. minEmitBox: Vector3;
  82435. /**
  82436. * 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.
  82437. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82438. */
  82439. maxEmitBox: Vector3;
  82440. /**
  82441. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  82442. */
  82443. color1: Color4;
  82444. /**
  82445. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  82446. */
  82447. color2: Color4;
  82448. /**
  82449. * Color the particle will have at the end of its lifetime
  82450. */
  82451. colorDead: Color4;
  82452. /**
  82453. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  82454. */
  82455. textureMask: Color4;
  82456. /**
  82457. * The particle emitter type defines the emitter used by the particle system.
  82458. * It can be for example box, sphere, or cone...
  82459. */
  82460. particleEmitterType: IParticleEmitterType;
  82461. /** @hidden */
  82462. _isSubEmitter: boolean;
  82463. /**
  82464. * Gets or sets the billboard mode to use when isBillboardBased = true.
  82465. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  82466. */
  82467. billboardMode: number;
  82468. protected _isBillboardBased: boolean;
  82469. /**
  82470. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  82471. */
  82472. isBillboardBased: boolean;
  82473. /**
  82474. * The scene the particle system belongs to.
  82475. */
  82476. protected _scene: Scene;
  82477. /**
  82478. * Local cache of defines for image processing.
  82479. */
  82480. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  82481. /**
  82482. * Default configuration related to image processing available in the standard Material.
  82483. */
  82484. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  82485. /**
  82486. * Gets the image processing configuration used either in this material.
  82487. */
  82488. /**
  82489. * Sets the Default image processing configuration used either in the this material.
  82490. *
  82491. * If sets to null, the scene one is in use.
  82492. */
  82493. imageProcessingConfiguration: ImageProcessingConfiguration;
  82494. /**
  82495. * Attaches a new image processing configuration to the Standard Material.
  82496. * @param configuration
  82497. */
  82498. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  82499. /** @hidden */
  82500. protected _reset(): void;
  82501. /** @hidden */
  82502. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  82503. /**
  82504. * Instantiates a particle system.
  82505. * 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.
  82506. * @param name The name of the particle system
  82507. */
  82508. constructor(name: string);
  82509. /**
  82510. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  82511. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82512. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82513. * @returns the emitter
  82514. */
  82515. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  82516. /**
  82517. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  82518. * @param radius The radius of the hemisphere to emit from
  82519. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82520. * @returns the emitter
  82521. */
  82522. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  82523. /**
  82524. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  82525. * @param radius The radius of the sphere to emit from
  82526. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82527. * @returns the emitter
  82528. */
  82529. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  82530. /**
  82531. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  82532. * @param radius The radius of the sphere to emit from
  82533. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  82534. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  82535. * @returns the emitter
  82536. */
  82537. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  82538. /**
  82539. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  82540. * @param radius The radius of the emission cylinder
  82541. * @param height The height of the emission cylinder
  82542. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  82543. * @param directionRandomizer How much to randomize the particle direction [0-1]
  82544. * @returns the emitter
  82545. */
  82546. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  82547. /**
  82548. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  82549. * @param radius The radius of the cylinder to emit from
  82550. * @param height The height of the emission cylinder
  82551. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82552. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  82553. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  82554. * @returns the emitter
  82555. */
  82556. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  82557. /**
  82558. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  82559. * @param radius The radius of the cone to emit from
  82560. * @param angle The base angle of the cone
  82561. * @returns the emitter
  82562. */
  82563. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  82564. /**
  82565. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  82566. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82567. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82568. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82569. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82570. * @returns the emitter
  82571. */
  82572. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  82573. }
  82574. }
  82575. declare module BABYLON {
  82576. /**
  82577. * Type of sub emitter
  82578. */
  82579. export enum SubEmitterType {
  82580. /**
  82581. * Attached to the particle over it's lifetime
  82582. */
  82583. ATTACHED = 0,
  82584. /**
  82585. * Created when the particle dies
  82586. */
  82587. END = 1
  82588. }
  82589. /**
  82590. * Sub emitter class used to emit particles from an existing particle
  82591. */
  82592. export class SubEmitter {
  82593. /**
  82594. * the particle system to be used by the sub emitter
  82595. */
  82596. particleSystem: ParticleSystem;
  82597. /**
  82598. * Type of the submitter (Default: END)
  82599. */
  82600. type: SubEmitterType;
  82601. /**
  82602. * 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)
  82603. * Note: This only is supported when using an emitter of type Mesh
  82604. */
  82605. inheritDirection: boolean;
  82606. /**
  82607. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  82608. */
  82609. inheritedVelocityAmount: number;
  82610. /**
  82611. * Creates a sub emitter
  82612. * @param particleSystem the particle system to be used by the sub emitter
  82613. */
  82614. constructor(
  82615. /**
  82616. * the particle system to be used by the sub emitter
  82617. */
  82618. particleSystem: ParticleSystem);
  82619. /**
  82620. * Clones the sub emitter
  82621. * @returns the cloned sub emitter
  82622. */
  82623. clone(): SubEmitter;
  82624. /**
  82625. * Serialize current object to a JSON object
  82626. * @returns the serialized object
  82627. */
  82628. serialize(): any;
  82629. /** @hidden */
  82630. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  82631. /**
  82632. * Creates a new SubEmitter from a serialized JSON version
  82633. * @param serializationObject defines the JSON object to read from
  82634. * @param scene defines the hosting scene
  82635. * @param rootUrl defines the rootUrl for data loading
  82636. * @returns a new SubEmitter
  82637. */
  82638. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  82639. /** Release associated resources */
  82640. dispose(): void;
  82641. }
  82642. }
  82643. declare module BABYLON {
  82644. /** @hidden */
  82645. export var clipPlaneFragmentDeclaration: {
  82646. name: string;
  82647. shader: string;
  82648. };
  82649. }
  82650. declare module BABYLON {
  82651. /** @hidden */
  82652. export var imageProcessingDeclaration: {
  82653. name: string;
  82654. shader: string;
  82655. };
  82656. }
  82657. declare module BABYLON {
  82658. /** @hidden */
  82659. export var imageProcessingFunctions: {
  82660. name: string;
  82661. shader: string;
  82662. };
  82663. }
  82664. declare module BABYLON {
  82665. /** @hidden */
  82666. export var clipPlaneFragment: {
  82667. name: string;
  82668. shader: string;
  82669. };
  82670. }
  82671. declare module BABYLON {
  82672. /** @hidden */
  82673. export var particlesPixelShader: {
  82674. name: string;
  82675. shader: string;
  82676. };
  82677. }
  82678. declare module BABYLON {
  82679. /** @hidden */
  82680. export var clipPlaneVertexDeclaration: {
  82681. name: string;
  82682. shader: string;
  82683. };
  82684. }
  82685. declare module BABYLON {
  82686. /** @hidden */
  82687. export var clipPlaneVertex: {
  82688. name: string;
  82689. shader: string;
  82690. };
  82691. }
  82692. declare module BABYLON {
  82693. /** @hidden */
  82694. export var particlesVertexShader: {
  82695. name: string;
  82696. shader: string;
  82697. };
  82698. }
  82699. declare module BABYLON {
  82700. /**
  82701. * This represents a particle system in Babylon.
  82702. * 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.
  82703. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  82704. * @example https://doc.babylonjs.com/babylon101/particles
  82705. */
  82706. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  82707. /**
  82708. * Billboard mode will only apply to Y axis
  82709. */
  82710. static readonly BILLBOARDMODE_Y: number;
  82711. /**
  82712. * Billboard mode will apply to all axes
  82713. */
  82714. static readonly BILLBOARDMODE_ALL: number;
  82715. /**
  82716. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  82717. */
  82718. static readonly BILLBOARDMODE_STRETCHED: number;
  82719. /**
  82720. * This function can be defined to provide custom update for active particles.
  82721. * This function will be called instead of regular update (age, position, color, etc.).
  82722. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  82723. */
  82724. updateFunction: (particles: Particle[]) => void;
  82725. private _emitterWorldMatrix;
  82726. /**
  82727. * This function can be defined to specify initial direction for every new particle.
  82728. * It by default use the emitterType defined function
  82729. */
  82730. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  82731. /**
  82732. * This function can be defined to specify initial position for every new particle.
  82733. * It by default use the emitterType defined function
  82734. */
  82735. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  82736. /**
  82737. * @hidden
  82738. */
  82739. _inheritedVelocityOffset: Vector3;
  82740. /**
  82741. * An event triggered when the system is disposed
  82742. */
  82743. onDisposeObservable: Observable<ParticleSystem>;
  82744. private _onDisposeObserver;
  82745. /**
  82746. * Sets a callback that will be triggered when the system is disposed
  82747. */
  82748. onDispose: () => void;
  82749. private _particles;
  82750. private _epsilon;
  82751. private _capacity;
  82752. private _stockParticles;
  82753. private _newPartsExcess;
  82754. private _vertexData;
  82755. private _vertexBuffer;
  82756. private _vertexBuffers;
  82757. private _spriteBuffer;
  82758. private _indexBuffer;
  82759. private _effect;
  82760. private _customEffect;
  82761. private _cachedDefines;
  82762. private _scaledColorStep;
  82763. private _colorDiff;
  82764. private _scaledDirection;
  82765. private _scaledGravity;
  82766. private _currentRenderId;
  82767. private _alive;
  82768. private _useInstancing;
  82769. private _started;
  82770. private _stopped;
  82771. private _actualFrame;
  82772. private _scaledUpdateSpeed;
  82773. private _vertexBufferSize;
  82774. /** @hidden */
  82775. _currentEmitRateGradient: Nullable<FactorGradient>;
  82776. /** @hidden */
  82777. _currentEmitRate1: number;
  82778. /** @hidden */
  82779. _currentEmitRate2: number;
  82780. /** @hidden */
  82781. _currentStartSizeGradient: Nullable<FactorGradient>;
  82782. /** @hidden */
  82783. _currentStartSize1: number;
  82784. /** @hidden */
  82785. _currentStartSize2: number;
  82786. private readonly _rawTextureWidth;
  82787. private _rampGradientsTexture;
  82788. private _useRampGradients;
  82789. /** Gets or sets a boolean indicating that ramp gradients must be used
  82790. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  82791. */
  82792. useRampGradients: boolean;
  82793. /**
  82794. * 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.
  82795. * 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: [])
  82796. */
  82797. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  82798. private _subEmitters;
  82799. /**
  82800. * @hidden
  82801. * If the particle systems emitter should be disposed when the particle system is disposed
  82802. */
  82803. _disposeEmitterOnDispose: boolean;
  82804. /**
  82805. * The current active Sub-systems, this property is used by the root particle system only.
  82806. */
  82807. activeSubSystems: Array<ParticleSystem>;
  82808. private _rootParticleSystem;
  82809. /**
  82810. * Gets the current list of active particles
  82811. */
  82812. readonly particles: Particle[];
  82813. /**
  82814. * Returns the string "ParticleSystem"
  82815. * @returns a string containing the class name
  82816. */
  82817. getClassName(): string;
  82818. /**
  82819. * Instantiates a particle system.
  82820. * 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.
  82821. * @param name The name of the particle system
  82822. * @param capacity The max number of particles alive at the same time
  82823. * @param scene The scene the particle system belongs to
  82824. * @param customEffect a custom effect used to change the way particles are rendered by default
  82825. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  82826. * @param epsilon Offset used to render the particles
  82827. */
  82828. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  82829. private _addFactorGradient;
  82830. private _removeFactorGradient;
  82831. /**
  82832. * Adds a new life time gradient
  82833. * @param gradient defines the gradient to use (between 0 and 1)
  82834. * @param factor defines the life time factor to affect to the specified gradient
  82835. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82836. * @returns the current particle system
  82837. */
  82838. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82839. /**
  82840. * Remove a specific life time gradient
  82841. * @param gradient defines the gradient to remove
  82842. * @returns the current particle system
  82843. */
  82844. removeLifeTimeGradient(gradient: number): IParticleSystem;
  82845. /**
  82846. * Adds a new size gradient
  82847. * @param gradient defines the gradient to use (between 0 and 1)
  82848. * @param factor defines the size factor to affect to the specified gradient
  82849. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82850. * @returns the current particle system
  82851. */
  82852. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82853. /**
  82854. * Remove a specific size gradient
  82855. * @param gradient defines the gradient to remove
  82856. * @returns the current particle system
  82857. */
  82858. removeSizeGradient(gradient: number): IParticleSystem;
  82859. /**
  82860. * Adds a new color remap gradient
  82861. * @param gradient defines the gradient to use (between 0 and 1)
  82862. * @param min defines the color remap minimal range
  82863. * @param max defines the color remap maximal range
  82864. * @returns the current particle system
  82865. */
  82866. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82867. /**
  82868. * Remove a specific color remap gradient
  82869. * @param gradient defines the gradient to remove
  82870. * @returns the current particle system
  82871. */
  82872. removeColorRemapGradient(gradient: number): IParticleSystem;
  82873. /**
  82874. * Adds a new alpha remap gradient
  82875. * @param gradient defines the gradient to use (between 0 and 1)
  82876. * @param min defines the alpha remap minimal range
  82877. * @param max defines the alpha remap maximal range
  82878. * @returns the current particle system
  82879. */
  82880. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82881. /**
  82882. * Remove a specific alpha remap gradient
  82883. * @param gradient defines the gradient to remove
  82884. * @returns the current particle system
  82885. */
  82886. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  82887. /**
  82888. * Adds a new angular speed gradient
  82889. * @param gradient defines the gradient to use (between 0 and 1)
  82890. * @param factor defines the angular speed to affect to the specified gradient
  82891. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82892. * @returns the current particle system
  82893. */
  82894. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82895. /**
  82896. * Remove a specific angular speed gradient
  82897. * @param gradient defines the gradient to remove
  82898. * @returns the current particle system
  82899. */
  82900. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  82901. /**
  82902. * Adds a new velocity gradient
  82903. * @param gradient defines the gradient to use (between 0 and 1)
  82904. * @param factor defines the velocity to affect to the specified gradient
  82905. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82906. * @returns the current particle system
  82907. */
  82908. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82909. /**
  82910. * Remove a specific velocity gradient
  82911. * @param gradient defines the gradient to remove
  82912. * @returns the current particle system
  82913. */
  82914. removeVelocityGradient(gradient: number): IParticleSystem;
  82915. /**
  82916. * Adds a new limit velocity gradient
  82917. * @param gradient defines the gradient to use (between 0 and 1)
  82918. * @param factor defines the limit velocity value to affect to the specified gradient
  82919. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82920. * @returns the current particle system
  82921. */
  82922. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82923. /**
  82924. * Remove a specific limit velocity gradient
  82925. * @param gradient defines the gradient to remove
  82926. * @returns the current particle system
  82927. */
  82928. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  82929. /**
  82930. * Adds a new drag gradient
  82931. * @param gradient defines the gradient to use (between 0 and 1)
  82932. * @param factor defines the drag value to affect to the specified gradient
  82933. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82934. * @returns the current particle system
  82935. */
  82936. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82937. /**
  82938. * Remove a specific drag gradient
  82939. * @param gradient defines the gradient to remove
  82940. * @returns the current particle system
  82941. */
  82942. removeDragGradient(gradient: number): IParticleSystem;
  82943. /**
  82944. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  82945. * @param gradient defines the gradient to use (between 0 and 1)
  82946. * @param factor defines the emit rate value to affect to the specified gradient
  82947. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82948. * @returns the current particle system
  82949. */
  82950. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82951. /**
  82952. * Remove a specific emit rate gradient
  82953. * @param gradient defines the gradient to remove
  82954. * @returns the current particle system
  82955. */
  82956. removeEmitRateGradient(gradient: number): IParticleSystem;
  82957. /**
  82958. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  82959. * @param gradient defines the gradient to use (between 0 and 1)
  82960. * @param factor defines the start size value to affect to the specified gradient
  82961. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82962. * @returns the current particle system
  82963. */
  82964. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82965. /**
  82966. * Remove a specific start size gradient
  82967. * @param gradient defines the gradient to remove
  82968. * @returns the current particle system
  82969. */
  82970. removeStartSizeGradient(gradient: number): IParticleSystem;
  82971. private _createRampGradientTexture;
  82972. /**
  82973. * Gets the current list of ramp gradients.
  82974. * You must use addRampGradient and removeRampGradient to udpate this list
  82975. * @returns the list of ramp gradients
  82976. */
  82977. getRampGradients(): Nullable<Array<Color3Gradient>>;
  82978. /**
  82979. * Adds a new ramp gradient used to remap particle colors
  82980. * @param gradient defines the gradient to use (between 0 and 1)
  82981. * @param color defines the color to affect to the specified gradient
  82982. * @returns the current particle system
  82983. */
  82984. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  82985. /**
  82986. * Remove a specific ramp gradient
  82987. * @param gradient defines the gradient to remove
  82988. * @returns the current particle system
  82989. */
  82990. removeRampGradient(gradient: number): ParticleSystem;
  82991. /**
  82992. * Adds a new color gradient
  82993. * @param gradient defines the gradient to use (between 0 and 1)
  82994. * @param color1 defines the color to affect to the specified gradient
  82995. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  82996. * @returns this particle system
  82997. */
  82998. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  82999. /**
  83000. * Remove a specific color gradient
  83001. * @param gradient defines the gradient to remove
  83002. * @returns this particle system
  83003. */
  83004. removeColorGradient(gradient: number): IParticleSystem;
  83005. private _fetchR;
  83006. protected _reset(): void;
  83007. private _resetEffect;
  83008. private _createVertexBuffers;
  83009. private _createIndexBuffer;
  83010. /**
  83011. * Gets the maximum number of particles active at the same time.
  83012. * @returns The max number of active particles.
  83013. */
  83014. getCapacity(): number;
  83015. /**
  83016. * Gets whether there are still active particles in the system.
  83017. * @returns True if it is alive, otherwise false.
  83018. */
  83019. isAlive(): boolean;
  83020. /**
  83021. * Gets if the system has been started. (Note: this will still be true after stop is called)
  83022. * @returns True if it has been started, otherwise false.
  83023. */
  83024. isStarted(): boolean;
  83025. private _prepareSubEmitterInternalArray;
  83026. /**
  83027. * Starts the particle system and begins to emit
  83028. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  83029. */
  83030. start(delay?: number): void;
  83031. /**
  83032. * Stops the particle system.
  83033. * @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.
  83034. */
  83035. stop(stopSubEmitters?: boolean): void;
  83036. /**
  83037. * Remove all active particles
  83038. */
  83039. reset(): void;
  83040. /**
  83041. * @hidden (for internal use only)
  83042. */
  83043. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  83044. /**
  83045. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  83046. * Its lifetime will start back at 0.
  83047. */
  83048. recycleParticle: (particle: Particle) => void;
  83049. private _stopSubEmitters;
  83050. private _createParticle;
  83051. private _removeFromRoot;
  83052. private _emitFromParticle;
  83053. private _update;
  83054. /** @hidden */
  83055. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  83056. /** @hidden */
  83057. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  83058. /** @hidden */
  83059. private _getEffect;
  83060. /**
  83061. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  83062. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  83063. */
  83064. animate(preWarmOnly?: boolean): void;
  83065. private _appendParticleVertices;
  83066. /**
  83067. * Rebuilds the particle system.
  83068. */
  83069. rebuild(): void;
  83070. /**
  83071. * Is this system ready to be used/rendered
  83072. * @return true if the system is ready
  83073. */
  83074. isReady(): boolean;
  83075. private _render;
  83076. /**
  83077. * Renders the particle system in its current state.
  83078. * @returns the current number of particles
  83079. */
  83080. render(): number;
  83081. /**
  83082. * Disposes the particle system and free the associated resources
  83083. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  83084. */
  83085. dispose(disposeTexture?: boolean): void;
  83086. /**
  83087. * Clones the particle system.
  83088. * @param name The name of the cloned object
  83089. * @param newEmitter The new emitter to use
  83090. * @returns the cloned particle system
  83091. */
  83092. clone(name: string, newEmitter: any): ParticleSystem;
  83093. /**
  83094. * Serializes the particle system to a JSON object.
  83095. * @returns the JSON object
  83096. */
  83097. serialize(): any;
  83098. /** @hidden */
  83099. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  83100. /** @hidden */
  83101. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  83102. /**
  83103. * Parses a JSON object to create a particle system.
  83104. * @param parsedParticleSystem The JSON object to parse
  83105. * @param scene The scene to create the particle system in
  83106. * @param rootUrl The root url to use to load external dependencies like texture
  83107. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  83108. * @returns the Parsed particle system
  83109. */
  83110. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  83111. }
  83112. }
  83113. declare module BABYLON {
  83114. /**
  83115. * A particle represents one of the element emitted by a particle system.
  83116. * This is mainly define by its coordinates, direction, velocity and age.
  83117. */
  83118. export class Particle {
  83119. /**
  83120. * The particle system the particle belongs to.
  83121. */
  83122. particleSystem: ParticleSystem;
  83123. private static _Count;
  83124. /**
  83125. * Unique ID of the particle
  83126. */
  83127. id: number;
  83128. /**
  83129. * The world position of the particle in the scene.
  83130. */
  83131. position: Vector3;
  83132. /**
  83133. * The world direction of the particle in the scene.
  83134. */
  83135. direction: Vector3;
  83136. /**
  83137. * The color of the particle.
  83138. */
  83139. color: Color4;
  83140. /**
  83141. * The color change of the particle per step.
  83142. */
  83143. colorStep: Color4;
  83144. /**
  83145. * Defines how long will the life of the particle be.
  83146. */
  83147. lifeTime: number;
  83148. /**
  83149. * The current age of the particle.
  83150. */
  83151. age: number;
  83152. /**
  83153. * The current size of the particle.
  83154. */
  83155. size: number;
  83156. /**
  83157. * The current scale of the particle.
  83158. */
  83159. scale: Vector2;
  83160. /**
  83161. * The current angle of the particle.
  83162. */
  83163. angle: number;
  83164. /**
  83165. * Defines how fast is the angle changing.
  83166. */
  83167. angularSpeed: number;
  83168. /**
  83169. * Defines the cell index used by the particle to be rendered from a sprite.
  83170. */
  83171. cellIndex: number;
  83172. /**
  83173. * The information required to support color remapping
  83174. */
  83175. remapData: Vector4;
  83176. /** @hidden */
  83177. _randomCellOffset?: number;
  83178. /** @hidden */
  83179. _initialDirection: Nullable<Vector3>;
  83180. /** @hidden */
  83181. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  83182. /** @hidden */
  83183. _initialStartSpriteCellID: number;
  83184. /** @hidden */
  83185. _initialEndSpriteCellID: number;
  83186. /** @hidden */
  83187. _currentColorGradient: Nullable<ColorGradient>;
  83188. /** @hidden */
  83189. _currentColor1: Color4;
  83190. /** @hidden */
  83191. _currentColor2: Color4;
  83192. /** @hidden */
  83193. _currentSizeGradient: Nullable<FactorGradient>;
  83194. /** @hidden */
  83195. _currentSize1: number;
  83196. /** @hidden */
  83197. _currentSize2: number;
  83198. /** @hidden */
  83199. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  83200. /** @hidden */
  83201. _currentAngularSpeed1: number;
  83202. /** @hidden */
  83203. _currentAngularSpeed2: number;
  83204. /** @hidden */
  83205. _currentVelocityGradient: Nullable<FactorGradient>;
  83206. /** @hidden */
  83207. _currentVelocity1: number;
  83208. /** @hidden */
  83209. _currentVelocity2: number;
  83210. /** @hidden */
  83211. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  83212. /** @hidden */
  83213. _currentLimitVelocity1: number;
  83214. /** @hidden */
  83215. _currentLimitVelocity2: number;
  83216. /** @hidden */
  83217. _currentDragGradient: Nullable<FactorGradient>;
  83218. /** @hidden */
  83219. _currentDrag1: number;
  83220. /** @hidden */
  83221. _currentDrag2: number;
  83222. /** @hidden */
  83223. _randomNoiseCoordinates1: Vector3;
  83224. /** @hidden */
  83225. _randomNoiseCoordinates2: Vector3;
  83226. /**
  83227. * Creates a new instance Particle
  83228. * @param particleSystem the particle system the particle belongs to
  83229. */
  83230. constructor(
  83231. /**
  83232. * The particle system the particle belongs to.
  83233. */
  83234. particleSystem: ParticleSystem);
  83235. private updateCellInfoFromSystem;
  83236. /**
  83237. * Defines how the sprite cell index is updated for the particle
  83238. */
  83239. updateCellIndex(): void;
  83240. /** @hidden */
  83241. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  83242. /** @hidden */
  83243. _inheritParticleInfoToSubEmitters(): void;
  83244. /** @hidden */
  83245. _reset(): void;
  83246. /**
  83247. * Copy the properties of particle to another one.
  83248. * @param other the particle to copy the information to.
  83249. */
  83250. copyTo(other: Particle): void;
  83251. }
  83252. }
  83253. declare module BABYLON {
  83254. /**
  83255. * Particle emitter represents a volume emitting particles.
  83256. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  83257. */
  83258. export interface IParticleEmitterType {
  83259. /**
  83260. * Called by the particle System when the direction is computed for the created particle.
  83261. * @param worldMatrix is the world matrix of the particle system
  83262. * @param directionToUpdate is the direction vector to update with the result
  83263. * @param particle is the particle we are computed the direction for
  83264. */
  83265. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83266. /**
  83267. * Called by the particle System when the position is computed for the created particle.
  83268. * @param worldMatrix is the world matrix of the particle system
  83269. * @param positionToUpdate is the position vector to update with the result
  83270. * @param particle is the particle we are computed the position for
  83271. */
  83272. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83273. /**
  83274. * Clones the current emitter and returns a copy of it
  83275. * @returns the new emitter
  83276. */
  83277. clone(): IParticleEmitterType;
  83278. /**
  83279. * Called by the GPUParticleSystem to setup the update shader
  83280. * @param effect defines the update shader
  83281. */
  83282. applyToShader(effect: Effect): void;
  83283. /**
  83284. * Returns a string to use to update the GPU particles update shader
  83285. * @returns the effect defines string
  83286. */
  83287. getEffectDefines(): string;
  83288. /**
  83289. * Returns a string representing the class name
  83290. * @returns a string containing the class name
  83291. */
  83292. getClassName(): string;
  83293. /**
  83294. * Serializes the particle system to a JSON object.
  83295. * @returns the JSON object
  83296. */
  83297. serialize(): any;
  83298. /**
  83299. * Parse properties from a JSON object
  83300. * @param serializationObject defines the JSON object
  83301. */
  83302. parse(serializationObject: any): void;
  83303. }
  83304. }
  83305. declare module BABYLON {
  83306. /**
  83307. * Particle emitter emitting particles from the inside of a box.
  83308. * It emits the particles randomly between 2 given directions.
  83309. */
  83310. export class BoxParticleEmitter implements IParticleEmitterType {
  83311. /**
  83312. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83313. */
  83314. direction1: Vector3;
  83315. /**
  83316. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83317. */
  83318. direction2: Vector3;
  83319. /**
  83320. * 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.
  83321. */
  83322. minEmitBox: Vector3;
  83323. /**
  83324. * 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.
  83325. */
  83326. maxEmitBox: Vector3;
  83327. /**
  83328. * Creates a new instance BoxParticleEmitter
  83329. */
  83330. constructor();
  83331. /**
  83332. * Called by the particle System when the direction is computed for the created particle.
  83333. * @param worldMatrix is the world matrix of the particle system
  83334. * @param directionToUpdate is the direction vector to update with the result
  83335. * @param particle is the particle we are computed the direction for
  83336. */
  83337. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83338. /**
  83339. * Called by the particle System when the position is computed for the created particle.
  83340. * @param worldMatrix is the world matrix of the particle system
  83341. * @param positionToUpdate is the position vector to update with the result
  83342. * @param particle is the particle we are computed the position for
  83343. */
  83344. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83345. /**
  83346. * Clones the current emitter and returns a copy of it
  83347. * @returns the new emitter
  83348. */
  83349. clone(): BoxParticleEmitter;
  83350. /**
  83351. * Called by the GPUParticleSystem to setup the update shader
  83352. * @param effect defines the update shader
  83353. */
  83354. applyToShader(effect: Effect): void;
  83355. /**
  83356. * Returns a string to use to update the GPU particles update shader
  83357. * @returns a string containng the defines string
  83358. */
  83359. getEffectDefines(): string;
  83360. /**
  83361. * Returns the string "BoxParticleEmitter"
  83362. * @returns a string containing the class name
  83363. */
  83364. getClassName(): string;
  83365. /**
  83366. * Serializes the particle system to a JSON object.
  83367. * @returns the JSON object
  83368. */
  83369. serialize(): any;
  83370. /**
  83371. * Parse properties from a JSON object
  83372. * @param serializationObject defines the JSON object
  83373. */
  83374. parse(serializationObject: any): void;
  83375. }
  83376. }
  83377. declare module BABYLON {
  83378. /**
  83379. * Particle emitter emitting particles from the inside of a cone.
  83380. * It emits the particles alongside the cone volume from the base to the particle.
  83381. * The emission direction might be randomized.
  83382. */
  83383. export class ConeParticleEmitter implements IParticleEmitterType {
  83384. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  83385. directionRandomizer: number;
  83386. private _radius;
  83387. private _angle;
  83388. private _height;
  83389. /**
  83390. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  83391. */
  83392. radiusRange: number;
  83393. /**
  83394. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  83395. */
  83396. heightRange: number;
  83397. /**
  83398. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  83399. */
  83400. emitFromSpawnPointOnly: boolean;
  83401. /**
  83402. * Gets or sets the radius of the emission cone
  83403. */
  83404. radius: number;
  83405. /**
  83406. * Gets or sets the angle of the emission cone
  83407. */
  83408. angle: number;
  83409. private _buildHeight;
  83410. /**
  83411. * Creates a new instance ConeParticleEmitter
  83412. * @param radius the radius of the emission cone (1 by default)
  83413. * @param angle the cone base angle (PI by default)
  83414. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  83415. */
  83416. constructor(radius?: number, angle?: number,
  83417. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  83418. directionRandomizer?: number);
  83419. /**
  83420. * Called by the particle System when the direction is computed for the created particle.
  83421. * @param worldMatrix is the world matrix of the particle system
  83422. * @param directionToUpdate is the direction vector to update with the result
  83423. * @param particle is the particle we are computed the direction for
  83424. */
  83425. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83426. /**
  83427. * Called by the particle System when the position is computed for the created particle.
  83428. * @param worldMatrix is the world matrix of the particle system
  83429. * @param positionToUpdate is the position vector to update with the result
  83430. * @param particle is the particle we are computed the position for
  83431. */
  83432. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83433. /**
  83434. * Clones the current emitter and returns a copy of it
  83435. * @returns the new emitter
  83436. */
  83437. clone(): ConeParticleEmitter;
  83438. /**
  83439. * Called by the GPUParticleSystem to setup the update shader
  83440. * @param effect defines the update shader
  83441. */
  83442. applyToShader(effect: Effect): void;
  83443. /**
  83444. * Returns a string to use to update the GPU particles update shader
  83445. * @returns a string containng the defines string
  83446. */
  83447. getEffectDefines(): string;
  83448. /**
  83449. * Returns the string "ConeParticleEmitter"
  83450. * @returns a string containing the class name
  83451. */
  83452. getClassName(): string;
  83453. /**
  83454. * Serializes the particle system to a JSON object.
  83455. * @returns the JSON object
  83456. */
  83457. serialize(): any;
  83458. /**
  83459. * Parse properties from a JSON object
  83460. * @param serializationObject defines the JSON object
  83461. */
  83462. parse(serializationObject: any): void;
  83463. }
  83464. }
  83465. declare module BABYLON {
  83466. /**
  83467. * Particle emitter emitting particles from the inside of a cylinder.
  83468. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  83469. */
  83470. export class CylinderParticleEmitter implements IParticleEmitterType {
  83471. /**
  83472. * The radius of the emission cylinder.
  83473. */
  83474. radius: number;
  83475. /**
  83476. * The height of the emission cylinder.
  83477. */
  83478. height: number;
  83479. /**
  83480. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83481. */
  83482. radiusRange: number;
  83483. /**
  83484. * How much to randomize the particle direction [0-1].
  83485. */
  83486. directionRandomizer: number;
  83487. /**
  83488. * Creates a new instance CylinderParticleEmitter
  83489. * @param radius the radius of the emission cylinder (1 by default)
  83490. * @param height the height of the emission cylinder (1 by default)
  83491. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83492. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83493. */
  83494. constructor(
  83495. /**
  83496. * The radius of the emission cylinder.
  83497. */
  83498. radius?: number,
  83499. /**
  83500. * The height of the emission cylinder.
  83501. */
  83502. height?: number,
  83503. /**
  83504. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83505. */
  83506. radiusRange?: number,
  83507. /**
  83508. * How much to randomize the particle direction [0-1].
  83509. */
  83510. directionRandomizer?: number);
  83511. /**
  83512. * Called by the particle System when the direction is computed for the created particle.
  83513. * @param worldMatrix is the world matrix of the particle system
  83514. * @param directionToUpdate is the direction vector to update with the result
  83515. * @param particle is the particle we are computed the direction for
  83516. */
  83517. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83518. /**
  83519. * Called by the particle System when the position is computed for the created particle.
  83520. * @param worldMatrix is the world matrix of the particle system
  83521. * @param positionToUpdate is the position vector to update with the result
  83522. * @param particle is the particle we are computed the position for
  83523. */
  83524. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83525. /**
  83526. * Clones the current emitter and returns a copy of it
  83527. * @returns the new emitter
  83528. */
  83529. clone(): CylinderParticleEmitter;
  83530. /**
  83531. * Called by the GPUParticleSystem to setup the update shader
  83532. * @param effect defines the update shader
  83533. */
  83534. applyToShader(effect: Effect): void;
  83535. /**
  83536. * Returns a string to use to update the GPU particles update shader
  83537. * @returns a string containng the defines string
  83538. */
  83539. getEffectDefines(): string;
  83540. /**
  83541. * Returns the string "CylinderParticleEmitter"
  83542. * @returns a string containing the class name
  83543. */
  83544. getClassName(): string;
  83545. /**
  83546. * Serializes the particle system to a JSON object.
  83547. * @returns the JSON object
  83548. */
  83549. serialize(): any;
  83550. /**
  83551. * Parse properties from a JSON object
  83552. * @param serializationObject defines the JSON object
  83553. */
  83554. parse(serializationObject: any): void;
  83555. }
  83556. /**
  83557. * Particle emitter emitting particles from the inside of a cylinder.
  83558. * It emits the particles randomly between two vectors.
  83559. */
  83560. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  83561. /**
  83562. * The min limit of the emission direction.
  83563. */
  83564. direction1: Vector3;
  83565. /**
  83566. * The max limit of the emission direction.
  83567. */
  83568. direction2: Vector3;
  83569. /**
  83570. * Creates a new instance CylinderDirectedParticleEmitter
  83571. * @param radius the radius of the emission cylinder (1 by default)
  83572. * @param height the height of the emission cylinder (1 by default)
  83573. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83574. * @param direction1 the min limit of the emission direction (up vector by default)
  83575. * @param direction2 the max limit of the emission direction (up vector by default)
  83576. */
  83577. constructor(radius?: number, height?: number, radiusRange?: number,
  83578. /**
  83579. * The min limit of the emission direction.
  83580. */
  83581. direction1?: Vector3,
  83582. /**
  83583. * The max limit of the emission direction.
  83584. */
  83585. direction2?: Vector3);
  83586. /**
  83587. * Called by the particle System when the direction is computed for the created particle.
  83588. * @param worldMatrix is the world matrix of the particle system
  83589. * @param directionToUpdate is the direction vector to update with the result
  83590. * @param particle is the particle we are computed the direction for
  83591. */
  83592. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83593. /**
  83594. * Clones the current emitter and returns a copy of it
  83595. * @returns the new emitter
  83596. */
  83597. clone(): CylinderDirectedParticleEmitter;
  83598. /**
  83599. * Called by the GPUParticleSystem to setup the update shader
  83600. * @param effect defines the update shader
  83601. */
  83602. applyToShader(effect: Effect): void;
  83603. /**
  83604. * Returns a string to use to update the GPU particles update shader
  83605. * @returns a string containng the defines string
  83606. */
  83607. getEffectDefines(): string;
  83608. /**
  83609. * Returns the string "CylinderDirectedParticleEmitter"
  83610. * @returns a string containing the class name
  83611. */
  83612. getClassName(): string;
  83613. /**
  83614. * Serializes the particle system to a JSON object.
  83615. * @returns the JSON object
  83616. */
  83617. serialize(): any;
  83618. /**
  83619. * Parse properties from a JSON object
  83620. * @param serializationObject defines the JSON object
  83621. */
  83622. parse(serializationObject: any): void;
  83623. }
  83624. }
  83625. declare module BABYLON {
  83626. /**
  83627. * Particle emitter emitting particles from the inside of a hemisphere.
  83628. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  83629. */
  83630. export class HemisphericParticleEmitter implements IParticleEmitterType {
  83631. /**
  83632. * The radius of the emission hemisphere.
  83633. */
  83634. radius: number;
  83635. /**
  83636. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83637. */
  83638. radiusRange: number;
  83639. /**
  83640. * How much to randomize the particle direction [0-1].
  83641. */
  83642. directionRandomizer: number;
  83643. /**
  83644. * Creates a new instance HemisphericParticleEmitter
  83645. * @param radius the radius of the emission hemisphere (1 by default)
  83646. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83647. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83648. */
  83649. constructor(
  83650. /**
  83651. * The radius of the emission hemisphere.
  83652. */
  83653. radius?: number,
  83654. /**
  83655. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83656. */
  83657. radiusRange?: number,
  83658. /**
  83659. * How much to randomize the particle direction [0-1].
  83660. */
  83661. directionRandomizer?: number);
  83662. /**
  83663. * Called by the particle System when the direction is computed for the created particle.
  83664. * @param worldMatrix is the world matrix of the particle system
  83665. * @param directionToUpdate is the direction vector to update with the result
  83666. * @param particle is the particle we are computed the direction for
  83667. */
  83668. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83669. /**
  83670. * Called by the particle System when the position is computed for the created particle.
  83671. * @param worldMatrix is the world matrix of the particle system
  83672. * @param positionToUpdate is the position vector to update with the result
  83673. * @param particle is the particle we are computed the position for
  83674. */
  83675. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83676. /**
  83677. * Clones the current emitter and returns a copy of it
  83678. * @returns the new emitter
  83679. */
  83680. clone(): HemisphericParticleEmitter;
  83681. /**
  83682. * Called by the GPUParticleSystem to setup the update shader
  83683. * @param effect defines the update shader
  83684. */
  83685. applyToShader(effect: Effect): void;
  83686. /**
  83687. * Returns a string to use to update the GPU particles update shader
  83688. * @returns a string containng the defines string
  83689. */
  83690. getEffectDefines(): string;
  83691. /**
  83692. * Returns the string "HemisphericParticleEmitter"
  83693. * @returns a string containing the class name
  83694. */
  83695. getClassName(): string;
  83696. /**
  83697. * Serializes the particle system to a JSON object.
  83698. * @returns the JSON object
  83699. */
  83700. serialize(): any;
  83701. /**
  83702. * Parse properties from a JSON object
  83703. * @param serializationObject defines the JSON object
  83704. */
  83705. parse(serializationObject: any): void;
  83706. }
  83707. }
  83708. declare module BABYLON {
  83709. /**
  83710. * Particle emitter emitting particles from a point.
  83711. * It emits the particles randomly between 2 given directions.
  83712. */
  83713. export class PointParticleEmitter implements IParticleEmitterType {
  83714. /**
  83715. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83716. */
  83717. direction1: Vector3;
  83718. /**
  83719. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83720. */
  83721. direction2: Vector3;
  83722. /**
  83723. * Creates a new instance PointParticleEmitter
  83724. */
  83725. constructor();
  83726. /**
  83727. * Called by the particle System when the direction is computed for the created particle.
  83728. * @param worldMatrix is the world matrix of the particle system
  83729. * @param directionToUpdate is the direction vector to update with the result
  83730. * @param particle is the particle we are computed the direction for
  83731. */
  83732. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83733. /**
  83734. * Called by the particle System when the position is computed for the created particle.
  83735. * @param worldMatrix is the world matrix of the particle system
  83736. * @param positionToUpdate is the position vector to update with the result
  83737. * @param particle is the particle we are computed the position for
  83738. */
  83739. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83740. /**
  83741. * Clones the current emitter and returns a copy of it
  83742. * @returns the new emitter
  83743. */
  83744. clone(): PointParticleEmitter;
  83745. /**
  83746. * Called by the GPUParticleSystem to setup the update shader
  83747. * @param effect defines the update shader
  83748. */
  83749. applyToShader(effect: Effect): void;
  83750. /**
  83751. * Returns a string to use to update the GPU particles update shader
  83752. * @returns a string containng the defines string
  83753. */
  83754. getEffectDefines(): string;
  83755. /**
  83756. * Returns the string "PointParticleEmitter"
  83757. * @returns a string containing the class name
  83758. */
  83759. getClassName(): string;
  83760. /**
  83761. * Serializes the particle system to a JSON object.
  83762. * @returns the JSON object
  83763. */
  83764. serialize(): any;
  83765. /**
  83766. * Parse properties from a JSON object
  83767. * @param serializationObject defines the JSON object
  83768. */
  83769. parse(serializationObject: any): void;
  83770. }
  83771. }
  83772. declare module BABYLON {
  83773. /**
  83774. * Particle emitter emitting particles from the inside of a sphere.
  83775. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  83776. */
  83777. export class SphereParticleEmitter implements IParticleEmitterType {
  83778. /**
  83779. * The radius of the emission sphere.
  83780. */
  83781. radius: number;
  83782. /**
  83783. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83784. */
  83785. radiusRange: number;
  83786. /**
  83787. * How much to randomize the particle direction [0-1].
  83788. */
  83789. directionRandomizer: number;
  83790. /**
  83791. * Creates a new instance SphereParticleEmitter
  83792. * @param radius the radius of the emission sphere (1 by default)
  83793. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83794. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83795. */
  83796. constructor(
  83797. /**
  83798. * The radius of the emission sphere.
  83799. */
  83800. radius?: number,
  83801. /**
  83802. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83803. */
  83804. radiusRange?: number,
  83805. /**
  83806. * How much to randomize the particle direction [0-1].
  83807. */
  83808. directionRandomizer?: number);
  83809. /**
  83810. * Called by the particle System when the direction is computed for the created particle.
  83811. * @param worldMatrix is the world matrix of the particle system
  83812. * @param directionToUpdate is the direction vector to update with the result
  83813. * @param particle is the particle we are computed the direction for
  83814. */
  83815. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83816. /**
  83817. * Called by the particle System when the position is computed for the created particle.
  83818. * @param worldMatrix is the world matrix of the particle system
  83819. * @param positionToUpdate is the position vector to update with the result
  83820. * @param particle is the particle we are computed the position for
  83821. */
  83822. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83823. /**
  83824. * Clones the current emitter and returns a copy of it
  83825. * @returns the new emitter
  83826. */
  83827. clone(): SphereParticleEmitter;
  83828. /**
  83829. * Called by the GPUParticleSystem to setup the update shader
  83830. * @param effect defines the update shader
  83831. */
  83832. applyToShader(effect: Effect): void;
  83833. /**
  83834. * Returns a string to use to update the GPU particles update shader
  83835. * @returns a string containng the defines string
  83836. */
  83837. getEffectDefines(): string;
  83838. /**
  83839. * Returns the string "SphereParticleEmitter"
  83840. * @returns a string containing the class name
  83841. */
  83842. getClassName(): string;
  83843. /**
  83844. * Serializes the particle system to a JSON object.
  83845. * @returns the JSON object
  83846. */
  83847. serialize(): any;
  83848. /**
  83849. * Parse properties from a JSON object
  83850. * @param serializationObject defines the JSON object
  83851. */
  83852. parse(serializationObject: any): void;
  83853. }
  83854. /**
  83855. * Particle emitter emitting particles from the inside of a sphere.
  83856. * It emits the particles randomly between two vectors.
  83857. */
  83858. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  83859. /**
  83860. * The min limit of the emission direction.
  83861. */
  83862. direction1: Vector3;
  83863. /**
  83864. * The max limit of the emission direction.
  83865. */
  83866. direction2: Vector3;
  83867. /**
  83868. * Creates a new instance SphereDirectedParticleEmitter
  83869. * @param radius the radius of the emission sphere (1 by default)
  83870. * @param direction1 the min limit of the emission direction (up vector by default)
  83871. * @param direction2 the max limit of the emission direction (up vector by default)
  83872. */
  83873. constructor(radius?: number,
  83874. /**
  83875. * The min limit of the emission direction.
  83876. */
  83877. direction1?: Vector3,
  83878. /**
  83879. * The max limit of the emission direction.
  83880. */
  83881. direction2?: Vector3);
  83882. /**
  83883. * Called by the particle System when the direction is computed for the created particle.
  83884. * @param worldMatrix is the world matrix of the particle system
  83885. * @param directionToUpdate is the direction vector to update with the result
  83886. * @param particle is the particle we are computed the direction for
  83887. */
  83888. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83889. /**
  83890. * Clones the current emitter and returns a copy of it
  83891. * @returns the new emitter
  83892. */
  83893. clone(): SphereDirectedParticleEmitter;
  83894. /**
  83895. * Called by the GPUParticleSystem to setup the update shader
  83896. * @param effect defines the update shader
  83897. */
  83898. applyToShader(effect: Effect): void;
  83899. /**
  83900. * Returns a string to use to update the GPU particles update shader
  83901. * @returns a string containng the defines string
  83902. */
  83903. getEffectDefines(): string;
  83904. /**
  83905. * Returns the string "SphereDirectedParticleEmitter"
  83906. * @returns a string containing the class name
  83907. */
  83908. getClassName(): string;
  83909. /**
  83910. * Serializes the particle system to a JSON object.
  83911. * @returns the JSON object
  83912. */
  83913. serialize(): any;
  83914. /**
  83915. * Parse properties from a JSON object
  83916. * @param serializationObject defines the JSON object
  83917. */
  83918. parse(serializationObject: any): void;
  83919. }
  83920. }
  83921. declare module BABYLON {
  83922. /**
  83923. * Interface representing a particle system in Babylon.js.
  83924. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  83925. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  83926. */
  83927. export interface IParticleSystem {
  83928. /**
  83929. * List of animations used by the particle system.
  83930. */
  83931. animations: Animation[];
  83932. /**
  83933. * The id of the Particle system.
  83934. */
  83935. id: string;
  83936. /**
  83937. * The name of the Particle system.
  83938. */
  83939. name: string;
  83940. /**
  83941. * The emitter represents the Mesh or position we are attaching the particle system to.
  83942. */
  83943. emitter: Nullable<AbstractMesh | Vector3>;
  83944. /**
  83945. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  83946. */
  83947. isBillboardBased: boolean;
  83948. /**
  83949. * The rendering group used by the Particle system to chose when to render.
  83950. */
  83951. renderingGroupId: number;
  83952. /**
  83953. * The layer mask we are rendering the particles through.
  83954. */
  83955. layerMask: number;
  83956. /**
  83957. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  83958. */
  83959. updateSpeed: number;
  83960. /**
  83961. * The amount of time the particle system is running (depends of the overall update speed).
  83962. */
  83963. targetStopDuration: number;
  83964. /**
  83965. * The texture used to render each particle. (this can be a spritesheet)
  83966. */
  83967. particleTexture: Nullable<Texture>;
  83968. /**
  83969. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  83970. */
  83971. blendMode: number;
  83972. /**
  83973. * Minimum life time of emitting particles.
  83974. */
  83975. minLifeTime: number;
  83976. /**
  83977. * Maximum life time of emitting particles.
  83978. */
  83979. maxLifeTime: number;
  83980. /**
  83981. * Minimum Size of emitting particles.
  83982. */
  83983. minSize: number;
  83984. /**
  83985. * Maximum Size of emitting particles.
  83986. */
  83987. maxSize: number;
  83988. /**
  83989. * Minimum scale of emitting particles on X axis.
  83990. */
  83991. minScaleX: number;
  83992. /**
  83993. * Maximum scale of emitting particles on X axis.
  83994. */
  83995. maxScaleX: number;
  83996. /**
  83997. * Minimum scale of emitting particles on Y axis.
  83998. */
  83999. minScaleY: number;
  84000. /**
  84001. * Maximum scale of emitting particles on Y axis.
  84002. */
  84003. maxScaleY: number;
  84004. /**
  84005. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  84006. */
  84007. color1: Color4;
  84008. /**
  84009. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  84010. */
  84011. color2: Color4;
  84012. /**
  84013. * Color the particle will have at the end of its lifetime.
  84014. */
  84015. colorDead: Color4;
  84016. /**
  84017. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  84018. */
  84019. emitRate: number;
  84020. /**
  84021. * You can use gravity if you want to give an orientation to your particles.
  84022. */
  84023. gravity: Vector3;
  84024. /**
  84025. * Minimum power of emitting particles.
  84026. */
  84027. minEmitPower: number;
  84028. /**
  84029. * Maximum power of emitting particles.
  84030. */
  84031. maxEmitPower: number;
  84032. /**
  84033. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  84034. */
  84035. minAngularSpeed: number;
  84036. /**
  84037. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  84038. */
  84039. maxAngularSpeed: number;
  84040. /**
  84041. * Gets or sets the minimal initial rotation in radians.
  84042. */
  84043. minInitialRotation: number;
  84044. /**
  84045. * Gets or sets the maximal initial rotation in radians.
  84046. */
  84047. maxInitialRotation: number;
  84048. /**
  84049. * The particle emitter type defines the emitter used by the particle system.
  84050. * It can be for example box, sphere, or cone...
  84051. */
  84052. particleEmitterType: Nullable<IParticleEmitterType>;
  84053. /**
  84054. * Defines the delay in milliseconds before starting the system (0 by default)
  84055. */
  84056. startDelay: number;
  84057. /**
  84058. * 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
  84059. */
  84060. preWarmCycles: number;
  84061. /**
  84062. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  84063. */
  84064. preWarmStepOffset: number;
  84065. /**
  84066. * 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)
  84067. */
  84068. spriteCellChangeSpeed: number;
  84069. /**
  84070. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  84071. */
  84072. startSpriteCellID: number;
  84073. /**
  84074. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  84075. */
  84076. endSpriteCellID: number;
  84077. /**
  84078. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  84079. */
  84080. spriteCellWidth: number;
  84081. /**
  84082. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  84083. */
  84084. spriteCellHeight: number;
  84085. /**
  84086. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  84087. */
  84088. spriteRandomStartCell: boolean;
  84089. /**
  84090. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  84091. */
  84092. isAnimationSheetEnabled: boolean;
  84093. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  84094. translationPivot: Vector2;
  84095. /**
  84096. * Gets or sets a texture used to add random noise to particle positions
  84097. */
  84098. noiseTexture: Nullable<BaseTexture>;
  84099. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  84100. noiseStrength: Vector3;
  84101. /**
  84102. * Gets or sets the billboard mode to use when isBillboardBased = true.
  84103. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  84104. */
  84105. billboardMode: number;
  84106. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  84107. limitVelocityDamping: number;
  84108. /**
  84109. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  84110. */
  84111. beginAnimationOnStart: boolean;
  84112. /**
  84113. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  84114. */
  84115. beginAnimationFrom: number;
  84116. /**
  84117. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  84118. */
  84119. beginAnimationTo: number;
  84120. /**
  84121. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  84122. */
  84123. beginAnimationLoop: boolean;
  84124. /**
  84125. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  84126. */
  84127. disposeOnStop: boolean;
  84128. /**
  84129. * Gets the maximum number of particles active at the same time.
  84130. * @returns The max number of active particles.
  84131. */
  84132. getCapacity(): number;
  84133. /**
  84134. * Gets if the system has been started. (Note: this will still be true after stop is called)
  84135. * @returns True if it has been started, otherwise false.
  84136. */
  84137. isStarted(): boolean;
  84138. /**
  84139. * Animates the particle system for this frame.
  84140. */
  84141. animate(): void;
  84142. /**
  84143. * Renders the particle system in its current state.
  84144. * @returns the current number of particles
  84145. */
  84146. render(): number;
  84147. /**
  84148. * Dispose the particle system and frees its associated resources.
  84149. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  84150. */
  84151. dispose(disposeTexture?: boolean): void;
  84152. /**
  84153. * Clones the particle system.
  84154. * @param name The name of the cloned object
  84155. * @param newEmitter The new emitter to use
  84156. * @returns the cloned particle system
  84157. */
  84158. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  84159. /**
  84160. * Serializes the particle system to a JSON object.
  84161. * @returns the JSON object
  84162. */
  84163. serialize(): any;
  84164. /**
  84165. * Rebuild the particle system
  84166. */
  84167. rebuild(): void;
  84168. /**
  84169. * Starts the particle system and begins to emit
  84170. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  84171. */
  84172. start(delay?: number): void;
  84173. /**
  84174. * Stops the particle system.
  84175. */
  84176. stop(): void;
  84177. /**
  84178. * Remove all active particles
  84179. */
  84180. reset(): void;
  84181. /**
  84182. * Is this system ready to be used/rendered
  84183. * @return true if the system is ready
  84184. */
  84185. isReady(): boolean;
  84186. /**
  84187. * Adds a new color gradient
  84188. * @param gradient defines the gradient to use (between 0 and 1)
  84189. * @param color1 defines the color to affect to the specified gradient
  84190. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  84191. * @returns the current particle system
  84192. */
  84193. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  84194. /**
  84195. * Remove a specific color gradient
  84196. * @param gradient defines the gradient to remove
  84197. * @returns the current particle system
  84198. */
  84199. removeColorGradient(gradient: number): IParticleSystem;
  84200. /**
  84201. * Adds a new size gradient
  84202. * @param gradient defines the gradient to use (between 0 and 1)
  84203. * @param factor defines the size factor to affect to the specified gradient
  84204. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84205. * @returns the current particle system
  84206. */
  84207. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84208. /**
  84209. * Remove a specific size gradient
  84210. * @param gradient defines the gradient to remove
  84211. * @returns the current particle system
  84212. */
  84213. removeSizeGradient(gradient: number): IParticleSystem;
  84214. /**
  84215. * Gets the current list of color gradients.
  84216. * You must use addColorGradient and removeColorGradient to udpate this list
  84217. * @returns the list of color gradients
  84218. */
  84219. getColorGradients(): Nullable<Array<ColorGradient>>;
  84220. /**
  84221. * Gets the current list of size gradients.
  84222. * You must use addSizeGradient and removeSizeGradient to udpate this list
  84223. * @returns the list of size gradients
  84224. */
  84225. getSizeGradients(): Nullable<Array<FactorGradient>>;
  84226. /**
  84227. * Gets the current list of angular speed gradients.
  84228. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  84229. * @returns the list of angular speed gradients
  84230. */
  84231. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  84232. /**
  84233. * Adds a new angular speed gradient
  84234. * @param gradient defines the gradient to use (between 0 and 1)
  84235. * @param factor defines the angular speed to affect to the specified gradient
  84236. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84237. * @returns the current particle system
  84238. */
  84239. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84240. /**
  84241. * Remove a specific angular speed gradient
  84242. * @param gradient defines the gradient to remove
  84243. * @returns the current particle system
  84244. */
  84245. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  84246. /**
  84247. * Gets the current list of velocity gradients.
  84248. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  84249. * @returns the list of velocity gradients
  84250. */
  84251. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  84252. /**
  84253. * Adds a new velocity gradient
  84254. * @param gradient defines the gradient to use (between 0 and 1)
  84255. * @param factor defines the velocity to affect to the specified gradient
  84256. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84257. * @returns the current particle system
  84258. */
  84259. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84260. /**
  84261. * Remove a specific velocity gradient
  84262. * @param gradient defines the gradient to remove
  84263. * @returns the current particle system
  84264. */
  84265. removeVelocityGradient(gradient: number): IParticleSystem;
  84266. /**
  84267. * Gets the current list of limit velocity gradients.
  84268. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  84269. * @returns the list of limit velocity gradients
  84270. */
  84271. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  84272. /**
  84273. * Adds a new limit velocity gradient
  84274. * @param gradient defines the gradient to use (between 0 and 1)
  84275. * @param factor defines the limit velocity to affect to the specified gradient
  84276. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84277. * @returns the current particle system
  84278. */
  84279. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84280. /**
  84281. * Remove a specific limit velocity gradient
  84282. * @param gradient defines the gradient to remove
  84283. * @returns the current particle system
  84284. */
  84285. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  84286. /**
  84287. * Adds a new drag gradient
  84288. * @param gradient defines the gradient to use (between 0 and 1)
  84289. * @param factor defines the drag to affect to the specified gradient
  84290. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84291. * @returns the current particle system
  84292. */
  84293. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84294. /**
  84295. * Remove a specific drag gradient
  84296. * @param gradient defines the gradient to remove
  84297. * @returns the current particle system
  84298. */
  84299. removeDragGradient(gradient: number): IParticleSystem;
  84300. /**
  84301. * Gets the current list of drag gradients.
  84302. * You must use addDragGradient and removeDragGradient to udpate this list
  84303. * @returns the list of drag gradients
  84304. */
  84305. getDragGradients(): Nullable<Array<FactorGradient>>;
  84306. /**
  84307. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  84308. * @param gradient defines the gradient to use (between 0 and 1)
  84309. * @param factor defines the emit rate to affect to the specified gradient
  84310. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84311. * @returns the current particle system
  84312. */
  84313. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84314. /**
  84315. * Remove a specific emit rate gradient
  84316. * @param gradient defines the gradient to remove
  84317. * @returns the current particle system
  84318. */
  84319. removeEmitRateGradient(gradient: number): IParticleSystem;
  84320. /**
  84321. * Gets the current list of emit rate gradients.
  84322. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  84323. * @returns the list of emit rate gradients
  84324. */
  84325. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  84326. /**
  84327. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  84328. * @param gradient defines the gradient to use (between 0 and 1)
  84329. * @param factor defines the start size to affect to the specified gradient
  84330. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84331. * @returns the current particle system
  84332. */
  84333. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84334. /**
  84335. * Remove a specific start size gradient
  84336. * @param gradient defines the gradient to remove
  84337. * @returns the current particle system
  84338. */
  84339. removeStartSizeGradient(gradient: number): IParticleSystem;
  84340. /**
  84341. * Gets the current list of start size gradients.
  84342. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  84343. * @returns the list of start size gradients
  84344. */
  84345. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  84346. /**
  84347. * Adds a new life time gradient
  84348. * @param gradient defines the gradient to use (between 0 and 1)
  84349. * @param factor defines the life time factor to affect to the specified gradient
  84350. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84351. * @returns the current particle system
  84352. */
  84353. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84354. /**
  84355. * Remove a specific life time gradient
  84356. * @param gradient defines the gradient to remove
  84357. * @returns the current particle system
  84358. */
  84359. removeLifeTimeGradient(gradient: number): IParticleSystem;
  84360. /**
  84361. * Gets the current list of life time gradients.
  84362. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  84363. * @returns the list of life time gradients
  84364. */
  84365. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  84366. /**
  84367. * Gets the current list of color gradients.
  84368. * You must use addColorGradient and removeColorGradient to udpate this list
  84369. * @returns the list of color gradients
  84370. */
  84371. getColorGradients(): Nullable<Array<ColorGradient>>;
  84372. /**
  84373. * Adds a new ramp gradient used to remap particle colors
  84374. * @param gradient defines the gradient to use (between 0 and 1)
  84375. * @param color defines the color to affect to the specified gradient
  84376. * @returns the current particle system
  84377. */
  84378. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  84379. /**
  84380. * Gets the current list of ramp gradients.
  84381. * You must use addRampGradient and removeRampGradient to udpate this list
  84382. * @returns the list of ramp gradients
  84383. */
  84384. getRampGradients(): Nullable<Array<Color3Gradient>>;
  84385. /** Gets or sets a boolean indicating that ramp gradients must be used
  84386. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  84387. */
  84388. useRampGradients: boolean;
  84389. /**
  84390. * Adds a new color remap gradient
  84391. * @param gradient defines the gradient to use (between 0 and 1)
  84392. * @param min defines the color remap minimal range
  84393. * @param max defines the color remap maximal range
  84394. * @returns the current particle system
  84395. */
  84396. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84397. /**
  84398. * Gets the current list of color remap gradients.
  84399. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  84400. * @returns the list of color remap gradients
  84401. */
  84402. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  84403. /**
  84404. * Adds a new alpha remap gradient
  84405. * @param gradient defines the gradient to use (between 0 and 1)
  84406. * @param min defines the alpha remap minimal range
  84407. * @param max defines the alpha remap maximal range
  84408. * @returns the current particle system
  84409. */
  84410. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84411. /**
  84412. * Gets the current list of alpha remap gradients.
  84413. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  84414. * @returns the list of alpha remap gradients
  84415. */
  84416. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  84417. /**
  84418. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  84419. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84420. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84421. * @returns the emitter
  84422. */
  84423. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84424. /**
  84425. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84426. * @param radius The radius of the hemisphere to emit from
  84427. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84428. * @returns the emitter
  84429. */
  84430. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  84431. /**
  84432. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84433. * @param radius The radius of the sphere to emit from
  84434. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84435. * @returns the emitter
  84436. */
  84437. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  84438. /**
  84439. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84440. * @param radius The radius of the sphere to emit from
  84441. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84442. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84443. * @returns the emitter
  84444. */
  84445. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  84446. /**
  84447. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84448. * @param radius The radius of the emission cylinder
  84449. * @param height The height of the emission cylinder
  84450. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84451. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84452. * @returns the emitter
  84453. */
  84454. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  84455. /**
  84456. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84457. * @param radius The radius of the cylinder to emit from
  84458. * @param height The height of the emission cylinder
  84459. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84460. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84461. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84462. * @returns the emitter
  84463. */
  84464. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  84465. /**
  84466. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84467. * @param radius The radius of the cone to emit from
  84468. * @param angle The base angle of the cone
  84469. * @returns the emitter
  84470. */
  84471. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  84472. /**
  84473. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84474. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84475. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84476. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84477. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84478. * @returns the emitter
  84479. */
  84480. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  84481. /**
  84482. * Get hosting scene
  84483. * @returns the scene
  84484. */
  84485. getScene(): Scene;
  84486. }
  84487. }
  84488. declare module BABYLON {
  84489. /**
  84490. * Creates an instance based on a source mesh.
  84491. */
  84492. export class InstancedMesh extends AbstractMesh {
  84493. private _sourceMesh;
  84494. private _currentLOD;
  84495. /** @hidden */
  84496. _indexInSourceMeshInstanceArray: number;
  84497. constructor(name: string, source: Mesh);
  84498. /**
  84499. * Returns the string "InstancedMesh".
  84500. */
  84501. getClassName(): string;
  84502. /** Gets the list of lights affecting that mesh */
  84503. readonly lightSources: Light[];
  84504. _resyncLightSources(): void;
  84505. _resyncLighSource(light: Light): void;
  84506. _removeLightSource(light: Light, dispose: boolean): void;
  84507. /**
  84508. * If the source mesh receives shadows
  84509. */
  84510. readonly receiveShadows: boolean;
  84511. /**
  84512. * The material of the source mesh
  84513. */
  84514. readonly material: Nullable<Material>;
  84515. /**
  84516. * Visibility of the source mesh
  84517. */
  84518. readonly visibility: number;
  84519. /**
  84520. * Skeleton of the source mesh
  84521. */
  84522. readonly skeleton: Nullable<Skeleton>;
  84523. /**
  84524. * Rendering ground id of the source mesh
  84525. */
  84526. renderingGroupId: number;
  84527. /**
  84528. * Returns the total number of vertices (integer).
  84529. */
  84530. getTotalVertices(): number;
  84531. /**
  84532. * Returns a positive integer : the total number of indices in this mesh geometry.
  84533. * @returns the numner of indices or zero if the mesh has no geometry.
  84534. */
  84535. getTotalIndices(): number;
  84536. /**
  84537. * The source mesh of the instance
  84538. */
  84539. readonly sourceMesh: Mesh;
  84540. /**
  84541. * Is this node ready to be used/rendered
  84542. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  84543. * @return {boolean} is it ready
  84544. */
  84545. isReady(completeCheck?: boolean): boolean;
  84546. /**
  84547. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  84548. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  84549. * @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.
  84550. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  84551. */
  84552. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  84553. /**
  84554. * Sets the vertex data of the mesh geometry for the requested `kind`.
  84555. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  84556. * The `data` are either a numeric array either a Float32Array.
  84557. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  84558. * 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).
  84559. * Note that a new underlying VertexBuffer object is created each call.
  84560. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  84561. *
  84562. * Possible `kind` values :
  84563. * - VertexBuffer.PositionKind
  84564. * - VertexBuffer.UVKind
  84565. * - VertexBuffer.UV2Kind
  84566. * - VertexBuffer.UV3Kind
  84567. * - VertexBuffer.UV4Kind
  84568. * - VertexBuffer.UV5Kind
  84569. * - VertexBuffer.UV6Kind
  84570. * - VertexBuffer.ColorKind
  84571. * - VertexBuffer.MatricesIndicesKind
  84572. * - VertexBuffer.MatricesIndicesExtraKind
  84573. * - VertexBuffer.MatricesWeightsKind
  84574. * - VertexBuffer.MatricesWeightsExtraKind
  84575. *
  84576. * Returns the Mesh.
  84577. */
  84578. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  84579. /**
  84580. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  84581. * If the mesh has no geometry, it is simply returned as it is.
  84582. * The `data` are either a numeric array either a Float32Array.
  84583. * No new underlying VertexBuffer object is created.
  84584. * 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.
  84585. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  84586. *
  84587. * Possible `kind` values :
  84588. * - VertexBuffer.PositionKind
  84589. * - VertexBuffer.UVKind
  84590. * - VertexBuffer.UV2Kind
  84591. * - VertexBuffer.UV3Kind
  84592. * - VertexBuffer.UV4Kind
  84593. * - VertexBuffer.UV5Kind
  84594. * - VertexBuffer.UV6Kind
  84595. * - VertexBuffer.ColorKind
  84596. * - VertexBuffer.MatricesIndicesKind
  84597. * - VertexBuffer.MatricesIndicesExtraKind
  84598. * - VertexBuffer.MatricesWeightsKind
  84599. * - VertexBuffer.MatricesWeightsExtraKind
  84600. *
  84601. * Returns the Mesh.
  84602. */
  84603. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  84604. /**
  84605. * Sets the mesh indices.
  84606. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  84607. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  84608. * This method creates a new index buffer each call.
  84609. * Returns the Mesh.
  84610. */
  84611. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  84612. /**
  84613. * Boolean : True if the mesh owns the requested kind of data.
  84614. */
  84615. isVerticesDataPresent(kind: string): boolean;
  84616. /**
  84617. * Returns an array of indices (IndicesArray).
  84618. */
  84619. getIndices(): Nullable<IndicesArray>;
  84620. readonly _positions: Nullable<Vector3[]>;
  84621. /**
  84622. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  84623. * This means the mesh underlying bounding box and sphere are recomputed.
  84624. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  84625. * @returns the current mesh
  84626. */
  84627. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  84628. /** @hidden */
  84629. _preActivate(): InstancedMesh;
  84630. /** @hidden */
  84631. _activate(renderId: number, intermediateRendering: boolean): boolean;
  84632. /** @hidden */
  84633. _postActivate(): void;
  84634. getWorldMatrix(): Matrix;
  84635. readonly isAnInstance: boolean;
  84636. /**
  84637. * Returns the current associated LOD AbstractMesh.
  84638. */
  84639. getLOD(camera: Camera): AbstractMesh;
  84640. /** @hidden */
  84641. _syncSubMeshes(): InstancedMesh;
  84642. /** @hidden */
  84643. _generatePointsArray(): boolean;
  84644. /**
  84645. * Creates a new InstancedMesh from the current mesh.
  84646. * - name (string) : the cloned mesh name
  84647. * - newParent (optional Node) : the optional Node to parent the clone to.
  84648. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  84649. *
  84650. * Returns the clone.
  84651. */
  84652. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  84653. /**
  84654. * Disposes the InstancedMesh.
  84655. * Returns nothing.
  84656. */
  84657. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  84658. }
  84659. }
  84660. declare module BABYLON {
  84661. /**
  84662. * Defines the options associated with the creation of a shader material.
  84663. */
  84664. export interface IShaderMaterialOptions {
  84665. /**
  84666. * Does the material work in alpha blend mode
  84667. */
  84668. needAlphaBlending: boolean;
  84669. /**
  84670. * Does the material work in alpha test mode
  84671. */
  84672. needAlphaTesting: boolean;
  84673. /**
  84674. * The list of attribute names used in the shader
  84675. */
  84676. attributes: string[];
  84677. /**
  84678. * The list of unifrom names used in the shader
  84679. */
  84680. uniforms: string[];
  84681. /**
  84682. * The list of UBO names used in the shader
  84683. */
  84684. uniformBuffers: string[];
  84685. /**
  84686. * The list of sampler names used in the shader
  84687. */
  84688. samplers: string[];
  84689. /**
  84690. * The list of defines used in the shader
  84691. */
  84692. defines: string[];
  84693. }
  84694. /**
  84695. * 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.
  84696. *
  84697. * This returned material effects how the mesh will look based on the code in the shaders.
  84698. *
  84699. * @see http://doc.babylonjs.com/how_to/shader_material
  84700. */
  84701. export class ShaderMaterial extends Material {
  84702. private _shaderPath;
  84703. private _options;
  84704. private _textures;
  84705. private _textureArrays;
  84706. private _floats;
  84707. private _ints;
  84708. private _floatsArrays;
  84709. private _colors3;
  84710. private _colors3Arrays;
  84711. private _colors4;
  84712. private _colors4Arrays;
  84713. private _vectors2;
  84714. private _vectors3;
  84715. private _vectors4;
  84716. private _matrices;
  84717. private _matrices3x3;
  84718. private _matrices2x2;
  84719. private _vectors2Arrays;
  84720. private _vectors3Arrays;
  84721. private _vectors4Arrays;
  84722. private _cachedWorldViewMatrix;
  84723. private _cachedWorldViewProjectionMatrix;
  84724. private _renderId;
  84725. /**
  84726. * Instantiate a new shader material.
  84727. * 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.
  84728. * This returned material effects how the mesh will look based on the code in the shaders.
  84729. * @see http://doc.babylonjs.com/how_to/shader_material
  84730. * @param name Define the name of the material in the scene
  84731. * @param scene Define the scene the material belongs to
  84732. * @param shaderPath Defines the route to the shader code in one of three ways:
  84733. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  84734. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  84735. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  84736. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  84737. * @param options Define the options used to create the shader
  84738. */
  84739. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  84740. /**
  84741. * Gets the options used to compile the shader.
  84742. * They can be modified to trigger a new compilation
  84743. */
  84744. readonly options: IShaderMaterialOptions;
  84745. /**
  84746. * Gets the current class name of the material e.g. "ShaderMaterial"
  84747. * Mainly use in serialization.
  84748. * @returns the class name
  84749. */
  84750. getClassName(): string;
  84751. /**
  84752. * Specifies if the material will require alpha blending
  84753. * @returns a boolean specifying if alpha blending is needed
  84754. */
  84755. needAlphaBlending(): boolean;
  84756. /**
  84757. * Specifies if this material should be rendered in alpha test mode
  84758. * @returns a boolean specifying if an alpha test is needed.
  84759. */
  84760. needAlphaTesting(): boolean;
  84761. private _checkUniform;
  84762. /**
  84763. * Set a texture in the shader.
  84764. * @param name Define the name of the uniform samplers as defined in the shader
  84765. * @param texture Define the texture to bind to this sampler
  84766. * @return the material itself allowing "fluent" like uniform updates
  84767. */
  84768. setTexture(name: string, texture: Texture): ShaderMaterial;
  84769. /**
  84770. * Set a texture array in the shader.
  84771. * @param name Define the name of the uniform sampler array as defined in the shader
  84772. * @param textures Define the list of textures to bind to this sampler
  84773. * @return the material itself allowing "fluent" like uniform updates
  84774. */
  84775. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  84776. /**
  84777. * Set a float in the shader.
  84778. * @param name Define the name of the uniform as defined in the shader
  84779. * @param value Define the value to give to the uniform
  84780. * @return the material itself allowing "fluent" like uniform updates
  84781. */
  84782. setFloat(name: string, value: number): ShaderMaterial;
  84783. /**
  84784. * Set a int in the shader.
  84785. * @param name Define the name of the uniform as defined in the shader
  84786. * @param value Define the value to give to the uniform
  84787. * @return the material itself allowing "fluent" like uniform updates
  84788. */
  84789. setInt(name: string, value: number): ShaderMaterial;
  84790. /**
  84791. * Set an array of floats in the shader.
  84792. * @param name Define the name of the uniform as defined in the shader
  84793. * @param value Define the value to give to the uniform
  84794. * @return the material itself allowing "fluent" like uniform updates
  84795. */
  84796. setFloats(name: string, value: number[]): ShaderMaterial;
  84797. /**
  84798. * Set a vec3 in the shader from a Color3.
  84799. * @param name Define the name of the uniform as defined in the shader
  84800. * @param value Define the value to give to the uniform
  84801. * @return the material itself allowing "fluent" like uniform updates
  84802. */
  84803. setColor3(name: string, value: Color3): ShaderMaterial;
  84804. /**
  84805. * Set a vec3 array in the shader from a Color3 array.
  84806. * @param name Define the name of the uniform as defined in the shader
  84807. * @param value Define the value to give to the uniform
  84808. * @return the material itself allowing "fluent" like uniform updates
  84809. */
  84810. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  84811. /**
  84812. * Set a vec4 in the shader from a Color4.
  84813. * @param name Define the name of the uniform as defined in the shader
  84814. * @param value Define the value to give to the uniform
  84815. * @return the material itself allowing "fluent" like uniform updates
  84816. */
  84817. setColor4(name: string, value: Color4): ShaderMaterial;
  84818. /**
  84819. * Set a vec4 array in the shader from a Color4 array.
  84820. * @param name Define the name of the uniform as defined in the shader
  84821. * @param value Define the value to give to the uniform
  84822. * @return the material itself allowing "fluent" like uniform updates
  84823. */
  84824. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  84825. /**
  84826. * Set a vec2 in the shader from a Vector2.
  84827. * @param name Define the name of the uniform as defined in the shader
  84828. * @param value Define the value to give to the uniform
  84829. * @return the material itself allowing "fluent" like uniform updates
  84830. */
  84831. setVector2(name: string, value: Vector2): ShaderMaterial;
  84832. /**
  84833. * Set a vec3 in the shader from a Vector3.
  84834. * @param name Define the name of the uniform as defined in the shader
  84835. * @param value Define the value to give to the uniform
  84836. * @return the material itself allowing "fluent" like uniform updates
  84837. */
  84838. setVector3(name: string, value: Vector3): ShaderMaterial;
  84839. /**
  84840. * Set a vec4 in the shader from a Vector4.
  84841. * @param name Define the name of the uniform as defined in the shader
  84842. * @param value Define the value to give to the uniform
  84843. * @return the material itself allowing "fluent" like uniform updates
  84844. */
  84845. setVector4(name: string, value: Vector4): ShaderMaterial;
  84846. /**
  84847. * Set a mat4 in the shader from a Matrix.
  84848. * @param name Define the name of the uniform as defined in the shader
  84849. * @param value Define the value to give to the uniform
  84850. * @return the material itself allowing "fluent" like uniform updates
  84851. */
  84852. setMatrix(name: string, value: Matrix): ShaderMaterial;
  84853. /**
  84854. * Set a mat3 in the shader from a Float32Array.
  84855. * @param name Define the name of the uniform as defined in the shader
  84856. * @param value Define the value to give to the uniform
  84857. * @return the material itself allowing "fluent" like uniform updates
  84858. */
  84859. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  84860. /**
  84861. * Set a mat2 in the shader from a Float32Array.
  84862. * @param name Define the name of the uniform as defined in the shader
  84863. * @param value Define the value to give to the uniform
  84864. * @return the material itself allowing "fluent" like uniform updates
  84865. */
  84866. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  84867. /**
  84868. * Set a vec2 array in the shader from a number array.
  84869. * @param name Define the name of the uniform as defined in the shader
  84870. * @param value Define the value to give to the uniform
  84871. * @return the material itself allowing "fluent" like uniform updates
  84872. */
  84873. setArray2(name: string, value: number[]): ShaderMaterial;
  84874. /**
  84875. * Set a vec3 array in the shader from a number array.
  84876. * @param name Define the name of the uniform as defined in the shader
  84877. * @param value Define the value to give to the uniform
  84878. * @return the material itself allowing "fluent" like uniform updates
  84879. */
  84880. setArray3(name: string, value: number[]): ShaderMaterial;
  84881. /**
  84882. * Set a vec4 array in the shader from a number array.
  84883. * @param name Define the name of the uniform as defined in the shader
  84884. * @param value Define the value to give to the uniform
  84885. * @return the material itself allowing "fluent" like uniform updates
  84886. */
  84887. setArray4(name: string, value: number[]): ShaderMaterial;
  84888. private _checkCache;
  84889. /**
  84890. * Specifies that the submesh is ready to be used
  84891. * @param mesh defines the mesh to check
  84892. * @param subMesh defines which submesh to check
  84893. * @param useInstances specifies that instances should be used
  84894. * @returns a boolean indicating that the submesh is ready or not
  84895. */
  84896. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  84897. /**
  84898. * Checks if the material is ready to render the requested mesh
  84899. * @param mesh Define the mesh to render
  84900. * @param useInstances Define whether or not the material is used with instances
  84901. * @returns true if ready, otherwise false
  84902. */
  84903. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  84904. /**
  84905. * Binds the world matrix to the material
  84906. * @param world defines the world transformation matrix
  84907. */
  84908. bindOnlyWorldMatrix(world: Matrix): void;
  84909. /**
  84910. * Binds the material to the mesh
  84911. * @param world defines the world transformation matrix
  84912. * @param mesh defines the mesh to bind the material to
  84913. */
  84914. bind(world: Matrix, mesh?: Mesh): void;
  84915. /**
  84916. * Gets the active textures from the material
  84917. * @returns an array of textures
  84918. */
  84919. getActiveTextures(): BaseTexture[];
  84920. /**
  84921. * Specifies if the material uses a texture
  84922. * @param texture defines the texture to check against the material
  84923. * @returns a boolean specifying if the material uses the texture
  84924. */
  84925. hasTexture(texture: BaseTexture): boolean;
  84926. /**
  84927. * Makes a duplicate of the material, and gives it a new name
  84928. * @param name defines the new name for the duplicated material
  84929. * @returns the cloned material
  84930. */
  84931. clone(name: string): ShaderMaterial;
  84932. /**
  84933. * Disposes the material
  84934. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  84935. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  84936. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  84937. */
  84938. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  84939. /**
  84940. * Serializes this material in a JSON representation
  84941. * @returns the serialized material object
  84942. */
  84943. serialize(): any;
  84944. /**
  84945. * Creates a shader material from parsed shader material data
  84946. * @param source defines the JSON represnetation of the material
  84947. * @param scene defines the hosting scene
  84948. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  84949. * @returns a new material
  84950. */
  84951. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  84952. }
  84953. }
  84954. declare module BABYLON {
  84955. /** @hidden */
  84956. export var colorPixelShader: {
  84957. name: string;
  84958. shader: string;
  84959. };
  84960. }
  84961. declare module BABYLON {
  84962. /** @hidden */
  84963. export var colorVertexShader: {
  84964. name: string;
  84965. shader: string;
  84966. };
  84967. }
  84968. declare module BABYLON {
  84969. /**
  84970. * Line mesh
  84971. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  84972. */
  84973. export class LinesMesh extends Mesh {
  84974. /**
  84975. * If vertex color should be applied to the mesh
  84976. */
  84977. readonly useVertexColor?: boolean | undefined;
  84978. /**
  84979. * If vertex alpha should be applied to the mesh
  84980. */
  84981. readonly useVertexAlpha?: boolean | undefined;
  84982. /**
  84983. * Color of the line (Default: White)
  84984. */
  84985. color: Color3;
  84986. /**
  84987. * Alpha of the line (Default: 1)
  84988. */
  84989. alpha: number;
  84990. /**
  84991. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  84992. * This margin is expressed in world space coordinates, so its value may vary.
  84993. * Default value is 0.1
  84994. */
  84995. intersectionThreshold: number;
  84996. private _colorShader;
  84997. private color4;
  84998. /**
  84999. * Creates a new LinesMesh
  85000. * @param name defines the name
  85001. * @param scene defines the hosting scene
  85002. * @param parent defines the parent mesh if any
  85003. * @param source defines the optional source LinesMesh used to clone data from
  85004. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  85005. * When false, achieved by calling a clone(), also passing False.
  85006. * This will make creation of children, recursive.
  85007. * @param useVertexColor defines if this LinesMesh supports vertex color
  85008. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  85009. */
  85010. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  85011. /**
  85012. * If vertex color should be applied to the mesh
  85013. */
  85014. useVertexColor?: boolean | undefined,
  85015. /**
  85016. * If vertex alpha should be applied to the mesh
  85017. */
  85018. useVertexAlpha?: boolean | undefined);
  85019. private _addClipPlaneDefine;
  85020. private _removeClipPlaneDefine;
  85021. isReady(): boolean;
  85022. /**
  85023. * Returns the string "LineMesh"
  85024. */
  85025. getClassName(): string;
  85026. /**
  85027. * @hidden
  85028. */
  85029. /**
  85030. * @hidden
  85031. */
  85032. material: Material;
  85033. /**
  85034. * @hidden
  85035. */
  85036. readonly checkCollisions: boolean;
  85037. /** @hidden */
  85038. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  85039. /** @hidden */
  85040. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  85041. /**
  85042. * Disposes of the line mesh
  85043. * @param doNotRecurse If children should be disposed
  85044. */
  85045. dispose(doNotRecurse?: boolean): void;
  85046. /**
  85047. * Returns a new LineMesh object cloned from the current one.
  85048. */
  85049. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  85050. /**
  85051. * Creates a new InstancedLinesMesh object from the mesh model.
  85052. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  85053. * @param name defines the name of the new instance
  85054. * @returns a new InstancedLinesMesh
  85055. */
  85056. createInstance(name: string): InstancedLinesMesh;
  85057. }
  85058. /**
  85059. * Creates an instance based on a source LinesMesh
  85060. */
  85061. export class InstancedLinesMesh extends InstancedMesh {
  85062. /**
  85063. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  85064. * This margin is expressed in world space coordinates, so its value may vary.
  85065. * Initilized with the intersectionThreshold value of the source LinesMesh
  85066. */
  85067. intersectionThreshold: number;
  85068. constructor(name: string, source: LinesMesh);
  85069. /**
  85070. * Returns the string "InstancedLinesMesh".
  85071. */
  85072. getClassName(): string;
  85073. }
  85074. }
  85075. declare module BABYLON {
  85076. /** @hidden */
  85077. export var linePixelShader: {
  85078. name: string;
  85079. shader: string;
  85080. };
  85081. }
  85082. declare module BABYLON {
  85083. /** @hidden */
  85084. export var lineVertexShader: {
  85085. name: string;
  85086. shader: string;
  85087. };
  85088. }
  85089. declare module BABYLON {
  85090. interface AbstractMesh {
  85091. /**
  85092. * Gets the edgesRenderer associated with the mesh
  85093. */
  85094. edgesRenderer: Nullable<EdgesRenderer>;
  85095. }
  85096. interface LinesMesh {
  85097. /**
  85098. * Enables the edge rendering mode on the mesh.
  85099. * This mode makes the mesh edges visible
  85100. * @param epsilon defines the maximal distance between two angles to detect a face
  85101. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  85102. * @returns the currentAbstractMesh
  85103. * @see https://www.babylonjs-playground.com/#19O9TU#0
  85104. */
  85105. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  85106. }
  85107. interface InstancedLinesMesh {
  85108. /**
  85109. * Enables the edge rendering mode on the mesh.
  85110. * This mode makes the mesh edges visible
  85111. * @param epsilon defines the maximal distance between two angles to detect a face
  85112. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  85113. * @returns the current InstancedLinesMesh
  85114. * @see https://www.babylonjs-playground.com/#19O9TU#0
  85115. */
  85116. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  85117. }
  85118. /**
  85119. * Defines the minimum contract an Edges renderer should follow.
  85120. */
  85121. export interface IEdgesRenderer extends IDisposable {
  85122. /**
  85123. * Gets or sets a boolean indicating if the edgesRenderer is active
  85124. */
  85125. isEnabled: boolean;
  85126. /**
  85127. * Renders the edges of the attached mesh,
  85128. */
  85129. render(): void;
  85130. /**
  85131. * Checks wether or not the edges renderer is ready to render.
  85132. * @return true if ready, otherwise false.
  85133. */
  85134. isReady(): boolean;
  85135. }
  85136. /**
  85137. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  85138. */
  85139. export class EdgesRenderer implements IEdgesRenderer {
  85140. /**
  85141. * Define the size of the edges with an orthographic camera
  85142. */
  85143. edgesWidthScalerForOrthographic: number;
  85144. /**
  85145. * Define the size of the edges with a perspective camera
  85146. */
  85147. edgesWidthScalerForPerspective: number;
  85148. protected _source: AbstractMesh;
  85149. protected _linesPositions: number[];
  85150. protected _linesNormals: number[];
  85151. protected _linesIndices: number[];
  85152. protected _epsilon: number;
  85153. protected _indicesCount: number;
  85154. protected _lineShader: ShaderMaterial;
  85155. protected _ib: DataBuffer;
  85156. protected _buffers: {
  85157. [key: string]: Nullable<VertexBuffer>;
  85158. };
  85159. protected _checkVerticesInsteadOfIndices: boolean;
  85160. private _meshRebuildObserver;
  85161. private _meshDisposeObserver;
  85162. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  85163. isEnabled: boolean;
  85164. /**
  85165. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  85166. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  85167. * @param source Mesh used to create edges
  85168. * @param epsilon sum of angles in adjacency to check for edge
  85169. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  85170. * @param generateEdgesLines - should generate Lines or only prepare resources.
  85171. */
  85172. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  85173. protected _prepareRessources(): void;
  85174. /** @hidden */
  85175. _rebuild(): void;
  85176. /**
  85177. * Releases the required resources for the edges renderer
  85178. */
  85179. dispose(): void;
  85180. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  85181. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  85182. /**
  85183. * Checks if the pair of p0 and p1 is en edge
  85184. * @param faceIndex
  85185. * @param edge
  85186. * @param faceNormals
  85187. * @param p0
  85188. * @param p1
  85189. * @private
  85190. */
  85191. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  85192. /**
  85193. * push line into the position, normal and index buffer
  85194. * @protected
  85195. */
  85196. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  85197. /**
  85198. * Generates lines edges from adjacencjes
  85199. * @private
  85200. */
  85201. _generateEdgesLines(): void;
  85202. /**
  85203. * Checks wether or not the edges renderer is ready to render.
  85204. * @return true if ready, otherwise false.
  85205. */
  85206. isReady(): boolean;
  85207. /**
  85208. * Renders the edges of the attached mesh,
  85209. */
  85210. render(): void;
  85211. }
  85212. /**
  85213. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  85214. */
  85215. export class LineEdgesRenderer extends EdgesRenderer {
  85216. /**
  85217. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  85218. * @param source LineMesh used to generate edges
  85219. * @param epsilon not important (specified angle for edge detection)
  85220. * @param checkVerticesInsteadOfIndices not important for LineMesh
  85221. */
  85222. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  85223. /**
  85224. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  85225. */
  85226. _generateEdgesLines(): void;
  85227. }
  85228. }
  85229. declare module BABYLON {
  85230. /**
  85231. * This represents the object necessary to create a rendering group.
  85232. * This is exclusively used and created by the rendering manager.
  85233. * To modify the behavior, you use the available helpers in your scene or meshes.
  85234. * @hidden
  85235. */
  85236. export class RenderingGroup {
  85237. index: number;
  85238. private static _zeroVector;
  85239. private _scene;
  85240. private _opaqueSubMeshes;
  85241. private _transparentSubMeshes;
  85242. private _alphaTestSubMeshes;
  85243. private _depthOnlySubMeshes;
  85244. private _particleSystems;
  85245. private _spriteManagers;
  85246. private _opaqueSortCompareFn;
  85247. private _alphaTestSortCompareFn;
  85248. private _transparentSortCompareFn;
  85249. private _renderOpaque;
  85250. private _renderAlphaTest;
  85251. private _renderTransparent;
  85252. /** @hidden */
  85253. _edgesRenderers: SmartArray<IEdgesRenderer>;
  85254. onBeforeTransparentRendering: () => void;
  85255. /**
  85256. * Set the opaque sort comparison function.
  85257. * If null the sub meshes will be render in the order they were created
  85258. */
  85259. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  85260. /**
  85261. * Set the alpha test sort comparison function.
  85262. * If null the sub meshes will be render in the order they were created
  85263. */
  85264. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  85265. /**
  85266. * Set the transparent sort comparison function.
  85267. * If null the sub meshes will be render in the order they were created
  85268. */
  85269. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  85270. /**
  85271. * Creates a new rendering group.
  85272. * @param index The rendering group index
  85273. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  85274. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  85275. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  85276. */
  85277. 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>);
  85278. /**
  85279. * Render all the sub meshes contained in the group.
  85280. * @param customRenderFunction Used to override the default render behaviour of the group.
  85281. * @returns true if rendered some submeshes.
  85282. */
  85283. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  85284. /**
  85285. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  85286. * @param subMeshes The submeshes to render
  85287. */
  85288. private renderOpaqueSorted;
  85289. /**
  85290. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  85291. * @param subMeshes The submeshes to render
  85292. */
  85293. private renderAlphaTestSorted;
  85294. /**
  85295. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  85296. * @param subMeshes The submeshes to render
  85297. */
  85298. private renderTransparentSorted;
  85299. /**
  85300. * Renders the submeshes in a specified order.
  85301. * @param subMeshes The submeshes to sort before render
  85302. * @param sortCompareFn The comparison function use to sort
  85303. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  85304. * @param transparent Specifies to activate blending if true
  85305. */
  85306. private static renderSorted;
  85307. /**
  85308. * Renders the submeshes in the order they were dispatched (no sort applied).
  85309. * @param subMeshes The submeshes to render
  85310. */
  85311. private static renderUnsorted;
  85312. /**
  85313. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  85314. * are rendered back to front if in the same alpha index.
  85315. *
  85316. * @param a The first submesh
  85317. * @param b The second submesh
  85318. * @returns The result of the comparison
  85319. */
  85320. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  85321. /**
  85322. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  85323. * are rendered back to front.
  85324. *
  85325. * @param a The first submesh
  85326. * @param b The second submesh
  85327. * @returns The result of the comparison
  85328. */
  85329. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  85330. /**
  85331. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  85332. * are rendered front to back (prevent overdraw).
  85333. *
  85334. * @param a The first submesh
  85335. * @param b The second submesh
  85336. * @returns The result of the comparison
  85337. */
  85338. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  85339. /**
  85340. * Resets the different lists of submeshes to prepare a new frame.
  85341. */
  85342. prepare(): void;
  85343. dispose(): void;
  85344. /**
  85345. * Inserts the submesh in its correct queue depending on its material.
  85346. * @param subMesh The submesh to dispatch
  85347. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  85348. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  85349. */
  85350. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  85351. dispatchSprites(spriteManager: ISpriteManager): void;
  85352. dispatchParticles(particleSystem: IParticleSystem): void;
  85353. private _renderParticles;
  85354. private _renderSprites;
  85355. }
  85356. }
  85357. declare module BABYLON {
  85358. /**
  85359. * Interface describing the different options available in the rendering manager
  85360. * regarding Auto Clear between groups.
  85361. */
  85362. export interface IRenderingManagerAutoClearSetup {
  85363. /**
  85364. * Defines whether or not autoclear is enable.
  85365. */
  85366. autoClear: boolean;
  85367. /**
  85368. * Defines whether or not to autoclear the depth buffer.
  85369. */
  85370. depth: boolean;
  85371. /**
  85372. * Defines whether or not to autoclear the stencil buffer.
  85373. */
  85374. stencil: boolean;
  85375. }
  85376. /**
  85377. * This class is used by the onRenderingGroupObservable
  85378. */
  85379. export class RenderingGroupInfo {
  85380. /**
  85381. * The Scene that being rendered
  85382. */
  85383. scene: Scene;
  85384. /**
  85385. * The camera currently used for the rendering pass
  85386. */
  85387. camera: Nullable<Camera>;
  85388. /**
  85389. * The ID of the renderingGroup being processed
  85390. */
  85391. renderingGroupId: number;
  85392. }
  85393. /**
  85394. * This is the manager responsible of all the rendering for meshes sprites and particles.
  85395. * It is enable to manage the different groups as well as the different necessary sort functions.
  85396. * This should not be used directly aside of the few static configurations
  85397. */
  85398. export class RenderingManager {
  85399. /**
  85400. * The max id used for rendering groups (not included)
  85401. */
  85402. static MAX_RENDERINGGROUPS: number;
  85403. /**
  85404. * The min id used for rendering groups (included)
  85405. */
  85406. static MIN_RENDERINGGROUPS: number;
  85407. /**
  85408. * Used to globally prevent autoclearing scenes.
  85409. */
  85410. static AUTOCLEAR: boolean;
  85411. /**
  85412. * @hidden
  85413. */
  85414. _useSceneAutoClearSetup: boolean;
  85415. private _scene;
  85416. private _renderingGroups;
  85417. private _depthStencilBufferAlreadyCleaned;
  85418. private _autoClearDepthStencil;
  85419. private _customOpaqueSortCompareFn;
  85420. private _customAlphaTestSortCompareFn;
  85421. private _customTransparentSortCompareFn;
  85422. private _renderingGroupInfo;
  85423. /**
  85424. * Instantiates a new rendering group for a particular scene
  85425. * @param scene Defines the scene the groups belongs to
  85426. */
  85427. constructor(scene: Scene);
  85428. private _clearDepthStencilBuffer;
  85429. /**
  85430. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  85431. * @hidden
  85432. */
  85433. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  85434. /**
  85435. * Resets the different information of the group to prepare a new frame
  85436. * @hidden
  85437. */
  85438. reset(): void;
  85439. /**
  85440. * Dispose and release the group and its associated resources.
  85441. * @hidden
  85442. */
  85443. dispose(): void;
  85444. /**
  85445. * Clear the info related to rendering groups preventing retention points during dispose.
  85446. */
  85447. freeRenderingGroups(): void;
  85448. private _prepareRenderingGroup;
  85449. /**
  85450. * Add a sprite manager to the rendering manager in order to render it this frame.
  85451. * @param spriteManager Define the sprite manager to render
  85452. */
  85453. dispatchSprites(spriteManager: ISpriteManager): void;
  85454. /**
  85455. * Add a particle system to the rendering manager in order to render it this frame.
  85456. * @param particleSystem Define the particle system to render
  85457. */
  85458. dispatchParticles(particleSystem: IParticleSystem): void;
  85459. /**
  85460. * Add a submesh to the manager in order to render it this frame
  85461. * @param subMesh The submesh to dispatch
  85462. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  85463. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  85464. */
  85465. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  85466. /**
  85467. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  85468. * This allowed control for front to back rendering or reversly depending of the special needs.
  85469. *
  85470. * @param renderingGroupId The rendering group id corresponding to its index
  85471. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  85472. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  85473. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  85474. */
  85475. 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;
  85476. /**
  85477. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  85478. *
  85479. * @param renderingGroupId The rendering group id corresponding to its index
  85480. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  85481. * @param depth Automatically clears depth between groups if true and autoClear is true.
  85482. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  85483. */
  85484. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  85485. /**
  85486. * Gets the current auto clear configuration for one rendering group of the rendering
  85487. * manager.
  85488. * @param index the rendering group index to get the information for
  85489. * @returns The auto clear setup for the requested rendering group
  85490. */
  85491. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  85492. }
  85493. }
  85494. declare module BABYLON {
  85495. /**
  85496. * This Helps creating a texture that will be created from a camera in your scene.
  85497. * It is basically a dynamic texture that could be used to create special effects for instance.
  85498. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  85499. */
  85500. export class RenderTargetTexture extends Texture {
  85501. isCube: boolean;
  85502. /**
  85503. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  85504. */
  85505. static readonly REFRESHRATE_RENDER_ONCE: number;
  85506. /**
  85507. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  85508. */
  85509. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  85510. /**
  85511. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  85512. * the central point of your effect and can save a lot of performances.
  85513. */
  85514. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  85515. /**
  85516. * Use this predicate to dynamically define the list of mesh you want to render.
  85517. * If set, the renderList property will be overwritten.
  85518. */
  85519. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  85520. private _renderList;
  85521. /**
  85522. * Use this list to define the list of mesh you want to render.
  85523. */
  85524. renderList: Nullable<Array<AbstractMesh>>;
  85525. private _hookArray;
  85526. /**
  85527. * Define if particles should be rendered in your texture.
  85528. */
  85529. renderParticles: boolean;
  85530. /**
  85531. * Define if sprites should be rendered in your texture.
  85532. */
  85533. renderSprites: boolean;
  85534. /**
  85535. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  85536. */
  85537. coordinatesMode: number;
  85538. /**
  85539. * Define the camera used to render the texture.
  85540. */
  85541. activeCamera: Nullable<Camera>;
  85542. /**
  85543. * Override the render function of the texture with your own one.
  85544. */
  85545. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  85546. /**
  85547. * Define if camera post processes should be use while rendering the texture.
  85548. */
  85549. useCameraPostProcesses: boolean;
  85550. /**
  85551. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  85552. */
  85553. ignoreCameraViewport: boolean;
  85554. private _postProcessManager;
  85555. private _postProcesses;
  85556. private _resizeObserver;
  85557. /**
  85558. * An event triggered when the texture is unbind.
  85559. */
  85560. onBeforeBindObservable: Observable<RenderTargetTexture>;
  85561. /**
  85562. * An event triggered when the texture is unbind.
  85563. */
  85564. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  85565. private _onAfterUnbindObserver;
  85566. /**
  85567. * Set a after unbind callback in the texture.
  85568. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  85569. */
  85570. onAfterUnbind: () => void;
  85571. /**
  85572. * An event triggered before rendering the texture
  85573. */
  85574. onBeforeRenderObservable: Observable<number>;
  85575. private _onBeforeRenderObserver;
  85576. /**
  85577. * Set a before render callback in the texture.
  85578. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  85579. */
  85580. onBeforeRender: (faceIndex: number) => void;
  85581. /**
  85582. * An event triggered after rendering the texture
  85583. */
  85584. onAfterRenderObservable: Observable<number>;
  85585. private _onAfterRenderObserver;
  85586. /**
  85587. * Set a after render callback in the texture.
  85588. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  85589. */
  85590. onAfterRender: (faceIndex: number) => void;
  85591. /**
  85592. * An event triggered after the texture clear
  85593. */
  85594. onClearObservable: Observable<Engine>;
  85595. private _onClearObserver;
  85596. /**
  85597. * Set a clear callback in the texture.
  85598. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  85599. */
  85600. onClear: (Engine: Engine) => void;
  85601. /**
  85602. * An event triggered when the texture is resized.
  85603. */
  85604. onResizeObservable: Observable<RenderTargetTexture>;
  85605. /**
  85606. * Define the clear color of the Render Target if it should be different from the scene.
  85607. */
  85608. clearColor: Color4;
  85609. protected _size: number | {
  85610. width: number;
  85611. height: number;
  85612. };
  85613. protected _initialSizeParameter: number | {
  85614. width: number;
  85615. height: number;
  85616. } | {
  85617. ratio: number;
  85618. };
  85619. protected _sizeRatio: Nullable<number>;
  85620. /** @hidden */
  85621. _generateMipMaps: boolean;
  85622. protected _renderingManager: RenderingManager;
  85623. /** @hidden */
  85624. _waitingRenderList: string[];
  85625. protected _doNotChangeAspectRatio: boolean;
  85626. protected _currentRefreshId: number;
  85627. protected _refreshRate: number;
  85628. protected _textureMatrix: Matrix;
  85629. protected _samples: number;
  85630. protected _renderTargetOptions: RenderTargetCreationOptions;
  85631. /**
  85632. * Gets render target creation options that were used.
  85633. */
  85634. readonly renderTargetOptions: RenderTargetCreationOptions;
  85635. protected _engine: Engine;
  85636. protected _onRatioRescale(): void;
  85637. /**
  85638. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  85639. * It must define where the camera used to render the texture is set
  85640. */
  85641. boundingBoxPosition: Vector3;
  85642. private _boundingBoxSize;
  85643. /**
  85644. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  85645. * When defined, the cubemap will switch to local mode
  85646. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  85647. * @example https://www.babylonjs-playground.com/#RNASML
  85648. */
  85649. boundingBoxSize: Vector3;
  85650. /**
  85651. * In case the RTT has been created with a depth texture, get the associated
  85652. * depth texture.
  85653. * Otherwise, return null.
  85654. */
  85655. depthStencilTexture: Nullable<InternalTexture>;
  85656. /**
  85657. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  85658. * or used a shadow, depth texture...
  85659. * @param name The friendly name of the texture
  85660. * @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)
  85661. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  85662. * @param generateMipMaps True if mip maps need to be generated after render.
  85663. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  85664. * @param type The type of the buffer in the RTT (int, half float, float...)
  85665. * @param isCube True if a cube texture needs to be created
  85666. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  85667. * @param generateDepthBuffer True to generate a depth buffer
  85668. * @param generateStencilBuffer True to generate a stencil buffer
  85669. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  85670. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  85671. * @param delayAllocation if the texture allocation should be delayed (default: false)
  85672. */
  85673. constructor(name: string, size: number | {
  85674. width: number;
  85675. height: number;
  85676. } | {
  85677. ratio: number;
  85678. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  85679. /**
  85680. * Creates a depth stencil texture.
  85681. * This is only available in WebGL 2 or with the depth texture extension available.
  85682. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  85683. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  85684. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  85685. */
  85686. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  85687. private _processSizeParameter;
  85688. /**
  85689. * Define the number of samples to use in case of MSAA.
  85690. * It defaults to one meaning no MSAA has been enabled.
  85691. */
  85692. samples: number;
  85693. /**
  85694. * Resets the refresh counter of the texture and start bak from scratch.
  85695. * Could be useful to regenerate the texture if it is setup to render only once.
  85696. */
  85697. resetRefreshCounter(): void;
  85698. /**
  85699. * Define the refresh rate of the texture or the rendering frequency.
  85700. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  85701. */
  85702. refreshRate: number;
  85703. /**
  85704. * Adds a post process to the render target rendering passes.
  85705. * @param postProcess define the post process to add
  85706. */
  85707. addPostProcess(postProcess: PostProcess): void;
  85708. /**
  85709. * Clear all the post processes attached to the render target
  85710. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  85711. */
  85712. clearPostProcesses(dispose?: boolean): void;
  85713. /**
  85714. * Remove one of the post process from the list of attached post processes to the texture
  85715. * @param postProcess define the post process to remove from the list
  85716. */
  85717. removePostProcess(postProcess: PostProcess): void;
  85718. /** @hidden */
  85719. _shouldRender(): boolean;
  85720. /**
  85721. * Gets the actual render size of the texture.
  85722. * @returns the width of the render size
  85723. */
  85724. getRenderSize(): number;
  85725. /**
  85726. * Gets the actual render width of the texture.
  85727. * @returns the width of the render size
  85728. */
  85729. getRenderWidth(): number;
  85730. /**
  85731. * Gets the actual render height of the texture.
  85732. * @returns the height of the render size
  85733. */
  85734. getRenderHeight(): number;
  85735. /**
  85736. * Get if the texture can be rescaled or not.
  85737. */
  85738. readonly canRescale: boolean;
  85739. /**
  85740. * Resize the texture using a ratio.
  85741. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  85742. */
  85743. scale(ratio: number): void;
  85744. /**
  85745. * Get the texture reflection matrix used to rotate/transform the reflection.
  85746. * @returns the reflection matrix
  85747. */
  85748. getReflectionTextureMatrix(): Matrix;
  85749. /**
  85750. * Resize the texture to a new desired size.
  85751. * Be carrefull as it will recreate all the data in the new texture.
  85752. * @param size Define the new size. It can be:
  85753. * - a number for squared texture,
  85754. * - an object containing { width: number, height: number }
  85755. * - or an object containing a ratio { ratio: number }
  85756. */
  85757. resize(size: number | {
  85758. width: number;
  85759. height: number;
  85760. } | {
  85761. ratio: number;
  85762. }): void;
  85763. /**
  85764. * Renders all the objects from the render list into the texture.
  85765. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  85766. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  85767. */
  85768. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  85769. private _bestReflectionRenderTargetDimension;
  85770. /**
  85771. * @hidden
  85772. * @param faceIndex face index to bind to if this is a cubetexture
  85773. */
  85774. _bindFrameBuffer(faceIndex?: number): void;
  85775. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  85776. private renderToTarget;
  85777. /**
  85778. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  85779. * This allowed control for front to back rendering or reversly depending of the special needs.
  85780. *
  85781. * @param renderingGroupId The rendering group id corresponding to its index
  85782. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  85783. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  85784. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  85785. */
  85786. 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;
  85787. /**
  85788. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  85789. *
  85790. * @param renderingGroupId The rendering group id corresponding to its index
  85791. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  85792. */
  85793. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  85794. /**
  85795. * Clones the texture.
  85796. * @returns the cloned texture
  85797. */
  85798. clone(): RenderTargetTexture;
  85799. /**
  85800. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  85801. * @returns The JSON representation of the texture
  85802. */
  85803. serialize(): any;
  85804. /**
  85805. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  85806. */
  85807. disposeFramebufferObjects(): void;
  85808. /**
  85809. * Dispose the texture and release its associated resources.
  85810. */
  85811. dispose(): void;
  85812. /** @hidden */
  85813. _rebuild(): void;
  85814. /**
  85815. * Clear the info related to rendering groups preventing retention point in material dispose.
  85816. */
  85817. freeRenderingGroups(): void;
  85818. /**
  85819. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  85820. * @returns the view count
  85821. */
  85822. getViewCount(): number;
  85823. }
  85824. }
  85825. declare module BABYLON {
  85826. /**
  85827. * Base class for the main features of a material in Babylon.js
  85828. */
  85829. export class Material implements IAnimatable {
  85830. /**
  85831. * Returns the triangle fill mode
  85832. */
  85833. static readonly TriangleFillMode: number;
  85834. /**
  85835. * Returns the wireframe mode
  85836. */
  85837. static readonly WireFrameFillMode: number;
  85838. /**
  85839. * Returns the point fill mode
  85840. */
  85841. static readonly PointFillMode: number;
  85842. /**
  85843. * Returns the point list draw mode
  85844. */
  85845. static readonly PointListDrawMode: number;
  85846. /**
  85847. * Returns the line list draw mode
  85848. */
  85849. static readonly LineListDrawMode: number;
  85850. /**
  85851. * Returns the line loop draw mode
  85852. */
  85853. static readonly LineLoopDrawMode: number;
  85854. /**
  85855. * Returns the line strip draw mode
  85856. */
  85857. static readonly LineStripDrawMode: number;
  85858. /**
  85859. * Returns the triangle strip draw mode
  85860. */
  85861. static readonly TriangleStripDrawMode: number;
  85862. /**
  85863. * Returns the triangle fan draw mode
  85864. */
  85865. static readonly TriangleFanDrawMode: number;
  85866. /**
  85867. * Stores the clock-wise side orientation
  85868. */
  85869. static readonly ClockWiseSideOrientation: number;
  85870. /**
  85871. * Stores the counter clock-wise side orientation
  85872. */
  85873. static readonly CounterClockWiseSideOrientation: number;
  85874. /**
  85875. * The dirty texture flag value
  85876. */
  85877. static readonly TextureDirtyFlag: number;
  85878. /**
  85879. * The dirty light flag value
  85880. */
  85881. static readonly LightDirtyFlag: number;
  85882. /**
  85883. * The dirty fresnel flag value
  85884. */
  85885. static readonly FresnelDirtyFlag: number;
  85886. /**
  85887. * The dirty attribute flag value
  85888. */
  85889. static readonly AttributesDirtyFlag: number;
  85890. /**
  85891. * The dirty misc flag value
  85892. */
  85893. static readonly MiscDirtyFlag: number;
  85894. /**
  85895. * The all dirty flag value
  85896. */
  85897. static readonly AllDirtyFlag: number;
  85898. /**
  85899. * The ID of the material
  85900. */
  85901. id: string;
  85902. /**
  85903. * Gets or sets the unique id of the material
  85904. */
  85905. uniqueId: number;
  85906. /**
  85907. * The name of the material
  85908. */
  85909. name: string;
  85910. /**
  85911. * Gets or sets user defined metadata
  85912. */
  85913. metadata: any;
  85914. /**
  85915. * For internal use only. Please do not use.
  85916. */
  85917. reservedDataStore: any;
  85918. /**
  85919. * Specifies if the ready state should be checked on each call
  85920. */
  85921. checkReadyOnEveryCall: boolean;
  85922. /**
  85923. * Specifies if the ready state should be checked once
  85924. */
  85925. checkReadyOnlyOnce: boolean;
  85926. /**
  85927. * The state of the material
  85928. */
  85929. state: string;
  85930. /**
  85931. * The alpha value of the material
  85932. */
  85933. protected _alpha: number;
  85934. /**
  85935. * List of inspectable custom properties (used by the Inspector)
  85936. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  85937. */
  85938. inspectableCustomProperties: IInspectable[];
  85939. /**
  85940. * Sets the alpha value of the material
  85941. */
  85942. /**
  85943. * Gets the alpha value of the material
  85944. */
  85945. alpha: number;
  85946. /**
  85947. * Specifies if back face culling is enabled
  85948. */
  85949. protected _backFaceCulling: boolean;
  85950. /**
  85951. * Sets the back-face culling state
  85952. */
  85953. /**
  85954. * Gets the back-face culling state
  85955. */
  85956. backFaceCulling: boolean;
  85957. /**
  85958. * Stores the value for side orientation
  85959. */
  85960. sideOrientation: number;
  85961. /**
  85962. * Callback triggered when the material is compiled
  85963. */
  85964. onCompiled: Nullable<(effect: Effect) => void>;
  85965. /**
  85966. * Callback triggered when an error occurs
  85967. */
  85968. onError: Nullable<(effect: Effect, errors: string) => void>;
  85969. /**
  85970. * Callback triggered to get the render target textures
  85971. */
  85972. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  85973. /**
  85974. * Gets a boolean indicating that current material needs to register RTT
  85975. */
  85976. readonly hasRenderTargetTextures: boolean;
  85977. /**
  85978. * Specifies if the material should be serialized
  85979. */
  85980. doNotSerialize: boolean;
  85981. /**
  85982. * @hidden
  85983. */
  85984. _storeEffectOnSubMeshes: boolean;
  85985. /**
  85986. * Stores the animations for the material
  85987. */
  85988. animations: Nullable<Array<Animation>>;
  85989. /**
  85990. * An event triggered when the material is disposed
  85991. */
  85992. onDisposeObservable: Observable<Material>;
  85993. /**
  85994. * An observer which watches for dispose events
  85995. */
  85996. private _onDisposeObserver;
  85997. private _onUnBindObservable;
  85998. /**
  85999. * Called during a dispose event
  86000. */
  86001. onDispose: () => void;
  86002. private _onBindObservable;
  86003. /**
  86004. * An event triggered when the material is bound
  86005. */
  86006. readonly onBindObservable: Observable<AbstractMesh>;
  86007. /**
  86008. * An observer which watches for bind events
  86009. */
  86010. private _onBindObserver;
  86011. /**
  86012. * Called during a bind event
  86013. */
  86014. onBind: (Mesh: AbstractMesh) => void;
  86015. /**
  86016. * An event triggered when the material is unbound
  86017. */
  86018. readonly onUnBindObservable: Observable<Material>;
  86019. /**
  86020. * Stores the value of the alpha mode
  86021. */
  86022. private _alphaMode;
  86023. /**
  86024. * Sets the value of the alpha mode.
  86025. *
  86026. * | Value | Type | Description |
  86027. * | --- | --- | --- |
  86028. * | 0 | ALPHA_DISABLE | |
  86029. * | 1 | ALPHA_ADD | |
  86030. * | 2 | ALPHA_COMBINE | |
  86031. * | 3 | ALPHA_SUBTRACT | |
  86032. * | 4 | ALPHA_MULTIPLY | |
  86033. * | 5 | ALPHA_MAXIMIZED | |
  86034. * | 6 | ALPHA_ONEONE | |
  86035. * | 7 | ALPHA_PREMULTIPLIED | |
  86036. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  86037. * | 9 | ALPHA_INTERPOLATE | |
  86038. * | 10 | ALPHA_SCREENMODE | |
  86039. *
  86040. */
  86041. /**
  86042. * Gets the value of the alpha mode
  86043. */
  86044. alphaMode: number;
  86045. /**
  86046. * Stores the state of the need depth pre-pass value
  86047. */
  86048. private _needDepthPrePass;
  86049. /**
  86050. * Sets the need depth pre-pass value
  86051. */
  86052. /**
  86053. * Gets the depth pre-pass value
  86054. */
  86055. needDepthPrePass: boolean;
  86056. /**
  86057. * Specifies if depth writing should be disabled
  86058. */
  86059. disableDepthWrite: boolean;
  86060. /**
  86061. * Specifies if depth writing should be forced
  86062. */
  86063. forceDepthWrite: boolean;
  86064. /**
  86065. * Specifies if there should be a separate pass for culling
  86066. */
  86067. separateCullingPass: boolean;
  86068. /**
  86069. * Stores the state specifing if fog should be enabled
  86070. */
  86071. private _fogEnabled;
  86072. /**
  86073. * Sets the state for enabling fog
  86074. */
  86075. /**
  86076. * Gets the value of the fog enabled state
  86077. */
  86078. fogEnabled: boolean;
  86079. /**
  86080. * Stores the size of points
  86081. */
  86082. pointSize: number;
  86083. /**
  86084. * Stores the z offset value
  86085. */
  86086. zOffset: number;
  86087. /**
  86088. * Gets a value specifying if wireframe mode is enabled
  86089. */
  86090. /**
  86091. * Sets the state of wireframe mode
  86092. */
  86093. wireframe: boolean;
  86094. /**
  86095. * Gets the value specifying if point clouds are enabled
  86096. */
  86097. /**
  86098. * Sets the state of point cloud mode
  86099. */
  86100. pointsCloud: boolean;
  86101. /**
  86102. * Gets the material fill mode
  86103. */
  86104. /**
  86105. * Sets the material fill mode
  86106. */
  86107. fillMode: number;
  86108. /**
  86109. * @hidden
  86110. * Stores the effects for the material
  86111. */
  86112. _effect: Nullable<Effect>;
  86113. /**
  86114. * @hidden
  86115. * Specifies if the material was previously ready
  86116. */
  86117. _wasPreviouslyReady: boolean;
  86118. /**
  86119. * Specifies if uniform buffers should be used
  86120. */
  86121. private _useUBO;
  86122. /**
  86123. * Stores a reference to the scene
  86124. */
  86125. private _scene;
  86126. /**
  86127. * Stores the fill mode state
  86128. */
  86129. private _fillMode;
  86130. /**
  86131. * Specifies if the depth write state should be cached
  86132. */
  86133. private _cachedDepthWriteState;
  86134. /**
  86135. * Stores the uniform buffer
  86136. */
  86137. protected _uniformBuffer: UniformBuffer;
  86138. /** @hidden */
  86139. _indexInSceneMaterialArray: number;
  86140. /** @hidden */
  86141. meshMap: Nullable<{
  86142. [id: string]: AbstractMesh | undefined;
  86143. }>;
  86144. /**
  86145. * Creates a material instance
  86146. * @param name defines the name of the material
  86147. * @param scene defines the scene to reference
  86148. * @param doNotAdd specifies if the material should be added to the scene
  86149. */
  86150. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  86151. /**
  86152. * Returns a string representation of the current material
  86153. * @param fullDetails defines a boolean indicating which levels of logging is desired
  86154. * @returns a string with material information
  86155. */
  86156. toString(fullDetails?: boolean): string;
  86157. /**
  86158. * Gets the class name of the material
  86159. * @returns a string with the class name of the material
  86160. */
  86161. getClassName(): string;
  86162. /**
  86163. * Specifies if updates for the material been locked
  86164. */
  86165. readonly isFrozen: boolean;
  86166. /**
  86167. * Locks updates for the material
  86168. */
  86169. freeze(): void;
  86170. /**
  86171. * Unlocks updates for the material
  86172. */
  86173. unfreeze(): void;
  86174. /**
  86175. * Specifies if the material is ready to be used
  86176. * @param mesh defines the mesh to check
  86177. * @param useInstances specifies if instances should be used
  86178. * @returns a boolean indicating if the material is ready to be used
  86179. */
  86180. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  86181. /**
  86182. * Specifies that the submesh is ready to be used
  86183. * @param mesh defines the mesh to check
  86184. * @param subMesh defines which submesh to check
  86185. * @param useInstances specifies that instances should be used
  86186. * @returns a boolean indicating that the submesh is ready or not
  86187. */
  86188. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  86189. /**
  86190. * Returns the material effect
  86191. * @returns the effect associated with the material
  86192. */
  86193. getEffect(): Nullable<Effect>;
  86194. /**
  86195. * Returns the current scene
  86196. * @returns a Scene
  86197. */
  86198. getScene(): Scene;
  86199. /**
  86200. * Specifies if the material will require alpha blending
  86201. * @returns a boolean specifying if alpha blending is needed
  86202. */
  86203. needAlphaBlending(): boolean;
  86204. /**
  86205. * Specifies if the mesh will require alpha blending
  86206. * @param mesh defines the mesh to check
  86207. * @returns a boolean specifying if alpha blending is needed for the mesh
  86208. */
  86209. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  86210. /**
  86211. * Specifies if this material should be rendered in alpha test mode
  86212. * @returns a boolean specifying if an alpha test is needed.
  86213. */
  86214. needAlphaTesting(): boolean;
  86215. /**
  86216. * Gets the texture used for the alpha test
  86217. * @returns the texture to use for alpha testing
  86218. */
  86219. getAlphaTestTexture(): Nullable<BaseTexture>;
  86220. /**
  86221. * Marks the material to indicate that it needs to be re-calculated
  86222. */
  86223. markDirty(): void;
  86224. /** @hidden */
  86225. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  86226. /**
  86227. * Binds the material to the mesh
  86228. * @param world defines the world transformation matrix
  86229. * @param mesh defines the mesh to bind the material to
  86230. */
  86231. bind(world: Matrix, mesh?: Mesh): void;
  86232. /**
  86233. * Binds the submesh to the material
  86234. * @param world defines the world transformation matrix
  86235. * @param mesh defines the mesh containing the submesh
  86236. * @param subMesh defines the submesh to bind the material to
  86237. */
  86238. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  86239. /**
  86240. * Binds the world matrix to the material
  86241. * @param world defines the world transformation matrix
  86242. */
  86243. bindOnlyWorldMatrix(world: Matrix): void;
  86244. /**
  86245. * Binds the scene's uniform buffer to the effect.
  86246. * @param effect defines the effect to bind to the scene uniform buffer
  86247. * @param sceneUbo defines the uniform buffer storing scene data
  86248. */
  86249. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  86250. /**
  86251. * Binds the view matrix to the effect
  86252. * @param effect defines the effect to bind the view matrix to
  86253. */
  86254. bindView(effect: Effect): void;
  86255. /**
  86256. * Binds the view projection matrix to the effect
  86257. * @param effect defines the effect to bind the view projection matrix to
  86258. */
  86259. bindViewProjection(effect: Effect): void;
  86260. /**
  86261. * Specifies if material alpha testing should be turned on for the mesh
  86262. * @param mesh defines the mesh to check
  86263. */
  86264. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  86265. /**
  86266. * Processes to execute after binding the material to a mesh
  86267. * @param mesh defines the rendered mesh
  86268. */
  86269. protected _afterBind(mesh?: Mesh): void;
  86270. /**
  86271. * Unbinds the material from the mesh
  86272. */
  86273. unbind(): void;
  86274. /**
  86275. * Gets the active textures from the material
  86276. * @returns an array of textures
  86277. */
  86278. getActiveTextures(): BaseTexture[];
  86279. /**
  86280. * Specifies if the material uses a texture
  86281. * @param texture defines the texture to check against the material
  86282. * @returns a boolean specifying if the material uses the texture
  86283. */
  86284. hasTexture(texture: BaseTexture): boolean;
  86285. /**
  86286. * Makes a duplicate of the material, and gives it a new name
  86287. * @param name defines the new name for the duplicated material
  86288. * @returns the cloned material
  86289. */
  86290. clone(name: string): Nullable<Material>;
  86291. /**
  86292. * Gets the meshes bound to the material
  86293. * @returns an array of meshes bound to the material
  86294. */
  86295. getBindedMeshes(): AbstractMesh[];
  86296. /**
  86297. * Force shader compilation
  86298. * @param mesh defines the mesh associated with this material
  86299. * @param onCompiled defines a function to execute once the material is compiled
  86300. * @param options defines the options to configure the compilation
  86301. */
  86302. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  86303. clipPlane: boolean;
  86304. }>): void;
  86305. /**
  86306. * Force shader compilation
  86307. * @param mesh defines the mesh that will use this material
  86308. * @param options defines additional options for compiling the shaders
  86309. * @returns a promise that resolves when the compilation completes
  86310. */
  86311. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  86312. clipPlane: boolean;
  86313. }>): Promise<void>;
  86314. private static readonly _AllDirtyCallBack;
  86315. private static readonly _ImageProcessingDirtyCallBack;
  86316. private static readonly _TextureDirtyCallBack;
  86317. private static readonly _FresnelDirtyCallBack;
  86318. private static readonly _MiscDirtyCallBack;
  86319. private static readonly _LightsDirtyCallBack;
  86320. private static readonly _AttributeDirtyCallBack;
  86321. private static _FresnelAndMiscDirtyCallBack;
  86322. private static _TextureAndMiscDirtyCallBack;
  86323. private static readonly _DirtyCallbackArray;
  86324. private static readonly _RunDirtyCallBacks;
  86325. /**
  86326. * Marks a define in the material to indicate that it needs to be re-computed
  86327. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  86328. */
  86329. markAsDirty(flag: number): void;
  86330. /**
  86331. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  86332. * @param func defines a function which checks material defines against the submeshes
  86333. */
  86334. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  86335. /**
  86336. * Indicates that we need to re-calculated for all submeshes
  86337. */
  86338. protected _markAllSubMeshesAsAllDirty(): void;
  86339. /**
  86340. * Indicates that image processing needs to be re-calculated for all submeshes
  86341. */
  86342. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  86343. /**
  86344. * Indicates that textures need to be re-calculated for all submeshes
  86345. */
  86346. protected _markAllSubMeshesAsTexturesDirty(): void;
  86347. /**
  86348. * Indicates that fresnel needs to be re-calculated for all submeshes
  86349. */
  86350. protected _markAllSubMeshesAsFresnelDirty(): void;
  86351. /**
  86352. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  86353. */
  86354. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  86355. /**
  86356. * Indicates that lights need to be re-calculated for all submeshes
  86357. */
  86358. protected _markAllSubMeshesAsLightsDirty(): void;
  86359. /**
  86360. * Indicates that attributes need to be re-calculated for all submeshes
  86361. */
  86362. protected _markAllSubMeshesAsAttributesDirty(): void;
  86363. /**
  86364. * Indicates that misc needs to be re-calculated for all submeshes
  86365. */
  86366. protected _markAllSubMeshesAsMiscDirty(): void;
  86367. /**
  86368. * Indicates that textures and misc need to be re-calculated for all submeshes
  86369. */
  86370. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  86371. /**
  86372. * Disposes the material
  86373. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  86374. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  86375. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  86376. */
  86377. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  86378. /** @hidden */
  86379. private releaseVertexArrayObject;
  86380. /**
  86381. * Serializes this material
  86382. * @returns the serialized material object
  86383. */
  86384. serialize(): any;
  86385. /**
  86386. * Creates a material from parsed material data
  86387. * @param parsedMaterial defines parsed material data
  86388. * @param scene defines the hosting scene
  86389. * @param rootUrl defines the root URL to use to load textures
  86390. * @returns a new material
  86391. */
  86392. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  86393. }
  86394. }
  86395. declare module BABYLON {
  86396. /**
  86397. * A multi-material is used to apply different materials to different parts of the same object without the need of
  86398. * separate meshes. This can be use to improve performances.
  86399. * @see http://doc.babylonjs.com/how_to/multi_materials
  86400. */
  86401. export class MultiMaterial extends Material {
  86402. private _subMaterials;
  86403. /**
  86404. * Gets or Sets the list of Materials used within the multi material.
  86405. * They need to be ordered according to the submeshes order in the associated mesh
  86406. */
  86407. subMaterials: Nullable<Material>[];
  86408. /**
  86409. * Function used to align with Node.getChildren()
  86410. * @returns the list of Materials used within the multi material
  86411. */
  86412. getChildren(): Nullable<Material>[];
  86413. /**
  86414. * Instantiates a new Multi Material
  86415. * A multi-material is used to apply different materials to different parts of the same object without the need of
  86416. * separate meshes. This can be use to improve performances.
  86417. * @see http://doc.babylonjs.com/how_to/multi_materials
  86418. * @param name Define the name in the scene
  86419. * @param scene Define the scene the material belongs to
  86420. */
  86421. constructor(name: string, scene: Scene);
  86422. private _hookArray;
  86423. /**
  86424. * Get one of the submaterial by its index in the submaterials array
  86425. * @param index The index to look the sub material at
  86426. * @returns The Material if the index has been defined
  86427. */
  86428. getSubMaterial(index: number): Nullable<Material>;
  86429. /**
  86430. * Get the list of active textures for the whole sub materials list.
  86431. * @returns All the textures that will be used during the rendering
  86432. */
  86433. getActiveTextures(): BaseTexture[];
  86434. /**
  86435. * Gets the current class name of the material e.g. "MultiMaterial"
  86436. * Mainly use in serialization.
  86437. * @returns the class name
  86438. */
  86439. getClassName(): string;
  86440. /**
  86441. * Checks if the material is ready to render the requested sub mesh
  86442. * @param mesh Define the mesh the submesh belongs to
  86443. * @param subMesh Define the sub mesh to look readyness for
  86444. * @param useInstances Define whether or not the material is used with instances
  86445. * @returns true if ready, otherwise false
  86446. */
  86447. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  86448. /**
  86449. * Clones the current material and its related sub materials
  86450. * @param name Define the name of the newly cloned material
  86451. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  86452. * @returns the cloned material
  86453. */
  86454. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  86455. /**
  86456. * Serializes the materials into a JSON representation.
  86457. * @returns the JSON representation
  86458. */
  86459. serialize(): any;
  86460. /**
  86461. * Dispose the material and release its associated resources
  86462. * @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)
  86463. * @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)
  86464. * @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)
  86465. */
  86466. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  86467. /**
  86468. * Creates a MultiMaterial from parsed MultiMaterial data.
  86469. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  86470. * @param scene defines the hosting scene
  86471. * @returns a new MultiMaterial
  86472. */
  86473. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  86474. }
  86475. }
  86476. declare module BABYLON {
  86477. /**
  86478. * Base class for submeshes
  86479. */
  86480. export class BaseSubMesh {
  86481. /** @hidden */
  86482. _materialDefines: Nullable<MaterialDefines>;
  86483. /** @hidden */
  86484. _materialEffect: Nullable<Effect>;
  86485. /**
  86486. * Gets associated effect
  86487. */
  86488. readonly effect: Nullable<Effect>;
  86489. /**
  86490. * Sets associated effect (effect used to render this submesh)
  86491. * @param effect defines the effect to associate with
  86492. * @param defines defines the set of defines used to compile this effect
  86493. */
  86494. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  86495. }
  86496. /**
  86497. * Defines a subdivision inside a mesh
  86498. */
  86499. export class SubMesh extends BaseSubMesh implements ICullable {
  86500. /** the material index to use */
  86501. materialIndex: number;
  86502. /** vertex index start */
  86503. verticesStart: number;
  86504. /** vertices count */
  86505. verticesCount: number;
  86506. /** index start */
  86507. indexStart: number;
  86508. /** indices count */
  86509. indexCount: number;
  86510. /** @hidden */
  86511. _linesIndexCount: number;
  86512. private _mesh;
  86513. private _renderingMesh;
  86514. private _boundingInfo;
  86515. private _linesIndexBuffer;
  86516. /** @hidden */
  86517. _lastColliderWorldVertices: Nullable<Vector3[]>;
  86518. /** @hidden */
  86519. _trianglePlanes: Plane[];
  86520. /** @hidden */
  86521. _lastColliderTransformMatrix: Nullable<Matrix>;
  86522. /** @hidden */
  86523. _renderId: number;
  86524. /** @hidden */
  86525. _alphaIndex: number;
  86526. /** @hidden */
  86527. _distanceToCamera: number;
  86528. /** @hidden */
  86529. _id: number;
  86530. private _currentMaterial;
  86531. /**
  86532. * Add a new submesh to a mesh
  86533. * @param materialIndex defines the material index to use
  86534. * @param verticesStart defines vertex index start
  86535. * @param verticesCount defines vertices count
  86536. * @param indexStart defines index start
  86537. * @param indexCount defines indices count
  86538. * @param mesh defines the parent mesh
  86539. * @param renderingMesh defines an optional rendering mesh
  86540. * @param createBoundingBox defines if bounding box should be created for this submesh
  86541. * @returns the new submesh
  86542. */
  86543. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  86544. /**
  86545. * Creates a new submesh
  86546. * @param materialIndex defines the material index to use
  86547. * @param verticesStart defines vertex index start
  86548. * @param verticesCount defines vertices count
  86549. * @param indexStart defines index start
  86550. * @param indexCount defines indices count
  86551. * @param mesh defines the parent mesh
  86552. * @param renderingMesh defines an optional rendering mesh
  86553. * @param createBoundingBox defines if bounding box should be created for this submesh
  86554. */
  86555. constructor(
  86556. /** the material index to use */
  86557. materialIndex: number,
  86558. /** vertex index start */
  86559. verticesStart: number,
  86560. /** vertices count */
  86561. verticesCount: number,
  86562. /** index start */
  86563. indexStart: number,
  86564. /** indices count */
  86565. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  86566. /**
  86567. * Returns true if this submesh covers the entire parent mesh
  86568. * @ignorenaming
  86569. */
  86570. readonly IsGlobal: boolean;
  86571. /**
  86572. * Returns the submesh BoudingInfo object
  86573. * @returns current bounding info (or mesh's one if the submesh is global)
  86574. */
  86575. getBoundingInfo(): BoundingInfo;
  86576. /**
  86577. * Sets the submesh BoundingInfo
  86578. * @param boundingInfo defines the new bounding info to use
  86579. * @returns the SubMesh
  86580. */
  86581. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  86582. /**
  86583. * Returns the mesh of the current submesh
  86584. * @return the parent mesh
  86585. */
  86586. getMesh(): AbstractMesh;
  86587. /**
  86588. * Returns the rendering mesh of the submesh
  86589. * @returns the rendering mesh (could be different from parent mesh)
  86590. */
  86591. getRenderingMesh(): Mesh;
  86592. /**
  86593. * Returns the submesh material
  86594. * @returns null or the current material
  86595. */
  86596. getMaterial(): Nullable<Material>;
  86597. /**
  86598. * Sets a new updated BoundingInfo object to the submesh
  86599. * @param data defines an optional position array to use to determine the bounding info
  86600. * @returns the SubMesh
  86601. */
  86602. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  86603. /** @hidden */
  86604. _checkCollision(collider: Collider): boolean;
  86605. /**
  86606. * Updates the submesh BoundingInfo
  86607. * @param world defines the world matrix to use to update the bounding info
  86608. * @returns the submesh
  86609. */
  86610. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  86611. /**
  86612. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  86613. * @param frustumPlanes defines the frustum planes
  86614. * @returns true if the submesh is intersecting with the frustum
  86615. */
  86616. isInFrustum(frustumPlanes: Plane[]): boolean;
  86617. /**
  86618. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  86619. * @param frustumPlanes defines the frustum planes
  86620. * @returns true if the submesh is inside the frustum
  86621. */
  86622. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  86623. /**
  86624. * Renders the submesh
  86625. * @param enableAlphaMode defines if alpha needs to be used
  86626. * @returns the submesh
  86627. */
  86628. render(enableAlphaMode: boolean): SubMesh;
  86629. /**
  86630. * @hidden
  86631. */
  86632. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  86633. /**
  86634. * Checks if the submesh intersects with a ray
  86635. * @param ray defines the ray to test
  86636. * @returns true is the passed ray intersects the submesh bounding box
  86637. */
  86638. canIntersects(ray: Ray): boolean;
  86639. /**
  86640. * Intersects current submesh with a ray
  86641. * @param ray defines the ray to test
  86642. * @param positions defines mesh's positions array
  86643. * @param indices defines mesh's indices array
  86644. * @param fastCheck defines if only bounding info should be used
  86645. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  86646. * @returns intersection info or null if no intersection
  86647. */
  86648. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  86649. /** @hidden */
  86650. private _intersectLines;
  86651. /** @hidden */
  86652. private _intersectUnIndexedLines;
  86653. /** @hidden */
  86654. private _intersectTriangles;
  86655. /** @hidden */
  86656. private _intersectUnIndexedTriangles;
  86657. /** @hidden */
  86658. _rebuild(): void;
  86659. /**
  86660. * Creates a new submesh from the passed mesh
  86661. * @param newMesh defines the new hosting mesh
  86662. * @param newRenderingMesh defines an optional rendering mesh
  86663. * @returns the new submesh
  86664. */
  86665. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  86666. /**
  86667. * Release associated resources
  86668. */
  86669. dispose(): void;
  86670. /**
  86671. * Gets the class name
  86672. * @returns the string "SubMesh".
  86673. */
  86674. getClassName(): string;
  86675. /**
  86676. * Creates a new submesh from indices data
  86677. * @param materialIndex the index of the main mesh material
  86678. * @param startIndex the index where to start the copy in the mesh indices array
  86679. * @param indexCount the number of indices to copy then from the startIndex
  86680. * @param mesh the main mesh to create the submesh from
  86681. * @param renderingMesh the optional rendering mesh
  86682. * @returns a new submesh
  86683. */
  86684. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  86685. }
  86686. }
  86687. declare module BABYLON {
  86688. /**
  86689. * Class used to represent data loading progression
  86690. */
  86691. export class SceneLoaderFlags {
  86692. private static _ForceFullSceneLoadingForIncremental;
  86693. private static _ShowLoadingScreen;
  86694. private static _CleanBoneMatrixWeights;
  86695. private static _loggingLevel;
  86696. /**
  86697. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  86698. */
  86699. static ForceFullSceneLoadingForIncremental: boolean;
  86700. /**
  86701. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  86702. */
  86703. static ShowLoadingScreen: boolean;
  86704. /**
  86705. * Defines the current logging level (while loading the scene)
  86706. * @ignorenaming
  86707. */
  86708. static loggingLevel: number;
  86709. /**
  86710. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  86711. */
  86712. static CleanBoneMatrixWeights: boolean;
  86713. }
  86714. }
  86715. declare module BABYLON {
  86716. /**
  86717. * Class used to store geometry data (vertex buffers + index buffer)
  86718. */
  86719. export class Geometry implements IGetSetVerticesData {
  86720. /**
  86721. * Gets or sets the ID of the geometry
  86722. */
  86723. id: string;
  86724. /**
  86725. * Gets or sets the unique ID of the geometry
  86726. */
  86727. uniqueId: number;
  86728. /**
  86729. * Gets the delay loading state of the geometry (none by default which means not delayed)
  86730. */
  86731. delayLoadState: number;
  86732. /**
  86733. * Gets the file containing the data to load when running in delay load state
  86734. */
  86735. delayLoadingFile: Nullable<string>;
  86736. /**
  86737. * Callback called when the geometry is updated
  86738. */
  86739. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  86740. private _scene;
  86741. private _engine;
  86742. private _meshes;
  86743. private _totalVertices;
  86744. /** @hidden */
  86745. _indices: IndicesArray;
  86746. /** @hidden */
  86747. _vertexBuffers: {
  86748. [key: string]: VertexBuffer;
  86749. };
  86750. private _isDisposed;
  86751. private _extend;
  86752. private _boundingBias;
  86753. /** @hidden */
  86754. _delayInfo: Array<string>;
  86755. private _indexBuffer;
  86756. private _indexBufferIsUpdatable;
  86757. /** @hidden */
  86758. _boundingInfo: Nullable<BoundingInfo>;
  86759. /** @hidden */
  86760. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  86761. /** @hidden */
  86762. _softwareSkinningFrameId: number;
  86763. private _vertexArrayObjects;
  86764. private _updatable;
  86765. /** @hidden */
  86766. _positions: Nullable<Vector3[]>;
  86767. /**
  86768. * 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
  86769. */
  86770. /**
  86771. * 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
  86772. */
  86773. boundingBias: Vector2;
  86774. /**
  86775. * Static function used to attach a new empty geometry to a mesh
  86776. * @param mesh defines the mesh to attach the geometry to
  86777. * @returns the new Geometry
  86778. */
  86779. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  86780. /**
  86781. * Creates a new geometry
  86782. * @param id defines the unique ID
  86783. * @param scene defines the hosting scene
  86784. * @param vertexData defines the VertexData used to get geometry data
  86785. * @param updatable defines if geometry must be updatable (false by default)
  86786. * @param mesh defines the mesh that will be associated with the geometry
  86787. */
  86788. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  86789. /**
  86790. * Gets the current extend of the geometry
  86791. */
  86792. readonly extend: {
  86793. minimum: Vector3;
  86794. maximum: Vector3;
  86795. };
  86796. /**
  86797. * Gets the hosting scene
  86798. * @returns the hosting Scene
  86799. */
  86800. getScene(): Scene;
  86801. /**
  86802. * Gets the hosting engine
  86803. * @returns the hosting Engine
  86804. */
  86805. getEngine(): Engine;
  86806. /**
  86807. * Defines if the geometry is ready to use
  86808. * @returns true if the geometry is ready to be used
  86809. */
  86810. isReady(): boolean;
  86811. /**
  86812. * Gets a value indicating that the geometry should not be serialized
  86813. */
  86814. readonly doNotSerialize: boolean;
  86815. /** @hidden */
  86816. _rebuild(): void;
  86817. /**
  86818. * Affects all geometry data in one call
  86819. * @param vertexData defines the geometry data
  86820. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  86821. */
  86822. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  86823. /**
  86824. * Set specific vertex data
  86825. * @param kind defines the data kind (Position, normal, etc...)
  86826. * @param data defines the vertex data to use
  86827. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  86828. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  86829. */
  86830. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  86831. /**
  86832. * Removes a specific vertex data
  86833. * @param kind defines the data kind (Position, normal, etc...)
  86834. */
  86835. removeVerticesData(kind: string): void;
  86836. /**
  86837. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  86838. * @param buffer defines the vertex buffer to use
  86839. * @param totalVertices defines the total number of vertices for position kind (could be null)
  86840. */
  86841. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  86842. /**
  86843. * Update a specific vertex buffer
  86844. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  86845. * It will do nothing if the buffer is not updatable
  86846. * @param kind defines the data kind (Position, normal, etc...)
  86847. * @param data defines the data to use
  86848. * @param offset defines the offset in the target buffer where to store the data
  86849. * @param useBytes set to true if the offset is in bytes
  86850. */
  86851. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  86852. /**
  86853. * Update a specific vertex buffer
  86854. * This function will create a new buffer if the current one is not updatable
  86855. * @param kind defines the data kind (Position, normal, etc...)
  86856. * @param data defines the data to use
  86857. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  86858. */
  86859. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  86860. private _updateBoundingInfo;
  86861. /** @hidden */
  86862. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  86863. /**
  86864. * Gets total number of vertices
  86865. * @returns the total number of vertices
  86866. */
  86867. getTotalVertices(): number;
  86868. /**
  86869. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  86870. * @param kind defines the data kind (Position, normal, etc...)
  86871. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  86872. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86873. * @returns a float array containing vertex data
  86874. */
  86875. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  86876. /**
  86877. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  86878. * @param kind defines the data kind (Position, normal, etc...)
  86879. * @returns true if the vertex buffer with the specified kind is updatable
  86880. */
  86881. isVertexBufferUpdatable(kind: string): boolean;
  86882. /**
  86883. * Gets a specific vertex buffer
  86884. * @param kind defines the data kind (Position, normal, etc...)
  86885. * @returns a VertexBuffer
  86886. */
  86887. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  86888. /**
  86889. * Returns all vertex buffers
  86890. * @return an object holding all vertex buffers indexed by kind
  86891. */
  86892. getVertexBuffers(): Nullable<{
  86893. [key: string]: VertexBuffer;
  86894. }>;
  86895. /**
  86896. * Gets a boolean indicating if specific vertex buffer is present
  86897. * @param kind defines the data kind (Position, normal, etc...)
  86898. * @returns true if data is present
  86899. */
  86900. isVerticesDataPresent(kind: string): boolean;
  86901. /**
  86902. * Gets a list of all attached data kinds (Position, normal, etc...)
  86903. * @returns a list of string containing all kinds
  86904. */
  86905. getVerticesDataKinds(): string[];
  86906. /**
  86907. * Update index buffer
  86908. * @param indices defines the indices to store in the index buffer
  86909. * @param offset defines the offset in the target buffer where to store the data
  86910. * @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)
  86911. */
  86912. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  86913. /**
  86914. * Creates a new index buffer
  86915. * @param indices defines the indices to store in the index buffer
  86916. * @param totalVertices defines the total number of vertices (could be null)
  86917. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  86918. */
  86919. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  86920. /**
  86921. * Return the total number of indices
  86922. * @returns the total number of indices
  86923. */
  86924. getTotalIndices(): number;
  86925. /**
  86926. * Gets the index buffer array
  86927. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  86928. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86929. * @returns the index buffer array
  86930. */
  86931. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  86932. /**
  86933. * Gets the index buffer
  86934. * @return the index buffer
  86935. */
  86936. getIndexBuffer(): Nullable<DataBuffer>;
  86937. /** @hidden */
  86938. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  86939. /**
  86940. * Release the associated resources for a specific mesh
  86941. * @param mesh defines the source mesh
  86942. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  86943. */
  86944. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  86945. /**
  86946. * Apply current geometry to a given mesh
  86947. * @param mesh defines the mesh to apply geometry to
  86948. */
  86949. applyToMesh(mesh: Mesh): void;
  86950. private _updateExtend;
  86951. private _applyToMesh;
  86952. private notifyUpdate;
  86953. /**
  86954. * Load the geometry if it was flagged as delay loaded
  86955. * @param scene defines the hosting scene
  86956. * @param onLoaded defines a callback called when the geometry is loaded
  86957. */
  86958. load(scene: Scene, onLoaded?: () => void): void;
  86959. private _queueLoad;
  86960. /**
  86961. * Invert the geometry to move from a right handed system to a left handed one.
  86962. */
  86963. toLeftHanded(): void;
  86964. /** @hidden */
  86965. _resetPointsArrayCache(): void;
  86966. /** @hidden */
  86967. _generatePointsArray(): boolean;
  86968. /**
  86969. * Gets a value indicating if the geometry is disposed
  86970. * @returns true if the geometry was disposed
  86971. */
  86972. isDisposed(): boolean;
  86973. private _disposeVertexArrayObjects;
  86974. /**
  86975. * Free all associated resources
  86976. */
  86977. dispose(): void;
  86978. /**
  86979. * Clone the current geometry into a new geometry
  86980. * @param id defines the unique ID of the new geometry
  86981. * @returns a new geometry object
  86982. */
  86983. copy(id: string): Geometry;
  86984. /**
  86985. * Serialize the current geometry info (and not the vertices data) into a JSON object
  86986. * @return a JSON representation of the current geometry data (without the vertices data)
  86987. */
  86988. serialize(): any;
  86989. private toNumberArray;
  86990. /**
  86991. * Serialize all vertices data into a JSON oject
  86992. * @returns a JSON representation of the current geometry data
  86993. */
  86994. serializeVerticeData(): any;
  86995. /**
  86996. * Extracts a clone of a mesh geometry
  86997. * @param mesh defines the source mesh
  86998. * @param id defines the unique ID of the new geometry object
  86999. * @returns the new geometry object
  87000. */
  87001. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  87002. /**
  87003. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  87004. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  87005. * Be aware Math.random() could cause collisions, but:
  87006. * "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"
  87007. * @returns a string containing a new GUID
  87008. */
  87009. static RandomId(): string;
  87010. /** @hidden */
  87011. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  87012. private static _CleanMatricesWeights;
  87013. /**
  87014. * Create a new geometry from persisted data (Using .babylon file format)
  87015. * @param parsedVertexData defines the persisted data
  87016. * @param scene defines the hosting scene
  87017. * @param rootUrl defines the root url to use to load assets (like delayed data)
  87018. * @returns the new geometry object
  87019. */
  87020. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  87021. }
  87022. }
  87023. declare module BABYLON {
  87024. /**
  87025. * Define an interface for all classes that will get and set the data on vertices
  87026. */
  87027. export interface IGetSetVerticesData {
  87028. /**
  87029. * Gets a boolean indicating if specific vertex data is present
  87030. * @param kind defines the vertex data kind to use
  87031. * @returns true is data kind is present
  87032. */
  87033. isVerticesDataPresent(kind: string): boolean;
  87034. /**
  87035. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  87036. * @param kind defines the data kind (Position, normal, etc...)
  87037. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  87038. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87039. * @returns a float array containing vertex data
  87040. */
  87041. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  87042. /**
  87043. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  87044. * @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.
  87045. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87046. * @returns the indices array or an empty array if the mesh has no geometry
  87047. */
  87048. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  87049. /**
  87050. * Set specific vertex data
  87051. * @param kind defines the data kind (Position, normal, etc...)
  87052. * @param data defines the vertex data to use
  87053. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  87054. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  87055. */
  87056. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  87057. /**
  87058. * Update a specific associated vertex buffer
  87059. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  87060. * - VertexBuffer.PositionKind
  87061. * - VertexBuffer.UVKind
  87062. * - VertexBuffer.UV2Kind
  87063. * - VertexBuffer.UV3Kind
  87064. * - VertexBuffer.UV4Kind
  87065. * - VertexBuffer.UV5Kind
  87066. * - VertexBuffer.UV6Kind
  87067. * - VertexBuffer.ColorKind
  87068. * - VertexBuffer.MatricesIndicesKind
  87069. * - VertexBuffer.MatricesIndicesExtraKind
  87070. * - VertexBuffer.MatricesWeightsKind
  87071. * - VertexBuffer.MatricesWeightsExtraKind
  87072. * @param data defines the data source
  87073. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  87074. * @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)
  87075. */
  87076. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  87077. /**
  87078. * Creates a new index buffer
  87079. * @param indices defines the indices to store in the index buffer
  87080. * @param totalVertices defines the total number of vertices (could be null)
  87081. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  87082. */
  87083. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  87084. }
  87085. /**
  87086. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  87087. */
  87088. export class VertexData {
  87089. /**
  87090. * Mesh side orientation : usually the external or front surface
  87091. */
  87092. static readonly FRONTSIDE: number;
  87093. /**
  87094. * Mesh side orientation : usually the internal or back surface
  87095. */
  87096. static readonly BACKSIDE: number;
  87097. /**
  87098. * Mesh side orientation : both internal and external or front and back surfaces
  87099. */
  87100. static readonly DOUBLESIDE: number;
  87101. /**
  87102. * Mesh side orientation : by default, `FRONTSIDE`
  87103. */
  87104. static readonly DEFAULTSIDE: number;
  87105. /**
  87106. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  87107. */
  87108. positions: Nullable<FloatArray>;
  87109. /**
  87110. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  87111. */
  87112. normals: Nullable<FloatArray>;
  87113. /**
  87114. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  87115. */
  87116. tangents: Nullable<FloatArray>;
  87117. /**
  87118. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87119. */
  87120. uvs: Nullable<FloatArray>;
  87121. /**
  87122. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87123. */
  87124. uvs2: Nullable<FloatArray>;
  87125. /**
  87126. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87127. */
  87128. uvs3: Nullable<FloatArray>;
  87129. /**
  87130. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87131. */
  87132. uvs4: Nullable<FloatArray>;
  87133. /**
  87134. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87135. */
  87136. uvs5: Nullable<FloatArray>;
  87137. /**
  87138. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87139. */
  87140. uvs6: Nullable<FloatArray>;
  87141. /**
  87142. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  87143. */
  87144. colors: Nullable<FloatArray>;
  87145. /**
  87146. * 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).
  87147. */
  87148. matricesIndices: Nullable<FloatArray>;
  87149. /**
  87150. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  87151. */
  87152. matricesWeights: Nullable<FloatArray>;
  87153. /**
  87154. * An array extending the number of possible indices
  87155. */
  87156. matricesIndicesExtra: Nullable<FloatArray>;
  87157. /**
  87158. * An array extending the number of possible weights when the number of indices is extended
  87159. */
  87160. matricesWeightsExtra: Nullable<FloatArray>;
  87161. /**
  87162. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  87163. */
  87164. indices: Nullable<IndicesArray>;
  87165. /**
  87166. * Uses the passed data array to set the set the values for the specified kind of data
  87167. * @param data a linear array of floating numbers
  87168. * @param kind the type of data that is being set, eg positions, colors etc
  87169. */
  87170. set(data: FloatArray, kind: string): void;
  87171. /**
  87172. * Associates the vertexData to the passed Mesh.
  87173. * Sets it as updatable or not (default `false`)
  87174. * @param mesh the mesh the vertexData is applied to
  87175. * @param updatable when used and having the value true allows new data to update the vertexData
  87176. * @returns the VertexData
  87177. */
  87178. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  87179. /**
  87180. * Associates the vertexData to the passed Geometry.
  87181. * Sets it as updatable or not (default `false`)
  87182. * @param geometry the geometry the vertexData is applied to
  87183. * @param updatable when used and having the value true allows new data to update the vertexData
  87184. * @returns VertexData
  87185. */
  87186. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  87187. /**
  87188. * Updates the associated mesh
  87189. * @param mesh the mesh to be updated
  87190. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  87191. * @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
  87192. * @returns VertexData
  87193. */
  87194. updateMesh(mesh: Mesh): VertexData;
  87195. /**
  87196. * Updates the associated geometry
  87197. * @param geometry the geometry to be updated
  87198. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  87199. * @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
  87200. * @returns VertexData.
  87201. */
  87202. updateGeometry(geometry: Geometry): VertexData;
  87203. private _applyTo;
  87204. private _update;
  87205. /**
  87206. * Transforms each position and each normal of the vertexData according to the passed Matrix
  87207. * @param matrix the transforming matrix
  87208. * @returns the VertexData
  87209. */
  87210. transform(matrix: Matrix): VertexData;
  87211. /**
  87212. * Merges the passed VertexData into the current one
  87213. * @param other the VertexData to be merged into the current one
  87214. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  87215. * @returns the modified VertexData
  87216. */
  87217. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  87218. private _mergeElement;
  87219. private _validate;
  87220. /**
  87221. * Serializes the VertexData
  87222. * @returns a serialized object
  87223. */
  87224. serialize(): any;
  87225. /**
  87226. * Extracts the vertexData from a mesh
  87227. * @param mesh the mesh from which to extract the VertexData
  87228. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  87229. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  87230. * @returns the object VertexData associated to the passed mesh
  87231. */
  87232. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  87233. /**
  87234. * Extracts the vertexData from the geometry
  87235. * @param geometry the geometry from which to extract the VertexData
  87236. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  87237. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  87238. * @returns the object VertexData associated to the passed mesh
  87239. */
  87240. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  87241. private static _ExtractFrom;
  87242. /**
  87243. * Creates the VertexData for a Ribbon
  87244. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  87245. * * pathArray array of paths, each of which an array of successive Vector3
  87246. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  87247. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  87248. * * 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
  87249. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87250. * * 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)
  87251. * * 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)
  87252. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  87253. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  87254. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  87255. * @returns the VertexData of the ribbon
  87256. */
  87257. static CreateRibbon(options: {
  87258. pathArray: Vector3[][];
  87259. closeArray?: boolean;
  87260. closePath?: boolean;
  87261. offset?: number;
  87262. sideOrientation?: number;
  87263. frontUVs?: Vector4;
  87264. backUVs?: Vector4;
  87265. invertUV?: boolean;
  87266. uvs?: Vector2[];
  87267. colors?: Color4[];
  87268. }): VertexData;
  87269. /**
  87270. * Creates the VertexData for a box
  87271. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87272. * * size sets the width, height and depth of the box to the value of size, optional default 1
  87273. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  87274. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  87275. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  87276. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  87277. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  87278. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87279. * * 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)
  87280. * * 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)
  87281. * @returns the VertexData of the box
  87282. */
  87283. static CreateBox(options: {
  87284. size?: number;
  87285. width?: number;
  87286. height?: number;
  87287. depth?: number;
  87288. faceUV?: Vector4[];
  87289. faceColors?: Color4[];
  87290. sideOrientation?: number;
  87291. frontUVs?: Vector4;
  87292. backUVs?: Vector4;
  87293. }): VertexData;
  87294. /**
  87295. * Creates the VertexData for a tiled box
  87296. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87297. * * faceTiles sets the pattern, tile size and number of tiles for a face
  87298. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  87299. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  87300. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87301. * @returns the VertexData of the box
  87302. */
  87303. static CreateTiledBox(options: {
  87304. pattern?: number;
  87305. width?: number;
  87306. height?: number;
  87307. depth?: number;
  87308. tileSize?: number;
  87309. tileWidth?: number;
  87310. tileHeight?: number;
  87311. alignHorizontal?: number;
  87312. alignVertical?: number;
  87313. faceUV?: Vector4[];
  87314. faceColors?: Color4[];
  87315. sideOrientation?: number;
  87316. }): VertexData;
  87317. /**
  87318. * Creates the VertexData for a tiled plane
  87319. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87320. * * pattern a limited pattern arrangement depending on the number
  87321. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  87322. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  87323. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  87324. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87325. * * 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)
  87326. * * 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)
  87327. * @returns the VertexData of the tiled plane
  87328. */
  87329. static CreateTiledPlane(options: {
  87330. pattern?: number;
  87331. tileSize?: number;
  87332. tileWidth?: number;
  87333. tileHeight?: number;
  87334. size?: number;
  87335. width?: number;
  87336. height?: number;
  87337. alignHorizontal?: number;
  87338. alignVertical?: number;
  87339. sideOrientation?: number;
  87340. frontUVs?: Vector4;
  87341. backUVs?: Vector4;
  87342. }): VertexData;
  87343. /**
  87344. * Creates the VertexData for an ellipsoid, defaults to a sphere
  87345. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87346. * * segments sets the number of horizontal strips optional, default 32
  87347. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  87348. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  87349. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  87350. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  87351. * * 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
  87352. * * 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
  87353. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87354. * * 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)
  87355. * * 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)
  87356. * @returns the VertexData of the ellipsoid
  87357. */
  87358. static CreateSphere(options: {
  87359. segments?: number;
  87360. diameter?: number;
  87361. diameterX?: number;
  87362. diameterY?: number;
  87363. diameterZ?: number;
  87364. arc?: number;
  87365. slice?: number;
  87366. sideOrientation?: number;
  87367. frontUVs?: Vector4;
  87368. backUVs?: Vector4;
  87369. }): VertexData;
  87370. /**
  87371. * Creates the VertexData for a cylinder, cone or prism
  87372. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87373. * * height sets the height (y direction) of the cylinder, optional, default 2
  87374. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  87375. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  87376. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  87377. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  87378. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  87379. * * 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
  87380. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87381. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87382. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  87383. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  87384. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87385. * * 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)
  87386. * * 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)
  87387. * @returns the VertexData of the cylinder, cone or prism
  87388. */
  87389. static CreateCylinder(options: {
  87390. height?: number;
  87391. diameterTop?: number;
  87392. diameterBottom?: number;
  87393. diameter?: number;
  87394. tessellation?: number;
  87395. subdivisions?: number;
  87396. arc?: number;
  87397. faceColors?: Color4[];
  87398. faceUV?: Vector4[];
  87399. hasRings?: boolean;
  87400. enclose?: boolean;
  87401. sideOrientation?: number;
  87402. frontUVs?: Vector4;
  87403. backUVs?: Vector4;
  87404. }): VertexData;
  87405. /**
  87406. * Creates the VertexData for a torus
  87407. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87408. * * diameter the diameter of the torus, optional default 1
  87409. * * thickness the diameter of the tube forming the torus, optional default 0.5
  87410. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  87411. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87412. * * 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)
  87413. * * 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)
  87414. * @returns the VertexData of the torus
  87415. */
  87416. static CreateTorus(options: {
  87417. diameter?: number;
  87418. thickness?: number;
  87419. tessellation?: number;
  87420. sideOrientation?: number;
  87421. frontUVs?: Vector4;
  87422. backUVs?: Vector4;
  87423. }): VertexData;
  87424. /**
  87425. * Creates the VertexData of the LineSystem
  87426. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  87427. * - lines an array of lines, each line being an array of successive Vector3
  87428. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  87429. * @returns the VertexData of the LineSystem
  87430. */
  87431. static CreateLineSystem(options: {
  87432. lines: Vector3[][];
  87433. colors?: Nullable<Color4[][]>;
  87434. }): VertexData;
  87435. /**
  87436. * Create the VertexData for a DashedLines
  87437. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  87438. * - points an array successive Vector3
  87439. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  87440. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  87441. * - dashNb the intended total number of dashes, optional, default 200
  87442. * @returns the VertexData for the DashedLines
  87443. */
  87444. static CreateDashedLines(options: {
  87445. points: Vector3[];
  87446. dashSize?: number;
  87447. gapSize?: number;
  87448. dashNb?: number;
  87449. }): VertexData;
  87450. /**
  87451. * Creates the VertexData for a Ground
  87452. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  87453. * - width the width (x direction) of the ground, optional, default 1
  87454. * - height the height (z direction) of the ground, optional, default 1
  87455. * - subdivisions the number of subdivisions per side, optional, default 1
  87456. * @returns the VertexData of the Ground
  87457. */
  87458. static CreateGround(options: {
  87459. width?: number;
  87460. height?: number;
  87461. subdivisions?: number;
  87462. subdivisionsX?: number;
  87463. subdivisionsY?: number;
  87464. }): VertexData;
  87465. /**
  87466. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  87467. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  87468. * * xmin the ground minimum X coordinate, optional, default -1
  87469. * * zmin the ground minimum Z coordinate, optional, default -1
  87470. * * xmax the ground maximum X coordinate, optional, default 1
  87471. * * zmax the ground maximum Z coordinate, optional, default 1
  87472. * * 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}
  87473. * * 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}
  87474. * @returns the VertexData of the TiledGround
  87475. */
  87476. static CreateTiledGround(options: {
  87477. xmin: number;
  87478. zmin: number;
  87479. xmax: number;
  87480. zmax: number;
  87481. subdivisions?: {
  87482. w: number;
  87483. h: number;
  87484. };
  87485. precision?: {
  87486. w: number;
  87487. h: number;
  87488. };
  87489. }): VertexData;
  87490. /**
  87491. * Creates the VertexData of the Ground designed from a heightmap
  87492. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  87493. * * width the width (x direction) of the ground
  87494. * * height the height (z direction) of the ground
  87495. * * subdivisions the number of subdivisions per side
  87496. * * minHeight the minimum altitude on the ground, optional, default 0
  87497. * * maxHeight the maximum altitude on the ground, optional default 1
  87498. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  87499. * * buffer the array holding the image color data
  87500. * * bufferWidth the width of image
  87501. * * bufferHeight the height of image
  87502. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  87503. * @returns the VertexData of the Ground designed from a heightmap
  87504. */
  87505. static CreateGroundFromHeightMap(options: {
  87506. width: number;
  87507. height: number;
  87508. subdivisions: number;
  87509. minHeight: number;
  87510. maxHeight: number;
  87511. colorFilter: Color3;
  87512. buffer: Uint8Array;
  87513. bufferWidth: number;
  87514. bufferHeight: number;
  87515. alphaFilter: number;
  87516. }): VertexData;
  87517. /**
  87518. * Creates the VertexData for a Plane
  87519. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  87520. * * size sets the width and height of the plane to the value of size, optional default 1
  87521. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  87522. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  87523. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87524. * * 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)
  87525. * * 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)
  87526. * @returns the VertexData of the box
  87527. */
  87528. static CreatePlane(options: {
  87529. size?: number;
  87530. width?: number;
  87531. height?: number;
  87532. sideOrientation?: number;
  87533. frontUVs?: Vector4;
  87534. backUVs?: Vector4;
  87535. }): VertexData;
  87536. /**
  87537. * Creates the VertexData of the Disc or regular Polygon
  87538. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  87539. * * radius the radius of the disc, optional default 0.5
  87540. * * tessellation the number of polygon sides, optional, default 64
  87541. * * 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
  87542. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87543. * * 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)
  87544. * * 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)
  87545. * @returns the VertexData of the box
  87546. */
  87547. static CreateDisc(options: {
  87548. radius?: number;
  87549. tessellation?: number;
  87550. arc?: number;
  87551. sideOrientation?: number;
  87552. frontUVs?: Vector4;
  87553. backUVs?: Vector4;
  87554. }): VertexData;
  87555. /**
  87556. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  87557. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  87558. * @param polygon a mesh built from polygonTriangulation.build()
  87559. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87560. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87561. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87562. * @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)
  87563. * @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)
  87564. * @returns the VertexData of the Polygon
  87565. */
  87566. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  87567. /**
  87568. * Creates the VertexData of the IcoSphere
  87569. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  87570. * * radius the radius of the IcoSphere, optional default 1
  87571. * * radiusX allows stretching in the x direction, optional, default radius
  87572. * * radiusY allows stretching in the y direction, optional, default radius
  87573. * * radiusZ allows stretching in the z direction, optional, default radius
  87574. * * flat when true creates a flat shaded mesh, optional, default true
  87575. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  87576. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87577. * * 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)
  87578. * * 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)
  87579. * @returns the VertexData of the IcoSphere
  87580. */
  87581. static CreateIcoSphere(options: {
  87582. radius?: number;
  87583. radiusX?: number;
  87584. radiusY?: number;
  87585. radiusZ?: number;
  87586. flat?: boolean;
  87587. subdivisions?: number;
  87588. sideOrientation?: number;
  87589. frontUVs?: Vector4;
  87590. backUVs?: Vector4;
  87591. }): VertexData;
  87592. /**
  87593. * Creates the VertexData for a Polyhedron
  87594. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  87595. * * type provided types are:
  87596. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  87597. * * 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)
  87598. * * size the size of the IcoSphere, optional default 1
  87599. * * sizeX allows stretching in the x direction, optional, default size
  87600. * * sizeY allows stretching in the y direction, optional, default size
  87601. * * sizeZ allows stretching in the z direction, optional, default size
  87602. * * 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
  87603. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87604. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87605. * * flat when true creates a flat shaded mesh, optional, default true
  87606. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  87607. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87608. * * 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)
  87609. * * 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)
  87610. * @returns the VertexData of the Polyhedron
  87611. */
  87612. static CreatePolyhedron(options: {
  87613. type?: number;
  87614. size?: number;
  87615. sizeX?: number;
  87616. sizeY?: number;
  87617. sizeZ?: number;
  87618. custom?: any;
  87619. faceUV?: Vector4[];
  87620. faceColors?: Color4[];
  87621. flat?: boolean;
  87622. sideOrientation?: number;
  87623. frontUVs?: Vector4;
  87624. backUVs?: Vector4;
  87625. }): VertexData;
  87626. /**
  87627. * Creates the VertexData for a TorusKnot
  87628. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  87629. * * radius the radius of the torus knot, optional, default 2
  87630. * * tube the thickness of the tube, optional, default 0.5
  87631. * * radialSegments the number of sides on each tube segments, optional, default 32
  87632. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  87633. * * p the number of windings around the z axis, optional, default 2
  87634. * * q the number of windings around the x axis, optional, default 3
  87635. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87636. * * 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)
  87637. * * 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)
  87638. * @returns the VertexData of the Torus Knot
  87639. */
  87640. static CreateTorusKnot(options: {
  87641. radius?: number;
  87642. tube?: number;
  87643. radialSegments?: number;
  87644. tubularSegments?: number;
  87645. p?: number;
  87646. q?: number;
  87647. sideOrientation?: number;
  87648. frontUVs?: Vector4;
  87649. backUVs?: Vector4;
  87650. }): VertexData;
  87651. /**
  87652. * Compute normals for given positions and indices
  87653. * @param positions an array of vertex positions, [...., x, y, z, ......]
  87654. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  87655. * @param normals an array of vertex normals, [...., x, y, z, ......]
  87656. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  87657. * * facetNormals : optional array of facet normals (vector3)
  87658. * * facetPositions : optional array of facet positions (vector3)
  87659. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  87660. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  87661. * * bInfo : optional bounding info, required for facetPartitioning computation
  87662. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  87663. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  87664. * * useRightHandedSystem: optional boolean to for right handed system computation
  87665. * * depthSort : optional boolean to enable the facet depth sort computation
  87666. * * distanceTo : optional Vector3 to compute the facet depth from this location
  87667. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  87668. */
  87669. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  87670. facetNormals?: any;
  87671. facetPositions?: any;
  87672. facetPartitioning?: any;
  87673. ratio?: number;
  87674. bInfo?: any;
  87675. bbSize?: Vector3;
  87676. subDiv?: any;
  87677. useRightHandedSystem?: boolean;
  87678. depthSort?: boolean;
  87679. distanceTo?: Vector3;
  87680. depthSortedFacets?: any;
  87681. }): void;
  87682. /** @hidden */
  87683. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  87684. /**
  87685. * Applies VertexData created from the imported parameters to the geometry
  87686. * @param parsedVertexData the parsed data from an imported file
  87687. * @param geometry the geometry to apply the VertexData to
  87688. */
  87689. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  87690. }
  87691. }
  87692. declare module BABYLON {
  87693. /**
  87694. * Defines a target to use with MorphTargetManager
  87695. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  87696. */
  87697. export class MorphTarget implements IAnimatable {
  87698. /** defines the name of the target */
  87699. name: string;
  87700. /**
  87701. * Gets or sets the list of animations
  87702. */
  87703. animations: Animation[];
  87704. private _scene;
  87705. private _positions;
  87706. private _normals;
  87707. private _tangents;
  87708. private _uvs;
  87709. private _influence;
  87710. /**
  87711. * Observable raised when the influence changes
  87712. */
  87713. onInfluenceChanged: Observable<boolean>;
  87714. /** @hidden */
  87715. _onDataLayoutChanged: Observable<void>;
  87716. /**
  87717. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  87718. */
  87719. influence: number;
  87720. /**
  87721. * Gets or sets the id of the morph Target
  87722. */
  87723. id: string;
  87724. private _animationPropertiesOverride;
  87725. /**
  87726. * Gets or sets the animation properties override
  87727. */
  87728. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  87729. /**
  87730. * Creates a new MorphTarget
  87731. * @param name defines the name of the target
  87732. * @param influence defines the influence to use
  87733. * @param scene defines the scene the morphtarget belongs to
  87734. */
  87735. constructor(
  87736. /** defines the name of the target */
  87737. name: string, influence?: number, scene?: Nullable<Scene>);
  87738. /**
  87739. * Gets a boolean defining if the target contains position data
  87740. */
  87741. readonly hasPositions: boolean;
  87742. /**
  87743. * Gets a boolean defining if the target contains normal data
  87744. */
  87745. readonly hasNormals: boolean;
  87746. /**
  87747. * Gets a boolean defining if the target contains tangent data
  87748. */
  87749. readonly hasTangents: boolean;
  87750. /**
  87751. * Gets a boolean defining if the target contains texture coordinates data
  87752. */
  87753. readonly hasUVs: boolean;
  87754. /**
  87755. * Affects position data to this target
  87756. * @param data defines the position data to use
  87757. */
  87758. setPositions(data: Nullable<FloatArray>): void;
  87759. /**
  87760. * Gets the position data stored in this target
  87761. * @returns a FloatArray containing the position data (or null if not present)
  87762. */
  87763. getPositions(): Nullable<FloatArray>;
  87764. /**
  87765. * Affects normal data to this target
  87766. * @param data defines the normal data to use
  87767. */
  87768. setNormals(data: Nullable<FloatArray>): void;
  87769. /**
  87770. * Gets the normal data stored in this target
  87771. * @returns a FloatArray containing the normal data (or null if not present)
  87772. */
  87773. getNormals(): Nullable<FloatArray>;
  87774. /**
  87775. * Affects tangent data to this target
  87776. * @param data defines the tangent data to use
  87777. */
  87778. setTangents(data: Nullable<FloatArray>): void;
  87779. /**
  87780. * Gets the tangent data stored in this target
  87781. * @returns a FloatArray containing the tangent data (or null if not present)
  87782. */
  87783. getTangents(): Nullable<FloatArray>;
  87784. /**
  87785. * Affects texture coordinates data to this target
  87786. * @param data defines the texture coordinates data to use
  87787. */
  87788. setUVs(data: Nullable<FloatArray>): void;
  87789. /**
  87790. * Gets the texture coordinates data stored in this target
  87791. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  87792. */
  87793. getUVs(): Nullable<FloatArray>;
  87794. /**
  87795. * Serializes the current target into a Serialization object
  87796. * @returns the serialized object
  87797. */
  87798. serialize(): any;
  87799. /**
  87800. * Returns the string "MorphTarget"
  87801. * @returns "MorphTarget"
  87802. */
  87803. getClassName(): string;
  87804. /**
  87805. * Creates a new target from serialized data
  87806. * @param serializationObject defines the serialized data to use
  87807. * @returns a new MorphTarget
  87808. */
  87809. static Parse(serializationObject: any): MorphTarget;
  87810. /**
  87811. * Creates a MorphTarget from mesh data
  87812. * @param mesh defines the source mesh
  87813. * @param name defines the name to use for the new target
  87814. * @param influence defines the influence to attach to the target
  87815. * @returns a new MorphTarget
  87816. */
  87817. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  87818. }
  87819. }
  87820. declare module BABYLON {
  87821. /**
  87822. * This class is used to deform meshes using morphing between different targets
  87823. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  87824. */
  87825. export class MorphTargetManager {
  87826. private _targets;
  87827. private _targetInfluenceChangedObservers;
  87828. private _targetDataLayoutChangedObservers;
  87829. private _activeTargets;
  87830. private _scene;
  87831. private _influences;
  87832. private _supportsNormals;
  87833. private _supportsTangents;
  87834. private _supportsUVs;
  87835. private _vertexCount;
  87836. private _uniqueId;
  87837. private _tempInfluences;
  87838. /**
  87839. * Gets or sets a boolean indicating if normals must be morphed
  87840. */
  87841. enableNormalMorphing: boolean;
  87842. /**
  87843. * Gets or sets a boolean indicating if tangents must be morphed
  87844. */
  87845. enableTangentMorphing: boolean;
  87846. /**
  87847. * Gets or sets a boolean indicating if UV must be morphed
  87848. */
  87849. enableUVMorphing: boolean;
  87850. /**
  87851. * Creates a new MorphTargetManager
  87852. * @param scene defines the current scene
  87853. */
  87854. constructor(scene?: Nullable<Scene>);
  87855. /**
  87856. * Gets the unique ID of this manager
  87857. */
  87858. readonly uniqueId: number;
  87859. /**
  87860. * Gets the number of vertices handled by this manager
  87861. */
  87862. readonly vertexCount: number;
  87863. /**
  87864. * Gets a boolean indicating if this manager supports morphing of normals
  87865. */
  87866. readonly supportsNormals: boolean;
  87867. /**
  87868. * Gets a boolean indicating if this manager supports morphing of tangents
  87869. */
  87870. readonly supportsTangents: boolean;
  87871. /**
  87872. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  87873. */
  87874. readonly supportsUVs: boolean;
  87875. /**
  87876. * Gets the number of targets stored in this manager
  87877. */
  87878. readonly numTargets: number;
  87879. /**
  87880. * Gets the number of influencers (ie. the number of targets with influences > 0)
  87881. */
  87882. readonly numInfluencers: number;
  87883. /**
  87884. * Gets the list of influences (one per target)
  87885. */
  87886. readonly influences: Float32Array;
  87887. /**
  87888. * Gets the active target at specified index. An active target is a target with an influence > 0
  87889. * @param index defines the index to check
  87890. * @returns the requested target
  87891. */
  87892. getActiveTarget(index: number): MorphTarget;
  87893. /**
  87894. * Gets the target at specified index
  87895. * @param index defines the index to check
  87896. * @returns the requested target
  87897. */
  87898. getTarget(index: number): MorphTarget;
  87899. /**
  87900. * Add a new target to this manager
  87901. * @param target defines the target to add
  87902. */
  87903. addTarget(target: MorphTarget): void;
  87904. /**
  87905. * Removes a target from the manager
  87906. * @param target defines the target to remove
  87907. */
  87908. removeTarget(target: MorphTarget): void;
  87909. /**
  87910. * Serializes the current manager into a Serialization object
  87911. * @returns the serialized object
  87912. */
  87913. serialize(): any;
  87914. private _syncActiveTargets;
  87915. /**
  87916. * Syncrhonize the targets with all the meshes using this morph target manager
  87917. */
  87918. synchronize(): void;
  87919. /**
  87920. * Creates a new MorphTargetManager from serialized data
  87921. * @param serializationObject defines the serialized data
  87922. * @param scene defines the hosting scene
  87923. * @returns the new MorphTargetManager
  87924. */
  87925. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  87926. }
  87927. }
  87928. declare module BABYLON {
  87929. /**
  87930. * Class used to represent a specific level of detail of a mesh
  87931. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  87932. */
  87933. export class MeshLODLevel {
  87934. /** Defines the distance where this level should start being displayed */
  87935. distance: number;
  87936. /** Defines the mesh to use to render this level */
  87937. mesh: Nullable<Mesh>;
  87938. /**
  87939. * Creates a new LOD level
  87940. * @param distance defines the distance where this level should star being displayed
  87941. * @param mesh defines the mesh to use to render this level
  87942. */
  87943. constructor(
  87944. /** Defines the distance where this level should start being displayed */
  87945. distance: number,
  87946. /** Defines the mesh to use to render this level */
  87947. mesh: Nullable<Mesh>);
  87948. }
  87949. }
  87950. declare module BABYLON {
  87951. /**
  87952. * Mesh representing the gorund
  87953. */
  87954. export class GroundMesh extends Mesh {
  87955. /** If octree should be generated */
  87956. generateOctree: boolean;
  87957. private _heightQuads;
  87958. /** @hidden */
  87959. _subdivisionsX: number;
  87960. /** @hidden */
  87961. _subdivisionsY: number;
  87962. /** @hidden */
  87963. _width: number;
  87964. /** @hidden */
  87965. _height: number;
  87966. /** @hidden */
  87967. _minX: number;
  87968. /** @hidden */
  87969. _maxX: number;
  87970. /** @hidden */
  87971. _minZ: number;
  87972. /** @hidden */
  87973. _maxZ: number;
  87974. constructor(name: string, scene: Scene);
  87975. /**
  87976. * "GroundMesh"
  87977. * @returns "GroundMesh"
  87978. */
  87979. getClassName(): string;
  87980. /**
  87981. * The minimum of x and y subdivisions
  87982. */
  87983. readonly subdivisions: number;
  87984. /**
  87985. * X subdivisions
  87986. */
  87987. readonly subdivisionsX: number;
  87988. /**
  87989. * Y subdivisions
  87990. */
  87991. readonly subdivisionsY: number;
  87992. /**
  87993. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  87994. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  87995. * @param chunksCount the number of subdivisions for x and y
  87996. * @param octreeBlocksSize (Default: 32)
  87997. */
  87998. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  87999. /**
  88000. * Returns a height (y) value in the Worl system :
  88001. * the ground altitude at the coordinates (x, z) expressed in the World system.
  88002. * @param x x coordinate
  88003. * @param z z coordinate
  88004. * @returns the ground y position if (x, z) are outside the ground surface.
  88005. */
  88006. getHeightAtCoordinates(x: number, z: number): number;
  88007. /**
  88008. * Returns a normalized vector (Vector3) orthogonal to the ground
  88009. * at the ground coordinates (x, z) expressed in the World system.
  88010. * @param x x coordinate
  88011. * @param z z coordinate
  88012. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  88013. */
  88014. getNormalAtCoordinates(x: number, z: number): Vector3;
  88015. /**
  88016. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  88017. * at the ground coordinates (x, z) expressed in the World system.
  88018. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  88019. * @param x x coordinate
  88020. * @param z z coordinate
  88021. * @param ref vector to store the result
  88022. * @returns the GroundMesh.
  88023. */
  88024. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  88025. /**
  88026. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  88027. * if the ground has been updated.
  88028. * This can be used in the render loop.
  88029. * @returns the GroundMesh.
  88030. */
  88031. updateCoordinateHeights(): GroundMesh;
  88032. private _getFacetAt;
  88033. private _initHeightQuads;
  88034. private _computeHeightQuads;
  88035. /**
  88036. * Serializes this ground mesh
  88037. * @param serializationObject object to write serialization to
  88038. */
  88039. serialize(serializationObject: any): void;
  88040. /**
  88041. * Parses a serialized ground mesh
  88042. * @param parsedMesh the serialized mesh
  88043. * @param scene the scene to create the ground mesh in
  88044. * @returns the created ground mesh
  88045. */
  88046. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  88047. }
  88048. }
  88049. declare module BABYLON {
  88050. /**
  88051. * Interface for Physics-Joint data
  88052. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88053. */
  88054. export interface PhysicsJointData {
  88055. /**
  88056. * The main pivot of the joint
  88057. */
  88058. mainPivot?: Vector3;
  88059. /**
  88060. * The connected pivot of the joint
  88061. */
  88062. connectedPivot?: Vector3;
  88063. /**
  88064. * The main axis of the joint
  88065. */
  88066. mainAxis?: Vector3;
  88067. /**
  88068. * The connected axis of the joint
  88069. */
  88070. connectedAxis?: Vector3;
  88071. /**
  88072. * The collision of the joint
  88073. */
  88074. collision?: boolean;
  88075. /**
  88076. * Native Oimo/Cannon/Energy data
  88077. */
  88078. nativeParams?: any;
  88079. }
  88080. /**
  88081. * This is a holder class for the physics joint created by the physics plugin
  88082. * It holds a set of functions to control the underlying joint
  88083. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88084. */
  88085. export class PhysicsJoint {
  88086. /**
  88087. * The type of the physics joint
  88088. */
  88089. type: number;
  88090. /**
  88091. * The data for the physics joint
  88092. */
  88093. jointData: PhysicsJointData;
  88094. private _physicsJoint;
  88095. protected _physicsPlugin: IPhysicsEnginePlugin;
  88096. /**
  88097. * Initializes the physics joint
  88098. * @param type The type of the physics joint
  88099. * @param jointData The data for the physics joint
  88100. */
  88101. constructor(
  88102. /**
  88103. * The type of the physics joint
  88104. */
  88105. type: number,
  88106. /**
  88107. * The data for the physics joint
  88108. */
  88109. jointData: PhysicsJointData);
  88110. /**
  88111. * Gets the physics joint
  88112. */
  88113. /**
  88114. * Sets the physics joint
  88115. */
  88116. physicsJoint: any;
  88117. /**
  88118. * Sets the physics plugin
  88119. */
  88120. physicsPlugin: IPhysicsEnginePlugin;
  88121. /**
  88122. * Execute a function that is physics-plugin specific.
  88123. * @param {Function} func the function that will be executed.
  88124. * It accepts two parameters: the physics world and the physics joint
  88125. */
  88126. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  88127. /**
  88128. * Distance-Joint type
  88129. */
  88130. static DistanceJoint: number;
  88131. /**
  88132. * Hinge-Joint type
  88133. */
  88134. static HingeJoint: number;
  88135. /**
  88136. * Ball-and-Socket joint type
  88137. */
  88138. static BallAndSocketJoint: number;
  88139. /**
  88140. * Wheel-Joint type
  88141. */
  88142. static WheelJoint: number;
  88143. /**
  88144. * Slider-Joint type
  88145. */
  88146. static SliderJoint: number;
  88147. /**
  88148. * Prismatic-Joint type
  88149. */
  88150. static PrismaticJoint: number;
  88151. /**
  88152. * Universal-Joint type
  88153. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  88154. */
  88155. static UniversalJoint: number;
  88156. /**
  88157. * Hinge-Joint 2 type
  88158. */
  88159. static Hinge2Joint: number;
  88160. /**
  88161. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  88162. */
  88163. static PointToPointJoint: number;
  88164. /**
  88165. * Spring-Joint type
  88166. */
  88167. static SpringJoint: number;
  88168. /**
  88169. * Lock-Joint type
  88170. */
  88171. static LockJoint: number;
  88172. }
  88173. /**
  88174. * A class representing a physics distance joint
  88175. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88176. */
  88177. export class DistanceJoint extends PhysicsJoint {
  88178. /**
  88179. *
  88180. * @param jointData The data for the Distance-Joint
  88181. */
  88182. constructor(jointData: DistanceJointData);
  88183. /**
  88184. * Update the predefined distance.
  88185. * @param maxDistance The maximum preferred distance
  88186. * @param minDistance The minimum preferred distance
  88187. */
  88188. updateDistance(maxDistance: number, minDistance?: number): void;
  88189. }
  88190. /**
  88191. * Represents a Motor-Enabled Joint
  88192. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88193. */
  88194. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  88195. /**
  88196. * Initializes the Motor-Enabled Joint
  88197. * @param type The type of the joint
  88198. * @param jointData The physica joint data for the joint
  88199. */
  88200. constructor(type: number, jointData: PhysicsJointData);
  88201. /**
  88202. * Set the motor values.
  88203. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88204. * @param force the force to apply
  88205. * @param maxForce max force for this motor.
  88206. */
  88207. setMotor(force?: number, maxForce?: number): void;
  88208. /**
  88209. * Set the motor's limits.
  88210. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88211. * @param upperLimit The upper limit of the motor
  88212. * @param lowerLimit The lower limit of the motor
  88213. */
  88214. setLimit(upperLimit: number, lowerLimit?: number): void;
  88215. }
  88216. /**
  88217. * This class represents a single physics Hinge-Joint
  88218. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88219. */
  88220. export class HingeJoint extends MotorEnabledJoint {
  88221. /**
  88222. * Initializes the Hinge-Joint
  88223. * @param jointData The joint data for the Hinge-Joint
  88224. */
  88225. constructor(jointData: PhysicsJointData);
  88226. /**
  88227. * Set the motor values.
  88228. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88229. * @param {number} force the force to apply
  88230. * @param {number} maxForce max force for this motor.
  88231. */
  88232. setMotor(force?: number, maxForce?: number): void;
  88233. /**
  88234. * Set the motor's limits.
  88235. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88236. * @param upperLimit The upper limit of the motor
  88237. * @param lowerLimit The lower limit of the motor
  88238. */
  88239. setLimit(upperLimit: number, lowerLimit?: number): void;
  88240. }
  88241. /**
  88242. * This class represents a dual hinge physics joint (same as wheel joint)
  88243. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88244. */
  88245. export class Hinge2Joint extends MotorEnabledJoint {
  88246. /**
  88247. * Initializes the Hinge2-Joint
  88248. * @param jointData The joint data for the Hinge2-Joint
  88249. */
  88250. constructor(jointData: PhysicsJointData);
  88251. /**
  88252. * Set the motor values.
  88253. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88254. * @param {number} targetSpeed the speed the motor is to reach
  88255. * @param {number} maxForce max force for this motor.
  88256. * @param {motorIndex} the motor's index, 0 or 1.
  88257. */
  88258. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  88259. /**
  88260. * Set the motor limits.
  88261. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88262. * @param {number} upperLimit the upper limit
  88263. * @param {number} lowerLimit lower limit
  88264. * @param {motorIndex} the motor's index, 0 or 1.
  88265. */
  88266. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  88267. }
  88268. /**
  88269. * Interface for a motor enabled joint
  88270. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88271. */
  88272. export interface IMotorEnabledJoint {
  88273. /**
  88274. * Physics joint
  88275. */
  88276. physicsJoint: any;
  88277. /**
  88278. * Sets the motor of the motor-enabled joint
  88279. * @param force The force of the motor
  88280. * @param maxForce The maximum force of the motor
  88281. * @param motorIndex The index of the motor
  88282. */
  88283. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  88284. /**
  88285. * Sets the limit of the motor
  88286. * @param upperLimit The upper limit of the motor
  88287. * @param lowerLimit The lower limit of the motor
  88288. * @param motorIndex The index of the motor
  88289. */
  88290. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  88291. }
  88292. /**
  88293. * Joint data for a Distance-Joint
  88294. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88295. */
  88296. export interface DistanceJointData extends PhysicsJointData {
  88297. /**
  88298. * Max distance the 2 joint objects can be apart
  88299. */
  88300. maxDistance: number;
  88301. }
  88302. /**
  88303. * Joint data from a spring joint
  88304. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88305. */
  88306. export interface SpringJointData extends PhysicsJointData {
  88307. /**
  88308. * Length of the spring
  88309. */
  88310. length: number;
  88311. /**
  88312. * Stiffness of the spring
  88313. */
  88314. stiffness: number;
  88315. /**
  88316. * Damping of the spring
  88317. */
  88318. damping: number;
  88319. /** this callback will be called when applying the force to the impostors. */
  88320. forceApplicationCallback: () => void;
  88321. }
  88322. }
  88323. declare module BABYLON {
  88324. /**
  88325. * Holds the data for the raycast result
  88326. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88327. */
  88328. export class PhysicsRaycastResult {
  88329. private _hasHit;
  88330. private _hitDistance;
  88331. private _hitNormalWorld;
  88332. private _hitPointWorld;
  88333. private _rayFromWorld;
  88334. private _rayToWorld;
  88335. /**
  88336. * Gets if there was a hit
  88337. */
  88338. readonly hasHit: boolean;
  88339. /**
  88340. * Gets the distance from the hit
  88341. */
  88342. readonly hitDistance: number;
  88343. /**
  88344. * Gets the hit normal/direction in the world
  88345. */
  88346. readonly hitNormalWorld: Vector3;
  88347. /**
  88348. * Gets the hit point in the world
  88349. */
  88350. readonly hitPointWorld: Vector3;
  88351. /**
  88352. * Gets the ray "start point" of the ray in the world
  88353. */
  88354. readonly rayFromWorld: Vector3;
  88355. /**
  88356. * Gets the ray "end point" of the ray in the world
  88357. */
  88358. readonly rayToWorld: Vector3;
  88359. /**
  88360. * Sets the hit data (normal & point in world space)
  88361. * @param hitNormalWorld defines the normal in world space
  88362. * @param hitPointWorld defines the point in world space
  88363. */
  88364. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  88365. /**
  88366. * Sets the distance from the start point to the hit point
  88367. * @param distance
  88368. */
  88369. setHitDistance(distance: number): void;
  88370. /**
  88371. * Calculates the distance manually
  88372. */
  88373. calculateHitDistance(): void;
  88374. /**
  88375. * Resets all the values to default
  88376. * @param from The from point on world space
  88377. * @param to The to point on world space
  88378. */
  88379. reset(from?: Vector3, to?: Vector3): void;
  88380. }
  88381. /**
  88382. * Interface for the size containing width and height
  88383. */
  88384. interface IXYZ {
  88385. /**
  88386. * X
  88387. */
  88388. x: number;
  88389. /**
  88390. * Y
  88391. */
  88392. y: number;
  88393. /**
  88394. * Z
  88395. */
  88396. z: number;
  88397. }
  88398. }
  88399. declare module BABYLON {
  88400. /**
  88401. * Interface used to describe a physics joint
  88402. */
  88403. export interface PhysicsImpostorJoint {
  88404. /** Defines the main impostor to which the joint is linked */
  88405. mainImpostor: PhysicsImpostor;
  88406. /** Defines the impostor that is connected to the main impostor using this joint */
  88407. connectedImpostor: PhysicsImpostor;
  88408. /** Defines the joint itself */
  88409. joint: PhysicsJoint;
  88410. }
  88411. /** @hidden */
  88412. export interface IPhysicsEnginePlugin {
  88413. world: any;
  88414. name: string;
  88415. setGravity(gravity: Vector3): void;
  88416. setTimeStep(timeStep: number): void;
  88417. getTimeStep(): number;
  88418. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  88419. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  88420. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  88421. generatePhysicsBody(impostor: PhysicsImpostor): void;
  88422. removePhysicsBody(impostor: PhysicsImpostor): void;
  88423. generateJoint(joint: PhysicsImpostorJoint): void;
  88424. removeJoint(joint: PhysicsImpostorJoint): void;
  88425. isSupported(): boolean;
  88426. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  88427. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  88428. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  88429. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  88430. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  88431. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  88432. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  88433. getBodyMass(impostor: PhysicsImpostor): number;
  88434. getBodyFriction(impostor: PhysicsImpostor): number;
  88435. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  88436. getBodyRestitution(impostor: PhysicsImpostor): number;
  88437. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  88438. getBodyPressure?(impostor: PhysicsImpostor): number;
  88439. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  88440. getBodyStiffness?(impostor: PhysicsImpostor): number;
  88441. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  88442. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  88443. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  88444. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  88445. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  88446. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  88447. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  88448. sleepBody(impostor: PhysicsImpostor): void;
  88449. wakeUpBody(impostor: PhysicsImpostor): void;
  88450. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  88451. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  88452. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  88453. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  88454. getRadius(impostor: PhysicsImpostor): number;
  88455. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  88456. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  88457. dispose(): void;
  88458. }
  88459. /**
  88460. * Interface used to define a physics engine
  88461. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  88462. */
  88463. export interface IPhysicsEngine {
  88464. /**
  88465. * Gets the gravity vector used by the simulation
  88466. */
  88467. gravity: Vector3;
  88468. /**
  88469. * Sets the gravity vector used by the simulation
  88470. * @param gravity defines the gravity vector to use
  88471. */
  88472. setGravity(gravity: Vector3): void;
  88473. /**
  88474. * Set the time step of the physics engine.
  88475. * Default is 1/60.
  88476. * To slow it down, enter 1/600 for example.
  88477. * To speed it up, 1/30
  88478. * @param newTimeStep the new timestep to apply to this world.
  88479. */
  88480. setTimeStep(newTimeStep: number): void;
  88481. /**
  88482. * Get the time step of the physics engine.
  88483. * @returns the current time step
  88484. */
  88485. getTimeStep(): number;
  88486. /**
  88487. * Release all resources
  88488. */
  88489. dispose(): void;
  88490. /**
  88491. * Gets the name of the current physics plugin
  88492. * @returns the name of the plugin
  88493. */
  88494. getPhysicsPluginName(): string;
  88495. /**
  88496. * Adding a new impostor for the impostor tracking.
  88497. * This will be done by the impostor itself.
  88498. * @param impostor the impostor to add
  88499. */
  88500. addImpostor(impostor: PhysicsImpostor): void;
  88501. /**
  88502. * Remove an impostor from the engine.
  88503. * This impostor and its mesh will not longer be updated by the physics engine.
  88504. * @param impostor the impostor to remove
  88505. */
  88506. removeImpostor(impostor: PhysicsImpostor): void;
  88507. /**
  88508. * Add a joint to the physics engine
  88509. * @param mainImpostor defines the main impostor to which the joint is added.
  88510. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  88511. * @param joint defines the joint that will connect both impostors.
  88512. */
  88513. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  88514. /**
  88515. * Removes a joint from the simulation
  88516. * @param mainImpostor defines the impostor used with the joint
  88517. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  88518. * @param joint defines the joint to remove
  88519. */
  88520. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  88521. /**
  88522. * Gets the current plugin used to run the simulation
  88523. * @returns current plugin
  88524. */
  88525. getPhysicsPlugin(): IPhysicsEnginePlugin;
  88526. /**
  88527. * Gets the list of physic impostors
  88528. * @returns an array of PhysicsImpostor
  88529. */
  88530. getImpostors(): Array<PhysicsImpostor>;
  88531. /**
  88532. * Gets the impostor for a physics enabled object
  88533. * @param object defines the object impersonated by the impostor
  88534. * @returns the PhysicsImpostor or null if not found
  88535. */
  88536. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  88537. /**
  88538. * Gets the impostor for a physics body object
  88539. * @param body defines physics body used by the impostor
  88540. * @returns the PhysicsImpostor or null if not found
  88541. */
  88542. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  88543. /**
  88544. * Does a raycast in the physics world
  88545. * @param from when should the ray start?
  88546. * @param to when should the ray end?
  88547. * @returns PhysicsRaycastResult
  88548. */
  88549. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  88550. /**
  88551. * Called by the scene. No need to call it.
  88552. * @param delta defines the timespam between frames
  88553. */
  88554. _step(delta: number): void;
  88555. }
  88556. }
  88557. declare module BABYLON {
  88558. /**
  88559. * The interface for the physics imposter parameters
  88560. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88561. */
  88562. export interface PhysicsImpostorParameters {
  88563. /**
  88564. * The mass of the physics imposter
  88565. */
  88566. mass: number;
  88567. /**
  88568. * The friction of the physics imposter
  88569. */
  88570. friction?: number;
  88571. /**
  88572. * The coefficient of restitution of the physics imposter
  88573. */
  88574. restitution?: number;
  88575. /**
  88576. * The native options of the physics imposter
  88577. */
  88578. nativeOptions?: any;
  88579. /**
  88580. * Specifies if the parent should be ignored
  88581. */
  88582. ignoreParent?: boolean;
  88583. /**
  88584. * Specifies if bi-directional transformations should be disabled
  88585. */
  88586. disableBidirectionalTransformation?: boolean;
  88587. /**
  88588. * The pressure inside the physics imposter, soft object only
  88589. */
  88590. pressure?: number;
  88591. /**
  88592. * The stiffness the physics imposter, soft object only
  88593. */
  88594. stiffness?: number;
  88595. /**
  88596. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  88597. */
  88598. velocityIterations?: number;
  88599. /**
  88600. * The number of iterations used in maintaining consistent vertex positions, soft object only
  88601. */
  88602. positionIterations?: number;
  88603. /**
  88604. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  88605. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  88606. * Add to fix multiple points
  88607. */
  88608. fixedPoints?: number;
  88609. /**
  88610. * The collision margin around a soft object
  88611. */
  88612. margin?: number;
  88613. /**
  88614. * The collision margin around a soft object
  88615. */
  88616. damping?: number;
  88617. /**
  88618. * The path for a rope based on an extrusion
  88619. */
  88620. path?: any;
  88621. /**
  88622. * The shape of an extrusion used for a rope based on an extrusion
  88623. */
  88624. shape?: any;
  88625. }
  88626. /**
  88627. * Interface for a physics-enabled object
  88628. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88629. */
  88630. export interface IPhysicsEnabledObject {
  88631. /**
  88632. * The position of the physics-enabled object
  88633. */
  88634. position: Vector3;
  88635. /**
  88636. * The rotation of the physics-enabled object
  88637. */
  88638. rotationQuaternion: Nullable<Quaternion>;
  88639. /**
  88640. * The scale of the physics-enabled object
  88641. */
  88642. scaling: Vector3;
  88643. /**
  88644. * The rotation of the physics-enabled object
  88645. */
  88646. rotation?: Vector3;
  88647. /**
  88648. * The parent of the physics-enabled object
  88649. */
  88650. parent?: any;
  88651. /**
  88652. * The bounding info of the physics-enabled object
  88653. * @returns The bounding info of the physics-enabled object
  88654. */
  88655. getBoundingInfo(): BoundingInfo;
  88656. /**
  88657. * Computes the world matrix
  88658. * @param force Specifies if the world matrix should be computed by force
  88659. * @returns A world matrix
  88660. */
  88661. computeWorldMatrix(force: boolean): Matrix;
  88662. /**
  88663. * Gets the world matrix
  88664. * @returns A world matrix
  88665. */
  88666. getWorldMatrix?(): Matrix;
  88667. /**
  88668. * Gets the child meshes
  88669. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  88670. * @returns An array of abstract meshes
  88671. */
  88672. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  88673. /**
  88674. * Gets the vertex data
  88675. * @param kind The type of vertex data
  88676. * @returns A nullable array of numbers, or a float32 array
  88677. */
  88678. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  88679. /**
  88680. * Gets the indices from the mesh
  88681. * @returns A nullable array of index arrays
  88682. */
  88683. getIndices?(): Nullable<IndicesArray>;
  88684. /**
  88685. * Gets the scene from the mesh
  88686. * @returns the indices array or null
  88687. */
  88688. getScene?(): Scene;
  88689. /**
  88690. * Gets the absolute position from the mesh
  88691. * @returns the absolute position
  88692. */
  88693. getAbsolutePosition(): Vector3;
  88694. /**
  88695. * Gets the absolute pivot point from the mesh
  88696. * @returns the absolute pivot point
  88697. */
  88698. getAbsolutePivotPoint(): Vector3;
  88699. /**
  88700. * Rotates the mesh
  88701. * @param axis The axis of rotation
  88702. * @param amount The amount of rotation
  88703. * @param space The space of the rotation
  88704. * @returns The rotation transform node
  88705. */
  88706. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  88707. /**
  88708. * Translates the mesh
  88709. * @param axis The axis of translation
  88710. * @param distance The distance of translation
  88711. * @param space The space of the translation
  88712. * @returns The transform node
  88713. */
  88714. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  88715. /**
  88716. * Sets the absolute position of the mesh
  88717. * @param absolutePosition The absolute position of the mesh
  88718. * @returns The transform node
  88719. */
  88720. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  88721. /**
  88722. * Gets the class name of the mesh
  88723. * @returns The class name
  88724. */
  88725. getClassName(): string;
  88726. }
  88727. /**
  88728. * Represents a physics imposter
  88729. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88730. */
  88731. export class PhysicsImpostor {
  88732. /**
  88733. * The physics-enabled object used as the physics imposter
  88734. */
  88735. object: IPhysicsEnabledObject;
  88736. /**
  88737. * The type of the physics imposter
  88738. */
  88739. type: number;
  88740. private _options;
  88741. private _scene?;
  88742. /**
  88743. * The default object size of the imposter
  88744. */
  88745. static DEFAULT_OBJECT_SIZE: Vector3;
  88746. /**
  88747. * The identity quaternion of the imposter
  88748. */
  88749. static IDENTITY_QUATERNION: Quaternion;
  88750. /** @hidden */
  88751. _pluginData: any;
  88752. private _physicsEngine;
  88753. private _physicsBody;
  88754. private _bodyUpdateRequired;
  88755. private _onBeforePhysicsStepCallbacks;
  88756. private _onAfterPhysicsStepCallbacks;
  88757. /** @hidden */
  88758. _onPhysicsCollideCallbacks: Array<{
  88759. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  88760. otherImpostors: Array<PhysicsImpostor>;
  88761. }>;
  88762. private _deltaPosition;
  88763. private _deltaRotation;
  88764. private _deltaRotationConjugated;
  88765. /** @hidden */
  88766. _isFromLine: boolean;
  88767. private _parent;
  88768. private _isDisposed;
  88769. private static _tmpVecs;
  88770. private static _tmpQuat;
  88771. /**
  88772. * Specifies if the physics imposter is disposed
  88773. */
  88774. readonly isDisposed: boolean;
  88775. /**
  88776. * Gets the mass of the physics imposter
  88777. */
  88778. mass: number;
  88779. /**
  88780. * Gets the coefficient of friction
  88781. */
  88782. /**
  88783. * Sets the coefficient of friction
  88784. */
  88785. friction: number;
  88786. /**
  88787. * Gets the coefficient of restitution
  88788. */
  88789. /**
  88790. * Sets the coefficient of restitution
  88791. */
  88792. restitution: number;
  88793. /**
  88794. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  88795. */
  88796. /**
  88797. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  88798. */
  88799. pressure: number;
  88800. /**
  88801. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  88802. */
  88803. /**
  88804. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  88805. */
  88806. stiffness: number;
  88807. /**
  88808. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  88809. */
  88810. /**
  88811. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  88812. */
  88813. velocityIterations: number;
  88814. /**
  88815. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  88816. */
  88817. /**
  88818. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  88819. */
  88820. positionIterations: number;
  88821. /**
  88822. * The unique id of the physics imposter
  88823. * set by the physics engine when adding this impostor to the array
  88824. */
  88825. uniqueId: number;
  88826. /**
  88827. * @hidden
  88828. */
  88829. soft: boolean;
  88830. /**
  88831. * @hidden
  88832. */
  88833. segments: number;
  88834. private _joints;
  88835. /**
  88836. * Initializes the physics imposter
  88837. * @param object The physics-enabled object used as the physics imposter
  88838. * @param type The type of the physics imposter
  88839. * @param _options The options for the physics imposter
  88840. * @param _scene The Babylon scene
  88841. */
  88842. constructor(
  88843. /**
  88844. * The physics-enabled object used as the physics imposter
  88845. */
  88846. object: IPhysicsEnabledObject,
  88847. /**
  88848. * The type of the physics imposter
  88849. */
  88850. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  88851. /**
  88852. * This function will completly initialize this impostor.
  88853. * It will create a new body - but only if this mesh has no parent.
  88854. * If it has, this impostor will not be used other than to define the impostor
  88855. * of the child mesh.
  88856. * @hidden
  88857. */
  88858. _init(): void;
  88859. private _getPhysicsParent;
  88860. /**
  88861. * Should a new body be generated.
  88862. * @returns boolean specifying if body initialization is required
  88863. */
  88864. isBodyInitRequired(): boolean;
  88865. /**
  88866. * Sets the updated scaling
  88867. * @param updated Specifies if the scaling is updated
  88868. */
  88869. setScalingUpdated(): void;
  88870. /**
  88871. * Force a regeneration of this or the parent's impostor's body.
  88872. * Use under cautious - This will remove all joints already implemented.
  88873. */
  88874. forceUpdate(): void;
  88875. /**
  88876. * Gets the body that holds this impostor. Either its own, or its parent.
  88877. */
  88878. /**
  88879. * Set the physics body. Used mainly by the physics engine/plugin
  88880. */
  88881. physicsBody: any;
  88882. /**
  88883. * Get the parent of the physics imposter
  88884. * @returns Physics imposter or null
  88885. */
  88886. /**
  88887. * Sets the parent of the physics imposter
  88888. */
  88889. parent: Nullable<PhysicsImpostor>;
  88890. /**
  88891. * Resets the update flags
  88892. */
  88893. resetUpdateFlags(): void;
  88894. /**
  88895. * Gets the object extend size
  88896. * @returns the object extend size
  88897. */
  88898. getObjectExtendSize(): Vector3;
  88899. /**
  88900. * Gets the object center
  88901. * @returns The object center
  88902. */
  88903. getObjectCenter(): Vector3;
  88904. /**
  88905. * Get a specific parametes from the options parameter
  88906. * @param paramName The object parameter name
  88907. * @returns The object parameter
  88908. */
  88909. getParam(paramName: string): any;
  88910. /**
  88911. * Sets a specific parameter in the options given to the physics plugin
  88912. * @param paramName The parameter name
  88913. * @param value The value of the parameter
  88914. */
  88915. setParam(paramName: string, value: number): void;
  88916. /**
  88917. * Specifically change the body's mass option. Won't recreate the physics body object
  88918. * @param mass The mass of the physics imposter
  88919. */
  88920. setMass(mass: number): void;
  88921. /**
  88922. * Gets the linear velocity
  88923. * @returns linear velocity or null
  88924. */
  88925. getLinearVelocity(): Nullable<Vector3>;
  88926. /**
  88927. * Sets the linear velocity
  88928. * @param velocity linear velocity or null
  88929. */
  88930. setLinearVelocity(velocity: Nullable<Vector3>): void;
  88931. /**
  88932. * Gets the angular velocity
  88933. * @returns angular velocity or null
  88934. */
  88935. getAngularVelocity(): Nullable<Vector3>;
  88936. /**
  88937. * Sets the angular velocity
  88938. * @param velocity The velocity or null
  88939. */
  88940. setAngularVelocity(velocity: Nullable<Vector3>): void;
  88941. /**
  88942. * Execute a function with the physics plugin native code
  88943. * Provide a function the will have two variables - the world object and the physics body object
  88944. * @param func The function to execute with the physics plugin native code
  88945. */
  88946. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  88947. /**
  88948. * Register a function that will be executed before the physics world is stepping forward
  88949. * @param func The function to execute before the physics world is stepped forward
  88950. */
  88951. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  88952. /**
  88953. * Unregister a function that will be executed before the physics world is stepping forward
  88954. * @param func The function to execute before the physics world is stepped forward
  88955. */
  88956. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  88957. /**
  88958. * Register a function that will be executed after the physics step
  88959. * @param func The function to execute after physics step
  88960. */
  88961. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  88962. /**
  88963. * Unregisters a function that will be executed after the physics step
  88964. * @param func The function to execute after physics step
  88965. */
  88966. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  88967. /**
  88968. * register a function that will be executed when this impostor collides against a different body
  88969. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  88970. * @param func Callback that is executed on collision
  88971. */
  88972. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  88973. /**
  88974. * Unregisters the physics imposter on contact
  88975. * @param collideAgainst The physics object to collide against
  88976. * @param func Callback to execute on collision
  88977. */
  88978. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  88979. private _tmpQuat;
  88980. private _tmpQuat2;
  88981. /**
  88982. * Get the parent rotation
  88983. * @returns The parent rotation
  88984. */
  88985. getParentsRotation(): Quaternion;
  88986. /**
  88987. * this function is executed by the physics engine.
  88988. */
  88989. beforeStep: () => void;
  88990. /**
  88991. * this function is executed by the physics engine
  88992. */
  88993. afterStep: () => void;
  88994. /**
  88995. * Legacy collision detection event support
  88996. */
  88997. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  88998. /**
  88999. * event and body object due to cannon's event-based architecture.
  89000. */
  89001. onCollide: (e: {
  89002. body: any;
  89003. }) => void;
  89004. /**
  89005. * Apply a force
  89006. * @param force The force to apply
  89007. * @param contactPoint The contact point for the force
  89008. * @returns The physics imposter
  89009. */
  89010. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  89011. /**
  89012. * Apply an impulse
  89013. * @param force The impulse force
  89014. * @param contactPoint The contact point for the impulse force
  89015. * @returns The physics imposter
  89016. */
  89017. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  89018. /**
  89019. * A help function to create a joint
  89020. * @param otherImpostor A physics imposter used to create a joint
  89021. * @param jointType The type of joint
  89022. * @param jointData The data for the joint
  89023. * @returns The physics imposter
  89024. */
  89025. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  89026. /**
  89027. * Add a joint to this impostor with a different impostor
  89028. * @param otherImpostor A physics imposter used to add a joint
  89029. * @param joint The joint to add
  89030. * @returns The physics imposter
  89031. */
  89032. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  89033. /**
  89034. * Add an anchor to a cloth impostor
  89035. * @param otherImpostor rigid impostor to anchor to
  89036. * @param width ratio across width from 0 to 1
  89037. * @param height ratio up height from 0 to 1
  89038. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  89039. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  89040. * @returns impostor the soft imposter
  89041. */
  89042. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  89043. /**
  89044. * Add a hook to a rope impostor
  89045. * @param otherImpostor rigid impostor to anchor to
  89046. * @param length ratio across rope from 0 to 1
  89047. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  89048. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  89049. * @returns impostor the rope imposter
  89050. */
  89051. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  89052. /**
  89053. * Will keep this body still, in a sleep mode.
  89054. * @returns the physics imposter
  89055. */
  89056. sleep(): PhysicsImpostor;
  89057. /**
  89058. * Wake the body up.
  89059. * @returns The physics imposter
  89060. */
  89061. wakeUp(): PhysicsImpostor;
  89062. /**
  89063. * Clones the physics imposter
  89064. * @param newObject The physics imposter clones to this physics-enabled object
  89065. * @returns A nullable physics imposter
  89066. */
  89067. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  89068. /**
  89069. * Disposes the physics imposter
  89070. */
  89071. dispose(): void;
  89072. /**
  89073. * Sets the delta position
  89074. * @param position The delta position amount
  89075. */
  89076. setDeltaPosition(position: Vector3): void;
  89077. /**
  89078. * Sets the delta rotation
  89079. * @param rotation The delta rotation amount
  89080. */
  89081. setDeltaRotation(rotation: Quaternion): void;
  89082. /**
  89083. * Gets the box size of the physics imposter and stores the result in the input parameter
  89084. * @param result Stores the box size
  89085. * @returns The physics imposter
  89086. */
  89087. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  89088. /**
  89089. * Gets the radius of the physics imposter
  89090. * @returns Radius of the physics imposter
  89091. */
  89092. getRadius(): number;
  89093. /**
  89094. * Sync a bone with this impostor
  89095. * @param bone The bone to sync to the impostor.
  89096. * @param boneMesh The mesh that the bone is influencing.
  89097. * @param jointPivot The pivot of the joint / bone in local space.
  89098. * @param distToJoint Optional distance from the impostor to the joint.
  89099. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  89100. */
  89101. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  89102. /**
  89103. * Sync impostor to a bone
  89104. * @param bone The bone that the impostor will be synced to.
  89105. * @param boneMesh The mesh that the bone is influencing.
  89106. * @param jointPivot The pivot of the joint / bone in local space.
  89107. * @param distToJoint Optional distance from the impostor to the joint.
  89108. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  89109. * @param boneAxis Optional vector3 axis the bone is aligned with
  89110. */
  89111. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  89112. /**
  89113. * No-Imposter type
  89114. */
  89115. static NoImpostor: number;
  89116. /**
  89117. * Sphere-Imposter type
  89118. */
  89119. static SphereImpostor: number;
  89120. /**
  89121. * Box-Imposter type
  89122. */
  89123. static BoxImpostor: number;
  89124. /**
  89125. * Plane-Imposter type
  89126. */
  89127. static PlaneImpostor: number;
  89128. /**
  89129. * Mesh-imposter type
  89130. */
  89131. static MeshImpostor: number;
  89132. /**
  89133. * Capsule-Impostor type (Ammo.js plugin only)
  89134. */
  89135. static CapsuleImpostor: number;
  89136. /**
  89137. * Cylinder-Imposter type
  89138. */
  89139. static CylinderImpostor: number;
  89140. /**
  89141. * Particle-Imposter type
  89142. */
  89143. static ParticleImpostor: number;
  89144. /**
  89145. * Heightmap-Imposter type
  89146. */
  89147. static HeightmapImpostor: number;
  89148. /**
  89149. * ConvexHull-Impostor type (Ammo.js plugin only)
  89150. */
  89151. static ConvexHullImpostor: number;
  89152. /**
  89153. * Rope-Imposter type
  89154. */
  89155. static RopeImpostor: number;
  89156. /**
  89157. * Cloth-Imposter type
  89158. */
  89159. static ClothImpostor: number;
  89160. /**
  89161. * Softbody-Imposter type
  89162. */
  89163. static SoftbodyImpostor: number;
  89164. }
  89165. }
  89166. declare module BABYLON {
  89167. /**
  89168. * @hidden
  89169. **/
  89170. export class _CreationDataStorage {
  89171. closePath?: boolean;
  89172. closeArray?: boolean;
  89173. idx: number[];
  89174. dashSize: number;
  89175. gapSize: number;
  89176. path3D: Path3D;
  89177. pathArray: Vector3[][];
  89178. arc: number;
  89179. radius: number;
  89180. cap: number;
  89181. tessellation: number;
  89182. }
  89183. /**
  89184. * @hidden
  89185. **/
  89186. class _InstanceDataStorage {
  89187. visibleInstances: any;
  89188. batchCache: _InstancesBatch;
  89189. instancesBufferSize: number;
  89190. instancesBuffer: Nullable<Buffer>;
  89191. instancesData: Float32Array;
  89192. overridenInstanceCount: number;
  89193. isFrozen: boolean;
  89194. previousBatch: Nullable<_InstancesBatch>;
  89195. hardwareInstancedRendering: boolean;
  89196. sideOrientation: number;
  89197. }
  89198. /**
  89199. * @hidden
  89200. **/
  89201. export class _InstancesBatch {
  89202. mustReturn: boolean;
  89203. visibleInstances: Nullable<InstancedMesh[]>[];
  89204. renderSelf: boolean[];
  89205. hardwareInstancedRendering: boolean[];
  89206. }
  89207. /**
  89208. * Class used to represent renderable models
  89209. */
  89210. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  89211. /**
  89212. * Mesh side orientation : usually the external or front surface
  89213. */
  89214. static readonly FRONTSIDE: number;
  89215. /**
  89216. * Mesh side orientation : usually the internal or back surface
  89217. */
  89218. static readonly BACKSIDE: number;
  89219. /**
  89220. * Mesh side orientation : both internal and external or front and back surfaces
  89221. */
  89222. static readonly DOUBLESIDE: number;
  89223. /**
  89224. * Mesh side orientation : by default, `FRONTSIDE`
  89225. */
  89226. static readonly DEFAULTSIDE: number;
  89227. /**
  89228. * Mesh cap setting : no cap
  89229. */
  89230. static readonly NO_CAP: number;
  89231. /**
  89232. * Mesh cap setting : one cap at the beginning of the mesh
  89233. */
  89234. static readonly CAP_START: number;
  89235. /**
  89236. * Mesh cap setting : one cap at the end of the mesh
  89237. */
  89238. static readonly CAP_END: number;
  89239. /**
  89240. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  89241. */
  89242. static readonly CAP_ALL: number;
  89243. /**
  89244. * Mesh pattern setting : no flip or rotate
  89245. */
  89246. static readonly NO_FLIP: number;
  89247. /**
  89248. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  89249. */
  89250. static readonly FLIP_TILE: number;
  89251. /**
  89252. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  89253. */
  89254. static readonly ROTATE_TILE: number;
  89255. /**
  89256. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  89257. */
  89258. static readonly FLIP_ROW: number;
  89259. /**
  89260. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  89261. */
  89262. static readonly ROTATE_ROW: number;
  89263. /**
  89264. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  89265. */
  89266. static readonly FLIP_N_ROTATE_TILE: number;
  89267. /**
  89268. * Mesh pattern setting : rotate pattern and rotate
  89269. */
  89270. static readonly FLIP_N_ROTATE_ROW: number;
  89271. /**
  89272. * Mesh tile positioning : part tiles same on left/right or top/bottom
  89273. */
  89274. static readonly CENTER: number;
  89275. /**
  89276. * Mesh tile positioning : part tiles on left
  89277. */
  89278. static readonly LEFT: number;
  89279. /**
  89280. * Mesh tile positioning : part tiles on right
  89281. */
  89282. static readonly RIGHT: number;
  89283. /**
  89284. * Mesh tile positioning : part tiles on top
  89285. */
  89286. static readonly TOP: number;
  89287. /**
  89288. * Mesh tile positioning : part tiles on bottom
  89289. */
  89290. static readonly BOTTOM: number;
  89291. /**
  89292. * Gets the default side orientation.
  89293. * @param orientation the orientation to value to attempt to get
  89294. * @returns the default orientation
  89295. * @hidden
  89296. */
  89297. static _GetDefaultSideOrientation(orientation?: number): number;
  89298. private _internalMeshDataInfo;
  89299. /**
  89300. * An event triggered before rendering the mesh
  89301. */
  89302. readonly onBeforeRenderObservable: Observable<Mesh>;
  89303. /**
  89304. * An event triggered before binding the mesh
  89305. */
  89306. readonly onBeforeBindObservable: Observable<Mesh>;
  89307. /**
  89308. * An event triggered after rendering the mesh
  89309. */
  89310. readonly onAfterRenderObservable: Observable<Mesh>;
  89311. /**
  89312. * An event triggered before drawing the mesh
  89313. */
  89314. readonly onBeforeDrawObservable: Observable<Mesh>;
  89315. private _onBeforeDrawObserver;
  89316. /**
  89317. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  89318. */
  89319. onBeforeDraw: () => void;
  89320. readonly hasInstances: boolean;
  89321. /**
  89322. * Gets the delay loading state of the mesh (when delay loading is turned on)
  89323. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  89324. */
  89325. delayLoadState: number;
  89326. /**
  89327. * Gets the list of instances created from this mesh
  89328. * it is not supposed to be modified manually.
  89329. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  89330. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  89331. */
  89332. instances: InstancedMesh[];
  89333. /**
  89334. * Gets the file containing delay loading data for this mesh
  89335. */
  89336. delayLoadingFile: string;
  89337. /** @hidden */
  89338. _binaryInfo: any;
  89339. /**
  89340. * User defined function used to change how LOD level selection is done
  89341. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  89342. */
  89343. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  89344. /**
  89345. * Gets or sets the morph target manager
  89346. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  89347. */
  89348. morphTargetManager: Nullable<MorphTargetManager>;
  89349. /** @hidden */
  89350. _creationDataStorage: Nullable<_CreationDataStorage>;
  89351. /** @hidden */
  89352. _geometry: Nullable<Geometry>;
  89353. /** @hidden */
  89354. _delayInfo: Array<string>;
  89355. /** @hidden */
  89356. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  89357. /** @hidden */
  89358. _instanceDataStorage: _InstanceDataStorage;
  89359. private _effectiveMaterial;
  89360. /** @hidden */
  89361. _shouldGenerateFlatShading: boolean;
  89362. /** @hidden */
  89363. _originalBuilderSideOrientation: number;
  89364. /**
  89365. * Use this property to change the original side orientation defined at construction time
  89366. */
  89367. overrideMaterialSideOrientation: Nullable<number>;
  89368. /**
  89369. * Gets the source mesh (the one used to clone this one from)
  89370. */
  89371. readonly source: Nullable<Mesh>;
  89372. /**
  89373. * Gets or sets a boolean indicating that this mesh does not use index buffer
  89374. */
  89375. isUnIndexed: boolean;
  89376. /**
  89377. * @constructor
  89378. * @param name The value used by scene.getMeshByName() to do a lookup.
  89379. * @param scene The scene to add this mesh to.
  89380. * @param parent The parent of this mesh, if it has one
  89381. * @param source An optional Mesh from which geometry is shared, cloned.
  89382. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  89383. * When false, achieved by calling a clone(), also passing False.
  89384. * This will make creation of children, recursive.
  89385. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  89386. */
  89387. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  89388. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  89389. /**
  89390. * Gets the class name
  89391. * @returns the string "Mesh".
  89392. */
  89393. getClassName(): string;
  89394. /** @hidden */
  89395. readonly _isMesh: boolean;
  89396. /**
  89397. * Returns a description of this mesh
  89398. * @param fullDetails define if full details about this mesh must be used
  89399. * @returns a descriptive string representing this mesh
  89400. */
  89401. toString(fullDetails?: boolean): string;
  89402. /** @hidden */
  89403. _unBindEffect(): void;
  89404. /**
  89405. * Gets a boolean indicating if this mesh has LOD
  89406. */
  89407. readonly hasLODLevels: boolean;
  89408. /**
  89409. * Gets the list of MeshLODLevel associated with the current mesh
  89410. * @returns an array of MeshLODLevel
  89411. */
  89412. getLODLevels(): MeshLODLevel[];
  89413. private _sortLODLevels;
  89414. /**
  89415. * Add a mesh as LOD level triggered at the given distance.
  89416. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89417. * @param distance The distance from the center of the object to show this level
  89418. * @param mesh The mesh to be added as LOD level (can be null)
  89419. * @return This mesh (for chaining)
  89420. */
  89421. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  89422. /**
  89423. * Returns the LOD level mesh at the passed distance or null if not found.
  89424. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89425. * @param distance The distance from the center of the object to show this level
  89426. * @returns a Mesh or `null`
  89427. */
  89428. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  89429. /**
  89430. * Remove a mesh from the LOD array
  89431. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89432. * @param mesh defines the mesh to be removed
  89433. * @return This mesh (for chaining)
  89434. */
  89435. removeLODLevel(mesh: Mesh): Mesh;
  89436. /**
  89437. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  89438. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89439. * @param camera defines the camera to use to compute distance
  89440. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  89441. * @return This mesh (for chaining)
  89442. */
  89443. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  89444. /**
  89445. * Gets the mesh internal Geometry object
  89446. */
  89447. readonly geometry: Nullable<Geometry>;
  89448. /**
  89449. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  89450. * @returns the total number of vertices
  89451. */
  89452. getTotalVertices(): number;
  89453. /**
  89454. * Returns the content of an associated vertex buffer
  89455. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  89456. * - VertexBuffer.PositionKind
  89457. * - VertexBuffer.UVKind
  89458. * - VertexBuffer.UV2Kind
  89459. * - VertexBuffer.UV3Kind
  89460. * - VertexBuffer.UV4Kind
  89461. * - VertexBuffer.UV5Kind
  89462. * - VertexBuffer.UV6Kind
  89463. * - VertexBuffer.ColorKind
  89464. * - VertexBuffer.MatricesIndicesKind
  89465. * - VertexBuffer.MatricesIndicesExtraKind
  89466. * - VertexBuffer.MatricesWeightsKind
  89467. * - VertexBuffer.MatricesWeightsExtraKind
  89468. * @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
  89469. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  89470. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  89471. */
  89472. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  89473. /**
  89474. * Returns the mesh VertexBuffer object from the requested `kind`
  89475. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  89476. * - VertexBuffer.PositionKind
  89477. * - VertexBuffer.NormalKind
  89478. * - VertexBuffer.UVKind
  89479. * - VertexBuffer.UV2Kind
  89480. * - VertexBuffer.UV3Kind
  89481. * - VertexBuffer.UV4Kind
  89482. * - VertexBuffer.UV5Kind
  89483. * - VertexBuffer.UV6Kind
  89484. * - VertexBuffer.ColorKind
  89485. * - VertexBuffer.MatricesIndicesKind
  89486. * - VertexBuffer.MatricesIndicesExtraKind
  89487. * - VertexBuffer.MatricesWeightsKind
  89488. * - VertexBuffer.MatricesWeightsExtraKind
  89489. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  89490. */
  89491. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  89492. /**
  89493. * Tests if a specific vertex buffer is associated with this mesh
  89494. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  89495. * - VertexBuffer.PositionKind
  89496. * - VertexBuffer.NormalKind
  89497. * - VertexBuffer.UVKind
  89498. * - VertexBuffer.UV2Kind
  89499. * - VertexBuffer.UV3Kind
  89500. * - VertexBuffer.UV4Kind
  89501. * - VertexBuffer.UV5Kind
  89502. * - VertexBuffer.UV6Kind
  89503. * - VertexBuffer.ColorKind
  89504. * - VertexBuffer.MatricesIndicesKind
  89505. * - VertexBuffer.MatricesIndicesExtraKind
  89506. * - VertexBuffer.MatricesWeightsKind
  89507. * - VertexBuffer.MatricesWeightsExtraKind
  89508. * @returns a boolean
  89509. */
  89510. isVerticesDataPresent(kind: string): boolean;
  89511. /**
  89512. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  89513. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  89514. * - VertexBuffer.PositionKind
  89515. * - VertexBuffer.UVKind
  89516. * - VertexBuffer.UV2Kind
  89517. * - VertexBuffer.UV3Kind
  89518. * - VertexBuffer.UV4Kind
  89519. * - VertexBuffer.UV5Kind
  89520. * - VertexBuffer.UV6Kind
  89521. * - VertexBuffer.ColorKind
  89522. * - VertexBuffer.MatricesIndicesKind
  89523. * - VertexBuffer.MatricesIndicesExtraKind
  89524. * - VertexBuffer.MatricesWeightsKind
  89525. * - VertexBuffer.MatricesWeightsExtraKind
  89526. * @returns a boolean
  89527. */
  89528. isVertexBufferUpdatable(kind: string): boolean;
  89529. /**
  89530. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  89531. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  89532. * - VertexBuffer.PositionKind
  89533. * - VertexBuffer.NormalKind
  89534. * - VertexBuffer.UVKind
  89535. * - VertexBuffer.UV2Kind
  89536. * - VertexBuffer.UV3Kind
  89537. * - VertexBuffer.UV4Kind
  89538. * - VertexBuffer.UV5Kind
  89539. * - VertexBuffer.UV6Kind
  89540. * - VertexBuffer.ColorKind
  89541. * - VertexBuffer.MatricesIndicesKind
  89542. * - VertexBuffer.MatricesIndicesExtraKind
  89543. * - VertexBuffer.MatricesWeightsKind
  89544. * - VertexBuffer.MatricesWeightsExtraKind
  89545. * @returns an array of strings
  89546. */
  89547. getVerticesDataKinds(): string[];
  89548. /**
  89549. * Returns a positive integer : the total number of indices in this mesh geometry.
  89550. * @returns the numner of indices or zero if the mesh has no geometry.
  89551. */
  89552. getTotalIndices(): number;
  89553. /**
  89554. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  89555. * @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.
  89556. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89557. * @returns the indices array or an empty array if the mesh has no geometry
  89558. */
  89559. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  89560. readonly isBlocked: boolean;
  89561. /**
  89562. * Determine if the current mesh is ready to be rendered
  89563. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  89564. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  89565. * @returns true if all associated assets are ready (material, textures, shaders)
  89566. */
  89567. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  89568. /**
  89569. * 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.
  89570. */
  89571. readonly areNormalsFrozen: boolean;
  89572. /**
  89573. * 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.
  89574. * @returns the current mesh
  89575. */
  89576. freezeNormals(): Mesh;
  89577. /**
  89578. * 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
  89579. * @returns the current mesh
  89580. */
  89581. unfreezeNormals(): Mesh;
  89582. /**
  89583. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  89584. */
  89585. overridenInstanceCount: number;
  89586. /** @hidden */
  89587. _preActivate(): Mesh;
  89588. /** @hidden */
  89589. _preActivateForIntermediateRendering(renderId: number): Mesh;
  89590. /** @hidden */
  89591. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  89592. /**
  89593. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  89594. * This means the mesh underlying bounding box and sphere are recomputed.
  89595. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  89596. * @returns the current mesh
  89597. */
  89598. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  89599. /** @hidden */
  89600. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  89601. /**
  89602. * This function will subdivide the mesh into multiple submeshes
  89603. * @param count defines the expected number of submeshes
  89604. */
  89605. subdivide(count: number): void;
  89606. /**
  89607. * Copy a FloatArray into a specific associated vertex buffer
  89608. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  89609. * - VertexBuffer.PositionKind
  89610. * - VertexBuffer.UVKind
  89611. * - VertexBuffer.UV2Kind
  89612. * - VertexBuffer.UV3Kind
  89613. * - VertexBuffer.UV4Kind
  89614. * - VertexBuffer.UV5Kind
  89615. * - VertexBuffer.UV6Kind
  89616. * - VertexBuffer.ColorKind
  89617. * - VertexBuffer.MatricesIndicesKind
  89618. * - VertexBuffer.MatricesIndicesExtraKind
  89619. * - VertexBuffer.MatricesWeightsKind
  89620. * - VertexBuffer.MatricesWeightsExtraKind
  89621. * @param data defines the data source
  89622. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  89623. * @param stride defines the data stride size (can be null)
  89624. * @returns the current mesh
  89625. */
  89626. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  89627. /**
  89628. * Flags an associated vertex buffer as updatable
  89629. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  89630. * - VertexBuffer.PositionKind
  89631. * - VertexBuffer.UVKind
  89632. * - VertexBuffer.UV2Kind
  89633. * - VertexBuffer.UV3Kind
  89634. * - VertexBuffer.UV4Kind
  89635. * - VertexBuffer.UV5Kind
  89636. * - VertexBuffer.UV6Kind
  89637. * - VertexBuffer.ColorKind
  89638. * - VertexBuffer.MatricesIndicesKind
  89639. * - VertexBuffer.MatricesIndicesExtraKind
  89640. * - VertexBuffer.MatricesWeightsKind
  89641. * - VertexBuffer.MatricesWeightsExtraKind
  89642. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  89643. */
  89644. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  89645. /**
  89646. * Sets the mesh global Vertex Buffer
  89647. * @param buffer defines the buffer to use
  89648. * @returns the current mesh
  89649. */
  89650. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  89651. /**
  89652. * Update a specific associated vertex buffer
  89653. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  89654. * - VertexBuffer.PositionKind
  89655. * - VertexBuffer.UVKind
  89656. * - VertexBuffer.UV2Kind
  89657. * - VertexBuffer.UV3Kind
  89658. * - VertexBuffer.UV4Kind
  89659. * - VertexBuffer.UV5Kind
  89660. * - VertexBuffer.UV6Kind
  89661. * - VertexBuffer.ColorKind
  89662. * - VertexBuffer.MatricesIndicesKind
  89663. * - VertexBuffer.MatricesIndicesExtraKind
  89664. * - VertexBuffer.MatricesWeightsKind
  89665. * - VertexBuffer.MatricesWeightsExtraKind
  89666. * @param data defines the data source
  89667. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  89668. * @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)
  89669. * @returns the current mesh
  89670. */
  89671. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  89672. /**
  89673. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  89674. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  89675. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  89676. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  89677. * @returns the current mesh
  89678. */
  89679. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  89680. /**
  89681. * Creates a un-shared specific occurence of the geometry for the mesh.
  89682. * @returns the current mesh
  89683. */
  89684. makeGeometryUnique(): Mesh;
  89685. /**
  89686. * Set the index buffer of this mesh
  89687. * @param indices defines the source data
  89688. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  89689. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  89690. * @returns the current mesh
  89691. */
  89692. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  89693. /**
  89694. * Update the current index buffer
  89695. * @param indices defines the source data
  89696. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  89697. * @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)
  89698. * @returns the current mesh
  89699. */
  89700. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  89701. /**
  89702. * Invert the geometry to move from a right handed system to a left handed one.
  89703. * @returns the current mesh
  89704. */
  89705. toLeftHanded(): Mesh;
  89706. /** @hidden */
  89707. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  89708. /** @hidden */
  89709. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  89710. /**
  89711. * Registers for this mesh a javascript function called just before the rendering process
  89712. * @param func defines the function to call before rendering this mesh
  89713. * @returns the current mesh
  89714. */
  89715. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  89716. /**
  89717. * Disposes a previously registered javascript function called before the rendering
  89718. * @param func defines the function to remove
  89719. * @returns the current mesh
  89720. */
  89721. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  89722. /**
  89723. * Registers for this mesh a javascript function called just after the rendering is complete
  89724. * @param func defines the function to call after rendering this mesh
  89725. * @returns the current mesh
  89726. */
  89727. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  89728. /**
  89729. * Disposes a previously registered javascript function called after the rendering.
  89730. * @param func defines the function to remove
  89731. * @returns the current mesh
  89732. */
  89733. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  89734. /** @hidden */
  89735. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  89736. /** @hidden */
  89737. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  89738. /** @hidden */
  89739. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  89740. /** @hidden */
  89741. _rebuild(): void;
  89742. /** @hidden */
  89743. _freeze(): void;
  89744. /** @hidden */
  89745. _unFreeze(): void;
  89746. /**
  89747. * 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
  89748. * @param subMesh defines the subMesh to render
  89749. * @param enableAlphaMode defines if alpha mode can be changed
  89750. * @returns the current mesh
  89751. */
  89752. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  89753. private _onBeforeDraw;
  89754. /**
  89755. * Renormalize the mesh and patch it up if there are no weights
  89756. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  89757. * However in the case of zero weights then we set just a single influence to 1.
  89758. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  89759. */
  89760. cleanMatrixWeights(): void;
  89761. private normalizeSkinFourWeights;
  89762. private normalizeSkinWeightsAndExtra;
  89763. /**
  89764. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  89765. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  89766. * the user know there was an issue with importing the mesh
  89767. * @returns a validation object with skinned, valid and report string
  89768. */
  89769. validateSkinning(): {
  89770. skinned: boolean;
  89771. valid: boolean;
  89772. report: string;
  89773. };
  89774. /** @hidden */
  89775. _checkDelayState(): Mesh;
  89776. private _queueLoad;
  89777. /**
  89778. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  89779. * A mesh is in the frustum if its bounding box intersects the frustum
  89780. * @param frustumPlanes defines the frustum to test
  89781. * @returns true if the mesh is in the frustum planes
  89782. */
  89783. isInFrustum(frustumPlanes: Plane[]): boolean;
  89784. /**
  89785. * Sets the mesh material by the material or multiMaterial `id` property
  89786. * @param id is a string identifying the material or the multiMaterial
  89787. * @returns the current mesh
  89788. */
  89789. setMaterialByID(id: string): Mesh;
  89790. /**
  89791. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  89792. * @returns an array of IAnimatable
  89793. */
  89794. getAnimatables(): IAnimatable[];
  89795. /**
  89796. * Modifies the mesh geometry according to the passed transformation matrix.
  89797. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  89798. * The mesh normals are modified using the same transformation.
  89799. * Note that, under the hood, this method sets a new VertexBuffer each call.
  89800. * @param transform defines the transform matrix to use
  89801. * @see http://doc.babylonjs.com/resources/baking_transformations
  89802. * @returns the current mesh
  89803. */
  89804. bakeTransformIntoVertices(transform: Matrix): Mesh;
  89805. /**
  89806. * Modifies the mesh geometry according to its own current World Matrix.
  89807. * The mesh World Matrix is then reset.
  89808. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  89809. * Note that, under the hood, this method sets a new VertexBuffer each call.
  89810. * @see http://doc.babylonjs.com/resources/baking_transformations
  89811. * @returns the current mesh
  89812. */
  89813. bakeCurrentTransformIntoVertices(): Mesh;
  89814. /** @hidden */
  89815. readonly _positions: Nullable<Vector3[]>;
  89816. /** @hidden */
  89817. _resetPointsArrayCache(): Mesh;
  89818. /** @hidden */
  89819. _generatePointsArray(): boolean;
  89820. /**
  89821. * Returns a new Mesh object generated from the current mesh properties.
  89822. * This method must not get confused with createInstance()
  89823. * @param name is a string, the name given to the new mesh
  89824. * @param newParent can be any Node object (default `null`)
  89825. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  89826. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  89827. * @returns a new mesh
  89828. */
  89829. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  89830. /**
  89831. * Releases resources associated with this mesh.
  89832. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  89833. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  89834. */
  89835. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89836. /**
  89837. * Modifies the mesh geometry according to a displacement map.
  89838. * 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.
  89839. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  89840. * @param url is a string, the URL from the image file is to be downloaded.
  89841. * @param minHeight is the lower limit of the displacement.
  89842. * @param maxHeight is the upper limit of the displacement.
  89843. * @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.
  89844. * @param uvOffset is an optional vector2 used to offset UV.
  89845. * @param uvScale is an optional vector2 used to scale UV.
  89846. * @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.
  89847. * @returns the Mesh.
  89848. */
  89849. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  89850. /**
  89851. * Modifies the mesh geometry according to a displacementMap buffer.
  89852. * 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.
  89853. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  89854. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  89855. * @param heightMapWidth is the width of the buffer image.
  89856. * @param heightMapHeight is the height of the buffer image.
  89857. * @param minHeight is the lower limit of the displacement.
  89858. * @param maxHeight is the upper limit of the displacement.
  89859. * @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.
  89860. * @param uvOffset is an optional vector2 used to offset UV.
  89861. * @param uvScale is an optional vector2 used to scale UV.
  89862. * @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.
  89863. * @returns the Mesh.
  89864. */
  89865. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  89866. /**
  89867. * Modify the mesh to get a flat shading rendering.
  89868. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  89869. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  89870. * @returns current mesh
  89871. */
  89872. convertToFlatShadedMesh(): Mesh;
  89873. /**
  89874. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  89875. * In other words, more vertices, no more indices and a single bigger VBO.
  89876. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  89877. * @returns current mesh
  89878. */
  89879. convertToUnIndexedMesh(): Mesh;
  89880. /**
  89881. * Inverses facet orientations.
  89882. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  89883. * @param flipNormals will also inverts the normals
  89884. * @returns current mesh
  89885. */
  89886. flipFaces(flipNormals?: boolean): Mesh;
  89887. /**
  89888. * Increase the number of facets and hence vertices in a mesh
  89889. * Vertex normals are interpolated from existing vertex normals
  89890. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  89891. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  89892. */
  89893. increaseVertices(numberPerEdge: number): void;
  89894. /**
  89895. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  89896. * This will undo any application of covertToFlatShadedMesh
  89897. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  89898. */
  89899. forceSharedVertices(): void;
  89900. /** @hidden */
  89901. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  89902. /** @hidden */
  89903. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  89904. /**
  89905. * Creates a new InstancedMesh object from the mesh model.
  89906. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  89907. * @param name defines the name of the new instance
  89908. * @returns a new InstancedMesh
  89909. */
  89910. createInstance(name: string): InstancedMesh;
  89911. /**
  89912. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  89913. * After this call, all the mesh instances have the same submeshes than the current mesh.
  89914. * @returns the current mesh
  89915. */
  89916. synchronizeInstances(): Mesh;
  89917. /**
  89918. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  89919. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  89920. * This should be used together with the simplification to avoid disappearing triangles.
  89921. * @param successCallback an optional success callback to be called after the optimization finished.
  89922. * @returns the current mesh
  89923. */
  89924. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  89925. /**
  89926. * Serialize current mesh
  89927. * @param serializationObject defines the object which will receive the serialization data
  89928. */
  89929. serialize(serializationObject: any): void;
  89930. /** @hidden */
  89931. _syncGeometryWithMorphTargetManager(): void;
  89932. /** @hidden */
  89933. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  89934. /**
  89935. * Returns a new Mesh object parsed from the source provided.
  89936. * @param parsedMesh is the source
  89937. * @param scene defines the hosting scene
  89938. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  89939. * @returns a new Mesh
  89940. */
  89941. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  89942. /**
  89943. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  89944. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  89945. * @param name defines the name of the mesh to create
  89946. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  89947. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  89948. * @param closePath creates a seam between the first and the last points of each path of the path array
  89949. * @param offset is taken in account only if the `pathArray` is containing a single path
  89950. * @param scene defines the hosting scene
  89951. * @param updatable defines if the mesh must be flagged as updatable
  89952. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89953. * @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)
  89954. * @returns a new Mesh
  89955. */
  89956. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  89957. /**
  89958. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  89959. * @param name defines the name of the mesh to create
  89960. * @param radius sets the radius size (float) of the polygon (default 0.5)
  89961. * @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
  89962. * @param scene defines the hosting scene
  89963. * @param updatable defines if the mesh must be flagged as updatable
  89964. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89965. * @returns a new Mesh
  89966. */
  89967. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  89968. /**
  89969. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  89970. * @param name defines the name of the mesh to create
  89971. * @param size sets the size (float) of each box side (default 1)
  89972. * @param scene defines the hosting scene
  89973. * @param updatable defines if the mesh must be flagged as updatable
  89974. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89975. * @returns a new Mesh
  89976. */
  89977. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  89978. /**
  89979. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  89980. * @param name defines the name of the mesh to create
  89981. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  89982. * @param diameter sets the diameter size (float) of the sphere (default 1)
  89983. * @param scene defines the hosting scene
  89984. * @param updatable defines if the mesh must be flagged as updatable
  89985. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89986. * @returns a new Mesh
  89987. */
  89988. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  89989. /**
  89990. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  89991. * @param name defines the name of the mesh to create
  89992. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  89993. * @param diameter sets the diameter size (float) of the sphere (default 1)
  89994. * @param scene defines the hosting scene
  89995. * @returns a new Mesh
  89996. */
  89997. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  89998. /**
  89999. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  90000. * @param name defines the name of the mesh to create
  90001. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  90002. * @param diameterTop set the top cap diameter (floats, default 1)
  90003. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  90004. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  90005. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  90006. * @param scene defines the hosting scene
  90007. * @param updatable defines if the mesh must be flagged as updatable
  90008. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90009. * @returns a new Mesh
  90010. */
  90011. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  90012. /**
  90013. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  90014. * @param name defines the name of the mesh to create
  90015. * @param diameter sets the diameter size (float) of the torus (default 1)
  90016. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  90017. * @param tessellation sets the number of torus sides (postive integer, default 16)
  90018. * @param scene defines the hosting scene
  90019. * @param updatable defines if the mesh must be flagged as updatable
  90020. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90021. * @returns a new Mesh
  90022. */
  90023. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90024. /**
  90025. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  90026. * @param name defines the name of the mesh to create
  90027. * @param radius sets the global radius size (float) of the torus knot (default 2)
  90028. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  90029. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  90030. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  90031. * @param p the number of windings on X axis (positive integers, default 2)
  90032. * @param q the number of windings on Y axis (positive integers, default 3)
  90033. * @param scene defines the hosting scene
  90034. * @param updatable defines if the mesh must be flagged as updatable
  90035. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90036. * @returns a new Mesh
  90037. */
  90038. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90039. /**
  90040. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  90041. * @param name defines the name of the mesh to create
  90042. * @param points is an array successive Vector3
  90043. * @param scene defines the hosting scene
  90044. * @param updatable defines if the mesh must be flagged as updatable
  90045. * @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).
  90046. * @returns a new Mesh
  90047. */
  90048. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  90049. /**
  90050. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  90051. * @param name defines the name of the mesh to create
  90052. * @param points is an array successive Vector3
  90053. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  90054. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  90055. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  90056. * @param scene defines the hosting scene
  90057. * @param updatable defines if the mesh must be flagged as updatable
  90058. * @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)
  90059. * @returns a new Mesh
  90060. */
  90061. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  90062. /**
  90063. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  90064. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  90065. * 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.
  90066. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90067. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  90068. * Remember you can only change the shape positions, not their number when updating a polygon.
  90069. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  90070. * @param name defines the name of the mesh to create
  90071. * @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
  90072. * @param scene defines the hosting scene
  90073. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  90074. * @param updatable defines if the mesh must be flagged as updatable
  90075. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90076. * @param earcutInjection can be used to inject your own earcut reference
  90077. * @returns a new Mesh
  90078. */
  90079. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  90080. /**
  90081. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  90082. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  90083. * @param name defines the name of the mesh to create
  90084. * @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
  90085. * @param depth defines the height of extrusion
  90086. * @param scene defines the hosting scene
  90087. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  90088. * @param updatable defines if the mesh must be flagged as updatable
  90089. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90090. * @param earcutInjection can be used to inject your own earcut reference
  90091. * @returns a new Mesh
  90092. */
  90093. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  90094. /**
  90095. * Creates an extruded shape mesh.
  90096. * 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
  90097. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  90098. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  90099. * @param name defines the name of the mesh to create
  90100. * @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
  90101. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  90102. * @param scale is the value to scale the shape
  90103. * @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
  90104. * @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
  90105. * @param scene defines the hosting scene
  90106. * @param updatable defines if the mesh must be flagged as updatable
  90107. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90108. * @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)
  90109. * @returns a new Mesh
  90110. */
  90111. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  90112. /**
  90113. * Creates an custom extruded shape mesh.
  90114. * The custom extrusion is a parametric shape.
  90115. * It has no predefined shape. Its final shape will depend on the input parameters.
  90116. * Please consider using the same method from the MeshBuilder class instead
  90117. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  90118. * @param name defines the name of the mesh to create
  90119. * @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
  90120. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  90121. * @param scaleFunction is a custom Javascript function called on each path point
  90122. * @param rotationFunction is a custom Javascript function called on each path point
  90123. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  90124. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  90125. * @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
  90126. * @param scene defines the hosting scene
  90127. * @param updatable defines if the mesh must be flagged as updatable
  90128. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90129. * @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)
  90130. * @returns a new Mesh
  90131. */
  90132. 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;
  90133. /**
  90134. * Creates lathe mesh.
  90135. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  90136. * Please consider using the same method from the MeshBuilder class instead
  90137. * @param name defines the name of the mesh to create
  90138. * @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
  90139. * @param radius is the radius value of the lathe
  90140. * @param tessellation is the side number of the lathe.
  90141. * @param scene defines the hosting scene
  90142. * @param updatable defines if the mesh must be flagged as updatable
  90143. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90144. * @returns a new Mesh
  90145. */
  90146. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90147. /**
  90148. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  90149. * @param name defines the name of the mesh to create
  90150. * @param size sets the size (float) of both sides of the plane at once (default 1)
  90151. * @param scene defines the hosting scene
  90152. * @param updatable defines if the mesh must be flagged as updatable
  90153. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90154. * @returns a new Mesh
  90155. */
  90156. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90157. /**
  90158. * Creates a ground mesh.
  90159. * Please consider using the same method from the MeshBuilder class instead
  90160. * @param name defines the name of the mesh to create
  90161. * @param width set the width of the ground
  90162. * @param height set the height of the ground
  90163. * @param subdivisions sets the number of subdivisions per side
  90164. * @param scene defines the hosting scene
  90165. * @param updatable defines if the mesh must be flagged as updatable
  90166. * @returns a new Mesh
  90167. */
  90168. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  90169. /**
  90170. * Creates a tiled ground mesh.
  90171. * Please consider using the same method from the MeshBuilder class instead
  90172. * @param name defines the name of the mesh to create
  90173. * @param xmin set the ground minimum X coordinate
  90174. * @param zmin set the ground minimum Y coordinate
  90175. * @param xmax set the ground maximum X coordinate
  90176. * @param zmax set the ground maximum Z coordinate
  90177. * @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
  90178. * @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
  90179. * @param scene defines the hosting scene
  90180. * @param updatable defines if the mesh must be flagged as updatable
  90181. * @returns a new Mesh
  90182. */
  90183. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  90184. w: number;
  90185. h: number;
  90186. }, precision: {
  90187. w: number;
  90188. h: number;
  90189. }, scene: Scene, updatable?: boolean): Mesh;
  90190. /**
  90191. * Creates a ground mesh from a height map.
  90192. * Please consider using the same method from the MeshBuilder class instead
  90193. * @see http://doc.babylonjs.com/babylon101/height_map
  90194. * @param name defines the name of the mesh to create
  90195. * @param url sets the URL of the height map image resource
  90196. * @param width set the ground width size
  90197. * @param height set the ground height size
  90198. * @param subdivisions sets the number of subdivision per side
  90199. * @param minHeight is the minimum altitude on the ground
  90200. * @param maxHeight is the maximum altitude on the ground
  90201. * @param scene defines the hosting scene
  90202. * @param updatable defines if the mesh must be flagged as updatable
  90203. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  90204. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  90205. * @returns a new Mesh
  90206. */
  90207. 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;
  90208. /**
  90209. * Creates a tube mesh.
  90210. * The tube is a parametric shape.
  90211. * It has no predefined shape. Its final shape will depend on the input parameters.
  90212. * Please consider using the same method from the MeshBuilder class instead
  90213. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  90214. * @param name defines the name of the mesh to create
  90215. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  90216. * @param radius sets the tube radius size
  90217. * @param tessellation is the number of sides on the tubular surface
  90218. * @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
  90219. * @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
  90220. * @param scene defines the hosting scene
  90221. * @param updatable defines if the mesh must be flagged as updatable
  90222. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90223. * @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)
  90224. * @returns a new Mesh
  90225. */
  90226. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  90227. (i: number, distance: number): number;
  90228. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  90229. /**
  90230. * Creates a polyhedron mesh.
  90231. * Please consider using the same method from the MeshBuilder class instead.
  90232. * * 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
  90233. * * The parameter `size` (positive float, default 1) sets the polygon size
  90234. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  90235. * * 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`
  90236. * * 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
  90237. * * 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)`)
  90238. * * 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
  90239. * * 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
  90240. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90241. * * If you create a double-sided mesh, you can choose what parts of 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
  90242. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90243. * @param name defines the name of the mesh to create
  90244. * @param options defines the options used to create the mesh
  90245. * @param scene defines the hosting scene
  90246. * @returns a new Mesh
  90247. */
  90248. static CreatePolyhedron(name: string, options: {
  90249. type?: number;
  90250. size?: number;
  90251. sizeX?: number;
  90252. sizeY?: number;
  90253. sizeZ?: number;
  90254. custom?: any;
  90255. faceUV?: Vector4[];
  90256. faceColors?: Color4[];
  90257. updatable?: boolean;
  90258. sideOrientation?: number;
  90259. }, scene: Scene): Mesh;
  90260. /**
  90261. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  90262. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  90263. * * 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`)
  90264. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  90265. * * 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
  90266. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90267. * * If you create a double-sided mesh, you can choose what parts of 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
  90268. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90269. * @param name defines the name of the mesh
  90270. * @param options defines the options used to create the mesh
  90271. * @param scene defines the hosting scene
  90272. * @returns a new Mesh
  90273. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  90274. */
  90275. static CreateIcoSphere(name: string, options: {
  90276. radius?: number;
  90277. flat?: boolean;
  90278. subdivisions?: number;
  90279. sideOrientation?: number;
  90280. updatable?: boolean;
  90281. }, scene: Scene): Mesh;
  90282. /**
  90283. * Creates a decal mesh.
  90284. * Please consider using the same method from the MeshBuilder class instead.
  90285. * A decal is a mesh usually applied as a model onto the surface of another mesh
  90286. * @param name defines the name of the mesh
  90287. * @param sourceMesh defines the mesh receiving the decal
  90288. * @param position sets the position of the decal in world coordinates
  90289. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  90290. * @param size sets the decal scaling
  90291. * @param angle sets the angle to rotate the decal
  90292. * @returns a new Mesh
  90293. */
  90294. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  90295. /**
  90296. * Prepare internal position array for software CPU skinning
  90297. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  90298. */
  90299. setPositionsForCPUSkinning(): Float32Array;
  90300. /**
  90301. * Prepare internal normal array for software CPU skinning
  90302. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  90303. */
  90304. setNormalsForCPUSkinning(): Float32Array;
  90305. /**
  90306. * Updates the vertex buffer by applying transformation from the bones
  90307. * @param skeleton defines the skeleton to apply to current mesh
  90308. * @returns the current mesh
  90309. */
  90310. applySkeleton(skeleton: Skeleton): Mesh;
  90311. /**
  90312. * 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
  90313. * @param meshes defines the list of meshes to scan
  90314. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  90315. */
  90316. static MinMax(meshes: AbstractMesh[]): {
  90317. min: Vector3;
  90318. max: Vector3;
  90319. };
  90320. /**
  90321. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  90322. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  90323. * @returns a vector3
  90324. */
  90325. static Center(meshesOrMinMaxVector: {
  90326. min: Vector3;
  90327. max: Vector3;
  90328. } | AbstractMesh[]): Vector3;
  90329. /**
  90330. * Merge the array of meshes into a single mesh for performance reasons.
  90331. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  90332. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  90333. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  90334. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  90335. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  90336. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  90337. * @returns a new mesh
  90338. */
  90339. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  90340. /** @hidden */
  90341. addInstance(instance: InstancedMesh): void;
  90342. /** @hidden */
  90343. removeInstance(instance: InstancedMesh): void;
  90344. }
  90345. }
  90346. declare module BABYLON {
  90347. /**
  90348. * This is the base class of all the camera used in the application.
  90349. * @see http://doc.babylonjs.com/features/cameras
  90350. */
  90351. export class Camera extends Node {
  90352. /** @hidden */
  90353. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  90354. /**
  90355. * This is the default projection mode used by the cameras.
  90356. * It helps recreating a feeling of perspective and better appreciate depth.
  90357. * This is the best way to simulate real life cameras.
  90358. */
  90359. static readonly PERSPECTIVE_CAMERA: number;
  90360. /**
  90361. * This helps creating camera with an orthographic mode.
  90362. * 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.
  90363. */
  90364. static readonly ORTHOGRAPHIC_CAMERA: number;
  90365. /**
  90366. * This is the default FOV mode for perspective cameras.
  90367. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  90368. */
  90369. static readonly FOVMODE_VERTICAL_FIXED: number;
  90370. /**
  90371. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  90372. */
  90373. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  90374. /**
  90375. * This specifies ther is no need for a camera rig.
  90376. * Basically only one eye is rendered corresponding to the camera.
  90377. */
  90378. static readonly RIG_MODE_NONE: number;
  90379. /**
  90380. * Simulates a camera Rig with one blue eye and one red eye.
  90381. * This can be use with 3d blue and red glasses.
  90382. */
  90383. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  90384. /**
  90385. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  90386. */
  90387. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  90388. /**
  90389. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  90390. */
  90391. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  90392. /**
  90393. * Defines that both eyes of the camera will be rendered over under each other.
  90394. */
  90395. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  90396. /**
  90397. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  90398. */
  90399. static readonly RIG_MODE_VR: number;
  90400. /**
  90401. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  90402. */
  90403. static readonly RIG_MODE_WEBVR: number;
  90404. /**
  90405. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  90406. */
  90407. static readonly RIG_MODE_CUSTOM: number;
  90408. /**
  90409. * Defines if by default attaching controls should prevent the default javascript event to continue.
  90410. */
  90411. static ForceAttachControlToAlwaysPreventDefault: boolean;
  90412. /**
  90413. * Define the input manager associated with the camera.
  90414. */
  90415. inputs: CameraInputsManager<Camera>;
  90416. /** @hidden */
  90417. _position: Vector3;
  90418. /**
  90419. * Define the current local position of the camera in the scene
  90420. */
  90421. position: Vector3;
  90422. /**
  90423. * The vector the camera should consider as up.
  90424. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  90425. */
  90426. upVector: Vector3;
  90427. /**
  90428. * Define the current limit on the left side for an orthographic camera
  90429. * In scene unit
  90430. */
  90431. orthoLeft: Nullable<number>;
  90432. /**
  90433. * Define the current limit on the right side for an orthographic camera
  90434. * In scene unit
  90435. */
  90436. orthoRight: Nullable<number>;
  90437. /**
  90438. * Define the current limit on the bottom side for an orthographic camera
  90439. * In scene unit
  90440. */
  90441. orthoBottom: Nullable<number>;
  90442. /**
  90443. * Define the current limit on the top side for an orthographic camera
  90444. * In scene unit
  90445. */
  90446. orthoTop: Nullable<number>;
  90447. /**
  90448. * Field Of View is set in Radians. (default is 0.8)
  90449. */
  90450. fov: number;
  90451. /**
  90452. * Define the minimum distance the camera can see from.
  90453. * This is important to note that the depth buffer are not infinite and the closer it starts
  90454. * the more your scene might encounter depth fighting issue.
  90455. */
  90456. minZ: number;
  90457. /**
  90458. * Define the maximum distance the camera can see to.
  90459. * This is important to note that the depth buffer are not infinite and the further it end
  90460. * the more your scene might encounter depth fighting issue.
  90461. */
  90462. maxZ: number;
  90463. /**
  90464. * Define the default inertia of the camera.
  90465. * This helps giving a smooth feeling to the camera movement.
  90466. */
  90467. inertia: number;
  90468. /**
  90469. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  90470. */
  90471. mode: number;
  90472. /**
  90473. * Define wether the camera is intermediate.
  90474. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  90475. */
  90476. isIntermediate: boolean;
  90477. /**
  90478. * Define the viewport of the camera.
  90479. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  90480. */
  90481. viewport: Viewport;
  90482. /**
  90483. * Restricts the camera to viewing objects with the same layerMask.
  90484. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  90485. */
  90486. layerMask: number;
  90487. /**
  90488. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  90489. */
  90490. fovMode: number;
  90491. /**
  90492. * Rig mode of the camera.
  90493. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  90494. * This is normally controlled byt the camera themselves as internal use.
  90495. */
  90496. cameraRigMode: number;
  90497. /**
  90498. * Defines the distance between both "eyes" in case of a RIG
  90499. */
  90500. interaxialDistance: number;
  90501. /**
  90502. * Defines if stereoscopic rendering is done side by side or over under.
  90503. */
  90504. isStereoscopicSideBySide: boolean;
  90505. /**
  90506. * 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
  90507. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  90508. * else in the scene. (Eg. security camera)
  90509. *
  90510. * 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)
  90511. */
  90512. customRenderTargets: RenderTargetTexture[];
  90513. /**
  90514. * When set, the camera will render to this render target instead of the default canvas
  90515. *
  90516. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  90517. */
  90518. outputRenderTarget: Nullable<RenderTargetTexture>;
  90519. /**
  90520. * Observable triggered when the camera view matrix has changed.
  90521. */
  90522. onViewMatrixChangedObservable: Observable<Camera>;
  90523. /**
  90524. * Observable triggered when the camera Projection matrix has changed.
  90525. */
  90526. onProjectionMatrixChangedObservable: Observable<Camera>;
  90527. /**
  90528. * Observable triggered when the inputs have been processed.
  90529. */
  90530. onAfterCheckInputsObservable: Observable<Camera>;
  90531. /**
  90532. * Observable triggered when reset has been called and applied to the camera.
  90533. */
  90534. onRestoreStateObservable: Observable<Camera>;
  90535. /** @hidden */
  90536. _cameraRigParams: any;
  90537. /** @hidden */
  90538. _rigCameras: Camera[];
  90539. /** @hidden */
  90540. _rigPostProcess: Nullable<PostProcess>;
  90541. protected _webvrViewMatrix: Matrix;
  90542. /** @hidden */
  90543. _skipRendering: boolean;
  90544. /** @hidden */
  90545. _projectionMatrix: Matrix;
  90546. /** @hidden */
  90547. _postProcesses: Nullable<PostProcess>[];
  90548. /** @hidden */
  90549. _activeMeshes: SmartArray<AbstractMesh>;
  90550. protected _globalPosition: Vector3;
  90551. /** @hidden */
  90552. _computedViewMatrix: Matrix;
  90553. private _doNotComputeProjectionMatrix;
  90554. private _transformMatrix;
  90555. private _frustumPlanes;
  90556. private _refreshFrustumPlanes;
  90557. private _storedFov;
  90558. private _stateStored;
  90559. /**
  90560. * Instantiates a new camera object.
  90561. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  90562. * @see http://doc.babylonjs.com/features/cameras
  90563. * @param name Defines the name of the camera in the scene
  90564. * @param position Defines the position of the camera
  90565. * @param scene Defines the scene the camera belongs too
  90566. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  90567. */
  90568. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  90569. /**
  90570. * Store current camera state (fov, position, etc..)
  90571. * @returns the camera
  90572. */
  90573. storeState(): Camera;
  90574. /**
  90575. * Restores the camera state values if it has been stored. You must call storeState() first
  90576. */
  90577. protected _restoreStateValues(): boolean;
  90578. /**
  90579. * Restored camera state. You must call storeState() first.
  90580. * @returns true if restored and false otherwise
  90581. */
  90582. restoreState(): boolean;
  90583. /**
  90584. * Gets the class name of the camera.
  90585. * @returns the class name
  90586. */
  90587. getClassName(): string;
  90588. /** @hidden */
  90589. readonly _isCamera: boolean;
  90590. /**
  90591. * Gets a string representation of the camera useful for debug purpose.
  90592. * @param fullDetails Defines that a more verboe level of logging is required
  90593. * @returns the string representation
  90594. */
  90595. toString(fullDetails?: boolean): string;
  90596. /**
  90597. * Gets the current world space position of the camera.
  90598. */
  90599. readonly globalPosition: Vector3;
  90600. /**
  90601. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  90602. * @returns the active meshe list
  90603. */
  90604. getActiveMeshes(): SmartArray<AbstractMesh>;
  90605. /**
  90606. * Check wether a mesh is part of the current active mesh list of the camera
  90607. * @param mesh Defines the mesh to check
  90608. * @returns true if active, false otherwise
  90609. */
  90610. isActiveMesh(mesh: Mesh): boolean;
  90611. /**
  90612. * Is this camera ready to be used/rendered
  90613. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  90614. * @return true if the camera is ready
  90615. */
  90616. isReady(completeCheck?: boolean): boolean;
  90617. /** @hidden */
  90618. _initCache(): void;
  90619. /** @hidden */
  90620. _updateCache(ignoreParentClass?: boolean): void;
  90621. /** @hidden */
  90622. _isSynchronized(): boolean;
  90623. /** @hidden */
  90624. _isSynchronizedViewMatrix(): boolean;
  90625. /** @hidden */
  90626. _isSynchronizedProjectionMatrix(): boolean;
  90627. /**
  90628. * Attach the input controls to a specific dom element to get the input from.
  90629. * @param element Defines the element the controls should be listened from
  90630. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90631. */
  90632. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90633. /**
  90634. * Detach the current controls from the specified dom element.
  90635. * @param element Defines the element to stop listening the inputs from
  90636. */
  90637. detachControl(element: HTMLElement): void;
  90638. /**
  90639. * Update the camera state according to the different inputs gathered during the frame.
  90640. */
  90641. update(): void;
  90642. /** @hidden */
  90643. _checkInputs(): void;
  90644. /** @hidden */
  90645. readonly rigCameras: Camera[];
  90646. /**
  90647. * Gets the post process used by the rig cameras
  90648. */
  90649. readonly rigPostProcess: Nullable<PostProcess>;
  90650. /**
  90651. * Internal, gets the first post proces.
  90652. * @returns the first post process to be run on this camera.
  90653. */
  90654. _getFirstPostProcess(): Nullable<PostProcess>;
  90655. private _cascadePostProcessesToRigCams;
  90656. /**
  90657. * Attach a post process to the camera.
  90658. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  90659. * @param postProcess The post process to attach to the camera
  90660. * @param insertAt The position of the post process in case several of them are in use in the scene
  90661. * @returns the position the post process has been inserted at
  90662. */
  90663. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  90664. /**
  90665. * Detach a post process to the camera.
  90666. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  90667. * @param postProcess The post process to detach from the camera
  90668. */
  90669. detachPostProcess(postProcess: PostProcess): void;
  90670. /**
  90671. * Gets the current world matrix of the camera
  90672. */
  90673. getWorldMatrix(): Matrix;
  90674. /** @hidden */
  90675. _getViewMatrix(): Matrix;
  90676. /**
  90677. * Gets the current view matrix of the camera.
  90678. * @param force forces the camera to recompute the matrix without looking at the cached state
  90679. * @returns the view matrix
  90680. */
  90681. getViewMatrix(force?: boolean): Matrix;
  90682. /**
  90683. * Freeze the projection matrix.
  90684. * It will prevent the cache check of the camera projection compute and can speed up perf
  90685. * if no parameter of the camera are meant to change
  90686. * @param projection Defines manually a projection if necessary
  90687. */
  90688. freezeProjectionMatrix(projection?: Matrix): void;
  90689. /**
  90690. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  90691. */
  90692. unfreezeProjectionMatrix(): void;
  90693. /**
  90694. * Gets the current projection matrix of the camera.
  90695. * @param force forces the camera to recompute the matrix without looking at the cached state
  90696. * @returns the projection matrix
  90697. */
  90698. getProjectionMatrix(force?: boolean): Matrix;
  90699. /**
  90700. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  90701. * @returns a Matrix
  90702. */
  90703. getTransformationMatrix(): Matrix;
  90704. private _updateFrustumPlanes;
  90705. /**
  90706. * Checks if a cullable object (mesh...) is in the camera frustum
  90707. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  90708. * @param target The object to check
  90709. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  90710. * @returns true if the object is in frustum otherwise false
  90711. */
  90712. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  90713. /**
  90714. * Checks if a cullable object (mesh...) is in the camera frustum
  90715. * Unlike isInFrustum this cheks the full bounding box
  90716. * @param target The object to check
  90717. * @returns true if the object is in frustum otherwise false
  90718. */
  90719. isCompletelyInFrustum(target: ICullable): boolean;
  90720. /**
  90721. * Gets a ray in the forward direction from the camera.
  90722. * @param length Defines the length of the ray to create
  90723. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  90724. * @param origin Defines the start point of the ray which defaults to the camera position
  90725. * @returns the forward ray
  90726. */
  90727. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  90728. /**
  90729. * Releases resources associated with this node.
  90730. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90731. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90732. */
  90733. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90734. /** @hidden */
  90735. _isLeftCamera: boolean;
  90736. /**
  90737. * Gets the left camera of a rig setup in case of Rigged Camera
  90738. */
  90739. readonly isLeftCamera: boolean;
  90740. /** @hidden */
  90741. _isRightCamera: boolean;
  90742. /**
  90743. * Gets the right camera of a rig setup in case of Rigged Camera
  90744. */
  90745. readonly isRightCamera: boolean;
  90746. /**
  90747. * Gets the left camera of a rig setup in case of Rigged Camera
  90748. */
  90749. readonly leftCamera: Nullable<FreeCamera>;
  90750. /**
  90751. * Gets the right camera of a rig setup in case of Rigged Camera
  90752. */
  90753. readonly rightCamera: Nullable<FreeCamera>;
  90754. /**
  90755. * Gets the left camera target of a rig setup in case of Rigged Camera
  90756. * @returns the target position
  90757. */
  90758. getLeftTarget(): Nullable<Vector3>;
  90759. /**
  90760. * Gets the right camera target of a rig setup in case of Rigged Camera
  90761. * @returns the target position
  90762. */
  90763. getRightTarget(): Nullable<Vector3>;
  90764. /**
  90765. * @hidden
  90766. */
  90767. setCameraRigMode(mode: number, rigParams: any): void;
  90768. /** @hidden */
  90769. static _setStereoscopicRigMode(camera: Camera): void;
  90770. /** @hidden */
  90771. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  90772. /** @hidden */
  90773. static _setVRRigMode(camera: Camera, rigParams: any): void;
  90774. /** @hidden */
  90775. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  90776. /** @hidden */
  90777. _getVRProjectionMatrix(): Matrix;
  90778. protected _updateCameraRotationMatrix(): void;
  90779. protected _updateWebVRCameraRotationMatrix(): void;
  90780. /**
  90781. * This function MUST be overwritten by the different WebVR cameras available.
  90782. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90783. * @hidden
  90784. */
  90785. _getWebVRProjectionMatrix(): Matrix;
  90786. /**
  90787. * This function MUST be overwritten by the different WebVR cameras available.
  90788. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90789. * @hidden
  90790. */
  90791. _getWebVRViewMatrix(): Matrix;
  90792. /** @hidden */
  90793. setCameraRigParameter(name: string, value: any): void;
  90794. /**
  90795. * needs to be overridden by children so sub has required properties to be copied
  90796. * @hidden
  90797. */
  90798. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  90799. /**
  90800. * May need to be overridden by children
  90801. * @hidden
  90802. */
  90803. _updateRigCameras(): void;
  90804. /** @hidden */
  90805. _setupInputs(): void;
  90806. /**
  90807. * Serialiaze the camera setup to a json represention
  90808. * @returns the JSON representation
  90809. */
  90810. serialize(): any;
  90811. /**
  90812. * Clones the current camera.
  90813. * @param name The cloned camera name
  90814. * @returns the cloned camera
  90815. */
  90816. clone(name: string): Camera;
  90817. /**
  90818. * Gets the direction of the camera relative to a given local axis.
  90819. * @param localAxis Defines the reference axis to provide a relative direction.
  90820. * @return the direction
  90821. */
  90822. getDirection(localAxis: Vector3): Vector3;
  90823. /**
  90824. * Returns the current camera absolute rotation
  90825. */
  90826. readonly absoluteRotation: Quaternion;
  90827. /**
  90828. * Gets the direction of the camera relative to a given local axis into a passed vector.
  90829. * @param localAxis Defines the reference axis to provide a relative direction.
  90830. * @param result Defines the vector to store the result in
  90831. */
  90832. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  90833. /**
  90834. * Gets a camera constructor for a given camera type
  90835. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  90836. * @param name The name of the camera the result will be able to instantiate
  90837. * @param scene The scene the result will construct the camera in
  90838. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  90839. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  90840. * @returns a factory method to construc the camera
  90841. */
  90842. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  90843. /**
  90844. * Compute the world matrix of the camera.
  90845. * @returns the camera workd matrix
  90846. */
  90847. computeWorldMatrix(): Matrix;
  90848. /**
  90849. * Parse a JSON and creates the camera from the parsed information
  90850. * @param parsedCamera The JSON to parse
  90851. * @param scene The scene to instantiate the camera in
  90852. * @returns the newly constructed camera
  90853. */
  90854. static Parse(parsedCamera: any, scene: Scene): Camera;
  90855. }
  90856. }
  90857. declare module BABYLON {
  90858. /**
  90859. * Class containing static functions to help procedurally build meshes
  90860. */
  90861. export class DiscBuilder {
  90862. /**
  90863. * Creates a plane polygonal mesh. By default, this is a disc
  90864. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  90865. * * 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
  90866. * * 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
  90867. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90868. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  90869. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90870. * @param name defines the name of the mesh
  90871. * @param options defines the options used to create the mesh
  90872. * @param scene defines the hosting scene
  90873. * @returns the plane polygonal mesh
  90874. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  90875. */
  90876. static CreateDisc(name: string, options: {
  90877. radius?: number;
  90878. tessellation?: number;
  90879. arc?: number;
  90880. updatable?: boolean;
  90881. sideOrientation?: number;
  90882. frontUVs?: Vector4;
  90883. backUVs?: Vector4;
  90884. }, scene?: Nullable<Scene>): Mesh;
  90885. }
  90886. }
  90887. declare module BABYLON {
  90888. /**
  90889. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  90890. *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.
  90891. * The SPS is also a particle system. It provides some methods to manage the particles.
  90892. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  90893. *
  90894. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  90895. */
  90896. export class SolidParticleSystem implements IDisposable {
  90897. /**
  90898. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  90899. * Example : var p = SPS.particles[i];
  90900. */
  90901. particles: SolidParticle[];
  90902. /**
  90903. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  90904. */
  90905. nbParticles: number;
  90906. /**
  90907. * If the particles must ever face the camera (default false). Useful for planar particles.
  90908. */
  90909. billboard: boolean;
  90910. /**
  90911. * Recompute normals when adding a shape
  90912. */
  90913. recomputeNormals: boolean;
  90914. /**
  90915. * This a counter ofr your own usage. It's not set by any SPS functions.
  90916. */
  90917. counter: number;
  90918. /**
  90919. * The SPS name. This name is also given to the underlying mesh.
  90920. */
  90921. name: string;
  90922. /**
  90923. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  90924. */
  90925. mesh: Mesh;
  90926. /**
  90927. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  90928. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  90929. */
  90930. vars: any;
  90931. /**
  90932. * This array is populated when the SPS is set as 'pickable'.
  90933. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  90934. * Each element of this array is an object `{idx: int, faceId: int}`.
  90935. * `idx` is the picked particle index in the `SPS.particles` array
  90936. * `faceId` is the picked face index counted within this particle.
  90937. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  90938. */
  90939. pickedParticles: {
  90940. idx: number;
  90941. faceId: number;
  90942. }[];
  90943. /**
  90944. * This array is populated when `enableDepthSort` is set to true.
  90945. * Each element of this array is an instance of the class DepthSortedParticle.
  90946. */
  90947. depthSortedParticles: DepthSortedParticle[];
  90948. /**
  90949. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  90950. * @hidden
  90951. */
  90952. _bSphereOnly: boolean;
  90953. /**
  90954. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  90955. * @hidden
  90956. */
  90957. _bSphereRadiusFactor: number;
  90958. private _scene;
  90959. private _positions;
  90960. private _indices;
  90961. private _normals;
  90962. private _colors;
  90963. private _uvs;
  90964. private _indices32;
  90965. private _positions32;
  90966. private _normals32;
  90967. private _fixedNormal32;
  90968. private _colors32;
  90969. private _uvs32;
  90970. private _index;
  90971. private _updatable;
  90972. private _pickable;
  90973. private _isVisibilityBoxLocked;
  90974. private _alwaysVisible;
  90975. private _depthSort;
  90976. private _shapeCounter;
  90977. private _copy;
  90978. private _color;
  90979. private _computeParticleColor;
  90980. private _computeParticleTexture;
  90981. private _computeParticleRotation;
  90982. private _computeParticleVertex;
  90983. private _computeBoundingBox;
  90984. private _depthSortParticles;
  90985. private _camera;
  90986. private _mustUnrotateFixedNormals;
  90987. private _particlesIntersect;
  90988. private _needs32Bits;
  90989. /**
  90990. * Creates a SPS (Solid Particle System) object.
  90991. * @param name (String) is the SPS name, this will be the underlying mesh name.
  90992. * @param scene (Scene) is the scene in which the SPS is added.
  90993. * @param options defines the options of the sps e.g.
  90994. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  90995. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  90996. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  90997. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  90998. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  90999. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  91000. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  91001. */
  91002. constructor(name: string, scene: Scene, options?: {
  91003. updatable?: boolean;
  91004. isPickable?: boolean;
  91005. enableDepthSort?: boolean;
  91006. particleIntersection?: boolean;
  91007. boundingSphereOnly?: boolean;
  91008. bSphereRadiusFactor?: number;
  91009. });
  91010. /**
  91011. * Builds the SPS underlying mesh. Returns a standard Mesh.
  91012. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  91013. * @returns the created mesh
  91014. */
  91015. buildMesh(): Mesh;
  91016. /**
  91017. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  91018. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  91019. * Thus the particles generated from `digest()` have their property `position` set yet.
  91020. * @param mesh ( Mesh ) is the mesh to be digested
  91021. * @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
  91022. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  91023. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  91024. * @returns the current SPS
  91025. */
  91026. digest(mesh: Mesh, options?: {
  91027. facetNb?: number;
  91028. number?: number;
  91029. delta?: number;
  91030. }): SolidParticleSystem;
  91031. private _unrotateFixedNormals;
  91032. private _resetCopy;
  91033. private _meshBuilder;
  91034. private _posToShape;
  91035. private _uvsToShapeUV;
  91036. private _addParticle;
  91037. /**
  91038. * Adds some particles to the SPS from the model shape. Returns the shape id.
  91039. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  91040. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  91041. * @param nb (positive integer) the number of particles to be created from this model
  91042. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  91043. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  91044. * @returns the number of shapes in the system
  91045. */
  91046. addShape(mesh: Mesh, nb: number, options?: {
  91047. positionFunction?: any;
  91048. vertexFunction?: any;
  91049. }): number;
  91050. private _rebuildParticle;
  91051. /**
  91052. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  91053. * @returns the SPS.
  91054. */
  91055. rebuildMesh(): SolidParticleSystem;
  91056. /**
  91057. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  91058. * This method calls `updateParticle()` for each particle of the SPS.
  91059. * For an animated SPS, it is usually called within the render loop.
  91060. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  91061. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  91062. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  91063. * @returns the SPS.
  91064. */
  91065. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  91066. /**
  91067. * Disposes the SPS.
  91068. */
  91069. dispose(): void;
  91070. /**
  91071. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  91072. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91073. * @returns the SPS.
  91074. */
  91075. refreshVisibleSize(): SolidParticleSystem;
  91076. /**
  91077. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  91078. * @param size the size (float) of the visibility box
  91079. * note : this doesn't lock the SPS mesh bounding box.
  91080. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91081. */
  91082. setVisibilityBox(size: number): void;
  91083. /**
  91084. * Gets whether the SPS as always visible or not
  91085. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91086. */
  91087. /**
  91088. * Sets the SPS as always visible or not
  91089. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91090. */
  91091. isAlwaysVisible: boolean;
  91092. /**
  91093. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  91094. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91095. */
  91096. /**
  91097. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  91098. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91099. */
  91100. isVisibilityBoxLocked: boolean;
  91101. /**
  91102. * Tells to `setParticles()` to compute the particle rotations or not.
  91103. * Default value : true. The SPS is faster when it's set to false.
  91104. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  91105. */
  91106. /**
  91107. * Gets if `setParticles()` computes the particle rotations or not.
  91108. * Default value : true. The SPS is faster when it's set to false.
  91109. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  91110. */
  91111. computeParticleRotation: boolean;
  91112. /**
  91113. * Tells to `setParticles()` to compute the particle colors or not.
  91114. * Default value : true. The SPS is faster when it's set to false.
  91115. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  91116. */
  91117. /**
  91118. * Gets if `setParticles()` computes the particle colors or not.
  91119. * Default value : true. The SPS is faster when it's set to false.
  91120. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  91121. */
  91122. computeParticleColor: boolean;
  91123. /**
  91124. * Gets if `setParticles()` computes the particle textures or not.
  91125. * Default value : true. The SPS is faster when it's set to false.
  91126. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  91127. */
  91128. computeParticleTexture: boolean;
  91129. /**
  91130. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  91131. * Default value : false. The SPS is faster when it's set to false.
  91132. * Note : the particle custom vertex positions aren't stored values.
  91133. */
  91134. /**
  91135. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  91136. * Default value : false. The SPS is faster when it's set to false.
  91137. * Note : the particle custom vertex positions aren't stored values.
  91138. */
  91139. computeParticleVertex: boolean;
  91140. /**
  91141. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  91142. */
  91143. /**
  91144. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  91145. */
  91146. computeBoundingBox: boolean;
  91147. /**
  91148. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  91149. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  91150. * Default : `true`
  91151. */
  91152. /**
  91153. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  91154. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  91155. * Default : `true`
  91156. */
  91157. depthSortParticles: boolean;
  91158. /**
  91159. * This function does nothing. It may be overwritten to set all the particle first values.
  91160. * The SPS doesn't call this function, you may have to call it by your own.
  91161. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  91162. */
  91163. initParticles(): void;
  91164. /**
  91165. * This function does nothing. It may be overwritten to recycle a particle.
  91166. * The SPS doesn't call this function, you may have to call it by your own.
  91167. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  91168. * @param particle The particle to recycle
  91169. * @returns the recycled particle
  91170. */
  91171. recycleParticle(particle: SolidParticle): SolidParticle;
  91172. /**
  91173. * Updates a particle : this function should be overwritten by the user.
  91174. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  91175. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  91176. * @example : just set a particle position or velocity and recycle conditions
  91177. * @param particle The particle to update
  91178. * @returns the updated particle
  91179. */
  91180. updateParticle(particle: SolidParticle): SolidParticle;
  91181. /**
  91182. * Updates a vertex of a particle : it can be overwritten by the user.
  91183. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  91184. * @param particle the current particle
  91185. * @param vertex the current index of the current particle
  91186. * @param pt the index of the current vertex in the particle shape
  91187. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  91188. * @example : just set a vertex particle position
  91189. * @returns the updated vertex
  91190. */
  91191. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  91192. /**
  91193. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  91194. * This does nothing and may be overwritten by the user.
  91195. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  91196. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  91197. * @param update the boolean update value actually passed to setParticles()
  91198. */
  91199. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  91200. /**
  91201. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  91202. * This will be passed three parameters.
  91203. * This does nothing and may be overwritten by the user.
  91204. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  91205. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  91206. * @param update the boolean update value actually passed to setParticles()
  91207. */
  91208. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  91209. }
  91210. }
  91211. declare module BABYLON {
  91212. /**
  91213. * Represents one particle of a solid particle system.
  91214. */
  91215. export class SolidParticle {
  91216. /**
  91217. * particle global index
  91218. */
  91219. idx: number;
  91220. /**
  91221. * The color of the particle
  91222. */
  91223. color: Nullable<Color4>;
  91224. /**
  91225. * The world space position of the particle.
  91226. */
  91227. position: Vector3;
  91228. /**
  91229. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  91230. */
  91231. rotation: Vector3;
  91232. /**
  91233. * The world space rotation quaternion of the particle.
  91234. */
  91235. rotationQuaternion: Nullable<Quaternion>;
  91236. /**
  91237. * The scaling of the particle.
  91238. */
  91239. scaling: Vector3;
  91240. /**
  91241. * The uvs of the particle.
  91242. */
  91243. uvs: Vector4;
  91244. /**
  91245. * The current speed of the particle.
  91246. */
  91247. velocity: Vector3;
  91248. /**
  91249. * The pivot point in the particle local space.
  91250. */
  91251. pivot: Vector3;
  91252. /**
  91253. * Must the particle be translated from its pivot point in its local space ?
  91254. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  91255. * Default : false
  91256. */
  91257. translateFromPivot: boolean;
  91258. /**
  91259. * Is the particle active or not ?
  91260. */
  91261. alive: boolean;
  91262. /**
  91263. * Is the particle visible or not ?
  91264. */
  91265. isVisible: boolean;
  91266. /**
  91267. * Index of this particle in the global "positions" array (Internal use)
  91268. * @hidden
  91269. */
  91270. _pos: number;
  91271. /**
  91272. * @hidden Index of this particle in the global "indices" array (Internal use)
  91273. */
  91274. _ind: number;
  91275. /**
  91276. * @hidden ModelShape of this particle (Internal use)
  91277. */
  91278. _model: ModelShape;
  91279. /**
  91280. * ModelShape id of this particle
  91281. */
  91282. shapeId: number;
  91283. /**
  91284. * Index of the particle in its shape id
  91285. */
  91286. idxInShape: number;
  91287. /**
  91288. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  91289. */
  91290. _modelBoundingInfo: BoundingInfo;
  91291. /**
  91292. * @hidden Particle BoundingInfo object (Internal use)
  91293. */
  91294. _boundingInfo: BoundingInfo;
  91295. /**
  91296. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  91297. */
  91298. _sps: SolidParticleSystem;
  91299. /**
  91300. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  91301. */
  91302. _stillInvisible: boolean;
  91303. /**
  91304. * @hidden Last computed particle rotation matrix
  91305. */
  91306. _rotationMatrix: number[];
  91307. /**
  91308. * Parent particle Id, if any.
  91309. * Default null.
  91310. */
  91311. parentId: Nullable<number>;
  91312. /**
  91313. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  91314. * The possible values are :
  91315. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  91316. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  91317. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  91318. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  91319. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  91320. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  91321. * */
  91322. cullingStrategy: number;
  91323. /**
  91324. * @hidden Internal global position in the SPS.
  91325. */
  91326. _globalPosition: Vector3;
  91327. /**
  91328. * Creates a Solid Particle object.
  91329. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  91330. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  91331. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  91332. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  91333. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  91334. * @param shapeId (integer) is the model shape identifier in the SPS.
  91335. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  91336. * @param sps defines the sps it is associated to
  91337. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  91338. */
  91339. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  91340. /**
  91341. * Legacy support, changed scale to scaling
  91342. */
  91343. /**
  91344. * Legacy support, changed scale to scaling
  91345. */
  91346. scale: Vector3;
  91347. /**
  91348. * Legacy support, changed quaternion to rotationQuaternion
  91349. */
  91350. /**
  91351. * Legacy support, changed quaternion to rotationQuaternion
  91352. */
  91353. quaternion: Nullable<Quaternion>;
  91354. /**
  91355. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  91356. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  91357. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  91358. * @returns true if it intersects
  91359. */
  91360. intersectsMesh(target: Mesh | SolidParticle): boolean;
  91361. /**
  91362. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  91363. * A particle is in the frustum if its bounding box intersects the frustum
  91364. * @param frustumPlanes defines the frustum to test
  91365. * @returns true if the particle is in the frustum planes
  91366. */
  91367. isInFrustum(frustumPlanes: Plane[]): boolean;
  91368. /**
  91369. * get the rotation matrix of the particle
  91370. * @hidden
  91371. */
  91372. getRotationMatrix(m: Matrix): void;
  91373. }
  91374. /**
  91375. * Represents the shape of the model used by one particle of a solid particle system.
  91376. * SPS internal tool, don't use it manually.
  91377. */
  91378. export class ModelShape {
  91379. /**
  91380. * The shape id
  91381. * @hidden
  91382. */
  91383. shapeID: number;
  91384. /**
  91385. * flat array of model positions (internal use)
  91386. * @hidden
  91387. */
  91388. _shape: Vector3[];
  91389. /**
  91390. * flat array of model UVs (internal use)
  91391. * @hidden
  91392. */
  91393. _shapeUV: number[];
  91394. /**
  91395. * length of the shape in the model indices array (internal use)
  91396. * @hidden
  91397. */
  91398. _indicesLength: number;
  91399. /**
  91400. * Custom position function (internal use)
  91401. * @hidden
  91402. */
  91403. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  91404. /**
  91405. * Custom vertex function (internal use)
  91406. * @hidden
  91407. */
  91408. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  91409. /**
  91410. * 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.
  91411. * SPS internal tool, don't use it manually.
  91412. * @hidden
  91413. */
  91414. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  91415. }
  91416. /**
  91417. * Represents a Depth Sorted Particle in the solid particle system.
  91418. */
  91419. export class DepthSortedParticle {
  91420. /**
  91421. * Index of the particle in the "indices" array
  91422. */
  91423. ind: number;
  91424. /**
  91425. * Length of the particle shape in the "indices" array
  91426. */
  91427. indicesLength: number;
  91428. /**
  91429. * Squared distance from the particle to the camera
  91430. */
  91431. sqDistance: number;
  91432. }
  91433. }
  91434. declare module BABYLON {
  91435. /**
  91436. * @hidden
  91437. */
  91438. export class _MeshCollisionData {
  91439. _checkCollisions: boolean;
  91440. _collisionMask: number;
  91441. _collisionGroup: number;
  91442. _collider: Nullable<Collider>;
  91443. _oldPositionForCollisions: Vector3;
  91444. _diffPositionForCollisions: Vector3;
  91445. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  91446. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  91447. }
  91448. }
  91449. declare module BABYLON {
  91450. /** @hidden */
  91451. class _FacetDataStorage {
  91452. facetPositions: Vector3[];
  91453. facetNormals: Vector3[];
  91454. facetPartitioning: number[][];
  91455. facetNb: number;
  91456. partitioningSubdivisions: number;
  91457. partitioningBBoxRatio: number;
  91458. facetDataEnabled: boolean;
  91459. facetParameters: any;
  91460. bbSize: Vector3;
  91461. subDiv: {
  91462. max: number;
  91463. X: number;
  91464. Y: number;
  91465. Z: number;
  91466. };
  91467. facetDepthSort: boolean;
  91468. facetDepthSortEnabled: boolean;
  91469. depthSortedIndices: IndicesArray;
  91470. depthSortedFacets: {
  91471. ind: number;
  91472. sqDistance: number;
  91473. }[];
  91474. facetDepthSortFunction: (f1: {
  91475. ind: number;
  91476. sqDistance: number;
  91477. }, f2: {
  91478. ind: number;
  91479. sqDistance: number;
  91480. }) => number;
  91481. facetDepthSortFrom: Vector3;
  91482. facetDepthSortOrigin: Vector3;
  91483. invertedMatrix: Matrix;
  91484. }
  91485. /**
  91486. * @hidden
  91487. **/
  91488. class _InternalAbstractMeshDataInfo {
  91489. _hasVertexAlpha: boolean;
  91490. _useVertexColors: boolean;
  91491. _numBoneInfluencers: number;
  91492. _applyFog: boolean;
  91493. _receiveShadows: boolean;
  91494. _facetData: _FacetDataStorage;
  91495. _visibility: number;
  91496. _skeleton: Nullable<Skeleton>;
  91497. _layerMask: number;
  91498. _computeBonesUsingShaders: boolean;
  91499. _isActive: boolean;
  91500. _onlyForInstances: boolean;
  91501. _isActiveIntermediate: boolean;
  91502. _onlyForInstancesIntermediate: boolean;
  91503. }
  91504. /**
  91505. * Class used to store all common mesh properties
  91506. */
  91507. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  91508. /** No occlusion */
  91509. static OCCLUSION_TYPE_NONE: number;
  91510. /** Occlusion set to optimisitic */
  91511. static OCCLUSION_TYPE_OPTIMISTIC: number;
  91512. /** Occlusion set to strict */
  91513. static OCCLUSION_TYPE_STRICT: number;
  91514. /** Use an accurante occlusion algorithm */
  91515. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  91516. /** Use a conservative occlusion algorithm */
  91517. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  91518. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  91519. * Test order :
  91520. * Is the bounding sphere outside the frustum ?
  91521. * If not, are the bounding box vertices outside the frustum ?
  91522. * It not, then the cullable object is in the frustum.
  91523. */
  91524. static readonly CULLINGSTRATEGY_STANDARD: number;
  91525. /** Culling strategy : Bounding Sphere Only.
  91526. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  91527. * It's also less accurate than the standard because some not visible objects can still be selected.
  91528. * Test : is the bounding sphere outside the frustum ?
  91529. * If not, then the cullable object is in the frustum.
  91530. */
  91531. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  91532. /** Culling strategy : Optimistic Inclusion.
  91533. * This in an inclusion test first, then the standard exclusion test.
  91534. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  91535. * 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.
  91536. * Anyway, it's as accurate as the standard strategy.
  91537. * Test :
  91538. * Is the cullable object bounding sphere center in the frustum ?
  91539. * If not, apply the default culling strategy.
  91540. */
  91541. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  91542. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  91543. * This in an inclusion test first, then the bounding sphere only exclusion test.
  91544. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  91545. * 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.
  91546. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  91547. * Test :
  91548. * Is the cullable object bounding sphere center in the frustum ?
  91549. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  91550. */
  91551. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  91552. /**
  91553. * No billboard
  91554. */
  91555. static readonly BILLBOARDMODE_NONE: number;
  91556. /** Billboard on X axis */
  91557. static readonly BILLBOARDMODE_X: number;
  91558. /** Billboard on Y axis */
  91559. static readonly BILLBOARDMODE_Y: number;
  91560. /** Billboard on Z axis */
  91561. static readonly BILLBOARDMODE_Z: number;
  91562. /** Billboard on all axes */
  91563. static readonly BILLBOARDMODE_ALL: number;
  91564. /** Billboard on using position instead of orientation */
  91565. static readonly BILLBOARDMODE_USE_POSITION: number;
  91566. /** @hidden */
  91567. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  91568. /**
  91569. * The culling strategy to use to check whether the mesh must be rendered or not.
  91570. * This value can be changed at any time and will be used on the next render mesh selection.
  91571. * The possible values are :
  91572. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  91573. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  91574. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  91575. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  91576. * Please read each static variable documentation to get details about the culling process.
  91577. * */
  91578. cullingStrategy: number;
  91579. /**
  91580. * Gets the number of facets in the mesh
  91581. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  91582. */
  91583. readonly facetNb: number;
  91584. /**
  91585. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  91586. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  91587. */
  91588. partitioningSubdivisions: number;
  91589. /**
  91590. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  91591. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  91592. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  91593. */
  91594. partitioningBBoxRatio: number;
  91595. /**
  91596. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  91597. * Works only for updatable meshes.
  91598. * Doesn't work with multi-materials
  91599. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  91600. */
  91601. mustDepthSortFacets: boolean;
  91602. /**
  91603. * The location (Vector3) where the facet depth sort must be computed from.
  91604. * By default, the active camera position.
  91605. * Used only when facet depth sort is enabled
  91606. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  91607. */
  91608. facetDepthSortFrom: Vector3;
  91609. /**
  91610. * gets a boolean indicating if facetData is enabled
  91611. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  91612. */
  91613. readonly isFacetDataEnabled: boolean;
  91614. /** @hidden */
  91615. _updateNonUniformScalingState(value: boolean): boolean;
  91616. /**
  91617. * An event triggered when this mesh collides with another one
  91618. */
  91619. onCollideObservable: Observable<AbstractMesh>;
  91620. /** Set a function to call when this mesh collides with another one */
  91621. onCollide: () => void;
  91622. /**
  91623. * An event triggered when the collision's position changes
  91624. */
  91625. onCollisionPositionChangeObservable: Observable<Vector3>;
  91626. /** Set a function to call when the collision's position changes */
  91627. onCollisionPositionChange: () => void;
  91628. /**
  91629. * An event triggered when material is changed
  91630. */
  91631. onMaterialChangedObservable: Observable<AbstractMesh>;
  91632. /**
  91633. * Gets or sets the orientation for POV movement & rotation
  91634. */
  91635. definedFacingForward: boolean;
  91636. /** @hidden */
  91637. _occlusionQuery: Nullable<WebGLQuery>;
  91638. /** @hidden */
  91639. _renderingGroup: Nullable<RenderingGroup>;
  91640. /**
  91641. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  91642. */
  91643. /**
  91644. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  91645. */
  91646. visibility: number;
  91647. /** Gets or sets the alpha index used to sort transparent meshes
  91648. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  91649. */
  91650. alphaIndex: number;
  91651. /**
  91652. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  91653. */
  91654. isVisible: boolean;
  91655. /**
  91656. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  91657. */
  91658. isPickable: boolean;
  91659. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  91660. showSubMeshesBoundingBox: boolean;
  91661. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  91662. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  91663. */
  91664. isBlocker: boolean;
  91665. /**
  91666. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  91667. */
  91668. enablePointerMoveEvents: boolean;
  91669. /**
  91670. * Specifies the rendering group id for this mesh (0 by default)
  91671. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  91672. */
  91673. renderingGroupId: number;
  91674. private _material;
  91675. /** Gets or sets current material */
  91676. material: Nullable<Material>;
  91677. /**
  91678. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  91679. * @see http://doc.babylonjs.com/babylon101/shadows
  91680. */
  91681. receiveShadows: boolean;
  91682. /** Defines color to use when rendering outline */
  91683. outlineColor: Color3;
  91684. /** Define width to use when rendering outline */
  91685. outlineWidth: number;
  91686. /** Defines color to use when rendering overlay */
  91687. overlayColor: Color3;
  91688. /** Defines alpha to use when rendering overlay */
  91689. overlayAlpha: number;
  91690. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  91691. hasVertexAlpha: boolean;
  91692. /** 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) */
  91693. useVertexColors: boolean;
  91694. /**
  91695. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  91696. */
  91697. computeBonesUsingShaders: boolean;
  91698. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  91699. numBoneInfluencers: number;
  91700. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  91701. applyFog: boolean;
  91702. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  91703. useOctreeForRenderingSelection: boolean;
  91704. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  91705. useOctreeForPicking: boolean;
  91706. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  91707. useOctreeForCollisions: boolean;
  91708. /**
  91709. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  91710. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  91711. */
  91712. layerMask: number;
  91713. /**
  91714. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  91715. */
  91716. alwaysSelectAsActiveMesh: boolean;
  91717. /**
  91718. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  91719. */
  91720. doNotSyncBoundingInfo: boolean;
  91721. /**
  91722. * Gets or sets the current action manager
  91723. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91724. */
  91725. actionManager: Nullable<AbstractActionManager>;
  91726. private _meshCollisionData;
  91727. /**
  91728. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  91729. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91730. */
  91731. ellipsoid: Vector3;
  91732. /**
  91733. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  91734. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91735. */
  91736. ellipsoidOffset: Vector3;
  91737. /**
  91738. * Gets or sets a collision mask used to mask collisions (default is -1).
  91739. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  91740. */
  91741. collisionMask: number;
  91742. /**
  91743. * Gets or sets the current collision group mask (-1 by default).
  91744. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  91745. */
  91746. collisionGroup: number;
  91747. /**
  91748. * Defines edge width used when edgesRenderer is enabled
  91749. * @see https://www.babylonjs-playground.com/#10OJSG#13
  91750. */
  91751. edgesWidth: number;
  91752. /**
  91753. * Defines edge color used when edgesRenderer is enabled
  91754. * @see https://www.babylonjs-playground.com/#10OJSG#13
  91755. */
  91756. edgesColor: Color4;
  91757. /** @hidden */
  91758. _edgesRenderer: Nullable<IEdgesRenderer>;
  91759. /** @hidden */
  91760. _masterMesh: Nullable<AbstractMesh>;
  91761. /** @hidden */
  91762. _boundingInfo: Nullable<BoundingInfo>;
  91763. /** @hidden */
  91764. _renderId: number;
  91765. /**
  91766. * Gets or sets the list of subMeshes
  91767. * @see http://doc.babylonjs.com/how_to/multi_materials
  91768. */
  91769. subMeshes: SubMesh[];
  91770. /** @hidden */
  91771. _intersectionsInProgress: AbstractMesh[];
  91772. /** @hidden */
  91773. _unIndexed: boolean;
  91774. /** @hidden */
  91775. _lightSources: Light[];
  91776. /** Gets the list of lights affecting that mesh */
  91777. readonly lightSources: Light[];
  91778. /** @hidden */
  91779. readonly _positions: Nullable<Vector3[]>;
  91780. /** @hidden */
  91781. _waitingData: {
  91782. lods: Nullable<any>;
  91783. actions: Nullable<any>;
  91784. freezeWorldMatrix: Nullable<boolean>;
  91785. };
  91786. /** @hidden */
  91787. _bonesTransformMatrices: Nullable<Float32Array>;
  91788. /** @hidden */
  91789. _transformMatrixTexture: Nullable<RawTexture>;
  91790. /**
  91791. * Gets or sets a skeleton to apply skining transformations
  91792. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  91793. */
  91794. skeleton: Nullable<Skeleton>;
  91795. /**
  91796. * An event triggered when the mesh is rebuilt.
  91797. */
  91798. onRebuildObservable: Observable<AbstractMesh>;
  91799. /**
  91800. * Creates a new AbstractMesh
  91801. * @param name defines the name of the mesh
  91802. * @param scene defines the hosting scene
  91803. */
  91804. constructor(name: string, scene?: Nullable<Scene>);
  91805. /**
  91806. * Returns the string "AbstractMesh"
  91807. * @returns "AbstractMesh"
  91808. */
  91809. getClassName(): string;
  91810. /**
  91811. * Gets a string representation of the current mesh
  91812. * @param fullDetails defines a boolean indicating if full details must be included
  91813. * @returns a string representation of the current mesh
  91814. */
  91815. toString(fullDetails?: boolean): string;
  91816. /**
  91817. * @hidden
  91818. */
  91819. protected _getEffectiveParent(): Nullable<Node>;
  91820. /** @hidden */
  91821. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  91822. /** @hidden */
  91823. _rebuild(): void;
  91824. /** @hidden */
  91825. _resyncLightSources(): void;
  91826. /** @hidden */
  91827. _resyncLighSource(light: Light): void;
  91828. /** @hidden */
  91829. _unBindEffect(): void;
  91830. /** @hidden */
  91831. _removeLightSource(light: Light, dispose: boolean): void;
  91832. private _markSubMeshesAsDirty;
  91833. /** @hidden */
  91834. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  91835. /** @hidden */
  91836. _markSubMeshesAsAttributesDirty(): void;
  91837. /** @hidden */
  91838. _markSubMeshesAsMiscDirty(): void;
  91839. /**
  91840. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  91841. */
  91842. scaling: Vector3;
  91843. /**
  91844. * Returns true if the mesh is blocked. Implemented by child classes
  91845. */
  91846. readonly isBlocked: boolean;
  91847. /**
  91848. * Returns the mesh itself by default. Implemented by child classes
  91849. * @param camera defines the camera to use to pick the right LOD level
  91850. * @returns the currentAbstractMesh
  91851. */
  91852. getLOD(camera: Camera): Nullable<AbstractMesh>;
  91853. /**
  91854. * Returns 0 by default. Implemented by child classes
  91855. * @returns an integer
  91856. */
  91857. getTotalVertices(): number;
  91858. /**
  91859. * Returns a positive integer : the total number of indices in this mesh geometry.
  91860. * @returns the numner of indices or zero if the mesh has no geometry.
  91861. */
  91862. getTotalIndices(): number;
  91863. /**
  91864. * Returns null by default. Implemented by child classes
  91865. * @returns null
  91866. */
  91867. getIndices(): Nullable<IndicesArray>;
  91868. /**
  91869. * Returns the array of the requested vertex data kind. Implemented by child classes
  91870. * @param kind defines the vertex data kind to use
  91871. * @returns null
  91872. */
  91873. getVerticesData(kind: string): Nullable<FloatArray>;
  91874. /**
  91875. * Sets the vertex data of the mesh geometry for the requested `kind`.
  91876. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  91877. * Note that a new underlying VertexBuffer object is created each call.
  91878. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  91879. * @param kind defines vertex data kind:
  91880. * * VertexBuffer.PositionKind
  91881. * * VertexBuffer.UVKind
  91882. * * VertexBuffer.UV2Kind
  91883. * * VertexBuffer.UV3Kind
  91884. * * VertexBuffer.UV4Kind
  91885. * * VertexBuffer.UV5Kind
  91886. * * VertexBuffer.UV6Kind
  91887. * * VertexBuffer.ColorKind
  91888. * * VertexBuffer.MatricesIndicesKind
  91889. * * VertexBuffer.MatricesIndicesExtraKind
  91890. * * VertexBuffer.MatricesWeightsKind
  91891. * * VertexBuffer.MatricesWeightsExtraKind
  91892. * @param data defines the data source
  91893. * @param updatable defines if the data must be flagged as updatable (or static)
  91894. * @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
  91895. * @returns the current mesh
  91896. */
  91897. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  91898. /**
  91899. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  91900. * If the mesh has no geometry, it is simply returned as it is.
  91901. * @param kind defines vertex data kind:
  91902. * * VertexBuffer.PositionKind
  91903. * * VertexBuffer.UVKind
  91904. * * VertexBuffer.UV2Kind
  91905. * * VertexBuffer.UV3Kind
  91906. * * VertexBuffer.UV4Kind
  91907. * * VertexBuffer.UV5Kind
  91908. * * VertexBuffer.UV6Kind
  91909. * * VertexBuffer.ColorKind
  91910. * * VertexBuffer.MatricesIndicesKind
  91911. * * VertexBuffer.MatricesIndicesExtraKind
  91912. * * VertexBuffer.MatricesWeightsKind
  91913. * * VertexBuffer.MatricesWeightsExtraKind
  91914. * @param data defines the data source
  91915. * @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
  91916. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  91917. * @returns the current mesh
  91918. */
  91919. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  91920. /**
  91921. * Sets the mesh indices,
  91922. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  91923. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  91924. * @param totalVertices Defines the total number of vertices
  91925. * @returns the current mesh
  91926. */
  91927. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  91928. /**
  91929. * Gets a boolean indicating if specific vertex data is present
  91930. * @param kind defines the vertex data kind to use
  91931. * @returns true is data kind is present
  91932. */
  91933. isVerticesDataPresent(kind: string): boolean;
  91934. /**
  91935. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  91936. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  91937. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  91938. * @returns a BoundingInfo
  91939. */
  91940. getBoundingInfo(): BoundingInfo;
  91941. /**
  91942. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  91943. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  91944. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  91945. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  91946. * @returns the current mesh
  91947. */
  91948. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  91949. /**
  91950. * Overwrite the current bounding info
  91951. * @param boundingInfo defines the new bounding info
  91952. * @returns the current mesh
  91953. */
  91954. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  91955. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  91956. readonly useBones: boolean;
  91957. /** @hidden */
  91958. _preActivate(): void;
  91959. /** @hidden */
  91960. _preActivateForIntermediateRendering(renderId: number): void;
  91961. /** @hidden */
  91962. _activate(renderId: number, intermediateRendering: boolean): boolean;
  91963. /** @hidden */
  91964. _postActivate(): void;
  91965. /** @hidden */
  91966. _freeze(): void;
  91967. /** @hidden */
  91968. _unFreeze(): void;
  91969. /**
  91970. * Gets the current world matrix
  91971. * @returns a Matrix
  91972. */
  91973. getWorldMatrix(): Matrix;
  91974. /** @hidden */
  91975. _getWorldMatrixDeterminant(): number;
  91976. /**
  91977. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  91978. */
  91979. readonly isAnInstance: boolean;
  91980. /**
  91981. * Gets a boolean indicating if this mesh has instances
  91982. */
  91983. readonly hasInstances: boolean;
  91984. /**
  91985. * Perform relative position change from the point of view of behind the front of the mesh.
  91986. * This is performed taking into account the meshes current rotation, so you do not have to care.
  91987. * Supports definition of mesh facing forward or backward
  91988. * @param amountRight defines the distance on the right axis
  91989. * @param amountUp defines the distance on the up axis
  91990. * @param amountForward defines the distance on the forward axis
  91991. * @returns the current mesh
  91992. */
  91993. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  91994. /**
  91995. * Calculate relative position change from the point of view of behind the front of the mesh.
  91996. * This is performed taking into account the meshes current rotation, so you do not have to care.
  91997. * Supports definition of mesh facing forward or backward
  91998. * @param amountRight defines the distance on the right axis
  91999. * @param amountUp defines the distance on the up axis
  92000. * @param amountForward defines the distance on the forward axis
  92001. * @returns the new displacement vector
  92002. */
  92003. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  92004. /**
  92005. * Perform relative rotation change from the point of view of behind the front of the mesh.
  92006. * Supports definition of mesh facing forward or backward
  92007. * @param flipBack defines the flip
  92008. * @param twirlClockwise defines the twirl
  92009. * @param tiltRight defines the tilt
  92010. * @returns the current mesh
  92011. */
  92012. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  92013. /**
  92014. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  92015. * Supports definition of mesh facing forward or backward.
  92016. * @param flipBack defines the flip
  92017. * @param twirlClockwise defines the twirl
  92018. * @param tiltRight defines the tilt
  92019. * @returns the new rotation vector
  92020. */
  92021. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  92022. /**
  92023. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  92024. * This means the mesh underlying bounding box and sphere are recomputed.
  92025. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  92026. * @returns the current mesh
  92027. */
  92028. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  92029. /** @hidden */
  92030. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  92031. /** @hidden */
  92032. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  92033. /** @hidden */
  92034. _updateBoundingInfo(): AbstractMesh;
  92035. /** @hidden */
  92036. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  92037. /** @hidden */
  92038. protected _afterComputeWorldMatrix(): void;
  92039. /** @hidden */
  92040. readonly _effectiveMesh: AbstractMesh;
  92041. /**
  92042. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  92043. * A mesh is in the frustum if its bounding box intersects the frustum
  92044. * @param frustumPlanes defines the frustum to test
  92045. * @returns true if the mesh is in the frustum planes
  92046. */
  92047. isInFrustum(frustumPlanes: Plane[]): boolean;
  92048. /**
  92049. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  92050. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  92051. * @param frustumPlanes defines the frustum to test
  92052. * @returns true if the mesh is completely in the frustum planes
  92053. */
  92054. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  92055. /**
  92056. * True if the mesh intersects another mesh or a SolidParticle object
  92057. * @param mesh defines a target mesh or SolidParticle to test
  92058. * @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)
  92059. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  92060. * @returns true if there is an intersection
  92061. */
  92062. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  92063. /**
  92064. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  92065. * @param point defines the point to test
  92066. * @returns true if there is an intersection
  92067. */
  92068. intersectsPoint(point: Vector3): boolean;
  92069. /**
  92070. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  92071. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92072. */
  92073. checkCollisions: boolean;
  92074. /**
  92075. * Gets Collider object used to compute collisions (not physics)
  92076. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92077. */
  92078. readonly collider: Nullable<Collider>;
  92079. /**
  92080. * Move the mesh using collision engine
  92081. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92082. * @param displacement defines the requested displacement vector
  92083. * @returns the current mesh
  92084. */
  92085. moveWithCollisions(displacement: Vector3): AbstractMesh;
  92086. private _onCollisionPositionChange;
  92087. /** @hidden */
  92088. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  92089. /** @hidden */
  92090. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  92091. /** @hidden */
  92092. _checkCollision(collider: Collider): AbstractMesh;
  92093. /** @hidden */
  92094. _generatePointsArray(): boolean;
  92095. /**
  92096. * Checks if the passed Ray intersects with the mesh
  92097. * @param ray defines the ray to use
  92098. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  92099. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92100. * @returns the picking info
  92101. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  92102. */
  92103. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  92104. /**
  92105. * Clones the current mesh
  92106. * @param name defines the mesh name
  92107. * @param newParent defines the new mesh parent
  92108. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  92109. * @returns the new mesh
  92110. */
  92111. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  92112. /**
  92113. * Disposes all the submeshes of the current meshnp
  92114. * @returns the current mesh
  92115. */
  92116. releaseSubMeshes(): AbstractMesh;
  92117. /**
  92118. * Releases resources associated with this abstract mesh.
  92119. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92120. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92121. */
  92122. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92123. /**
  92124. * Adds the passed mesh as a child to the current mesh
  92125. * @param mesh defines the child mesh
  92126. * @returns the current mesh
  92127. */
  92128. addChild(mesh: AbstractMesh): AbstractMesh;
  92129. /**
  92130. * Removes the passed mesh from the current mesh children list
  92131. * @param mesh defines the child mesh
  92132. * @returns the current mesh
  92133. */
  92134. removeChild(mesh: AbstractMesh): AbstractMesh;
  92135. /** @hidden */
  92136. private _initFacetData;
  92137. /**
  92138. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  92139. * This method can be called within the render loop.
  92140. * 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
  92141. * @returns the current mesh
  92142. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92143. */
  92144. updateFacetData(): AbstractMesh;
  92145. /**
  92146. * Returns the facetLocalNormals array.
  92147. * The normals are expressed in the mesh local spac
  92148. * @returns an array of Vector3
  92149. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92150. */
  92151. getFacetLocalNormals(): Vector3[];
  92152. /**
  92153. * Returns the facetLocalPositions array.
  92154. * The facet positions are expressed in the mesh local space
  92155. * @returns an array of Vector3
  92156. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92157. */
  92158. getFacetLocalPositions(): Vector3[];
  92159. /**
  92160. * Returns the facetLocalPartioning array
  92161. * @returns an array of array of numbers
  92162. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92163. */
  92164. getFacetLocalPartitioning(): number[][];
  92165. /**
  92166. * Returns the i-th facet position in the world system.
  92167. * This method allocates a new Vector3 per call
  92168. * @param i defines the facet index
  92169. * @returns a new Vector3
  92170. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92171. */
  92172. getFacetPosition(i: number): Vector3;
  92173. /**
  92174. * Sets the reference Vector3 with the i-th facet position in the world system
  92175. * @param i defines the facet index
  92176. * @param ref defines the target vector
  92177. * @returns the current mesh
  92178. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92179. */
  92180. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  92181. /**
  92182. * Returns the i-th facet normal in the world system.
  92183. * This method allocates a new Vector3 per call
  92184. * @param i defines the facet index
  92185. * @returns a new Vector3
  92186. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92187. */
  92188. getFacetNormal(i: number): Vector3;
  92189. /**
  92190. * Sets the reference Vector3 with the i-th facet normal in the world system
  92191. * @param i defines the facet index
  92192. * @param ref defines the target vector
  92193. * @returns the current mesh
  92194. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92195. */
  92196. getFacetNormalToRef(i: number, ref: Vector3): this;
  92197. /**
  92198. * 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)
  92199. * @param x defines x coordinate
  92200. * @param y defines y coordinate
  92201. * @param z defines z coordinate
  92202. * @returns the array of facet indexes
  92203. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92204. */
  92205. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  92206. /**
  92207. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  92208. * @param projected sets as the (x,y,z) world projection on the facet
  92209. * @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
  92210. * @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
  92211. * @param x defines x coordinate
  92212. * @param y defines y coordinate
  92213. * @param z defines z coordinate
  92214. * @returns the face index if found (or null instead)
  92215. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92216. */
  92217. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  92218. /**
  92219. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  92220. * @param projected sets as the (x,y,z) local projection on the facet
  92221. * @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
  92222. * @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
  92223. * @param x defines x coordinate
  92224. * @param y defines y coordinate
  92225. * @param z defines z coordinate
  92226. * @returns the face index if found (or null instead)
  92227. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92228. */
  92229. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  92230. /**
  92231. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  92232. * @returns the parameters
  92233. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92234. */
  92235. getFacetDataParameters(): any;
  92236. /**
  92237. * Disables the feature FacetData and frees the related memory
  92238. * @returns the current mesh
  92239. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92240. */
  92241. disableFacetData(): AbstractMesh;
  92242. /**
  92243. * Updates the AbstractMesh indices array
  92244. * @param indices defines the data source
  92245. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  92246. * @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)
  92247. * @returns the current mesh
  92248. */
  92249. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  92250. /**
  92251. * Creates new normals data for the mesh
  92252. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  92253. * @returns the current mesh
  92254. */
  92255. createNormals(updatable: boolean): AbstractMesh;
  92256. /**
  92257. * Align the mesh with a normal
  92258. * @param normal defines the normal to use
  92259. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  92260. * @returns the current mesh
  92261. */
  92262. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  92263. /** @hidden */
  92264. _checkOcclusionQuery(): boolean;
  92265. /**
  92266. * Disables the mesh edge rendering mode
  92267. * @returns the currentAbstractMesh
  92268. */
  92269. disableEdgesRendering(): AbstractMesh;
  92270. /**
  92271. * Enables the edge rendering mode on the mesh.
  92272. * This mode makes the mesh edges visible
  92273. * @param epsilon defines the maximal distance between two angles to detect a face
  92274. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  92275. * @returns the currentAbstractMesh
  92276. * @see https://www.babylonjs-playground.com/#19O9TU#0
  92277. */
  92278. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  92279. }
  92280. }
  92281. declare module BABYLON {
  92282. /**
  92283. * Interface used to define ActionEvent
  92284. */
  92285. export interface IActionEvent {
  92286. /** The mesh or sprite that triggered the action */
  92287. source: any;
  92288. /** The X mouse cursor position at the time of the event */
  92289. pointerX: number;
  92290. /** The Y mouse cursor position at the time of the event */
  92291. pointerY: number;
  92292. /** The mesh that is currently pointed at (can be null) */
  92293. meshUnderPointer: Nullable<AbstractMesh>;
  92294. /** the original (browser) event that triggered the ActionEvent */
  92295. sourceEvent?: any;
  92296. /** additional data for the event */
  92297. additionalData?: any;
  92298. }
  92299. /**
  92300. * ActionEvent is the event being sent when an action is triggered.
  92301. */
  92302. export class ActionEvent implements IActionEvent {
  92303. /** The mesh or sprite that triggered the action */
  92304. source: any;
  92305. /** The X mouse cursor position at the time of the event */
  92306. pointerX: number;
  92307. /** The Y mouse cursor position at the time of the event */
  92308. pointerY: number;
  92309. /** The mesh that is currently pointed at (can be null) */
  92310. meshUnderPointer: Nullable<AbstractMesh>;
  92311. /** the original (browser) event that triggered the ActionEvent */
  92312. sourceEvent?: any;
  92313. /** additional data for the event */
  92314. additionalData?: any;
  92315. /**
  92316. * Creates a new ActionEvent
  92317. * @param source The mesh or sprite that triggered the action
  92318. * @param pointerX The X mouse cursor position at the time of the event
  92319. * @param pointerY The Y mouse cursor position at the time of the event
  92320. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  92321. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  92322. * @param additionalData additional data for the event
  92323. */
  92324. constructor(
  92325. /** The mesh or sprite that triggered the action */
  92326. source: any,
  92327. /** The X mouse cursor position at the time of the event */
  92328. pointerX: number,
  92329. /** The Y mouse cursor position at the time of the event */
  92330. pointerY: number,
  92331. /** The mesh that is currently pointed at (can be null) */
  92332. meshUnderPointer: Nullable<AbstractMesh>,
  92333. /** the original (browser) event that triggered the ActionEvent */
  92334. sourceEvent?: any,
  92335. /** additional data for the event */
  92336. additionalData?: any);
  92337. /**
  92338. * Helper function to auto-create an ActionEvent from a source mesh.
  92339. * @param source The source mesh that triggered the event
  92340. * @param evt The original (browser) event
  92341. * @param additionalData additional data for the event
  92342. * @returns the new ActionEvent
  92343. */
  92344. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  92345. /**
  92346. * Helper function to auto-create an ActionEvent from a source sprite
  92347. * @param source The source sprite that triggered the event
  92348. * @param scene Scene associated with the sprite
  92349. * @param evt The original (browser) event
  92350. * @param additionalData additional data for the event
  92351. * @returns the new ActionEvent
  92352. */
  92353. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  92354. /**
  92355. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  92356. * @param scene the scene where the event occurred
  92357. * @param evt The original (browser) event
  92358. * @returns the new ActionEvent
  92359. */
  92360. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  92361. /**
  92362. * Helper function to auto-create an ActionEvent from a primitive
  92363. * @param prim defines the target primitive
  92364. * @param pointerPos defines the pointer position
  92365. * @param evt The original (browser) event
  92366. * @param additionalData additional data for the event
  92367. * @returns the new ActionEvent
  92368. */
  92369. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  92370. }
  92371. }
  92372. declare module BABYLON {
  92373. /**
  92374. * Abstract class used to decouple action Manager from scene and meshes.
  92375. * Do not instantiate.
  92376. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92377. */
  92378. export abstract class AbstractActionManager implements IDisposable {
  92379. /** Gets the list of active triggers */
  92380. static Triggers: {
  92381. [key: string]: number;
  92382. };
  92383. /** Gets the cursor to use when hovering items */
  92384. hoverCursor: string;
  92385. /** Gets the list of actions */
  92386. actions: IAction[];
  92387. /**
  92388. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  92389. */
  92390. isRecursive: boolean;
  92391. /**
  92392. * Releases all associated resources
  92393. */
  92394. abstract dispose(): void;
  92395. /**
  92396. * Does this action manager has pointer triggers
  92397. */
  92398. abstract readonly hasPointerTriggers: boolean;
  92399. /**
  92400. * Does this action manager has pick triggers
  92401. */
  92402. abstract readonly hasPickTriggers: boolean;
  92403. /**
  92404. * Process a specific trigger
  92405. * @param trigger defines the trigger to process
  92406. * @param evt defines the event details to be processed
  92407. */
  92408. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  92409. /**
  92410. * Does this action manager handles actions of any of the given triggers
  92411. * @param triggers defines the triggers to be tested
  92412. * @return a boolean indicating whether one (or more) of the triggers is handled
  92413. */
  92414. abstract hasSpecificTriggers(triggers: number[]): boolean;
  92415. /**
  92416. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  92417. * speed.
  92418. * @param triggerA defines the trigger to be tested
  92419. * @param triggerB defines the trigger to be tested
  92420. * @return a boolean indicating whether one (or more) of the triggers is handled
  92421. */
  92422. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  92423. /**
  92424. * Does this action manager handles actions of a given trigger
  92425. * @param trigger defines the trigger to be tested
  92426. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  92427. * @return whether the trigger is handled
  92428. */
  92429. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  92430. /**
  92431. * Serialize this manager to a JSON object
  92432. * @param name defines the property name to store this manager
  92433. * @returns a JSON representation of this manager
  92434. */
  92435. abstract serialize(name: string): any;
  92436. /**
  92437. * Registers an action to this action manager
  92438. * @param action defines the action to be registered
  92439. * @return the action amended (prepared) after registration
  92440. */
  92441. abstract registerAction(action: IAction): Nullable<IAction>;
  92442. /**
  92443. * Unregisters an action to this action manager
  92444. * @param action defines the action to be unregistered
  92445. * @return a boolean indicating whether the action has been unregistered
  92446. */
  92447. abstract unregisterAction(action: IAction): Boolean;
  92448. /**
  92449. * Does exist one action manager with at least one trigger
  92450. **/
  92451. static readonly HasTriggers: boolean;
  92452. /**
  92453. * Does exist one action manager with at least one pick trigger
  92454. **/
  92455. static readonly HasPickTriggers: boolean;
  92456. /**
  92457. * Does exist one action manager that handles actions of a given trigger
  92458. * @param trigger defines the trigger to be tested
  92459. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  92460. **/
  92461. static HasSpecificTrigger(trigger: number): boolean;
  92462. }
  92463. }
  92464. declare module BABYLON {
  92465. /**
  92466. * Defines how a node can be built from a string name.
  92467. */
  92468. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  92469. /**
  92470. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  92471. */
  92472. export class Node implements IBehaviorAware<Node> {
  92473. /** @hidden */
  92474. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  92475. private static _NodeConstructors;
  92476. /**
  92477. * Add a new node constructor
  92478. * @param type defines the type name of the node to construct
  92479. * @param constructorFunc defines the constructor function
  92480. */
  92481. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  92482. /**
  92483. * Returns a node constructor based on type name
  92484. * @param type defines the type name
  92485. * @param name defines the new node name
  92486. * @param scene defines the hosting scene
  92487. * @param options defines optional options to transmit to constructors
  92488. * @returns the new constructor or null
  92489. */
  92490. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  92491. /**
  92492. * Gets or sets the name of the node
  92493. */
  92494. name: string;
  92495. /**
  92496. * Gets or sets the id of the node
  92497. */
  92498. id: string;
  92499. /**
  92500. * Gets or sets the unique id of the node
  92501. */
  92502. uniqueId: number;
  92503. /**
  92504. * Gets or sets a string used to store user defined state for the node
  92505. */
  92506. state: string;
  92507. /**
  92508. * Gets or sets an object used to store user defined information for the node
  92509. */
  92510. metadata: any;
  92511. /**
  92512. * For internal use only. Please do not use.
  92513. */
  92514. reservedDataStore: any;
  92515. /**
  92516. * List of inspectable custom properties (used by the Inspector)
  92517. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  92518. */
  92519. inspectableCustomProperties: IInspectable[];
  92520. /**
  92521. * Gets or sets a boolean used to define if the node must be serialized
  92522. */
  92523. doNotSerialize: boolean;
  92524. /** @hidden */
  92525. _isDisposed: boolean;
  92526. /**
  92527. * Gets a list of Animations associated with the node
  92528. */
  92529. animations: Animation[];
  92530. protected _ranges: {
  92531. [name: string]: Nullable<AnimationRange>;
  92532. };
  92533. /**
  92534. * Callback raised when the node is ready to be used
  92535. */
  92536. onReady: Nullable<(node: Node) => void>;
  92537. private _isEnabled;
  92538. private _isParentEnabled;
  92539. private _isReady;
  92540. /** @hidden */
  92541. _currentRenderId: number;
  92542. private _parentUpdateId;
  92543. /** @hidden */
  92544. _childUpdateId: number;
  92545. /** @hidden */
  92546. _waitingParentId: Nullable<string>;
  92547. /** @hidden */
  92548. _scene: Scene;
  92549. /** @hidden */
  92550. _cache: any;
  92551. private _parentNode;
  92552. private _children;
  92553. /** @hidden */
  92554. _worldMatrix: Matrix;
  92555. /** @hidden */
  92556. _worldMatrixDeterminant: number;
  92557. /** @hidden */
  92558. _worldMatrixDeterminantIsDirty: boolean;
  92559. /** @hidden */
  92560. private _sceneRootNodesIndex;
  92561. /**
  92562. * Gets a boolean indicating if the node has been disposed
  92563. * @returns true if the node was disposed
  92564. */
  92565. isDisposed(): boolean;
  92566. /**
  92567. * Gets or sets the parent of the node (without keeping the current position in the scene)
  92568. * @see https://doc.babylonjs.com/how_to/parenting
  92569. */
  92570. parent: Nullable<Node>;
  92571. private addToSceneRootNodes;
  92572. private removeFromSceneRootNodes;
  92573. private _animationPropertiesOverride;
  92574. /**
  92575. * Gets or sets the animation properties override
  92576. */
  92577. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  92578. /**
  92579. * Gets a string idenfifying the name of the class
  92580. * @returns "Node" string
  92581. */
  92582. getClassName(): string;
  92583. /** @hidden */
  92584. readonly _isNode: boolean;
  92585. /**
  92586. * An event triggered when the mesh is disposed
  92587. */
  92588. onDisposeObservable: Observable<Node>;
  92589. private _onDisposeObserver;
  92590. /**
  92591. * Sets a callback that will be raised when the node will be disposed
  92592. */
  92593. onDispose: () => void;
  92594. /**
  92595. * Creates a new Node
  92596. * @param name the name and id to be given to this node
  92597. * @param scene the scene this node will be added to
  92598. * @param addToRootNodes the node will be added to scene.rootNodes
  92599. */
  92600. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  92601. /**
  92602. * Gets the scene of the node
  92603. * @returns a scene
  92604. */
  92605. getScene(): Scene;
  92606. /**
  92607. * Gets the engine of the node
  92608. * @returns a Engine
  92609. */
  92610. getEngine(): Engine;
  92611. private _behaviors;
  92612. /**
  92613. * Attach a behavior to the node
  92614. * @see http://doc.babylonjs.com/features/behaviour
  92615. * @param behavior defines the behavior to attach
  92616. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  92617. * @returns the current Node
  92618. */
  92619. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  92620. /**
  92621. * Remove an attached behavior
  92622. * @see http://doc.babylonjs.com/features/behaviour
  92623. * @param behavior defines the behavior to attach
  92624. * @returns the current Node
  92625. */
  92626. removeBehavior(behavior: Behavior<Node>): Node;
  92627. /**
  92628. * Gets the list of attached behaviors
  92629. * @see http://doc.babylonjs.com/features/behaviour
  92630. */
  92631. readonly behaviors: Behavior<Node>[];
  92632. /**
  92633. * Gets an attached behavior by name
  92634. * @param name defines the name of the behavior to look for
  92635. * @see http://doc.babylonjs.com/features/behaviour
  92636. * @returns null if behavior was not found else the requested behavior
  92637. */
  92638. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  92639. /**
  92640. * Returns the latest update of the World matrix
  92641. * @returns a Matrix
  92642. */
  92643. getWorldMatrix(): Matrix;
  92644. /** @hidden */
  92645. _getWorldMatrixDeterminant(): number;
  92646. /**
  92647. * Returns directly the latest state of the mesh World matrix.
  92648. * A Matrix is returned.
  92649. */
  92650. readonly worldMatrixFromCache: Matrix;
  92651. /** @hidden */
  92652. _initCache(): void;
  92653. /** @hidden */
  92654. updateCache(force?: boolean): void;
  92655. /** @hidden */
  92656. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  92657. /** @hidden */
  92658. _updateCache(ignoreParentClass?: boolean): void;
  92659. /** @hidden */
  92660. _isSynchronized(): boolean;
  92661. /** @hidden */
  92662. _markSyncedWithParent(): void;
  92663. /** @hidden */
  92664. isSynchronizedWithParent(): boolean;
  92665. /** @hidden */
  92666. isSynchronized(): boolean;
  92667. /**
  92668. * Is this node ready to be used/rendered
  92669. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  92670. * @return true if the node is ready
  92671. */
  92672. isReady(completeCheck?: boolean): boolean;
  92673. /**
  92674. * Is this node enabled?
  92675. * 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
  92676. * @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
  92677. * @return whether this node (and its parent) is enabled
  92678. */
  92679. isEnabled(checkAncestors?: boolean): boolean;
  92680. /** @hidden */
  92681. protected _syncParentEnabledState(): void;
  92682. /**
  92683. * Set the enabled state of this node
  92684. * @param value defines the new enabled state
  92685. */
  92686. setEnabled(value: boolean): void;
  92687. /**
  92688. * Is this node a descendant of the given node?
  92689. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  92690. * @param ancestor defines the parent node to inspect
  92691. * @returns a boolean indicating if this node is a descendant of the given node
  92692. */
  92693. isDescendantOf(ancestor: Node): boolean;
  92694. /** @hidden */
  92695. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  92696. /**
  92697. * Will return all nodes that have this node as ascendant
  92698. * @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
  92699. * @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
  92700. * @return all children nodes of all types
  92701. */
  92702. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  92703. /**
  92704. * Get all child-meshes of this node
  92705. * @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)
  92706. * @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
  92707. * @returns an array of AbstractMesh
  92708. */
  92709. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  92710. /**
  92711. * Get all direct children of this node
  92712. * @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
  92713. * @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)
  92714. * @returns an array of Node
  92715. */
  92716. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  92717. /** @hidden */
  92718. _setReady(state: boolean): void;
  92719. /**
  92720. * Get an animation by name
  92721. * @param name defines the name of the animation to look for
  92722. * @returns null if not found else the requested animation
  92723. */
  92724. getAnimationByName(name: string): Nullable<Animation>;
  92725. /**
  92726. * Creates an animation range for this node
  92727. * @param name defines the name of the range
  92728. * @param from defines the starting key
  92729. * @param to defines the end key
  92730. */
  92731. createAnimationRange(name: string, from: number, to: number): void;
  92732. /**
  92733. * Delete a specific animation range
  92734. * @param name defines the name of the range to delete
  92735. * @param deleteFrames defines if animation frames from the range must be deleted as well
  92736. */
  92737. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  92738. /**
  92739. * Get an animation range by name
  92740. * @param name defines the name of the animation range to look for
  92741. * @returns null if not found else the requested animation range
  92742. */
  92743. getAnimationRange(name: string): Nullable<AnimationRange>;
  92744. /**
  92745. * Gets the list of all animation ranges defined on this node
  92746. * @returns an array
  92747. */
  92748. getAnimationRanges(): Nullable<AnimationRange>[];
  92749. /**
  92750. * Will start the animation sequence
  92751. * @param name defines the range frames for animation sequence
  92752. * @param loop defines if the animation should loop (false by default)
  92753. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  92754. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  92755. * @returns the object created for this animation. If range does not exist, it will return null
  92756. */
  92757. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  92758. /**
  92759. * Serialize animation ranges into a JSON compatible object
  92760. * @returns serialization object
  92761. */
  92762. serializeAnimationRanges(): any;
  92763. /**
  92764. * Computes the world matrix of the node
  92765. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  92766. * @returns the world matrix
  92767. */
  92768. computeWorldMatrix(force?: boolean): Matrix;
  92769. /**
  92770. * Releases resources associated with this node.
  92771. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92772. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92773. */
  92774. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92775. /**
  92776. * Parse animation range data from a serialization object and store them into a given node
  92777. * @param node defines where to store the animation ranges
  92778. * @param parsedNode defines the serialization object to read data from
  92779. * @param scene defines the hosting scene
  92780. */
  92781. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  92782. /**
  92783. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  92784. * @param includeDescendants Include bounding info from descendants as well (true by default)
  92785. * @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
  92786. * @returns the new bounding vectors
  92787. */
  92788. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  92789. min: Vector3;
  92790. max: Vector3;
  92791. };
  92792. }
  92793. }
  92794. declare module BABYLON {
  92795. /**
  92796. * @hidden
  92797. */
  92798. export class _IAnimationState {
  92799. key: number;
  92800. repeatCount: number;
  92801. workValue?: any;
  92802. loopMode?: number;
  92803. offsetValue?: any;
  92804. highLimitValue?: any;
  92805. }
  92806. /**
  92807. * Class used to store any kind of animation
  92808. */
  92809. export class Animation {
  92810. /**Name of the animation */
  92811. name: string;
  92812. /**Property to animate */
  92813. targetProperty: string;
  92814. /**The frames per second of the animation */
  92815. framePerSecond: number;
  92816. /**The data type of the animation */
  92817. dataType: number;
  92818. /**The loop mode of the animation */
  92819. loopMode?: number | undefined;
  92820. /**Specifies if blending should be enabled */
  92821. enableBlending?: boolean | undefined;
  92822. /**
  92823. * Use matrix interpolation instead of using direct key value when animating matrices
  92824. */
  92825. static AllowMatricesInterpolation: boolean;
  92826. /**
  92827. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  92828. */
  92829. static AllowMatrixDecomposeForInterpolation: boolean;
  92830. /**
  92831. * Stores the key frames of the animation
  92832. */
  92833. private _keys;
  92834. /**
  92835. * Stores the easing function of the animation
  92836. */
  92837. private _easingFunction;
  92838. /**
  92839. * @hidden Internal use only
  92840. */
  92841. _runtimeAnimations: RuntimeAnimation[];
  92842. /**
  92843. * The set of event that will be linked to this animation
  92844. */
  92845. private _events;
  92846. /**
  92847. * Stores an array of target property paths
  92848. */
  92849. targetPropertyPath: string[];
  92850. /**
  92851. * Stores the blending speed of the animation
  92852. */
  92853. blendingSpeed: number;
  92854. /**
  92855. * Stores the animation ranges for the animation
  92856. */
  92857. private _ranges;
  92858. /**
  92859. * @hidden Internal use
  92860. */
  92861. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  92862. /**
  92863. * Sets up an animation
  92864. * @param property The property to animate
  92865. * @param animationType The animation type to apply
  92866. * @param framePerSecond The frames per second of the animation
  92867. * @param easingFunction The easing function used in the animation
  92868. * @returns The created animation
  92869. */
  92870. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  92871. /**
  92872. * Create and start an animation on a node
  92873. * @param name defines the name of the global animation that will be run on all nodes
  92874. * @param node defines the root node where the animation will take place
  92875. * @param targetProperty defines property to animate
  92876. * @param framePerSecond defines the number of frame per second yo use
  92877. * @param totalFrame defines the number of frames in total
  92878. * @param from defines the initial value
  92879. * @param to defines the final value
  92880. * @param loopMode defines which loop mode you want to use (off by default)
  92881. * @param easingFunction defines the easing function to use (linear by default)
  92882. * @param onAnimationEnd defines the callback to call when animation end
  92883. * @returns the animatable created for this animation
  92884. */
  92885. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  92886. /**
  92887. * Create and start an animation on a node and its descendants
  92888. * @param name defines the name of the global animation that will be run on all nodes
  92889. * @param node defines the root node where the animation will take place
  92890. * @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
  92891. * @param targetProperty defines property to animate
  92892. * @param framePerSecond defines the number of frame per second to use
  92893. * @param totalFrame defines the number of frames in total
  92894. * @param from defines the initial value
  92895. * @param to defines the final value
  92896. * @param loopMode defines which loop mode you want to use (off by default)
  92897. * @param easingFunction defines the easing function to use (linear by default)
  92898. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  92899. * @returns the list of animatables created for all nodes
  92900. * @example https://www.babylonjs-playground.com/#MH0VLI
  92901. */
  92902. 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[]>;
  92903. /**
  92904. * Creates a new animation, merges it with the existing animations and starts it
  92905. * @param name Name of the animation
  92906. * @param node Node which contains the scene that begins the animations
  92907. * @param targetProperty Specifies which property to animate
  92908. * @param framePerSecond The frames per second of the animation
  92909. * @param totalFrame The total number of frames
  92910. * @param from The frame at the beginning of the animation
  92911. * @param to The frame at the end of the animation
  92912. * @param loopMode Specifies the loop mode of the animation
  92913. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  92914. * @param onAnimationEnd Callback to run once the animation is complete
  92915. * @returns Nullable animation
  92916. */
  92917. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  92918. /**
  92919. * Transition property of an host to the target Value
  92920. * @param property The property to transition
  92921. * @param targetValue The target Value of the property
  92922. * @param host The object where the property to animate belongs
  92923. * @param scene Scene used to run the animation
  92924. * @param frameRate Framerate (in frame/s) to use
  92925. * @param transition The transition type we want to use
  92926. * @param duration The duration of the animation, in milliseconds
  92927. * @param onAnimationEnd Callback trigger at the end of the animation
  92928. * @returns Nullable animation
  92929. */
  92930. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  92931. /**
  92932. * Return the array of runtime animations currently using this animation
  92933. */
  92934. readonly runtimeAnimations: RuntimeAnimation[];
  92935. /**
  92936. * Specifies if any of the runtime animations are currently running
  92937. */
  92938. readonly hasRunningRuntimeAnimations: boolean;
  92939. /**
  92940. * Initializes the animation
  92941. * @param name Name of the animation
  92942. * @param targetProperty Property to animate
  92943. * @param framePerSecond The frames per second of the animation
  92944. * @param dataType The data type of the animation
  92945. * @param loopMode The loop mode of the animation
  92946. * @param enableBlending Specifies if blending should be enabled
  92947. */
  92948. constructor(
  92949. /**Name of the animation */
  92950. name: string,
  92951. /**Property to animate */
  92952. targetProperty: string,
  92953. /**The frames per second of the animation */
  92954. framePerSecond: number,
  92955. /**The data type of the animation */
  92956. dataType: number,
  92957. /**The loop mode of the animation */
  92958. loopMode?: number | undefined,
  92959. /**Specifies if blending should be enabled */
  92960. enableBlending?: boolean | undefined);
  92961. /**
  92962. * Converts the animation to a string
  92963. * @param fullDetails support for multiple levels of logging within scene loading
  92964. * @returns String form of the animation
  92965. */
  92966. toString(fullDetails?: boolean): string;
  92967. /**
  92968. * Add an event to this animation
  92969. * @param event Event to add
  92970. */
  92971. addEvent(event: AnimationEvent): void;
  92972. /**
  92973. * Remove all events found at the given frame
  92974. * @param frame The frame to remove events from
  92975. */
  92976. removeEvents(frame: number): void;
  92977. /**
  92978. * Retrieves all the events from the animation
  92979. * @returns Events from the animation
  92980. */
  92981. getEvents(): AnimationEvent[];
  92982. /**
  92983. * Creates an animation range
  92984. * @param name Name of the animation range
  92985. * @param from Starting frame of the animation range
  92986. * @param to Ending frame of the animation
  92987. */
  92988. createRange(name: string, from: number, to: number): void;
  92989. /**
  92990. * Deletes an animation range by name
  92991. * @param name Name of the animation range to delete
  92992. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  92993. */
  92994. deleteRange(name: string, deleteFrames?: boolean): void;
  92995. /**
  92996. * Gets the animation range by name, or null if not defined
  92997. * @param name Name of the animation range
  92998. * @returns Nullable animation range
  92999. */
  93000. getRange(name: string): Nullable<AnimationRange>;
  93001. /**
  93002. * Gets the key frames from the animation
  93003. * @returns The key frames of the animation
  93004. */
  93005. getKeys(): Array<IAnimationKey>;
  93006. /**
  93007. * Gets the highest frame rate of the animation
  93008. * @returns Highest frame rate of the animation
  93009. */
  93010. getHighestFrame(): number;
  93011. /**
  93012. * Gets the easing function of the animation
  93013. * @returns Easing function of the animation
  93014. */
  93015. getEasingFunction(): IEasingFunction;
  93016. /**
  93017. * Sets the easing function of the animation
  93018. * @param easingFunction A custom mathematical formula for animation
  93019. */
  93020. setEasingFunction(easingFunction: EasingFunction): void;
  93021. /**
  93022. * Interpolates a scalar linearly
  93023. * @param startValue Start value of the animation curve
  93024. * @param endValue End value of the animation curve
  93025. * @param gradient Scalar amount to interpolate
  93026. * @returns Interpolated scalar value
  93027. */
  93028. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  93029. /**
  93030. * Interpolates a scalar cubically
  93031. * @param startValue Start value of the animation curve
  93032. * @param outTangent End tangent of the animation
  93033. * @param endValue End value of the animation curve
  93034. * @param inTangent Start tangent of the animation curve
  93035. * @param gradient Scalar amount to interpolate
  93036. * @returns Interpolated scalar value
  93037. */
  93038. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  93039. /**
  93040. * Interpolates a quaternion using a spherical linear interpolation
  93041. * @param startValue Start value of the animation curve
  93042. * @param endValue End value of the animation curve
  93043. * @param gradient Scalar amount to interpolate
  93044. * @returns Interpolated quaternion value
  93045. */
  93046. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  93047. /**
  93048. * Interpolates a quaternion cubically
  93049. * @param startValue Start value of the animation curve
  93050. * @param outTangent End tangent of the animation curve
  93051. * @param endValue End value of the animation curve
  93052. * @param inTangent Start tangent of the animation curve
  93053. * @param gradient Scalar amount to interpolate
  93054. * @returns Interpolated quaternion value
  93055. */
  93056. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  93057. /**
  93058. * Interpolates a Vector3 linearl
  93059. * @param startValue Start value of the animation curve
  93060. * @param endValue End value of the animation curve
  93061. * @param gradient Scalar amount to interpolate
  93062. * @returns Interpolated scalar value
  93063. */
  93064. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  93065. /**
  93066. * Interpolates a Vector3 cubically
  93067. * @param startValue Start value of the animation curve
  93068. * @param outTangent End tangent of the animation
  93069. * @param endValue End value of the animation curve
  93070. * @param inTangent Start tangent of the animation curve
  93071. * @param gradient Scalar amount to interpolate
  93072. * @returns InterpolatedVector3 value
  93073. */
  93074. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  93075. /**
  93076. * Interpolates a Vector2 linearly
  93077. * @param startValue Start value of the animation curve
  93078. * @param endValue End value of the animation curve
  93079. * @param gradient Scalar amount to interpolate
  93080. * @returns Interpolated Vector2 value
  93081. */
  93082. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  93083. /**
  93084. * Interpolates a Vector2 cubically
  93085. * @param startValue Start value of the animation curve
  93086. * @param outTangent End tangent of the animation
  93087. * @param endValue End value of the animation curve
  93088. * @param inTangent Start tangent of the animation curve
  93089. * @param gradient Scalar amount to interpolate
  93090. * @returns Interpolated Vector2 value
  93091. */
  93092. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  93093. /**
  93094. * Interpolates a size linearly
  93095. * @param startValue Start value of the animation curve
  93096. * @param endValue End value of the animation curve
  93097. * @param gradient Scalar amount to interpolate
  93098. * @returns Interpolated Size value
  93099. */
  93100. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  93101. /**
  93102. * Interpolates a Color3 linearly
  93103. * @param startValue Start value of the animation curve
  93104. * @param endValue End value of the animation curve
  93105. * @param gradient Scalar amount to interpolate
  93106. * @returns Interpolated Color3 value
  93107. */
  93108. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  93109. /**
  93110. * @hidden Internal use only
  93111. */
  93112. _getKeyValue(value: any): any;
  93113. /**
  93114. * @hidden Internal use only
  93115. */
  93116. _interpolate(currentFrame: number, state: _IAnimationState): any;
  93117. /**
  93118. * Defines the function to use to interpolate matrices
  93119. * @param startValue defines the start matrix
  93120. * @param endValue defines the end matrix
  93121. * @param gradient defines the gradient between both matrices
  93122. * @param result defines an optional target matrix where to store the interpolation
  93123. * @returns the interpolated matrix
  93124. */
  93125. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  93126. /**
  93127. * Makes a copy of the animation
  93128. * @returns Cloned animation
  93129. */
  93130. clone(): Animation;
  93131. /**
  93132. * Sets the key frames of the animation
  93133. * @param values The animation key frames to set
  93134. */
  93135. setKeys(values: Array<IAnimationKey>): void;
  93136. /**
  93137. * Serializes the animation to an object
  93138. * @returns Serialized object
  93139. */
  93140. serialize(): any;
  93141. /**
  93142. * Float animation type
  93143. */
  93144. private static _ANIMATIONTYPE_FLOAT;
  93145. /**
  93146. * Vector3 animation type
  93147. */
  93148. private static _ANIMATIONTYPE_VECTOR3;
  93149. /**
  93150. * Quaternion animation type
  93151. */
  93152. private static _ANIMATIONTYPE_QUATERNION;
  93153. /**
  93154. * Matrix animation type
  93155. */
  93156. private static _ANIMATIONTYPE_MATRIX;
  93157. /**
  93158. * Color3 animation type
  93159. */
  93160. private static _ANIMATIONTYPE_COLOR3;
  93161. /**
  93162. * Vector2 animation type
  93163. */
  93164. private static _ANIMATIONTYPE_VECTOR2;
  93165. /**
  93166. * Size animation type
  93167. */
  93168. private static _ANIMATIONTYPE_SIZE;
  93169. /**
  93170. * Relative Loop Mode
  93171. */
  93172. private static _ANIMATIONLOOPMODE_RELATIVE;
  93173. /**
  93174. * Cycle Loop Mode
  93175. */
  93176. private static _ANIMATIONLOOPMODE_CYCLE;
  93177. /**
  93178. * Constant Loop Mode
  93179. */
  93180. private static _ANIMATIONLOOPMODE_CONSTANT;
  93181. /**
  93182. * Get the float animation type
  93183. */
  93184. static readonly ANIMATIONTYPE_FLOAT: number;
  93185. /**
  93186. * Get the Vector3 animation type
  93187. */
  93188. static readonly ANIMATIONTYPE_VECTOR3: number;
  93189. /**
  93190. * Get the Vector2 animation type
  93191. */
  93192. static readonly ANIMATIONTYPE_VECTOR2: number;
  93193. /**
  93194. * Get the Size animation type
  93195. */
  93196. static readonly ANIMATIONTYPE_SIZE: number;
  93197. /**
  93198. * Get the Quaternion animation type
  93199. */
  93200. static readonly ANIMATIONTYPE_QUATERNION: number;
  93201. /**
  93202. * Get the Matrix animation type
  93203. */
  93204. static readonly ANIMATIONTYPE_MATRIX: number;
  93205. /**
  93206. * Get the Color3 animation type
  93207. */
  93208. static readonly ANIMATIONTYPE_COLOR3: number;
  93209. /**
  93210. * Get the Relative Loop Mode
  93211. */
  93212. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  93213. /**
  93214. * Get the Cycle Loop Mode
  93215. */
  93216. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  93217. /**
  93218. * Get the Constant Loop Mode
  93219. */
  93220. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  93221. /** @hidden */
  93222. static _UniversalLerp(left: any, right: any, amount: number): any;
  93223. /**
  93224. * Parses an animation object and creates an animation
  93225. * @param parsedAnimation Parsed animation object
  93226. * @returns Animation object
  93227. */
  93228. static Parse(parsedAnimation: any): Animation;
  93229. /**
  93230. * Appends the serialized animations from the source animations
  93231. * @param source Source containing the animations
  93232. * @param destination Target to store the animations
  93233. */
  93234. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  93235. }
  93236. }
  93237. declare module BABYLON {
  93238. /**
  93239. * Interface containing an array of animations
  93240. */
  93241. export interface IAnimatable {
  93242. /**
  93243. * Array of animations
  93244. */
  93245. animations: Nullable<Array<Animation>>;
  93246. }
  93247. }
  93248. declare module BABYLON {
  93249. /**
  93250. * This represents all the required information to add a fresnel effect on a material:
  93251. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  93252. */
  93253. export class FresnelParameters {
  93254. private _isEnabled;
  93255. /**
  93256. * Define if the fresnel effect is enable or not.
  93257. */
  93258. isEnabled: boolean;
  93259. /**
  93260. * Define the color used on edges (grazing angle)
  93261. */
  93262. leftColor: Color3;
  93263. /**
  93264. * Define the color used on center
  93265. */
  93266. rightColor: Color3;
  93267. /**
  93268. * Define bias applied to computed fresnel term
  93269. */
  93270. bias: number;
  93271. /**
  93272. * Defined the power exponent applied to fresnel term
  93273. */
  93274. power: number;
  93275. /**
  93276. * Clones the current fresnel and its valuues
  93277. * @returns a clone fresnel configuration
  93278. */
  93279. clone(): FresnelParameters;
  93280. /**
  93281. * Serializes the current fresnel parameters to a JSON representation.
  93282. * @return the JSON serialization
  93283. */
  93284. serialize(): any;
  93285. /**
  93286. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  93287. * @param parsedFresnelParameters Define the JSON representation
  93288. * @returns the parsed parameters
  93289. */
  93290. static Parse(parsedFresnelParameters: any): FresnelParameters;
  93291. }
  93292. }
  93293. declare module BABYLON {
  93294. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  93295. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93296. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93297. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93298. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93299. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93300. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93301. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93302. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93303. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93304. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93305. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93306. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93307. /**
  93308. * Decorator used to define property that can be serialized as reference to a camera
  93309. * @param sourceName defines the name of the property to decorate
  93310. */
  93311. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93312. /**
  93313. * Class used to help serialization objects
  93314. */
  93315. export class SerializationHelper {
  93316. /** @hidden */
  93317. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  93318. /** @hidden */
  93319. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  93320. /** @hidden */
  93321. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  93322. /** @hidden */
  93323. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  93324. /**
  93325. * Appends the serialized animations from the source animations
  93326. * @param source Source containing the animations
  93327. * @param destination Target to store the animations
  93328. */
  93329. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  93330. /**
  93331. * Static function used to serialized a specific entity
  93332. * @param entity defines the entity to serialize
  93333. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  93334. * @returns a JSON compatible object representing the serialization of the entity
  93335. */
  93336. static Serialize<T>(entity: T, serializationObject?: any): any;
  93337. /**
  93338. * Creates a new entity from a serialization data object
  93339. * @param creationFunction defines a function used to instanciated the new entity
  93340. * @param source defines the source serialization data
  93341. * @param scene defines the hosting scene
  93342. * @param rootUrl defines the root url for resources
  93343. * @returns a new entity
  93344. */
  93345. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  93346. /**
  93347. * Clones an object
  93348. * @param creationFunction defines the function used to instanciate the new object
  93349. * @param source defines the source object
  93350. * @returns the cloned object
  93351. */
  93352. static Clone<T>(creationFunction: () => T, source: T): T;
  93353. /**
  93354. * Instanciates a new object based on a source one (some data will be shared between both object)
  93355. * @param creationFunction defines the function used to instanciate the new object
  93356. * @param source defines the source object
  93357. * @returns the new object
  93358. */
  93359. static Instanciate<T>(creationFunction: () => T, source: T): T;
  93360. }
  93361. }
  93362. declare module BABYLON {
  93363. /**
  93364. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  93365. */
  93366. export interface CubeMapInfo {
  93367. /**
  93368. * The pixel array for the front face.
  93369. * This is stored in format, left to right, up to down format.
  93370. */
  93371. front: Nullable<ArrayBufferView>;
  93372. /**
  93373. * The pixel array for the back face.
  93374. * This is stored in format, left to right, up to down format.
  93375. */
  93376. back: Nullable<ArrayBufferView>;
  93377. /**
  93378. * The pixel array for the left face.
  93379. * This is stored in format, left to right, up to down format.
  93380. */
  93381. left: Nullable<ArrayBufferView>;
  93382. /**
  93383. * The pixel array for the right face.
  93384. * This is stored in format, left to right, up to down format.
  93385. */
  93386. right: Nullable<ArrayBufferView>;
  93387. /**
  93388. * The pixel array for the up face.
  93389. * This is stored in format, left to right, up to down format.
  93390. */
  93391. up: Nullable<ArrayBufferView>;
  93392. /**
  93393. * The pixel array for the down face.
  93394. * This is stored in format, left to right, up to down format.
  93395. */
  93396. down: Nullable<ArrayBufferView>;
  93397. /**
  93398. * The size of the cubemap stored.
  93399. *
  93400. * Each faces will be size * size pixels.
  93401. */
  93402. size: number;
  93403. /**
  93404. * The format of the texture.
  93405. *
  93406. * RGBA, RGB.
  93407. */
  93408. format: number;
  93409. /**
  93410. * The type of the texture data.
  93411. *
  93412. * UNSIGNED_INT, FLOAT.
  93413. */
  93414. type: number;
  93415. /**
  93416. * Specifies whether the texture is in gamma space.
  93417. */
  93418. gammaSpace: boolean;
  93419. }
  93420. /**
  93421. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  93422. */
  93423. export class PanoramaToCubeMapTools {
  93424. private static FACE_FRONT;
  93425. private static FACE_BACK;
  93426. private static FACE_RIGHT;
  93427. private static FACE_LEFT;
  93428. private static FACE_DOWN;
  93429. private static FACE_UP;
  93430. /**
  93431. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  93432. *
  93433. * @param float32Array The source data.
  93434. * @param inputWidth The width of the input panorama.
  93435. * @param inputHeight The height of the input panorama.
  93436. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  93437. * @return The cubemap data
  93438. */
  93439. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  93440. private static CreateCubemapTexture;
  93441. private static CalcProjectionSpherical;
  93442. }
  93443. }
  93444. declare module BABYLON {
  93445. /**
  93446. * Helper class dealing with the extraction of spherical polynomial dataArray
  93447. * from a cube map.
  93448. */
  93449. export class CubeMapToSphericalPolynomialTools {
  93450. private static FileFaces;
  93451. /**
  93452. * Converts a texture to the according Spherical Polynomial data.
  93453. * This extracts the first 3 orders only as they are the only one used in the lighting.
  93454. *
  93455. * @param texture The texture to extract the information from.
  93456. * @return The Spherical Polynomial data.
  93457. */
  93458. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  93459. /**
  93460. * Converts a cubemap to the according Spherical Polynomial data.
  93461. * This extracts the first 3 orders only as they are the only one used in the lighting.
  93462. *
  93463. * @param cubeInfo The Cube map to extract the information from.
  93464. * @return The Spherical Polynomial data.
  93465. */
  93466. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  93467. }
  93468. }
  93469. declare module BABYLON {
  93470. /**
  93471. * Class used to manipulate GUIDs
  93472. */
  93473. export class GUID {
  93474. /**
  93475. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  93476. * Be aware Math.random() could cause collisions, but:
  93477. * "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"
  93478. * @returns a pseudo random id
  93479. */
  93480. static RandomId(): string;
  93481. }
  93482. }
  93483. declare module BABYLON {
  93484. /**
  93485. * Base class of all the textures in babylon.
  93486. * It groups all the common properties the materials, post process, lights... might need
  93487. * in order to make a correct use of the texture.
  93488. */
  93489. export class BaseTexture implements IAnimatable {
  93490. /**
  93491. * Default anisotropic filtering level for the application.
  93492. * It is set to 4 as a good tradeoff between perf and quality.
  93493. */
  93494. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  93495. /**
  93496. * Gets or sets the unique id of the texture
  93497. */
  93498. uniqueId: number;
  93499. /**
  93500. * Define the name of the texture.
  93501. */
  93502. name: string;
  93503. /**
  93504. * Gets or sets an object used to store user defined information.
  93505. */
  93506. metadata: any;
  93507. /**
  93508. * For internal use only. Please do not use.
  93509. */
  93510. reservedDataStore: any;
  93511. private _hasAlpha;
  93512. /**
  93513. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  93514. */
  93515. hasAlpha: boolean;
  93516. /**
  93517. * Defines if the alpha value should be determined via the rgb values.
  93518. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  93519. */
  93520. getAlphaFromRGB: boolean;
  93521. /**
  93522. * Intensity or strength of the texture.
  93523. * It is commonly used by materials to fine tune the intensity of the texture
  93524. */
  93525. level: number;
  93526. /**
  93527. * Define the UV chanel to use starting from 0 and defaulting to 0.
  93528. * This is part of the texture as textures usually maps to one uv set.
  93529. */
  93530. coordinatesIndex: number;
  93531. private _coordinatesMode;
  93532. /**
  93533. * How a texture is mapped.
  93534. *
  93535. * | Value | Type | Description |
  93536. * | ----- | ----------------------------------- | ----------- |
  93537. * | 0 | EXPLICIT_MODE | |
  93538. * | 1 | SPHERICAL_MODE | |
  93539. * | 2 | PLANAR_MODE | |
  93540. * | 3 | CUBIC_MODE | |
  93541. * | 4 | PROJECTION_MODE | |
  93542. * | 5 | SKYBOX_MODE | |
  93543. * | 6 | INVCUBIC_MODE | |
  93544. * | 7 | EQUIRECTANGULAR_MODE | |
  93545. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  93546. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  93547. */
  93548. coordinatesMode: number;
  93549. /**
  93550. * | Value | Type | Description |
  93551. * | ----- | ------------------ | ----------- |
  93552. * | 0 | CLAMP_ADDRESSMODE | |
  93553. * | 1 | WRAP_ADDRESSMODE | |
  93554. * | 2 | MIRROR_ADDRESSMODE | |
  93555. */
  93556. wrapU: number;
  93557. /**
  93558. * | Value | Type | Description |
  93559. * | ----- | ------------------ | ----------- |
  93560. * | 0 | CLAMP_ADDRESSMODE | |
  93561. * | 1 | WRAP_ADDRESSMODE | |
  93562. * | 2 | MIRROR_ADDRESSMODE | |
  93563. */
  93564. wrapV: number;
  93565. /**
  93566. * | Value | Type | Description |
  93567. * | ----- | ------------------ | ----------- |
  93568. * | 0 | CLAMP_ADDRESSMODE | |
  93569. * | 1 | WRAP_ADDRESSMODE | |
  93570. * | 2 | MIRROR_ADDRESSMODE | |
  93571. */
  93572. wrapR: number;
  93573. /**
  93574. * With compliant hardware and browser (supporting anisotropic filtering)
  93575. * this defines the level of anisotropic filtering in the texture.
  93576. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  93577. */
  93578. anisotropicFilteringLevel: number;
  93579. /**
  93580. * Define if the texture is a cube texture or if false a 2d texture.
  93581. */
  93582. isCube: boolean;
  93583. /**
  93584. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  93585. */
  93586. is3D: boolean;
  93587. /**
  93588. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  93589. * HDR texture are usually stored in linear space.
  93590. * This only impacts the PBR and Background materials
  93591. */
  93592. gammaSpace: boolean;
  93593. /**
  93594. * Gets or sets whether or not the texture contains RGBD data.
  93595. */
  93596. isRGBD: boolean;
  93597. /**
  93598. * Is Z inverted in the texture (useful in a cube texture).
  93599. */
  93600. invertZ: boolean;
  93601. /**
  93602. * Are mip maps generated for this texture or not.
  93603. */
  93604. readonly noMipmap: boolean;
  93605. /**
  93606. * @hidden
  93607. */
  93608. lodLevelInAlpha: boolean;
  93609. /**
  93610. * With prefiltered texture, defined the offset used during the prefiltering steps.
  93611. */
  93612. lodGenerationOffset: number;
  93613. /**
  93614. * With prefiltered texture, defined the scale used during the prefiltering steps.
  93615. */
  93616. lodGenerationScale: number;
  93617. /**
  93618. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  93619. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  93620. * average roughness values.
  93621. */
  93622. linearSpecularLOD: boolean;
  93623. /**
  93624. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  93625. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  93626. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  93627. */
  93628. irradianceTexture: Nullable<BaseTexture>;
  93629. /**
  93630. * Define if the texture is a render target.
  93631. */
  93632. isRenderTarget: boolean;
  93633. /**
  93634. * Define the unique id of the texture in the scene.
  93635. */
  93636. readonly uid: string;
  93637. /**
  93638. * Return a string representation of the texture.
  93639. * @returns the texture as a string
  93640. */
  93641. toString(): string;
  93642. /**
  93643. * Get the class name of the texture.
  93644. * @returns "BaseTexture"
  93645. */
  93646. getClassName(): string;
  93647. /**
  93648. * Define the list of animation attached to the texture.
  93649. */
  93650. animations: Animation[];
  93651. /**
  93652. * An event triggered when the texture is disposed.
  93653. */
  93654. onDisposeObservable: Observable<BaseTexture>;
  93655. private _onDisposeObserver;
  93656. /**
  93657. * Callback triggered when the texture has been disposed.
  93658. * Kept for back compatibility, you can use the onDisposeObservable instead.
  93659. */
  93660. onDispose: () => void;
  93661. /**
  93662. * Define the current state of the loading sequence when in delayed load mode.
  93663. */
  93664. delayLoadState: number;
  93665. private _scene;
  93666. /** @hidden */
  93667. _texture: Nullable<InternalTexture>;
  93668. private _uid;
  93669. /**
  93670. * Define if the texture is preventinga material to render or not.
  93671. * If not and the texture is not ready, the engine will use a default black texture instead.
  93672. */
  93673. readonly isBlocking: boolean;
  93674. /**
  93675. * Instantiates a new BaseTexture.
  93676. * Base class of all the textures in babylon.
  93677. * It groups all the common properties the materials, post process, lights... might need
  93678. * in order to make a correct use of the texture.
  93679. * @param scene Define the scene the texture blongs to
  93680. */
  93681. constructor(scene: Nullable<Scene>);
  93682. /**
  93683. * Get the scene the texture belongs to.
  93684. * @returns the scene or null if undefined
  93685. */
  93686. getScene(): Nullable<Scene>;
  93687. /**
  93688. * Get the texture transform matrix used to offset tile the texture for istance.
  93689. * @returns the transformation matrix
  93690. */
  93691. getTextureMatrix(): Matrix;
  93692. /**
  93693. * Get the texture reflection matrix used to rotate/transform the reflection.
  93694. * @returns the reflection matrix
  93695. */
  93696. getReflectionTextureMatrix(): Matrix;
  93697. /**
  93698. * Get the underlying lower level texture from Babylon.
  93699. * @returns the insternal texture
  93700. */
  93701. getInternalTexture(): Nullable<InternalTexture>;
  93702. /**
  93703. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  93704. * @returns true if ready or not blocking
  93705. */
  93706. isReadyOrNotBlocking(): boolean;
  93707. /**
  93708. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  93709. * @returns true if fully ready
  93710. */
  93711. isReady(): boolean;
  93712. private _cachedSize;
  93713. /**
  93714. * Get the size of the texture.
  93715. * @returns the texture size.
  93716. */
  93717. getSize(): ISize;
  93718. /**
  93719. * Get the base size of the texture.
  93720. * It can be different from the size if the texture has been resized for POT for instance
  93721. * @returns the base size
  93722. */
  93723. getBaseSize(): ISize;
  93724. /**
  93725. * Update the sampling mode of the texture.
  93726. * Default is Trilinear mode.
  93727. *
  93728. * | Value | Type | Description |
  93729. * | ----- | ------------------ | ----------- |
  93730. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  93731. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  93732. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  93733. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  93734. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  93735. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  93736. * | 7 | NEAREST_LINEAR | |
  93737. * | 8 | NEAREST_NEAREST | |
  93738. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  93739. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  93740. * | 11 | LINEAR_LINEAR | |
  93741. * | 12 | LINEAR_NEAREST | |
  93742. *
  93743. * > _mag_: magnification filter (close to the viewer)
  93744. * > _min_: minification filter (far from the viewer)
  93745. * > _mip_: filter used between mip map levels
  93746. *@param samplingMode Define the new sampling mode of the texture
  93747. */
  93748. updateSamplingMode(samplingMode: number): void;
  93749. /**
  93750. * Scales the texture if is `canRescale()`
  93751. * @param ratio the resize factor we want to use to rescale
  93752. */
  93753. scale(ratio: number): void;
  93754. /**
  93755. * Get if the texture can rescale.
  93756. */
  93757. readonly canRescale: boolean;
  93758. /** @hidden */
  93759. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  93760. /** @hidden */
  93761. _rebuild(): void;
  93762. /**
  93763. * Triggers the load sequence in delayed load mode.
  93764. */
  93765. delayLoad(): void;
  93766. /**
  93767. * Clones the texture.
  93768. * @returns the cloned texture
  93769. */
  93770. clone(): Nullable<BaseTexture>;
  93771. /**
  93772. * Get the texture underlying type (INT, FLOAT...)
  93773. */
  93774. readonly textureType: number;
  93775. /**
  93776. * Get the texture underlying format (RGB, RGBA...)
  93777. */
  93778. readonly textureFormat: number;
  93779. /**
  93780. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  93781. * This will returns an RGBA array buffer containing either in values (0-255) or
  93782. * float values (0-1) depending of the underlying buffer type.
  93783. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  93784. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  93785. * @param buffer defines a user defined buffer to fill with data (can be null)
  93786. * @returns The Array buffer containing the pixels data.
  93787. */
  93788. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  93789. /**
  93790. * Release and destroy the underlying lower level texture aka internalTexture.
  93791. */
  93792. releaseInternalTexture(): void;
  93793. /**
  93794. * Get the polynomial representation of the texture data.
  93795. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  93796. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  93797. */
  93798. sphericalPolynomial: Nullable<SphericalPolynomial>;
  93799. /** @hidden */
  93800. readonly _lodTextureHigh: Nullable<BaseTexture>;
  93801. /** @hidden */
  93802. readonly _lodTextureMid: Nullable<BaseTexture>;
  93803. /** @hidden */
  93804. readonly _lodTextureLow: Nullable<BaseTexture>;
  93805. /**
  93806. * Dispose the texture and release its associated resources.
  93807. */
  93808. dispose(): void;
  93809. /**
  93810. * Serialize the texture into a JSON representation that can be parsed later on.
  93811. * @returns the JSON representation of the texture
  93812. */
  93813. serialize(): any;
  93814. /**
  93815. * Helper function to be called back once a list of texture contains only ready textures.
  93816. * @param textures Define the list of textures to wait for
  93817. * @param callback Define the callback triggered once the entire list will be ready
  93818. */
  93819. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  93820. }
  93821. }
  93822. declare module BABYLON {
  93823. /**
  93824. * Class used to store data associated with WebGL texture data for the engine
  93825. * This class should not be used directly
  93826. */
  93827. export class InternalTexture {
  93828. /** @hidden */
  93829. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  93830. /**
  93831. * The source of the texture data is unknown
  93832. */
  93833. static DATASOURCE_UNKNOWN: number;
  93834. /**
  93835. * Texture data comes from an URL
  93836. */
  93837. static DATASOURCE_URL: number;
  93838. /**
  93839. * Texture data is only used for temporary storage
  93840. */
  93841. static DATASOURCE_TEMP: number;
  93842. /**
  93843. * Texture data comes from raw data (ArrayBuffer)
  93844. */
  93845. static DATASOURCE_RAW: number;
  93846. /**
  93847. * Texture content is dynamic (video or dynamic texture)
  93848. */
  93849. static DATASOURCE_DYNAMIC: number;
  93850. /**
  93851. * Texture content is generated by rendering to it
  93852. */
  93853. static DATASOURCE_RENDERTARGET: number;
  93854. /**
  93855. * Texture content is part of a multi render target process
  93856. */
  93857. static DATASOURCE_MULTIRENDERTARGET: number;
  93858. /**
  93859. * Texture data comes from a cube data file
  93860. */
  93861. static DATASOURCE_CUBE: number;
  93862. /**
  93863. * Texture data comes from a raw cube data
  93864. */
  93865. static DATASOURCE_CUBERAW: number;
  93866. /**
  93867. * Texture data come from a prefiltered cube data file
  93868. */
  93869. static DATASOURCE_CUBEPREFILTERED: number;
  93870. /**
  93871. * Texture content is raw 3D data
  93872. */
  93873. static DATASOURCE_RAW3D: number;
  93874. /**
  93875. * Texture content is a depth texture
  93876. */
  93877. static DATASOURCE_DEPTHTEXTURE: number;
  93878. /**
  93879. * Texture data comes from a raw cube data encoded with RGBD
  93880. */
  93881. static DATASOURCE_CUBERAW_RGBD: number;
  93882. /**
  93883. * Defines if the texture is ready
  93884. */
  93885. isReady: boolean;
  93886. /**
  93887. * Defines if the texture is a cube texture
  93888. */
  93889. isCube: boolean;
  93890. /**
  93891. * Defines if the texture contains 3D data
  93892. */
  93893. is3D: boolean;
  93894. /**
  93895. * Defines if the texture contains multiview data
  93896. */
  93897. isMultiview: boolean;
  93898. /**
  93899. * Gets the URL used to load this texture
  93900. */
  93901. url: string;
  93902. /**
  93903. * Gets the sampling mode of the texture
  93904. */
  93905. samplingMode: number;
  93906. /**
  93907. * Gets a boolean indicating if the texture needs mipmaps generation
  93908. */
  93909. generateMipMaps: boolean;
  93910. /**
  93911. * Gets the number of samples used by the texture (WebGL2+ only)
  93912. */
  93913. samples: number;
  93914. /**
  93915. * Gets the type of the texture (int, float...)
  93916. */
  93917. type: number;
  93918. /**
  93919. * Gets the format of the texture (RGB, RGBA...)
  93920. */
  93921. format: number;
  93922. /**
  93923. * Observable called when the texture is loaded
  93924. */
  93925. onLoadedObservable: Observable<InternalTexture>;
  93926. /**
  93927. * Gets the width of the texture
  93928. */
  93929. width: number;
  93930. /**
  93931. * Gets the height of the texture
  93932. */
  93933. height: number;
  93934. /**
  93935. * Gets the depth of the texture
  93936. */
  93937. depth: number;
  93938. /**
  93939. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  93940. */
  93941. baseWidth: number;
  93942. /**
  93943. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  93944. */
  93945. baseHeight: number;
  93946. /**
  93947. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  93948. */
  93949. baseDepth: number;
  93950. /**
  93951. * Gets a boolean indicating if the texture is inverted on Y axis
  93952. */
  93953. invertY: boolean;
  93954. /** @hidden */
  93955. _invertVScale: boolean;
  93956. /** @hidden */
  93957. _associatedChannel: number;
  93958. /** @hidden */
  93959. _dataSource: number;
  93960. /** @hidden */
  93961. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  93962. /** @hidden */
  93963. _bufferView: Nullable<ArrayBufferView>;
  93964. /** @hidden */
  93965. _bufferViewArray: Nullable<ArrayBufferView[]>;
  93966. /** @hidden */
  93967. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  93968. /** @hidden */
  93969. _size: number;
  93970. /** @hidden */
  93971. _extension: string;
  93972. /** @hidden */
  93973. _files: Nullable<string[]>;
  93974. /** @hidden */
  93975. _workingCanvas: Nullable<HTMLCanvasElement>;
  93976. /** @hidden */
  93977. _workingContext: Nullable<CanvasRenderingContext2D>;
  93978. /** @hidden */
  93979. _framebuffer: Nullable<WebGLFramebuffer>;
  93980. /** @hidden */
  93981. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  93982. /** @hidden */
  93983. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  93984. /** @hidden */
  93985. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  93986. /** @hidden */
  93987. _attachments: Nullable<number[]>;
  93988. /** @hidden */
  93989. _cachedCoordinatesMode: Nullable<number>;
  93990. /** @hidden */
  93991. _cachedWrapU: Nullable<number>;
  93992. /** @hidden */
  93993. _cachedWrapV: Nullable<number>;
  93994. /** @hidden */
  93995. _cachedWrapR: Nullable<number>;
  93996. /** @hidden */
  93997. _cachedAnisotropicFilteringLevel: Nullable<number>;
  93998. /** @hidden */
  93999. _isDisabled: boolean;
  94000. /** @hidden */
  94001. _compression: Nullable<string>;
  94002. /** @hidden */
  94003. _generateStencilBuffer: boolean;
  94004. /** @hidden */
  94005. _generateDepthBuffer: boolean;
  94006. /** @hidden */
  94007. _comparisonFunction: number;
  94008. /** @hidden */
  94009. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  94010. /** @hidden */
  94011. _lodGenerationScale: number;
  94012. /** @hidden */
  94013. _lodGenerationOffset: number;
  94014. /** @hidden */
  94015. _colorTextureArray: Nullable<WebGLTexture>;
  94016. /** @hidden */
  94017. _depthStencilTextureArray: Nullable<WebGLTexture>;
  94018. /** @hidden */
  94019. _lodTextureHigh: Nullable<BaseTexture>;
  94020. /** @hidden */
  94021. _lodTextureMid: Nullable<BaseTexture>;
  94022. /** @hidden */
  94023. _lodTextureLow: Nullable<BaseTexture>;
  94024. /** @hidden */
  94025. _isRGBD: boolean;
  94026. /** @hidden */
  94027. _linearSpecularLOD: boolean;
  94028. /** @hidden */
  94029. _irradianceTexture: Nullable<BaseTexture>;
  94030. /** @hidden */
  94031. _webGLTexture: Nullable<WebGLTexture>;
  94032. /** @hidden */
  94033. _references: number;
  94034. private _engine;
  94035. /**
  94036. * Gets the Engine the texture belongs to.
  94037. * @returns The babylon engine
  94038. */
  94039. getEngine(): Engine;
  94040. /**
  94041. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  94042. */
  94043. readonly dataSource: number;
  94044. /**
  94045. * Creates a new InternalTexture
  94046. * @param engine defines the engine to use
  94047. * @param dataSource defines the type of data that will be used
  94048. * @param delayAllocation if the texture allocation should be delayed (default: false)
  94049. */
  94050. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  94051. /**
  94052. * Increments the number of references (ie. the number of Texture that point to it)
  94053. */
  94054. incrementReferences(): void;
  94055. /**
  94056. * Change the size of the texture (not the size of the content)
  94057. * @param width defines the new width
  94058. * @param height defines the new height
  94059. * @param depth defines the new depth (1 by default)
  94060. */
  94061. updateSize(width: int, height: int, depth?: int): void;
  94062. /** @hidden */
  94063. _rebuild(): void;
  94064. /** @hidden */
  94065. _swapAndDie(target: InternalTexture): void;
  94066. /**
  94067. * Dispose the current allocated resources
  94068. */
  94069. dispose(): void;
  94070. }
  94071. }
  94072. declare module BABYLON {
  94073. /**
  94074. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  94075. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  94076. */
  94077. export class EffectFallbacks {
  94078. private _defines;
  94079. private _currentRank;
  94080. private _maxRank;
  94081. private _mesh;
  94082. /**
  94083. * Removes the fallback from the bound mesh.
  94084. */
  94085. unBindMesh(): void;
  94086. /**
  94087. * Adds a fallback on the specified property.
  94088. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  94089. * @param define The name of the define in the shader
  94090. */
  94091. addFallback(rank: number, define: string): void;
  94092. /**
  94093. * Sets the mesh to use CPU skinning when needing to fallback.
  94094. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  94095. * @param mesh The mesh to use the fallbacks.
  94096. */
  94097. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  94098. /**
  94099. * Checks to see if more fallbacks are still availible.
  94100. */
  94101. readonly hasMoreFallbacks: boolean;
  94102. /**
  94103. * Removes the defines that should be removed when falling back.
  94104. * @param currentDefines defines the current define statements for the shader.
  94105. * @param effect defines the current effect we try to compile
  94106. * @returns The resulting defines with defines of the current rank removed.
  94107. */
  94108. reduce(currentDefines: string, effect: Effect): string;
  94109. }
  94110. /**
  94111. * Options to be used when creating an effect.
  94112. */
  94113. export class EffectCreationOptions {
  94114. /**
  94115. * Atrributes that will be used in the shader.
  94116. */
  94117. attributes: string[];
  94118. /**
  94119. * Uniform varible names that will be set in the shader.
  94120. */
  94121. uniformsNames: string[];
  94122. /**
  94123. * Uniform buffer varible names that will be set in the shader.
  94124. */
  94125. uniformBuffersNames: string[];
  94126. /**
  94127. * Sampler texture variable names that will be set in the shader.
  94128. */
  94129. samplers: string[];
  94130. /**
  94131. * Define statements that will be set in the shader.
  94132. */
  94133. defines: any;
  94134. /**
  94135. * Possible fallbacks for this effect to improve performance when needed.
  94136. */
  94137. fallbacks: Nullable<EffectFallbacks>;
  94138. /**
  94139. * Callback that will be called when the shader is compiled.
  94140. */
  94141. onCompiled: Nullable<(effect: Effect) => void>;
  94142. /**
  94143. * Callback that will be called if an error occurs during shader compilation.
  94144. */
  94145. onError: Nullable<(effect: Effect, errors: string) => void>;
  94146. /**
  94147. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  94148. */
  94149. indexParameters: any;
  94150. /**
  94151. * Max number of lights that can be used in the shader.
  94152. */
  94153. maxSimultaneousLights: number;
  94154. /**
  94155. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  94156. */
  94157. transformFeedbackVaryings: Nullable<string[]>;
  94158. }
  94159. /**
  94160. * Effect containing vertex and fragment shader that can be executed on an object.
  94161. */
  94162. export class Effect implements IDisposable {
  94163. /**
  94164. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  94165. */
  94166. static ShadersRepository: string;
  94167. /**
  94168. * Name of the effect.
  94169. */
  94170. name: any;
  94171. /**
  94172. * String container all the define statements that should be set on the shader.
  94173. */
  94174. defines: string;
  94175. /**
  94176. * Callback that will be called when the shader is compiled.
  94177. */
  94178. onCompiled: Nullable<(effect: Effect) => void>;
  94179. /**
  94180. * Callback that will be called if an error occurs during shader compilation.
  94181. */
  94182. onError: Nullable<(effect: Effect, errors: string) => void>;
  94183. /**
  94184. * Callback that will be called when effect is bound.
  94185. */
  94186. onBind: Nullable<(effect: Effect) => void>;
  94187. /**
  94188. * Unique ID of the effect.
  94189. */
  94190. uniqueId: number;
  94191. /**
  94192. * Observable that will be called when the shader is compiled.
  94193. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  94194. */
  94195. onCompileObservable: Observable<Effect>;
  94196. /**
  94197. * Observable that will be called if an error occurs during shader compilation.
  94198. */
  94199. onErrorObservable: Observable<Effect>;
  94200. /** @hidden */
  94201. _onBindObservable: Nullable<Observable<Effect>>;
  94202. /**
  94203. * Observable that will be called when effect is bound.
  94204. */
  94205. readonly onBindObservable: Observable<Effect>;
  94206. /** @hidden */
  94207. _bonesComputationForcedToCPU: boolean;
  94208. private static _uniqueIdSeed;
  94209. private _engine;
  94210. private _uniformBuffersNames;
  94211. private _uniformsNames;
  94212. private _samplerList;
  94213. private _samplers;
  94214. private _isReady;
  94215. private _compilationError;
  94216. private _attributesNames;
  94217. private _attributes;
  94218. private _uniforms;
  94219. /**
  94220. * Key for the effect.
  94221. * @hidden
  94222. */
  94223. _key: string;
  94224. private _indexParameters;
  94225. private _fallbacks;
  94226. private _vertexSourceCode;
  94227. private _fragmentSourceCode;
  94228. private _vertexSourceCodeOverride;
  94229. private _fragmentSourceCodeOverride;
  94230. private _transformFeedbackVaryings;
  94231. /**
  94232. * Compiled shader to webGL program.
  94233. * @hidden
  94234. */
  94235. _pipelineContext: Nullable<IPipelineContext>;
  94236. private _valueCache;
  94237. private static _baseCache;
  94238. /**
  94239. * Instantiates an effect.
  94240. * An effect can be used to create/manage/execute vertex and fragment shaders.
  94241. * @param baseName Name of the effect.
  94242. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  94243. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  94244. * @param samplers List of sampler variables that will be passed to the shader.
  94245. * @param engine Engine to be used to render the effect
  94246. * @param defines Define statements to be added to the shader.
  94247. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  94248. * @param onCompiled Callback that will be called when the shader is compiled.
  94249. * @param onError Callback that will be called if an error occurs during shader compilation.
  94250. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  94251. */
  94252. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  94253. private _useFinalCode;
  94254. /**
  94255. * Unique key for this effect
  94256. */
  94257. readonly key: string;
  94258. /**
  94259. * If the effect has been compiled and prepared.
  94260. * @returns if the effect is compiled and prepared.
  94261. */
  94262. isReady(): boolean;
  94263. private _isReadyInternal;
  94264. /**
  94265. * The engine the effect was initialized with.
  94266. * @returns the engine.
  94267. */
  94268. getEngine(): Engine;
  94269. /**
  94270. * The pipeline context for this effect
  94271. * @returns the associated pipeline context
  94272. */
  94273. getPipelineContext(): Nullable<IPipelineContext>;
  94274. /**
  94275. * The set of names of attribute variables for the shader.
  94276. * @returns An array of attribute names.
  94277. */
  94278. getAttributesNames(): string[];
  94279. /**
  94280. * Returns the attribute at the given index.
  94281. * @param index The index of the attribute.
  94282. * @returns The location of the attribute.
  94283. */
  94284. getAttributeLocation(index: number): number;
  94285. /**
  94286. * Returns the attribute based on the name of the variable.
  94287. * @param name of the attribute to look up.
  94288. * @returns the attribute location.
  94289. */
  94290. getAttributeLocationByName(name: string): number;
  94291. /**
  94292. * The number of attributes.
  94293. * @returns the numnber of attributes.
  94294. */
  94295. getAttributesCount(): number;
  94296. /**
  94297. * Gets the index of a uniform variable.
  94298. * @param uniformName of the uniform to look up.
  94299. * @returns the index.
  94300. */
  94301. getUniformIndex(uniformName: string): number;
  94302. /**
  94303. * Returns the attribute based on the name of the variable.
  94304. * @param uniformName of the uniform to look up.
  94305. * @returns the location of the uniform.
  94306. */
  94307. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  94308. /**
  94309. * Returns an array of sampler variable names
  94310. * @returns The array of sampler variable neames.
  94311. */
  94312. getSamplers(): string[];
  94313. /**
  94314. * The error from the last compilation.
  94315. * @returns the error string.
  94316. */
  94317. getCompilationError(): string;
  94318. /**
  94319. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  94320. * @param func The callback to be used.
  94321. */
  94322. executeWhenCompiled(func: (effect: Effect) => void): void;
  94323. private _checkIsReady;
  94324. /** @hidden */
  94325. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  94326. /** @hidden */
  94327. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  94328. /** @hidden */
  94329. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  94330. /**
  94331. * Recompiles the webGL program
  94332. * @param vertexSourceCode The source code for the vertex shader.
  94333. * @param fragmentSourceCode The source code for the fragment shader.
  94334. * @param onCompiled Callback called when completed.
  94335. * @param onError Callback called on error.
  94336. * @hidden
  94337. */
  94338. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  94339. /**
  94340. * Prepares the effect
  94341. * @hidden
  94342. */
  94343. _prepareEffect(): void;
  94344. private _processCompilationErrors;
  94345. /**
  94346. * Checks if the effect is supported. (Must be called after compilation)
  94347. */
  94348. readonly isSupported: boolean;
  94349. /**
  94350. * Binds a texture to the engine to be used as output of the shader.
  94351. * @param channel Name of the output variable.
  94352. * @param texture Texture to bind.
  94353. * @hidden
  94354. */
  94355. _bindTexture(channel: string, texture: InternalTexture): void;
  94356. /**
  94357. * Sets a texture on the engine to be used in the shader.
  94358. * @param channel Name of the sampler variable.
  94359. * @param texture Texture to set.
  94360. */
  94361. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  94362. /**
  94363. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  94364. * @param channel Name of the sampler variable.
  94365. * @param texture Texture to set.
  94366. */
  94367. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  94368. /**
  94369. * Sets an array of textures on the engine to be used in the shader.
  94370. * @param channel Name of the variable.
  94371. * @param textures Textures to set.
  94372. */
  94373. setTextureArray(channel: string, textures: BaseTexture[]): void;
  94374. /**
  94375. * 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)
  94376. * @param channel Name of the sampler variable.
  94377. * @param postProcess Post process to get the input texture from.
  94378. */
  94379. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  94380. /**
  94381. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  94382. * 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)
  94383. * @param channel Name of the sampler variable.
  94384. * @param postProcess Post process to get the output texture from.
  94385. */
  94386. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  94387. /** @hidden */
  94388. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  94389. /** @hidden */
  94390. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  94391. /** @hidden */
  94392. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  94393. /** @hidden */
  94394. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  94395. /**
  94396. * Binds a buffer to a uniform.
  94397. * @param buffer Buffer to bind.
  94398. * @param name Name of the uniform variable to bind to.
  94399. */
  94400. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  94401. /**
  94402. * Binds block to a uniform.
  94403. * @param blockName Name of the block to bind.
  94404. * @param index Index to bind.
  94405. */
  94406. bindUniformBlock(blockName: string, index: number): void;
  94407. /**
  94408. * Sets an interger value on a uniform variable.
  94409. * @param uniformName Name of the variable.
  94410. * @param value Value to be set.
  94411. * @returns this effect.
  94412. */
  94413. setInt(uniformName: string, value: number): Effect;
  94414. /**
  94415. * Sets an int array on a uniform variable.
  94416. * @param uniformName Name of the variable.
  94417. * @param array array to be set.
  94418. * @returns this effect.
  94419. */
  94420. setIntArray(uniformName: string, array: Int32Array): Effect;
  94421. /**
  94422. * 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)
  94423. * @param uniformName Name of the variable.
  94424. * @param array array to be set.
  94425. * @returns this effect.
  94426. */
  94427. setIntArray2(uniformName: string, array: Int32Array): Effect;
  94428. /**
  94429. * 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)
  94430. * @param uniformName Name of the variable.
  94431. * @param array array to be set.
  94432. * @returns this effect.
  94433. */
  94434. setIntArray3(uniformName: string, array: Int32Array): Effect;
  94435. /**
  94436. * 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)
  94437. * @param uniformName Name of the variable.
  94438. * @param array array to be set.
  94439. * @returns this effect.
  94440. */
  94441. setIntArray4(uniformName: string, array: Int32Array): Effect;
  94442. /**
  94443. * Sets an float array on a uniform variable.
  94444. * @param uniformName Name of the variable.
  94445. * @param array array to be set.
  94446. * @returns this effect.
  94447. */
  94448. setFloatArray(uniformName: string, array: Float32Array): Effect;
  94449. /**
  94450. * 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)
  94451. * @param uniformName Name of the variable.
  94452. * @param array array to be set.
  94453. * @returns this effect.
  94454. */
  94455. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  94456. /**
  94457. * 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)
  94458. * @param uniformName Name of the variable.
  94459. * @param array array to be set.
  94460. * @returns this effect.
  94461. */
  94462. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  94463. /**
  94464. * 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)
  94465. * @param uniformName Name of the variable.
  94466. * @param array array to be set.
  94467. * @returns this effect.
  94468. */
  94469. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  94470. /**
  94471. * Sets an array on a uniform variable.
  94472. * @param uniformName Name of the variable.
  94473. * @param array array to be set.
  94474. * @returns this effect.
  94475. */
  94476. setArray(uniformName: string, array: number[]): Effect;
  94477. /**
  94478. * 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)
  94479. * @param uniformName Name of the variable.
  94480. * @param array array to be set.
  94481. * @returns this effect.
  94482. */
  94483. setArray2(uniformName: string, array: number[]): Effect;
  94484. /**
  94485. * 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)
  94486. * @param uniformName Name of the variable.
  94487. * @param array array to be set.
  94488. * @returns this effect.
  94489. */
  94490. setArray3(uniformName: string, array: number[]): Effect;
  94491. /**
  94492. * 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)
  94493. * @param uniformName Name of the variable.
  94494. * @param array array to be set.
  94495. * @returns this effect.
  94496. */
  94497. setArray4(uniformName: string, array: number[]): Effect;
  94498. /**
  94499. * Sets matrices on a uniform variable.
  94500. * @param uniformName Name of the variable.
  94501. * @param matrices matrices to be set.
  94502. * @returns this effect.
  94503. */
  94504. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  94505. /**
  94506. * Sets matrix on a uniform variable.
  94507. * @param uniformName Name of the variable.
  94508. * @param matrix matrix to be set.
  94509. * @returns this effect.
  94510. */
  94511. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  94512. /**
  94513. * 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)
  94514. * @param uniformName Name of the variable.
  94515. * @param matrix matrix to be set.
  94516. * @returns this effect.
  94517. */
  94518. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  94519. /**
  94520. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  94521. * @param uniformName Name of the variable.
  94522. * @param matrix matrix to be set.
  94523. * @returns this effect.
  94524. */
  94525. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  94526. /**
  94527. * Sets a float on a uniform variable.
  94528. * @param uniformName Name of the variable.
  94529. * @param value value to be set.
  94530. * @returns this effect.
  94531. */
  94532. setFloat(uniformName: string, value: number): Effect;
  94533. /**
  94534. * Sets a boolean on a uniform variable.
  94535. * @param uniformName Name of the variable.
  94536. * @param bool value to be set.
  94537. * @returns this effect.
  94538. */
  94539. setBool(uniformName: string, bool: boolean): Effect;
  94540. /**
  94541. * Sets a Vector2 on a uniform variable.
  94542. * @param uniformName Name of the variable.
  94543. * @param vector2 vector2 to be set.
  94544. * @returns this effect.
  94545. */
  94546. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  94547. /**
  94548. * Sets a float2 on a uniform variable.
  94549. * @param uniformName Name of the variable.
  94550. * @param x First float in float2.
  94551. * @param y Second float in float2.
  94552. * @returns this effect.
  94553. */
  94554. setFloat2(uniformName: string, x: number, y: number): Effect;
  94555. /**
  94556. * Sets a Vector3 on a uniform variable.
  94557. * @param uniformName Name of the variable.
  94558. * @param vector3 Value to be set.
  94559. * @returns this effect.
  94560. */
  94561. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  94562. /**
  94563. * Sets a float3 on a uniform variable.
  94564. * @param uniformName Name of the variable.
  94565. * @param x First float in float3.
  94566. * @param y Second float in float3.
  94567. * @param z Third float in float3.
  94568. * @returns this effect.
  94569. */
  94570. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  94571. /**
  94572. * Sets a Vector4 on a uniform variable.
  94573. * @param uniformName Name of the variable.
  94574. * @param vector4 Value to be set.
  94575. * @returns this effect.
  94576. */
  94577. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  94578. /**
  94579. * Sets a float4 on a uniform variable.
  94580. * @param uniformName Name of the variable.
  94581. * @param x First float in float4.
  94582. * @param y Second float in float4.
  94583. * @param z Third float in float4.
  94584. * @param w Fourth float in float4.
  94585. * @returns this effect.
  94586. */
  94587. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  94588. /**
  94589. * Sets a Color3 on a uniform variable.
  94590. * @param uniformName Name of the variable.
  94591. * @param color3 Value to be set.
  94592. * @returns this effect.
  94593. */
  94594. setColor3(uniformName: string, color3: IColor3Like): Effect;
  94595. /**
  94596. * Sets a Color4 on a uniform variable.
  94597. * @param uniformName Name of the variable.
  94598. * @param color3 Value to be set.
  94599. * @param alpha Alpha value to be set.
  94600. * @returns this effect.
  94601. */
  94602. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  94603. /**
  94604. * Sets a Color4 on a uniform variable
  94605. * @param uniformName defines the name of the variable
  94606. * @param color4 defines the value to be set
  94607. * @returns this effect.
  94608. */
  94609. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  94610. /** Release all associated resources */
  94611. dispose(): void;
  94612. /**
  94613. * This function will add a new shader to the shader store
  94614. * @param name the name of the shader
  94615. * @param pixelShader optional pixel shader content
  94616. * @param vertexShader optional vertex shader content
  94617. */
  94618. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  94619. /**
  94620. * Store of each shader (The can be looked up using effect.key)
  94621. */
  94622. static ShadersStore: {
  94623. [key: string]: string;
  94624. };
  94625. /**
  94626. * Store of each included file for a shader (The can be looked up using effect.key)
  94627. */
  94628. static IncludesShadersStore: {
  94629. [key: string]: string;
  94630. };
  94631. /**
  94632. * Resets the cache of effects.
  94633. */
  94634. static ResetCache(): void;
  94635. }
  94636. }
  94637. declare module BABYLON {
  94638. /**
  94639. * Uniform buffer objects.
  94640. *
  94641. * Handles blocks of uniform on the GPU.
  94642. *
  94643. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  94644. *
  94645. * For more information, please refer to :
  94646. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  94647. */
  94648. export class UniformBuffer {
  94649. private _engine;
  94650. private _buffer;
  94651. private _data;
  94652. private _bufferData;
  94653. private _dynamic?;
  94654. private _uniformLocations;
  94655. private _uniformSizes;
  94656. private _uniformLocationPointer;
  94657. private _needSync;
  94658. private _noUBO;
  94659. private _currentEffect;
  94660. private static _MAX_UNIFORM_SIZE;
  94661. private static _tempBuffer;
  94662. /**
  94663. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  94664. * This is dynamic to allow compat with webgl 1 and 2.
  94665. * You will need to pass the name of the uniform as well as the value.
  94666. */
  94667. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  94668. /**
  94669. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  94670. * This is dynamic to allow compat with webgl 1 and 2.
  94671. * You will need to pass the name of the uniform as well as the value.
  94672. */
  94673. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  94674. /**
  94675. * Lambda to Update a single float in a uniform buffer.
  94676. * This is dynamic to allow compat with webgl 1 and 2.
  94677. * You will need to pass the name of the uniform as well as the value.
  94678. */
  94679. updateFloat: (name: string, x: number) => void;
  94680. /**
  94681. * Lambda to Update a vec2 of float in a uniform buffer.
  94682. * This is dynamic to allow compat with webgl 1 and 2.
  94683. * You will need to pass the name of the uniform as well as the value.
  94684. */
  94685. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  94686. /**
  94687. * Lambda to Update a vec3 of float in a uniform buffer.
  94688. * This is dynamic to allow compat with webgl 1 and 2.
  94689. * You will need to pass the name of the uniform as well as the value.
  94690. */
  94691. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  94692. /**
  94693. * Lambda to Update a vec4 of float in a uniform buffer.
  94694. * This is dynamic to allow compat with webgl 1 and 2.
  94695. * You will need to pass the name of the uniform as well as the value.
  94696. */
  94697. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  94698. /**
  94699. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  94700. * This is dynamic to allow compat with webgl 1 and 2.
  94701. * You will need to pass the name of the uniform as well as the value.
  94702. */
  94703. updateMatrix: (name: string, mat: Matrix) => void;
  94704. /**
  94705. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  94706. * This is dynamic to allow compat with webgl 1 and 2.
  94707. * You will need to pass the name of the uniform as well as the value.
  94708. */
  94709. updateVector3: (name: string, vector: Vector3) => void;
  94710. /**
  94711. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  94712. * This is dynamic to allow compat with webgl 1 and 2.
  94713. * You will need to pass the name of the uniform as well as the value.
  94714. */
  94715. updateVector4: (name: string, vector: Vector4) => void;
  94716. /**
  94717. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  94718. * This is dynamic to allow compat with webgl 1 and 2.
  94719. * You will need to pass the name of the uniform as well as the value.
  94720. */
  94721. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  94722. /**
  94723. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  94724. * This is dynamic to allow compat with webgl 1 and 2.
  94725. * You will need to pass the name of the uniform as well as the value.
  94726. */
  94727. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  94728. /**
  94729. * Instantiates a new Uniform buffer objects.
  94730. *
  94731. * Handles blocks of uniform on the GPU.
  94732. *
  94733. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  94734. *
  94735. * For more information, please refer to :
  94736. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  94737. * @param engine Define the engine the buffer is associated with
  94738. * @param data Define the data contained in the buffer
  94739. * @param dynamic Define if the buffer is updatable
  94740. */
  94741. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  94742. /**
  94743. * Indicates if the buffer is using the WebGL2 UBO implementation,
  94744. * or just falling back on setUniformXXX calls.
  94745. */
  94746. readonly useUbo: boolean;
  94747. /**
  94748. * Indicates if the WebGL underlying uniform buffer is in sync
  94749. * with the javascript cache data.
  94750. */
  94751. readonly isSync: boolean;
  94752. /**
  94753. * Indicates if the WebGL underlying uniform buffer is dynamic.
  94754. * Also, a dynamic UniformBuffer will disable cache verification and always
  94755. * update the underlying WebGL uniform buffer to the GPU.
  94756. * @returns if Dynamic, otherwise false
  94757. */
  94758. isDynamic(): boolean;
  94759. /**
  94760. * The data cache on JS side.
  94761. * @returns the underlying data as a float array
  94762. */
  94763. getData(): Float32Array;
  94764. /**
  94765. * The underlying WebGL Uniform buffer.
  94766. * @returns the webgl buffer
  94767. */
  94768. getBuffer(): Nullable<DataBuffer>;
  94769. /**
  94770. * std140 layout specifies how to align data within an UBO structure.
  94771. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  94772. * for specs.
  94773. */
  94774. private _fillAlignment;
  94775. /**
  94776. * Adds an uniform in the buffer.
  94777. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  94778. * for the layout to be correct !
  94779. * @param name Name of the uniform, as used in the uniform block in the shader.
  94780. * @param size Data size, or data directly.
  94781. */
  94782. addUniform(name: string, size: number | number[]): void;
  94783. /**
  94784. * Adds a Matrix 4x4 to the uniform buffer.
  94785. * @param name Name of the uniform, as used in the uniform block in the shader.
  94786. * @param mat A 4x4 matrix.
  94787. */
  94788. addMatrix(name: string, mat: Matrix): void;
  94789. /**
  94790. * Adds a vec2 to the uniform buffer.
  94791. * @param name Name of the uniform, as used in the uniform block in the shader.
  94792. * @param x Define the x component value of the vec2
  94793. * @param y Define the y component value of the vec2
  94794. */
  94795. addFloat2(name: string, x: number, y: number): void;
  94796. /**
  94797. * Adds a vec3 to the uniform buffer.
  94798. * @param name Name of the uniform, as used in the uniform block in the shader.
  94799. * @param x Define the x component value of the vec3
  94800. * @param y Define the y component value of the vec3
  94801. * @param z Define the z component value of the vec3
  94802. */
  94803. addFloat3(name: string, x: number, y: number, z: number): void;
  94804. /**
  94805. * Adds a vec3 to the uniform buffer.
  94806. * @param name Name of the uniform, as used in the uniform block in the shader.
  94807. * @param color Define the vec3 from a Color
  94808. */
  94809. addColor3(name: string, color: Color3): void;
  94810. /**
  94811. * Adds a vec4 to the uniform buffer.
  94812. * @param name Name of the uniform, as used in the uniform block in the shader.
  94813. * @param color Define the rgb components from a Color
  94814. * @param alpha Define the a component of the vec4
  94815. */
  94816. addColor4(name: string, color: Color3, alpha: number): void;
  94817. /**
  94818. * Adds a vec3 to the uniform buffer.
  94819. * @param name Name of the uniform, as used in the uniform block in the shader.
  94820. * @param vector Define the vec3 components from a Vector
  94821. */
  94822. addVector3(name: string, vector: Vector3): void;
  94823. /**
  94824. * Adds a Matrix 3x3 to the uniform buffer.
  94825. * @param name Name of the uniform, as used in the uniform block in the shader.
  94826. */
  94827. addMatrix3x3(name: string): void;
  94828. /**
  94829. * Adds a Matrix 2x2 to the uniform buffer.
  94830. * @param name Name of the uniform, as used in the uniform block in the shader.
  94831. */
  94832. addMatrix2x2(name: string): void;
  94833. /**
  94834. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  94835. */
  94836. create(): void;
  94837. /** @hidden */
  94838. _rebuild(): void;
  94839. /**
  94840. * Updates the WebGL Uniform Buffer on the GPU.
  94841. * If the `dynamic` flag is set to true, no cache comparison is done.
  94842. * Otherwise, the buffer will be updated only if the cache differs.
  94843. */
  94844. update(): void;
  94845. /**
  94846. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  94847. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  94848. * @param data Define the flattened data
  94849. * @param size Define the size of the data.
  94850. */
  94851. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  94852. private _valueCache;
  94853. private _cacheMatrix;
  94854. private _updateMatrix3x3ForUniform;
  94855. private _updateMatrix3x3ForEffect;
  94856. private _updateMatrix2x2ForEffect;
  94857. private _updateMatrix2x2ForUniform;
  94858. private _updateFloatForEffect;
  94859. private _updateFloatForUniform;
  94860. private _updateFloat2ForEffect;
  94861. private _updateFloat2ForUniform;
  94862. private _updateFloat3ForEffect;
  94863. private _updateFloat3ForUniform;
  94864. private _updateFloat4ForEffect;
  94865. private _updateFloat4ForUniform;
  94866. private _updateMatrixForEffect;
  94867. private _updateMatrixForUniform;
  94868. private _updateVector3ForEffect;
  94869. private _updateVector3ForUniform;
  94870. private _updateVector4ForEffect;
  94871. private _updateVector4ForUniform;
  94872. private _updateColor3ForEffect;
  94873. private _updateColor3ForUniform;
  94874. private _updateColor4ForEffect;
  94875. private _updateColor4ForUniform;
  94876. /**
  94877. * Sets a sampler uniform on the effect.
  94878. * @param name Define the name of the sampler.
  94879. * @param texture Define the texture to set in the sampler
  94880. */
  94881. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  94882. /**
  94883. * Directly updates the value of the uniform in the cache AND on the GPU.
  94884. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  94885. * @param data Define the flattened data
  94886. */
  94887. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  94888. /**
  94889. * Binds this uniform buffer to an effect.
  94890. * @param effect Define the effect to bind the buffer to
  94891. * @param name Name of the uniform block in the shader.
  94892. */
  94893. bindToEffect(effect: Effect, name: string): void;
  94894. /**
  94895. * Disposes the uniform buffer.
  94896. */
  94897. dispose(): void;
  94898. }
  94899. }
  94900. declare module BABYLON {
  94901. /**
  94902. * Class used to work with sound analyzer using fast fourier transform (FFT)
  94903. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94904. */
  94905. export class Analyser {
  94906. /**
  94907. * Gets or sets the smoothing
  94908. * @ignorenaming
  94909. */
  94910. SMOOTHING: number;
  94911. /**
  94912. * Gets or sets the FFT table size
  94913. * @ignorenaming
  94914. */
  94915. FFT_SIZE: number;
  94916. /**
  94917. * Gets or sets the bar graph amplitude
  94918. * @ignorenaming
  94919. */
  94920. BARGRAPHAMPLITUDE: number;
  94921. /**
  94922. * Gets or sets the position of the debug canvas
  94923. * @ignorenaming
  94924. */
  94925. DEBUGCANVASPOS: {
  94926. x: number;
  94927. y: number;
  94928. };
  94929. /**
  94930. * Gets or sets the debug canvas size
  94931. * @ignorenaming
  94932. */
  94933. DEBUGCANVASSIZE: {
  94934. width: number;
  94935. height: number;
  94936. };
  94937. private _byteFreqs;
  94938. private _byteTime;
  94939. private _floatFreqs;
  94940. private _webAudioAnalyser;
  94941. private _debugCanvas;
  94942. private _debugCanvasContext;
  94943. private _scene;
  94944. private _registerFunc;
  94945. private _audioEngine;
  94946. /**
  94947. * Creates a new analyser
  94948. * @param scene defines hosting scene
  94949. */
  94950. constructor(scene: Scene);
  94951. /**
  94952. * Get the number of data values you will have to play with for the visualization
  94953. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  94954. * @returns a number
  94955. */
  94956. getFrequencyBinCount(): number;
  94957. /**
  94958. * Gets the current frequency data as a byte array
  94959. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  94960. * @returns a Uint8Array
  94961. */
  94962. getByteFrequencyData(): Uint8Array;
  94963. /**
  94964. * Gets the current waveform as a byte array
  94965. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  94966. * @returns a Uint8Array
  94967. */
  94968. getByteTimeDomainData(): Uint8Array;
  94969. /**
  94970. * Gets the current frequency data as a float array
  94971. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  94972. * @returns a Float32Array
  94973. */
  94974. getFloatFrequencyData(): Float32Array;
  94975. /**
  94976. * Renders the debug canvas
  94977. */
  94978. drawDebugCanvas(): void;
  94979. /**
  94980. * Stops rendering the debug canvas and removes it
  94981. */
  94982. stopDebugCanvas(): void;
  94983. /**
  94984. * Connects two audio nodes
  94985. * @param inputAudioNode defines first node to connect
  94986. * @param outputAudioNode defines second node to connect
  94987. */
  94988. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  94989. /**
  94990. * Releases all associated resources
  94991. */
  94992. dispose(): void;
  94993. }
  94994. }
  94995. declare module BABYLON {
  94996. /**
  94997. * This represents an audio engine and it is responsible
  94998. * to play, synchronize and analyse sounds throughout the application.
  94999. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  95000. */
  95001. export interface IAudioEngine extends IDisposable {
  95002. /**
  95003. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  95004. */
  95005. readonly canUseWebAudio: boolean;
  95006. /**
  95007. * Gets the current AudioContext if available.
  95008. */
  95009. readonly audioContext: Nullable<AudioContext>;
  95010. /**
  95011. * The master gain node defines the global audio volume of your audio engine.
  95012. */
  95013. readonly masterGain: GainNode;
  95014. /**
  95015. * Gets whether or not mp3 are supported by your browser.
  95016. */
  95017. readonly isMP3supported: boolean;
  95018. /**
  95019. * Gets whether or not ogg are supported by your browser.
  95020. */
  95021. readonly isOGGsupported: boolean;
  95022. /**
  95023. * Defines if Babylon should emit a warning if WebAudio is not supported.
  95024. * @ignoreNaming
  95025. */
  95026. WarnedWebAudioUnsupported: boolean;
  95027. /**
  95028. * Defines if the audio engine relies on a custom unlocked button.
  95029. * In this case, the embedded button will not be displayed.
  95030. */
  95031. useCustomUnlockedButton: boolean;
  95032. /**
  95033. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  95034. */
  95035. readonly unlocked: boolean;
  95036. /**
  95037. * Event raised when audio has been unlocked on the browser.
  95038. */
  95039. onAudioUnlockedObservable: Observable<AudioEngine>;
  95040. /**
  95041. * Event raised when audio has been locked on the browser.
  95042. */
  95043. onAudioLockedObservable: Observable<AudioEngine>;
  95044. /**
  95045. * Flags the audio engine in Locked state.
  95046. * This happens due to new browser policies preventing audio to autoplay.
  95047. */
  95048. lock(): void;
  95049. /**
  95050. * Unlocks the audio engine once a user action has been done on the dom.
  95051. * This is helpful to resume play once browser policies have been satisfied.
  95052. */
  95053. unlock(): void;
  95054. }
  95055. /**
  95056. * This represents the default audio engine used in babylon.
  95057. * It is responsible to play, synchronize and analyse sounds throughout the application.
  95058. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  95059. */
  95060. export class AudioEngine implements IAudioEngine {
  95061. private _audioContext;
  95062. private _audioContextInitialized;
  95063. private _muteButton;
  95064. private _hostElement;
  95065. /**
  95066. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  95067. */
  95068. canUseWebAudio: boolean;
  95069. /**
  95070. * The master gain node defines the global audio volume of your audio engine.
  95071. */
  95072. masterGain: GainNode;
  95073. /**
  95074. * Defines if Babylon should emit a warning if WebAudio is not supported.
  95075. * @ignoreNaming
  95076. */
  95077. WarnedWebAudioUnsupported: boolean;
  95078. /**
  95079. * Gets whether or not mp3 are supported by your browser.
  95080. */
  95081. isMP3supported: boolean;
  95082. /**
  95083. * Gets whether or not ogg are supported by your browser.
  95084. */
  95085. isOGGsupported: boolean;
  95086. /**
  95087. * Gets whether audio has been unlocked on the device.
  95088. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  95089. * a user interaction has happened.
  95090. */
  95091. unlocked: boolean;
  95092. /**
  95093. * Defines if the audio engine relies on a custom unlocked button.
  95094. * In this case, the embedded button will not be displayed.
  95095. */
  95096. useCustomUnlockedButton: boolean;
  95097. /**
  95098. * Event raised when audio has been unlocked on the browser.
  95099. */
  95100. onAudioUnlockedObservable: Observable<AudioEngine>;
  95101. /**
  95102. * Event raised when audio has been locked on the browser.
  95103. */
  95104. onAudioLockedObservable: Observable<AudioEngine>;
  95105. /**
  95106. * Gets the current AudioContext if available.
  95107. */
  95108. readonly audioContext: Nullable<AudioContext>;
  95109. private _connectedAnalyser;
  95110. /**
  95111. * Instantiates a new audio engine.
  95112. *
  95113. * There should be only one per page as some browsers restrict the number
  95114. * of audio contexts you can create.
  95115. * @param hostElement defines the host element where to display the mute icon if necessary
  95116. */
  95117. constructor(hostElement?: Nullable<HTMLElement>);
  95118. /**
  95119. * Flags the audio engine in Locked state.
  95120. * This happens due to new browser policies preventing audio to autoplay.
  95121. */
  95122. lock(): void;
  95123. /**
  95124. * Unlocks the audio engine once a user action has been done on the dom.
  95125. * This is helpful to resume play once browser policies have been satisfied.
  95126. */
  95127. unlock(): void;
  95128. private _resumeAudioContext;
  95129. private _initializeAudioContext;
  95130. private _tryToRun;
  95131. private _triggerRunningState;
  95132. private _triggerSuspendedState;
  95133. private _displayMuteButton;
  95134. private _moveButtonToTopLeft;
  95135. private _onResize;
  95136. private _hideMuteButton;
  95137. /**
  95138. * Destroy and release the resources associated with the audio ccontext.
  95139. */
  95140. dispose(): void;
  95141. /**
  95142. * Gets the global volume sets on the master gain.
  95143. * @returns the global volume if set or -1 otherwise
  95144. */
  95145. getGlobalVolume(): number;
  95146. /**
  95147. * Sets the global volume of your experience (sets on the master gain).
  95148. * @param newVolume Defines the new global volume of the application
  95149. */
  95150. setGlobalVolume(newVolume: number): void;
  95151. /**
  95152. * Connect the audio engine to an audio analyser allowing some amazing
  95153. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  95154. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  95155. * @param analyser The analyser to connect to the engine
  95156. */
  95157. connectToAnalyser(analyser: Analyser): void;
  95158. }
  95159. }
  95160. declare module BABYLON {
  95161. /**
  95162. * Interface used to present a loading screen while loading a scene
  95163. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95164. */
  95165. export interface ILoadingScreen {
  95166. /**
  95167. * Function called to display the loading screen
  95168. */
  95169. displayLoadingUI: () => void;
  95170. /**
  95171. * Function called to hide the loading screen
  95172. */
  95173. hideLoadingUI: () => void;
  95174. /**
  95175. * Gets or sets the color to use for the background
  95176. */
  95177. loadingUIBackgroundColor: string;
  95178. /**
  95179. * Gets or sets the text to display while loading
  95180. */
  95181. loadingUIText: string;
  95182. }
  95183. /**
  95184. * Class used for the default loading screen
  95185. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95186. */
  95187. export class DefaultLoadingScreen implements ILoadingScreen {
  95188. private _renderingCanvas;
  95189. private _loadingText;
  95190. private _loadingDivBackgroundColor;
  95191. private _loadingDiv;
  95192. private _loadingTextDiv;
  95193. /** Gets or sets the logo url to use for the default loading screen */
  95194. static DefaultLogoUrl: string;
  95195. /** Gets or sets the spinner url to use for the default loading screen */
  95196. static DefaultSpinnerUrl: string;
  95197. /**
  95198. * Creates a new default loading screen
  95199. * @param _renderingCanvas defines the canvas used to render the scene
  95200. * @param _loadingText defines the default text to display
  95201. * @param _loadingDivBackgroundColor defines the default background color
  95202. */
  95203. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  95204. /**
  95205. * Function called to display the loading screen
  95206. */
  95207. displayLoadingUI(): void;
  95208. /**
  95209. * Function called to hide the loading screen
  95210. */
  95211. hideLoadingUI(): void;
  95212. /**
  95213. * Gets or sets the text to display while loading
  95214. */
  95215. loadingUIText: string;
  95216. /**
  95217. * Gets or sets the color to use for the background
  95218. */
  95219. loadingUIBackgroundColor: string;
  95220. private _resizeLoadingUI;
  95221. }
  95222. }
  95223. declare module BABYLON {
  95224. /** @hidden */
  95225. export class WebGLPipelineContext implements IPipelineContext {
  95226. engine: Engine;
  95227. program: Nullable<WebGLProgram>;
  95228. context?: WebGLRenderingContext;
  95229. vertexShader?: WebGLShader;
  95230. fragmentShader?: WebGLShader;
  95231. isParallelCompiled: boolean;
  95232. onCompiled?: () => void;
  95233. transformFeedback?: WebGLTransformFeedback | null;
  95234. readonly isAsync: boolean;
  95235. readonly isReady: boolean;
  95236. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  95237. }
  95238. }
  95239. declare module BABYLON {
  95240. /** @hidden */
  95241. export class WebGLDataBuffer extends DataBuffer {
  95242. private _buffer;
  95243. constructor(resource: WebGLBuffer);
  95244. readonly underlyingResource: any;
  95245. }
  95246. }
  95247. declare module BABYLON {
  95248. /** @hidden */
  95249. export class WebGL2ShaderProcessor implements IShaderProcessor {
  95250. attributeProcessor(attribute: string): string;
  95251. varyingProcessor(varying: string, isFragment: boolean): string;
  95252. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  95253. }
  95254. }
  95255. declare module BABYLON {
  95256. /**
  95257. * This class is used to track a performance counter which is number based.
  95258. * The user has access to many properties which give statistics of different nature.
  95259. *
  95260. * The implementer can track two kinds of Performance Counter: time and count.
  95261. * 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.
  95262. * 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.
  95263. */
  95264. export class PerfCounter {
  95265. /**
  95266. * Gets or sets a global boolean to turn on and off all the counters
  95267. */
  95268. static Enabled: boolean;
  95269. /**
  95270. * Returns the smallest value ever
  95271. */
  95272. readonly min: number;
  95273. /**
  95274. * Returns the biggest value ever
  95275. */
  95276. readonly max: number;
  95277. /**
  95278. * Returns the average value since the performance counter is running
  95279. */
  95280. readonly average: number;
  95281. /**
  95282. * Returns the average value of the last second the counter was monitored
  95283. */
  95284. readonly lastSecAverage: number;
  95285. /**
  95286. * Returns the current value
  95287. */
  95288. readonly current: number;
  95289. /**
  95290. * Gets the accumulated total
  95291. */
  95292. readonly total: number;
  95293. /**
  95294. * Gets the total value count
  95295. */
  95296. readonly count: number;
  95297. /**
  95298. * Creates a new counter
  95299. */
  95300. constructor();
  95301. /**
  95302. * Call this method to start monitoring a new frame.
  95303. * 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.
  95304. */
  95305. fetchNewFrame(): void;
  95306. /**
  95307. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  95308. * @param newCount the count value to add to the monitored count
  95309. * @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.
  95310. */
  95311. addCount(newCount: number, fetchResult: boolean): void;
  95312. /**
  95313. * Start monitoring this performance counter
  95314. */
  95315. beginMonitoring(): void;
  95316. /**
  95317. * Compute the time lapsed since the previous beginMonitoring() call.
  95318. * @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
  95319. */
  95320. endMonitoring(newFrame?: boolean): void;
  95321. private _fetchResult;
  95322. private _startMonitoringTime;
  95323. private _min;
  95324. private _max;
  95325. private _average;
  95326. private _current;
  95327. private _totalValueCount;
  95328. private _totalAccumulated;
  95329. private _lastSecAverage;
  95330. private _lastSecAccumulated;
  95331. private _lastSecTime;
  95332. private _lastSecValueCount;
  95333. }
  95334. }
  95335. declare module BABYLON {
  95336. /**
  95337. * Interface for any object that can request an animation frame
  95338. */
  95339. export interface ICustomAnimationFrameRequester {
  95340. /**
  95341. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  95342. */
  95343. renderFunction?: Function;
  95344. /**
  95345. * Called to request the next frame to render to
  95346. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  95347. */
  95348. requestAnimationFrame: Function;
  95349. /**
  95350. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  95351. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  95352. */
  95353. requestID?: number;
  95354. }
  95355. }
  95356. declare module BABYLON {
  95357. /**
  95358. * Settings for finer control over video usage
  95359. */
  95360. export interface VideoTextureSettings {
  95361. /**
  95362. * Applies `autoplay` to video, if specified
  95363. */
  95364. autoPlay?: boolean;
  95365. /**
  95366. * Applies `loop` to video, if specified
  95367. */
  95368. loop?: boolean;
  95369. /**
  95370. * Automatically updates internal texture from video at every frame in the render loop
  95371. */
  95372. autoUpdateTexture: boolean;
  95373. /**
  95374. * Image src displayed during the video loading or until the user interacts with the video.
  95375. */
  95376. poster?: string;
  95377. }
  95378. /**
  95379. * If you want to display a video in your scene, this is the special texture for that.
  95380. * This special texture works similar to other textures, with the exception of a few parameters.
  95381. * @see https://doc.babylonjs.com/how_to/video_texture
  95382. */
  95383. export class VideoTexture extends Texture {
  95384. /**
  95385. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  95386. */
  95387. readonly autoUpdateTexture: boolean;
  95388. /**
  95389. * The video instance used by the texture internally
  95390. */
  95391. readonly video: HTMLVideoElement;
  95392. private _onUserActionRequestedObservable;
  95393. /**
  95394. * Event triggerd when a dom action is required by the user to play the video.
  95395. * This happens due to recent changes in browser policies preventing video to auto start.
  95396. */
  95397. readonly onUserActionRequestedObservable: Observable<Texture>;
  95398. private _generateMipMaps;
  95399. private _engine;
  95400. private _stillImageCaptured;
  95401. private _displayingPosterTexture;
  95402. private _settings;
  95403. private _createInternalTextureOnEvent;
  95404. private _frameId;
  95405. /**
  95406. * Creates a video texture.
  95407. * If you want to display a video in your scene, this is the special texture for that.
  95408. * This special texture works similar to other textures, with the exception of a few parameters.
  95409. * @see https://doc.babylonjs.com/how_to/video_texture
  95410. * @param name optional name, will detect from video source, if not defined
  95411. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  95412. * @param scene is obviously the current scene.
  95413. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  95414. * @param invertY is false by default but can be used to invert video on Y axis
  95415. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  95416. * @param settings allows finer control over video usage
  95417. */
  95418. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  95419. private _getName;
  95420. private _getVideo;
  95421. private _createInternalTexture;
  95422. private reset;
  95423. /**
  95424. * @hidden Internal method to initiate `update`.
  95425. */
  95426. _rebuild(): void;
  95427. /**
  95428. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  95429. */
  95430. update(): void;
  95431. /**
  95432. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  95433. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  95434. */
  95435. updateTexture(isVisible: boolean): void;
  95436. protected _updateInternalTexture: () => void;
  95437. /**
  95438. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  95439. * @param url New url.
  95440. */
  95441. updateURL(url: string): void;
  95442. /**
  95443. * Dispose the texture and release its associated resources.
  95444. */
  95445. dispose(): void;
  95446. /**
  95447. * Creates a video texture straight from a stream.
  95448. * @param scene Define the scene the texture should be created in
  95449. * @param stream Define the stream the texture should be created from
  95450. * @returns The created video texture as a promise
  95451. */
  95452. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  95453. /**
  95454. * Creates a video texture straight from your WebCam video feed.
  95455. * @param scene Define the scene the texture should be created in
  95456. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95457. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95458. * @returns The created video texture as a promise
  95459. */
  95460. static CreateFromWebCamAsync(scene: Scene, constraints: {
  95461. minWidth: number;
  95462. maxWidth: number;
  95463. minHeight: number;
  95464. maxHeight: number;
  95465. deviceId: string;
  95466. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  95467. /**
  95468. * Creates a video texture straight from your WebCam video feed.
  95469. * @param scene Define the scene the texture should be created in
  95470. * @param onReady Define a callback to triggered once the texture will be ready
  95471. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95472. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95473. */
  95474. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  95475. minWidth: number;
  95476. maxWidth: number;
  95477. minHeight: number;
  95478. maxHeight: number;
  95479. deviceId: string;
  95480. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  95481. }
  95482. }
  95483. declare module BABYLON {
  95484. /**
  95485. * Defines the interface used by objects containing a viewport (like a camera)
  95486. */
  95487. interface IViewportOwnerLike {
  95488. /**
  95489. * Gets or sets the viewport
  95490. */
  95491. viewport: IViewportLike;
  95492. }
  95493. /**
  95494. * Interface for attribute information associated with buffer instanciation
  95495. */
  95496. export class InstancingAttributeInfo {
  95497. /**
  95498. * Index/offset of the attribute in the vertex shader
  95499. */
  95500. index: number;
  95501. /**
  95502. * size of the attribute, 1, 2, 3 or 4
  95503. */
  95504. attributeSize: number;
  95505. /**
  95506. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  95507. * default is FLOAT
  95508. */
  95509. attribyteType: number;
  95510. /**
  95511. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  95512. */
  95513. normalized: boolean;
  95514. /**
  95515. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  95516. */
  95517. offset: number;
  95518. /**
  95519. * Name of the GLSL attribute, for debugging purpose only
  95520. */
  95521. attributeName: string;
  95522. }
  95523. /**
  95524. * Define options used to create a depth texture
  95525. */
  95526. export class DepthTextureCreationOptions {
  95527. /** Specifies whether or not a stencil should be allocated in the texture */
  95528. generateStencil?: boolean;
  95529. /** Specifies whether or not bilinear filtering is enable on the texture */
  95530. bilinearFiltering?: boolean;
  95531. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  95532. comparisonFunction?: number;
  95533. /** Specifies if the created texture is a cube texture */
  95534. isCube?: boolean;
  95535. }
  95536. /**
  95537. * Class used to describe the capabilities of the engine relatively to the current browser
  95538. */
  95539. export class EngineCapabilities {
  95540. /** Maximum textures units per fragment shader */
  95541. maxTexturesImageUnits: number;
  95542. /** Maximum texture units per vertex shader */
  95543. maxVertexTextureImageUnits: number;
  95544. /** Maximum textures units in the entire pipeline */
  95545. maxCombinedTexturesImageUnits: number;
  95546. /** Maximum texture size */
  95547. maxTextureSize: number;
  95548. /** Maximum cube texture size */
  95549. maxCubemapTextureSize: number;
  95550. /** Maximum render texture size */
  95551. maxRenderTextureSize: number;
  95552. /** Maximum number of vertex attributes */
  95553. maxVertexAttribs: number;
  95554. /** Maximum number of varyings */
  95555. maxVaryingVectors: number;
  95556. /** Maximum number of uniforms per vertex shader */
  95557. maxVertexUniformVectors: number;
  95558. /** Maximum number of uniforms per fragment shader */
  95559. maxFragmentUniformVectors: number;
  95560. /** Defines if standard derivates (dx/dy) are supported */
  95561. standardDerivatives: boolean;
  95562. /** Defines if s3tc texture compression is supported */
  95563. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  95564. /** Defines if pvrtc texture compression is supported */
  95565. pvrtc: any;
  95566. /** Defines if etc1 texture compression is supported */
  95567. etc1: any;
  95568. /** Defines if etc2 texture compression is supported */
  95569. etc2: any;
  95570. /** Defines if astc texture compression is supported */
  95571. astc: any;
  95572. /** Defines if float textures are supported */
  95573. textureFloat: boolean;
  95574. /** Defines if vertex array objects are supported */
  95575. vertexArrayObject: boolean;
  95576. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  95577. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  95578. /** Gets the maximum level of anisotropy supported */
  95579. maxAnisotropy: number;
  95580. /** Defines if instancing is supported */
  95581. instancedArrays: boolean;
  95582. /** Defines if 32 bits indices are supported */
  95583. uintIndices: boolean;
  95584. /** Defines if high precision shaders are supported */
  95585. highPrecisionShaderSupported: boolean;
  95586. /** Defines if depth reading in the fragment shader is supported */
  95587. fragmentDepthSupported: boolean;
  95588. /** Defines if float texture linear filtering is supported*/
  95589. textureFloatLinearFiltering: boolean;
  95590. /** Defines if rendering to float textures is supported */
  95591. textureFloatRender: boolean;
  95592. /** Defines if half float textures are supported*/
  95593. textureHalfFloat: boolean;
  95594. /** Defines if half float texture linear filtering is supported*/
  95595. textureHalfFloatLinearFiltering: boolean;
  95596. /** Defines if rendering to half float textures is supported */
  95597. textureHalfFloatRender: boolean;
  95598. /** Defines if textureLOD shader command is supported */
  95599. textureLOD: boolean;
  95600. /** Defines if draw buffers extension is supported */
  95601. drawBuffersExtension: boolean;
  95602. /** Defines if depth textures are supported */
  95603. depthTextureExtension: boolean;
  95604. /** Defines if float color buffer are supported */
  95605. colorBufferFloat: boolean;
  95606. /** Gets disjoint timer query extension (null if not supported) */
  95607. timerQuery: EXT_disjoint_timer_query;
  95608. /** Defines if timestamp can be used with timer query */
  95609. canUseTimestampForTimerQuery: boolean;
  95610. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  95611. multiview: any;
  95612. /** Function used to let the system compiles shaders in background */
  95613. parallelShaderCompile: {
  95614. COMPLETION_STATUS_KHR: number;
  95615. };
  95616. /** Max number of texture samples for MSAA */
  95617. maxMSAASamples: number;
  95618. }
  95619. /** Interface defining initialization parameters for Engine class */
  95620. export interface EngineOptions extends WebGLContextAttributes {
  95621. /**
  95622. * Defines if the engine should no exceed a specified device ratio
  95623. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  95624. */
  95625. limitDeviceRatio?: number;
  95626. /**
  95627. * Defines if webvr should be enabled automatically
  95628. * @see http://doc.babylonjs.com/how_to/webvr_camera
  95629. */
  95630. autoEnableWebVR?: boolean;
  95631. /**
  95632. * Defines if webgl2 should be turned off even if supported
  95633. * @see http://doc.babylonjs.com/features/webgl2
  95634. */
  95635. disableWebGL2Support?: boolean;
  95636. /**
  95637. * Defines if webaudio should be initialized as well
  95638. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  95639. */
  95640. audioEngine?: boolean;
  95641. /**
  95642. * Defines if animations should run using a deterministic lock step
  95643. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95644. */
  95645. deterministicLockstep?: boolean;
  95646. /** Defines the maximum steps to use with deterministic lock step mode */
  95647. lockstepMaxSteps?: number;
  95648. /**
  95649. * Defines that engine should ignore context lost events
  95650. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  95651. */
  95652. doNotHandleContextLost?: boolean;
  95653. /**
  95654. * Defines that engine should ignore modifying touch action attribute and style
  95655. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  95656. */
  95657. doNotHandleTouchAction?: boolean;
  95658. /**
  95659. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  95660. */
  95661. useHighPrecisionFloats?: boolean;
  95662. }
  95663. /**
  95664. * Defines the interface used by display changed events
  95665. */
  95666. export interface IDisplayChangedEventArgs {
  95667. /** Gets the vrDisplay object (if any) */
  95668. vrDisplay: Nullable<any>;
  95669. /** Gets a boolean indicating if webVR is supported */
  95670. vrSupported: boolean;
  95671. }
  95672. /**
  95673. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  95674. */
  95675. export class Engine {
  95676. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  95677. static ExceptionList: ({
  95678. key: string;
  95679. capture: string;
  95680. captureConstraint: number;
  95681. targets: string[];
  95682. } | {
  95683. key: string;
  95684. capture: null;
  95685. captureConstraint: null;
  95686. targets: string[];
  95687. })[];
  95688. /** Gets the list of created engines */
  95689. static readonly Instances: Engine[];
  95690. /**
  95691. * Gets the latest created engine
  95692. */
  95693. static readonly LastCreatedEngine: Nullable<Engine>;
  95694. /**
  95695. * Gets the latest created scene
  95696. */
  95697. static readonly LastCreatedScene: Nullable<Scene>;
  95698. /**
  95699. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  95700. * @param flag defines which part of the materials must be marked as dirty
  95701. * @param predicate defines a predicate used to filter which materials should be affected
  95702. */
  95703. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  95704. /** @hidden */
  95705. static _TextureLoaders: IInternalTextureLoader[];
  95706. /** Defines that alpha blending is disabled */
  95707. static readonly ALPHA_DISABLE: number;
  95708. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  95709. static readonly ALPHA_ADD: number;
  95710. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  95711. static readonly ALPHA_COMBINE: number;
  95712. /** Defines that alpha blending to DEST - SRC * DEST */
  95713. static readonly ALPHA_SUBTRACT: number;
  95714. /** Defines that alpha blending to SRC * DEST */
  95715. static readonly ALPHA_MULTIPLY: number;
  95716. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  95717. static readonly ALPHA_MAXIMIZED: number;
  95718. /** Defines that alpha blending to SRC + DEST */
  95719. static readonly ALPHA_ONEONE: number;
  95720. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  95721. static readonly ALPHA_PREMULTIPLIED: number;
  95722. /**
  95723. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  95724. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  95725. */
  95726. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  95727. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  95728. static readonly ALPHA_INTERPOLATE: number;
  95729. /**
  95730. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  95731. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  95732. */
  95733. static readonly ALPHA_SCREENMODE: number;
  95734. /** Defines that the ressource is not delayed*/
  95735. static readonly DELAYLOADSTATE_NONE: number;
  95736. /** Defines that the ressource was successfully delay loaded */
  95737. static readonly DELAYLOADSTATE_LOADED: number;
  95738. /** Defines that the ressource is currently delay loading */
  95739. static readonly DELAYLOADSTATE_LOADING: number;
  95740. /** Defines that the ressource is delayed and has not started loading */
  95741. static readonly DELAYLOADSTATE_NOTLOADED: number;
  95742. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  95743. static readonly NEVER: number;
  95744. /** 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 */
  95745. static readonly ALWAYS: number;
  95746. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  95747. static readonly LESS: number;
  95748. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  95749. static readonly EQUAL: number;
  95750. /** 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 */
  95751. static readonly LEQUAL: number;
  95752. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  95753. static readonly GREATER: number;
  95754. /** 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 */
  95755. static readonly GEQUAL: number;
  95756. /** 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 */
  95757. static readonly NOTEQUAL: number;
  95758. /** Passed to stencilOperation to specify that stencil value must be kept */
  95759. static readonly KEEP: number;
  95760. /** Passed to stencilOperation to specify that stencil value must be replaced */
  95761. static readonly REPLACE: number;
  95762. /** Passed to stencilOperation to specify that stencil value must be incremented */
  95763. static readonly INCR: number;
  95764. /** Passed to stencilOperation to specify that stencil value must be decremented */
  95765. static readonly DECR: number;
  95766. /** Passed to stencilOperation to specify that stencil value must be inverted */
  95767. static readonly INVERT: number;
  95768. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  95769. static readonly INCR_WRAP: number;
  95770. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  95771. static readonly DECR_WRAP: number;
  95772. /** Texture is not repeating outside of 0..1 UVs */
  95773. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  95774. /** Texture is repeating outside of 0..1 UVs */
  95775. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  95776. /** Texture is repeating and mirrored */
  95777. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  95778. /** ALPHA */
  95779. static readonly TEXTUREFORMAT_ALPHA: number;
  95780. /** LUMINANCE */
  95781. static readonly TEXTUREFORMAT_LUMINANCE: number;
  95782. /** LUMINANCE_ALPHA */
  95783. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  95784. /** RGB */
  95785. static readonly TEXTUREFORMAT_RGB: number;
  95786. /** RGBA */
  95787. static readonly TEXTUREFORMAT_RGBA: number;
  95788. /** RED */
  95789. static readonly TEXTUREFORMAT_RED: number;
  95790. /** RED (2nd reference) */
  95791. static readonly TEXTUREFORMAT_R: number;
  95792. /** RG */
  95793. static readonly TEXTUREFORMAT_RG: number;
  95794. /** RED_INTEGER */
  95795. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  95796. /** RED_INTEGER (2nd reference) */
  95797. static readonly TEXTUREFORMAT_R_INTEGER: number;
  95798. /** RG_INTEGER */
  95799. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  95800. /** RGB_INTEGER */
  95801. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  95802. /** RGBA_INTEGER */
  95803. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  95804. /** UNSIGNED_BYTE */
  95805. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  95806. /** UNSIGNED_BYTE (2nd reference) */
  95807. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  95808. /** FLOAT */
  95809. static readonly TEXTURETYPE_FLOAT: number;
  95810. /** HALF_FLOAT */
  95811. static readonly TEXTURETYPE_HALF_FLOAT: number;
  95812. /** BYTE */
  95813. static readonly TEXTURETYPE_BYTE: number;
  95814. /** SHORT */
  95815. static readonly TEXTURETYPE_SHORT: number;
  95816. /** UNSIGNED_SHORT */
  95817. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  95818. /** INT */
  95819. static readonly TEXTURETYPE_INT: number;
  95820. /** UNSIGNED_INT */
  95821. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  95822. /** UNSIGNED_SHORT_4_4_4_4 */
  95823. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  95824. /** UNSIGNED_SHORT_5_5_5_1 */
  95825. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  95826. /** UNSIGNED_SHORT_5_6_5 */
  95827. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  95828. /** UNSIGNED_INT_2_10_10_10_REV */
  95829. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  95830. /** UNSIGNED_INT_24_8 */
  95831. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  95832. /** UNSIGNED_INT_10F_11F_11F_REV */
  95833. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  95834. /** UNSIGNED_INT_5_9_9_9_REV */
  95835. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  95836. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  95837. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  95838. /** nearest is mag = nearest and min = nearest and mip = linear */
  95839. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  95840. /** Bilinear is mag = linear and min = linear and mip = nearest */
  95841. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  95842. /** Trilinear is mag = linear and min = linear and mip = linear */
  95843. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  95844. /** nearest is mag = nearest and min = nearest and mip = linear */
  95845. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  95846. /** Bilinear is mag = linear and min = linear and mip = nearest */
  95847. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  95848. /** Trilinear is mag = linear and min = linear and mip = linear */
  95849. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  95850. /** mag = nearest and min = nearest and mip = nearest */
  95851. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  95852. /** mag = nearest and min = linear and mip = nearest */
  95853. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  95854. /** mag = nearest and min = linear and mip = linear */
  95855. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  95856. /** mag = nearest and min = linear and mip = none */
  95857. static readonly TEXTURE_NEAREST_LINEAR: number;
  95858. /** mag = nearest and min = nearest and mip = none */
  95859. static readonly TEXTURE_NEAREST_NEAREST: number;
  95860. /** mag = linear and min = nearest and mip = nearest */
  95861. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  95862. /** mag = linear and min = nearest and mip = linear */
  95863. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  95864. /** mag = linear and min = linear and mip = none */
  95865. static readonly TEXTURE_LINEAR_LINEAR: number;
  95866. /** mag = linear and min = nearest and mip = none */
  95867. static readonly TEXTURE_LINEAR_NEAREST: number;
  95868. /** Explicit coordinates mode */
  95869. static readonly TEXTURE_EXPLICIT_MODE: number;
  95870. /** Spherical coordinates mode */
  95871. static readonly TEXTURE_SPHERICAL_MODE: number;
  95872. /** Planar coordinates mode */
  95873. static readonly TEXTURE_PLANAR_MODE: number;
  95874. /** Cubic coordinates mode */
  95875. static readonly TEXTURE_CUBIC_MODE: number;
  95876. /** Projection coordinates mode */
  95877. static readonly TEXTURE_PROJECTION_MODE: number;
  95878. /** Skybox coordinates mode */
  95879. static readonly TEXTURE_SKYBOX_MODE: number;
  95880. /** Inverse Cubic coordinates mode */
  95881. static readonly TEXTURE_INVCUBIC_MODE: number;
  95882. /** Equirectangular coordinates mode */
  95883. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  95884. /** Equirectangular Fixed coordinates mode */
  95885. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  95886. /** Equirectangular Fixed Mirrored coordinates mode */
  95887. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  95888. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  95889. static readonly SCALEMODE_FLOOR: number;
  95890. /** Defines that texture rescaling will look for the nearest power of 2 size */
  95891. static readonly SCALEMODE_NEAREST: number;
  95892. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  95893. static readonly SCALEMODE_CEILING: number;
  95894. /**
  95895. * Returns the current npm package of the sdk
  95896. */
  95897. static readonly NpmPackage: string;
  95898. /**
  95899. * Returns the current version of the framework
  95900. */
  95901. static readonly Version: string;
  95902. /**
  95903. * Returns a string describing the current engine
  95904. */
  95905. readonly description: string;
  95906. /**
  95907. * Gets or sets the epsilon value used by collision engine
  95908. */
  95909. static CollisionsEpsilon: number;
  95910. /**
  95911. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  95912. */
  95913. static ShadersRepository: string;
  95914. /**
  95915. * Method called to create the default loading screen.
  95916. * This can be overriden in your own app.
  95917. * @param canvas The rendering canvas element
  95918. * @returns The loading screen
  95919. */
  95920. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  95921. /**
  95922. * Method called to create the default rescale post process on each engine.
  95923. */
  95924. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  95925. /** @hidden */
  95926. _shaderProcessor: IShaderProcessor;
  95927. /**
  95928. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  95929. */
  95930. forcePOTTextures: boolean;
  95931. /**
  95932. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  95933. */
  95934. isFullscreen: boolean;
  95935. /**
  95936. * Gets a boolean indicating if the pointer is currently locked
  95937. */
  95938. isPointerLock: boolean;
  95939. /**
  95940. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  95941. */
  95942. cullBackFaces: boolean;
  95943. /**
  95944. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  95945. */
  95946. renderEvenInBackground: boolean;
  95947. /**
  95948. * Gets or sets a boolean indicating that cache can be kept between frames
  95949. */
  95950. preventCacheWipeBetweenFrames: boolean;
  95951. /**
  95952. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  95953. **/
  95954. enableOfflineSupport: boolean;
  95955. /**
  95956. * 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)
  95957. **/
  95958. disableManifestCheck: boolean;
  95959. /**
  95960. * Gets the list of created scenes
  95961. */
  95962. scenes: Scene[];
  95963. /**
  95964. * Event raised when a new scene is created
  95965. */
  95966. onNewSceneAddedObservable: Observable<Scene>;
  95967. /**
  95968. * Gets the list of created postprocesses
  95969. */
  95970. postProcesses: PostProcess[];
  95971. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  95972. validateShaderPrograms: boolean;
  95973. /**
  95974. * Observable event triggered each time the rendering canvas is resized
  95975. */
  95976. onResizeObservable: Observable<Engine>;
  95977. /**
  95978. * Observable event triggered each time the canvas loses focus
  95979. */
  95980. onCanvasBlurObservable: Observable<Engine>;
  95981. /**
  95982. * Observable event triggered each time the canvas gains focus
  95983. */
  95984. onCanvasFocusObservable: Observable<Engine>;
  95985. /**
  95986. * Observable event triggered each time the canvas receives pointerout event
  95987. */
  95988. onCanvasPointerOutObservable: Observable<PointerEvent>;
  95989. /**
  95990. * Observable event triggered before each texture is initialized
  95991. */
  95992. onBeforeTextureInitObservable: Observable<Texture>;
  95993. /**
  95994. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  95995. */
  95996. disableUniformBuffers: boolean;
  95997. /** @hidden */
  95998. _uniformBuffers: UniformBuffer[];
  95999. /**
  96000. * Gets a boolean indicating that the engine supports uniform buffers
  96001. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96002. */
  96003. readonly supportsUniformBuffers: boolean;
  96004. /**
  96005. * Observable raised when the engine begins a new frame
  96006. */
  96007. onBeginFrameObservable: Observable<Engine>;
  96008. /**
  96009. * If set, will be used to request the next animation frame for the render loop
  96010. */
  96011. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  96012. /**
  96013. * Observable raised when the engine ends the current frame
  96014. */
  96015. onEndFrameObservable: Observable<Engine>;
  96016. /**
  96017. * Observable raised when the engine is about to compile a shader
  96018. */
  96019. onBeforeShaderCompilationObservable: Observable<Engine>;
  96020. /**
  96021. * Observable raised when the engine has jsut compiled a shader
  96022. */
  96023. onAfterShaderCompilationObservable: Observable<Engine>;
  96024. /** @hidden */
  96025. _gl: WebGLRenderingContext;
  96026. private _renderingCanvas;
  96027. private _windowIsBackground;
  96028. protected _webGLVersion: number;
  96029. protected _highPrecisionShadersAllowed: boolean;
  96030. /** @hidden */
  96031. readonly _shouldUseHighPrecisionShader: boolean;
  96032. /**
  96033. * Gets a boolean indicating that only power of 2 textures are supported
  96034. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  96035. */
  96036. readonly needPOTTextures: boolean;
  96037. /** @hidden */
  96038. _badOS: boolean;
  96039. /** @hidden */
  96040. _badDesktopOS: boolean;
  96041. /**
  96042. * Gets the audio engine
  96043. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  96044. * @ignorenaming
  96045. */
  96046. static audioEngine: IAudioEngine;
  96047. /**
  96048. * Default AudioEngine factory responsible of creating the Audio Engine.
  96049. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  96050. */
  96051. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  96052. /**
  96053. * Default offline support factory responsible of creating a tool used to store data locally.
  96054. * By default, this will create a Database object if the workload has been embedded.
  96055. */
  96056. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  96057. private _onFocus;
  96058. private _onBlur;
  96059. private _onCanvasPointerOut;
  96060. private _onCanvasBlur;
  96061. private _onCanvasFocus;
  96062. private _onFullscreenChange;
  96063. private _onPointerLockChange;
  96064. private _hardwareScalingLevel;
  96065. /** @hidden */
  96066. _caps: EngineCapabilities;
  96067. private _pointerLockRequested;
  96068. private _isStencilEnable;
  96069. protected _colorWrite: boolean;
  96070. private _loadingScreen;
  96071. /** @hidden */
  96072. _drawCalls: PerfCounter;
  96073. private _glVersion;
  96074. private _glRenderer;
  96075. private _glVendor;
  96076. private _videoTextureSupported;
  96077. private _renderingQueueLaunched;
  96078. private _activeRenderLoops;
  96079. private _deterministicLockstep;
  96080. private _lockstepMaxSteps;
  96081. /**
  96082. * Observable signaled when a context lost event is raised
  96083. */
  96084. onContextLostObservable: Observable<Engine>;
  96085. /**
  96086. * Observable signaled when a context restored event is raised
  96087. */
  96088. onContextRestoredObservable: Observable<Engine>;
  96089. private _onContextLost;
  96090. private _onContextRestored;
  96091. private _contextWasLost;
  96092. /** @hidden */
  96093. _doNotHandleContextLost: boolean;
  96094. /**
  96095. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  96096. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  96097. */
  96098. doNotHandleContextLost: boolean;
  96099. private _performanceMonitor;
  96100. private _fps;
  96101. private _deltaTime;
  96102. /**
  96103. * Turn this value on if you want to pause FPS computation when in background
  96104. */
  96105. disablePerformanceMonitorInBackground: boolean;
  96106. /**
  96107. * Gets the performance monitor attached to this engine
  96108. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  96109. */
  96110. readonly performanceMonitor: PerformanceMonitor;
  96111. /**
  96112. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  96113. */
  96114. disableVertexArrayObjects: boolean;
  96115. /** @hidden */
  96116. protected _depthCullingState: _DepthCullingState;
  96117. /** @hidden */
  96118. protected _stencilState: _StencilState;
  96119. /** @hidden */
  96120. protected _alphaState: _AlphaState;
  96121. /** @hidden */
  96122. protected _alphaMode: number;
  96123. /** @hidden */
  96124. _internalTexturesCache: InternalTexture[];
  96125. /** @hidden */
  96126. protected _activeChannel: number;
  96127. private _currentTextureChannel;
  96128. /** @hidden */
  96129. protected _boundTexturesCache: {
  96130. [key: string]: Nullable<InternalTexture>;
  96131. };
  96132. /** @hidden */
  96133. protected _currentEffect: Nullable<Effect>;
  96134. /** @hidden */
  96135. protected _currentProgram: Nullable<WebGLProgram>;
  96136. private _compiledEffects;
  96137. private _vertexAttribArraysEnabled;
  96138. /** @hidden */
  96139. protected _cachedViewport: Nullable<IViewportLike>;
  96140. private _cachedVertexArrayObject;
  96141. /** @hidden */
  96142. protected _cachedVertexBuffers: any;
  96143. /** @hidden */
  96144. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  96145. /** @hidden */
  96146. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  96147. /** @hidden */
  96148. _currentRenderTarget: Nullable<InternalTexture>;
  96149. private _uintIndicesCurrentlySet;
  96150. private _currentBoundBuffer;
  96151. /** @hidden */
  96152. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  96153. private _currentBufferPointers;
  96154. private _currentInstanceLocations;
  96155. private _currentInstanceBuffers;
  96156. private _textureUnits;
  96157. /** @hidden */
  96158. _workingCanvas: Nullable<HTMLCanvasElement>;
  96159. /** @hidden */
  96160. _workingContext: Nullable<CanvasRenderingContext2D>;
  96161. private _rescalePostProcess;
  96162. private _dummyFramebuffer;
  96163. private _externalData;
  96164. /** @hidden */
  96165. _bindedRenderFunction: any;
  96166. private _vaoRecordInProgress;
  96167. private _mustWipeVertexAttributes;
  96168. private _emptyTexture;
  96169. private _emptyCubeTexture;
  96170. private _emptyTexture3D;
  96171. /** @hidden */
  96172. _frameHandler: number;
  96173. private _nextFreeTextureSlots;
  96174. private _maxSimultaneousTextures;
  96175. private _activeRequests;
  96176. private _texturesSupported;
  96177. /** @hidden */
  96178. _textureFormatInUse: Nullable<string>;
  96179. /**
  96180. * Gets the list of texture formats supported
  96181. */
  96182. readonly texturesSupported: Array<string>;
  96183. /**
  96184. * Gets the list of texture formats in use
  96185. */
  96186. readonly textureFormatInUse: Nullable<string>;
  96187. /**
  96188. * Gets the current viewport
  96189. */
  96190. readonly currentViewport: Nullable<IViewportLike>;
  96191. /**
  96192. * Gets the default empty texture
  96193. */
  96194. readonly emptyTexture: InternalTexture;
  96195. /**
  96196. * Gets the default empty 3D texture
  96197. */
  96198. readonly emptyTexture3D: InternalTexture;
  96199. /**
  96200. * Gets the default empty cube texture
  96201. */
  96202. readonly emptyCubeTexture: InternalTexture;
  96203. /**
  96204. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  96205. */
  96206. readonly premultipliedAlpha: boolean;
  96207. /**
  96208. * Creates a new engine
  96209. * @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
  96210. * @param antialias defines enable antialiasing (default: false)
  96211. * @param options defines further options to be sent to the getContext() function
  96212. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  96213. */
  96214. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  96215. /**
  96216. * Initializes a webVR display and starts listening to display change events
  96217. * The onVRDisplayChangedObservable will be notified upon these changes
  96218. * @returns The onVRDisplayChangedObservable
  96219. */
  96220. initWebVR(): Observable<IDisplayChangedEventArgs>;
  96221. /** @hidden */
  96222. _prepareVRComponent(): void;
  96223. /** @hidden */
  96224. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  96225. /** @hidden */
  96226. _submitVRFrame(): void;
  96227. /**
  96228. * Call this function to leave webVR mode
  96229. * Will do nothing if webVR is not supported or if there is no webVR device
  96230. * @see http://doc.babylonjs.com/how_to/webvr_camera
  96231. */
  96232. disableVR(): void;
  96233. /**
  96234. * Gets a boolean indicating that the system is in VR mode and is presenting
  96235. * @returns true if VR mode is engaged
  96236. */
  96237. isVRPresenting(): boolean;
  96238. /** @hidden */
  96239. _requestVRFrame(): void;
  96240. private _disableTouchAction;
  96241. private _rebuildInternalTextures;
  96242. private _rebuildEffects;
  96243. /**
  96244. * Gets a boolean indicating if all created effects are ready
  96245. * @returns true if all effects are ready
  96246. */
  96247. areAllEffectsReady(): boolean;
  96248. private _rebuildBuffers;
  96249. private _initGLContext;
  96250. /**
  96251. * Gets version of the current webGL context
  96252. */
  96253. readonly webGLVersion: number;
  96254. /**
  96255. * Gets a string idenfifying the name of the class
  96256. * @returns "Engine" string
  96257. */
  96258. getClassName(): string;
  96259. /**
  96260. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  96261. */
  96262. readonly isStencilEnable: boolean;
  96263. /** @hidden */
  96264. _prepareWorkingCanvas(): void;
  96265. /**
  96266. * Reset the texture cache to empty state
  96267. */
  96268. resetTextureCache(): void;
  96269. /**
  96270. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  96271. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96272. * @returns true if engine is in deterministic lock step mode
  96273. */
  96274. isDeterministicLockStep(): boolean;
  96275. /**
  96276. * Gets the max steps when engine is running in deterministic lock step
  96277. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96278. * @returns the max steps
  96279. */
  96280. getLockstepMaxSteps(): number;
  96281. /**
  96282. * Gets an object containing information about the current webGL context
  96283. * @returns an object containing the vender, the renderer and the version of the current webGL context
  96284. */
  96285. getGlInfo(): {
  96286. vendor: string;
  96287. renderer: string;
  96288. version: string;
  96289. };
  96290. /**
  96291. * Gets current aspect ratio
  96292. * @param viewportOwner defines the camera to use to get the aspect ratio
  96293. * @param useScreen defines if screen size must be used (or the current render target if any)
  96294. * @returns a number defining the aspect ratio
  96295. */
  96296. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  96297. /**
  96298. * Gets current screen aspect ratio
  96299. * @returns a number defining the aspect ratio
  96300. */
  96301. getScreenAspectRatio(): number;
  96302. /**
  96303. * Gets the current render width
  96304. * @param useScreen defines if screen size must be used (or the current render target if any)
  96305. * @returns a number defining the current render width
  96306. */
  96307. getRenderWidth(useScreen?: boolean): number;
  96308. /**
  96309. * Gets the current render height
  96310. * @param useScreen defines if screen size must be used (or the current render target if any)
  96311. * @returns a number defining the current render height
  96312. */
  96313. getRenderHeight(useScreen?: boolean): number;
  96314. /**
  96315. * Gets the HTML canvas attached with the current webGL context
  96316. * @returns a HTML canvas
  96317. */
  96318. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  96319. /**
  96320. * Gets host window
  96321. * @returns the host window object
  96322. */
  96323. getHostWindow(): Window;
  96324. /**
  96325. * Gets host document
  96326. * @returns the host document object
  96327. */
  96328. getHostDocument(): Document;
  96329. /**
  96330. * Gets the client rect of the HTML canvas attached with the current webGL context
  96331. * @returns a client rectanglee
  96332. */
  96333. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  96334. /**
  96335. * Defines the hardware scaling level.
  96336. * By default the hardware scaling level is computed from the window device ratio.
  96337. * 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.
  96338. * @param level defines the level to use
  96339. */
  96340. setHardwareScalingLevel(level: number): void;
  96341. /**
  96342. * Gets the current hardware scaling level.
  96343. * By default the hardware scaling level is computed from the window device ratio.
  96344. * 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.
  96345. * @returns a number indicating the current hardware scaling level
  96346. */
  96347. getHardwareScalingLevel(): number;
  96348. /**
  96349. * Gets the list of loaded textures
  96350. * @returns an array containing all loaded textures
  96351. */
  96352. getLoadedTexturesCache(): InternalTexture[];
  96353. /**
  96354. * Gets the object containing all engine capabilities
  96355. * @returns the EngineCapabilities object
  96356. */
  96357. getCaps(): EngineCapabilities;
  96358. /**
  96359. * Gets the current depth function
  96360. * @returns a number defining the depth function
  96361. */
  96362. getDepthFunction(): Nullable<number>;
  96363. /**
  96364. * Sets the current depth function
  96365. * @param depthFunc defines the function to use
  96366. */
  96367. setDepthFunction(depthFunc: number): void;
  96368. /**
  96369. * Sets the current depth function to GREATER
  96370. */
  96371. setDepthFunctionToGreater(): void;
  96372. /**
  96373. * Sets the current depth function to GEQUAL
  96374. */
  96375. setDepthFunctionToGreaterOrEqual(): void;
  96376. /**
  96377. * Sets the current depth function to LESS
  96378. */
  96379. setDepthFunctionToLess(): void;
  96380. private _cachedStencilBuffer;
  96381. private _cachedStencilFunction;
  96382. private _cachedStencilMask;
  96383. private _cachedStencilOperationPass;
  96384. private _cachedStencilOperationFail;
  96385. private _cachedStencilOperationDepthFail;
  96386. private _cachedStencilReference;
  96387. /**
  96388. * Caches the the state of the stencil buffer
  96389. */
  96390. cacheStencilState(): void;
  96391. /**
  96392. * Restores the state of the stencil buffer
  96393. */
  96394. restoreStencilState(): void;
  96395. /**
  96396. * Sets the current depth function to LEQUAL
  96397. */
  96398. setDepthFunctionToLessOrEqual(): void;
  96399. /**
  96400. * Gets a boolean indicating if stencil buffer is enabled
  96401. * @returns the current stencil buffer state
  96402. */
  96403. getStencilBuffer(): boolean;
  96404. /**
  96405. * Enable or disable the stencil buffer
  96406. * @param enable defines if the stencil buffer must be enabled or disabled
  96407. */
  96408. setStencilBuffer(enable: boolean): void;
  96409. /**
  96410. * Gets the current stencil mask
  96411. * @returns a number defining the new stencil mask to use
  96412. */
  96413. getStencilMask(): number;
  96414. /**
  96415. * Sets the current stencil mask
  96416. * @param mask defines the new stencil mask to use
  96417. */
  96418. setStencilMask(mask: number): void;
  96419. /**
  96420. * Gets the current stencil function
  96421. * @returns a number defining the stencil function to use
  96422. */
  96423. getStencilFunction(): number;
  96424. /**
  96425. * Gets the current stencil reference value
  96426. * @returns a number defining the stencil reference value to use
  96427. */
  96428. getStencilFunctionReference(): number;
  96429. /**
  96430. * Gets the current stencil mask
  96431. * @returns a number defining the stencil mask to use
  96432. */
  96433. getStencilFunctionMask(): number;
  96434. /**
  96435. * Sets the current stencil function
  96436. * @param stencilFunc defines the new stencil function to use
  96437. */
  96438. setStencilFunction(stencilFunc: number): void;
  96439. /**
  96440. * Sets the current stencil reference
  96441. * @param reference defines the new stencil reference to use
  96442. */
  96443. setStencilFunctionReference(reference: number): void;
  96444. /**
  96445. * Sets the current stencil mask
  96446. * @param mask defines the new stencil mask to use
  96447. */
  96448. setStencilFunctionMask(mask: number): void;
  96449. /**
  96450. * Gets the current stencil operation when stencil fails
  96451. * @returns a number defining stencil operation to use when stencil fails
  96452. */
  96453. getStencilOperationFail(): number;
  96454. /**
  96455. * Gets the current stencil operation when depth fails
  96456. * @returns a number defining stencil operation to use when depth fails
  96457. */
  96458. getStencilOperationDepthFail(): number;
  96459. /**
  96460. * Gets the current stencil operation when stencil passes
  96461. * @returns a number defining stencil operation to use when stencil passes
  96462. */
  96463. getStencilOperationPass(): number;
  96464. /**
  96465. * Sets the stencil operation to use when stencil fails
  96466. * @param operation defines the stencil operation to use when stencil fails
  96467. */
  96468. setStencilOperationFail(operation: number): void;
  96469. /**
  96470. * Sets the stencil operation to use when depth fails
  96471. * @param operation defines the stencil operation to use when depth fails
  96472. */
  96473. setStencilOperationDepthFail(operation: number): void;
  96474. /**
  96475. * Sets the stencil operation to use when stencil passes
  96476. * @param operation defines the stencil operation to use when stencil passes
  96477. */
  96478. setStencilOperationPass(operation: number): void;
  96479. /**
  96480. * Sets a boolean indicating if the dithering state is enabled or disabled
  96481. * @param value defines the dithering state
  96482. */
  96483. setDitheringState(value: boolean): void;
  96484. /**
  96485. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  96486. * @param value defines the rasterizer state
  96487. */
  96488. setRasterizerState(value: boolean): void;
  96489. /**
  96490. * stop executing a render loop function and remove it from the execution array
  96491. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  96492. */
  96493. stopRenderLoop(renderFunction?: () => void): void;
  96494. /** @hidden */
  96495. _renderLoop(): void;
  96496. /**
  96497. * Can be used to override the current requestAnimationFrame requester.
  96498. * @hidden
  96499. */
  96500. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  96501. /**
  96502. * Register and execute a render loop. The engine can have more than one render function
  96503. * @param renderFunction defines the function to continuously execute
  96504. */
  96505. runRenderLoop(renderFunction: () => void): void;
  96506. /**
  96507. * Toggle full screen mode
  96508. * @param requestPointerLock defines if a pointer lock should be requested from the user
  96509. */
  96510. switchFullscreen(requestPointerLock: boolean): void;
  96511. /**
  96512. * Enters full screen mode
  96513. * @param requestPointerLock defines if a pointer lock should be requested from the user
  96514. */
  96515. enterFullscreen(requestPointerLock: boolean): void;
  96516. /**
  96517. * Exits full screen mode
  96518. */
  96519. exitFullscreen(): void;
  96520. /**
  96521. * Enters Pointerlock mode
  96522. */
  96523. enterPointerlock(): void;
  96524. /**
  96525. * Exits Pointerlock mode
  96526. */
  96527. exitPointerlock(): void;
  96528. /**
  96529. * Clear the current render buffer or the current render target (if any is set up)
  96530. * @param color defines the color to use
  96531. * @param backBuffer defines if the back buffer must be cleared
  96532. * @param depth defines if the depth buffer must be cleared
  96533. * @param stencil defines if the stencil buffer must be cleared
  96534. */
  96535. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  96536. /**
  96537. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  96538. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  96539. * @param y defines the y-coordinate of the corner of the clear rectangle
  96540. * @param width defines the width of the clear rectangle
  96541. * @param height defines the height of the clear rectangle
  96542. * @param clearColor defines the clear color
  96543. */
  96544. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  96545. /**
  96546. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  96547. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  96548. * @param y defines the y-coordinate of the corner of the clear rectangle
  96549. * @param width defines the width of the clear rectangle
  96550. * @param height defines the height of the clear rectangle
  96551. */
  96552. enableScissor(x: number, y: number, width: number, height: number): void;
  96553. /**
  96554. * Disable previously set scissor test rectangle
  96555. */
  96556. disableScissor(): void;
  96557. private _viewportCached;
  96558. /** @hidden */
  96559. _viewport(x: number, y: number, width: number, height: number): void;
  96560. /**
  96561. * Set the WebGL's viewport
  96562. * @param viewport defines the viewport element to be used
  96563. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  96564. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  96565. */
  96566. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  96567. /**
  96568. * Directly set the WebGL Viewport
  96569. * @param x defines the x coordinate of the viewport (in screen space)
  96570. * @param y defines the y coordinate of the viewport (in screen space)
  96571. * @param width defines the width of the viewport (in screen space)
  96572. * @param height defines the height of the viewport (in screen space)
  96573. * @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
  96574. */
  96575. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  96576. /**
  96577. * Begin a new frame
  96578. */
  96579. beginFrame(): void;
  96580. /**
  96581. * Enf the current frame
  96582. */
  96583. endFrame(): void;
  96584. /**
  96585. * Resize the view according to the canvas' size
  96586. */
  96587. resize(): void;
  96588. /**
  96589. * Force a specific size of the canvas
  96590. * @param width defines the new canvas' width
  96591. * @param height defines the new canvas' height
  96592. */
  96593. setSize(width: number, height: number): void;
  96594. /**
  96595. * Binds the frame buffer to the specified texture.
  96596. * @param texture The texture to render to or null for the default canvas
  96597. * @param faceIndex The face of the texture to render to in case of cube texture
  96598. * @param requiredWidth The width of the target to render to
  96599. * @param requiredHeight The height of the target to render to
  96600. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  96601. * @param depthStencilTexture The depth stencil texture to use to render
  96602. * @param lodLevel defines le lod level to bind to the frame buffer
  96603. */
  96604. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  96605. /** @hidden */
  96606. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  96607. /**
  96608. * Unbind the current render target texture from the webGL context
  96609. * @param texture defines the render target texture to unbind
  96610. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  96611. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  96612. */
  96613. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  96614. /**
  96615. * Force the mipmap generation for the given render target texture
  96616. * @param texture defines the render target texture to use
  96617. */
  96618. generateMipMapsForCubemap(texture: InternalTexture): void;
  96619. /**
  96620. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  96621. */
  96622. flushFramebuffer(): void;
  96623. /**
  96624. * Unbind the current render target and bind the default framebuffer
  96625. */
  96626. restoreDefaultFramebuffer(): void;
  96627. /**
  96628. * Create an uniform buffer
  96629. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96630. * @param elements defines the content of the uniform buffer
  96631. * @returns the webGL uniform buffer
  96632. */
  96633. createUniformBuffer(elements: FloatArray): DataBuffer;
  96634. /**
  96635. * Create a dynamic uniform buffer
  96636. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96637. * @param elements defines the content of the uniform buffer
  96638. * @returns the webGL uniform buffer
  96639. */
  96640. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  96641. /**
  96642. * Update an existing uniform buffer
  96643. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96644. * @param uniformBuffer defines the target uniform buffer
  96645. * @param elements defines the content to update
  96646. * @param offset defines the offset in the uniform buffer where update should start
  96647. * @param count defines the size of the data to update
  96648. */
  96649. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  96650. private _resetVertexBufferBinding;
  96651. /**
  96652. * Creates a vertex buffer
  96653. * @param data the data for the vertex buffer
  96654. * @returns the new WebGL static buffer
  96655. */
  96656. createVertexBuffer(data: DataArray): DataBuffer;
  96657. /**
  96658. * Creates a dynamic vertex buffer
  96659. * @param data the data for the dynamic vertex buffer
  96660. * @returns the new WebGL dynamic buffer
  96661. */
  96662. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  96663. /**
  96664. * Update a dynamic index buffer
  96665. * @param indexBuffer defines the target index buffer
  96666. * @param indices defines the data to update
  96667. * @param offset defines the offset in the target index buffer where update should start
  96668. */
  96669. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  96670. /**
  96671. * Updates a dynamic vertex buffer.
  96672. * @param vertexBuffer the vertex buffer to update
  96673. * @param data the data used to update the vertex buffer
  96674. * @param byteOffset the byte offset of the data
  96675. * @param byteLength the byte length of the data
  96676. */
  96677. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  96678. private _resetIndexBufferBinding;
  96679. /**
  96680. * Creates a new index buffer
  96681. * @param indices defines the content of the index buffer
  96682. * @param updatable defines if the index buffer must be updatable
  96683. * @returns a new webGL buffer
  96684. */
  96685. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  96686. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  96687. /**
  96688. * Bind a webGL buffer to the webGL context
  96689. * @param buffer defines the buffer to bind
  96690. */
  96691. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  96692. /**
  96693. * Bind an uniform buffer to the current webGL context
  96694. * @param buffer defines the buffer to bind
  96695. */
  96696. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  96697. /**
  96698. * Bind a buffer to the current webGL context at a given location
  96699. * @param buffer defines the buffer to bind
  96700. * @param location defines the index where to bind the buffer
  96701. */
  96702. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  96703. /**
  96704. * Bind a specific block at a given index in a specific shader program
  96705. * @param pipelineContext defines the pipeline context to use
  96706. * @param blockName defines the block name
  96707. * @param index defines the index where to bind the block
  96708. */
  96709. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  96710. private bindIndexBuffer;
  96711. private bindBuffer;
  96712. /**
  96713. * update the bound buffer with the given data
  96714. * @param data defines the data to update
  96715. */
  96716. updateArrayBuffer(data: Float32Array): void;
  96717. private _vertexAttribPointer;
  96718. private _bindIndexBufferWithCache;
  96719. private _bindVertexBuffersAttributes;
  96720. /**
  96721. * Records a vertex array object
  96722. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96723. * @param vertexBuffers defines the list of vertex buffers to store
  96724. * @param indexBuffer defines the index buffer to store
  96725. * @param effect defines the effect to store
  96726. * @returns the new vertex array object
  96727. */
  96728. recordVertexArrayObject(vertexBuffers: {
  96729. [key: string]: VertexBuffer;
  96730. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  96731. /**
  96732. * Bind a specific vertex array object
  96733. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96734. * @param vertexArrayObject defines the vertex array object to bind
  96735. * @param indexBuffer defines the index buffer to bind
  96736. */
  96737. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  96738. /**
  96739. * Bind webGl buffers directly to the webGL context
  96740. * @param vertexBuffer defines the vertex buffer to bind
  96741. * @param indexBuffer defines the index buffer to bind
  96742. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  96743. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  96744. * @param effect defines the effect associated with the vertex buffer
  96745. */
  96746. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  96747. private _unbindVertexArrayObject;
  96748. /**
  96749. * Bind a list of vertex buffers to the webGL context
  96750. * @param vertexBuffers defines the list of vertex buffers to bind
  96751. * @param indexBuffer defines the index buffer to bind
  96752. * @param effect defines the effect associated with the vertex buffers
  96753. */
  96754. bindBuffers(vertexBuffers: {
  96755. [key: string]: Nullable<VertexBuffer>;
  96756. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  96757. /**
  96758. * Unbind all instance attributes
  96759. */
  96760. unbindInstanceAttributes(): void;
  96761. /**
  96762. * Release and free the memory of a vertex array object
  96763. * @param vao defines the vertex array object to delete
  96764. */
  96765. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  96766. /** @hidden */
  96767. _releaseBuffer(buffer: DataBuffer): boolean;
  96768. protected _deleteBuffer(buffer: DataBuffer): void;
  96769. /**
  96770. * Creates a webGL buffer to use with instanciation
  96771. * @param capacity defines the size of the buffer
  96772. * @returns the webGL buffer
  96773. */
  96774. createInstancesBuffer(capacity: number): DataBuffer;
  96775. /**
  96776. * Delete a webGL buffer used with instanciation
  96777. * @param buffer defines the webGL buffer to delete
  96778. */
  96779. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  96780. /**
  96781. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  96782. * @param instancesBuffer defines the webGL buffer to update and bind
  96783. * @param data defines the data to store in the buffer
  96784. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  96785. */
  96786. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  96787. /**
  96788. * Apply all cached states (depth, culling, stencil and alpha)
  96789. */
  96790. applyStates(): void;
  96791. /**
  96792. * Send a draw order
  96793. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96794. * @param indexStart defines the starting index
  96795. * @param indexCount defines the number of index to draw
  96796. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96797. */
  96798. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  96799. /**
  96800. * Draw a list of points
  96801. * @param verticesStart defines the index of first vertex to draw
  96802. * @param verticesCount defines the count of vertices to draw
  96803. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96804. */
  96805. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96806. /**
  96807. * Draw a list of unindexed primitives
  96808. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96809. * @param verticesStart defines the index of first vertex to draw
  96810. * @param verticesCount defines the count of vertices to draw
  96811. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96812. */
  96813. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96814. /**
  96815. * Draw a list of indexed primitives
  96816. * @param fillMode defines the primitive to use
  96817. * @param indexStart defines the starting index
  96818. * @param indexCount defines the number of index to draw
  96819. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96820. */
  96821. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  96822. /**
  96823. * Draw a list of unindexed primitives
  96824. * @param fillMode defines the primitive to use
  96825. * @param verticesStart defines the index of first vertex to draw
  96826. * @param verticesCount defines the count of vertices to draw
  96827. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96828. */
  96829. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96830. private _drawMode;
  96831. /** @hidden */
  96832. _releaseEffect(effect: Effect): void;
  96833. /** @hidden */
  96834. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  96835. /**
  96836. * Create a new effect (used to store vertex/fragment shaders)
  96837. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  96838. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  96839. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  96840. * @param samplers defines an array of string used to represent textures
  96841. * @param defines defines the string containing the defines to use to compile the shaders
  96842. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  96843. * @param onCompiled defines a function to call when the effect creation is successful
  96844. * @param onError defines a function to call when the effect creation has failed
  96845. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  96846. * @returns the new Effect
  96847. */
  96848. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  96849. protected static _concatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  96850. private _compileShader;
  96851. private _compileRawShader;
  96852. /**
  96853. * Directly creates a webGL program
  96854. * @param pipelineContext defines the pipeline context to attach to
  96855. * @param vertexCode defines the vertex shader code to use
  96856. * @param fragmentCode defines the fragment shader code to use
  96857. * @param context defines the webGL context to use (if not set, the current one will be used)
  96858. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96859. * @returns the new webGL program
  96860. */
  96861. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96862. /**
  96863. * Creates a webGL program
  96864. * @param pipelineContext defines the pipeline context to attach to
  96865. * @param vertexCode defines the vertex shader code to use
  96866. * @param fragmentCode defines the fragment shader code to use
  96867. * @param defines defines the string containing the defines to use to compile the shaders
  96868. * @param context defines the webGL context to use (if not set, the current one will be used)
  96869. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96870. * @returns the new webGL program
  96871. */
  96872. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96873. /**
  96874. * Creates a new pipeline context
  96875. * @returns the new pipeline
  96876. */
  96877. createPipelineContext(): IPipelineContext;
  96878. private _createShaderProgram;
  96879. private _finalizePipelineContext;
  96880. /** @hidden */
  96881. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  96882. /** @hidden */
  96883. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  96884. /** @hidden */
  96885. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  96886. /**
  96887. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  96888. * @param pipelineContext defines the pipeline context to use
  96889. * @param uniformsNames defines the list of uniform names
  96890. * @returns an array of webGL uniform locations
  96891. */
  96892. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  96893. /**
  96894. * Gets the lsit of active attributes for a given webGL program
  96895. * @param pipelineContext defines the pipeline context to use
  96896. * @param attributesNames defines the list of attribute names to get
  96897. * @returns an array of indices indicating the offset of each attribute
  96898. */
  96899. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  96900. /**
  96901. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  96902. * @param effect defines the effect to activate
  96903. */
  96904. enableEffect(effect: Nullable<Effect>): void;
  96905. /**
  96906. * Set the value of an uniform to an array of int32
  96907. * @param uniform defines the webGL uniform location where to store the value
  96908. * @param array defines the array of int32 to store
  96909. */
  96910. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96911. /**
  96912. * Set the value of an uniform to an array of int32 (stored as vec2)
  96913. * @param uniform defines the webGL uniform location where to store the value
  96914. * @param array defines the array of int32 to store
  96915. */
  96916. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96917. /**
  96918. * Set the value of an uniform to an array of int32 (stored as vec3)
  96919. * @param uniform defines the webGL uniform location where to store the value
  96920. * @param array defines the array of int32 to store
  96921. */
  96922. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96923. /**
  96924. * Set the value of an uniform to an array of int32 (stored as vec4)
  96925. * @param uniform defines the webGL uniform location where to store the value
  96926. * @param array defines the array of int32 to store
  96927. */
  96928. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96929. /**
  96930. * Set the value of an uniform to an array of float32
  96931. * @param uniform defines the webGL uniform location where to store the value
  96932. * @param array defines the array of float32 to store
  96933. */
  96934. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96935. /**
  96936. * Set the value of an uniform to an array of float32 (stored as vec2)
  96937. * @param uniform defines the webGL uniform location where to store the value
  96938. * @param array defines the array of float32 to store
  96939. */
  96940. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96941. /**
  96942. * Set the value of an uniform to an array of float32 (stored as vec3)
  96943. * @param uniform defines the webGL uniform location where to store the value
  96944. * @param array defines the array of float32 to store
  96945. */
  96946. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96947. /**
  96948. * Set the value of an uniform to an array of float32 (stored as vec4)
  96949. * @param uniform defines the webGL uniform location where to store the value
  96950. * @param array defines the array of float32 to store
  96951. */
  96952. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96953. /**
  96954. * Set the value of an uniform to an array of number
  96955. * @param uniform defines the webGL uniform location where to store the value
  96956. * @param array defines the array of number to store
  96957. */
  96958. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96959. /**
  96960. * Set the value of an uniform to an array of number (stored as vec2)
  96961. * @param uniform defines the webGL uniform location where to store the value
  96962. * @param array defines the array of number to store
  96963. */
  96964. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96965. /**
  96966. * Set the value of an uniform to an array of number (stored as vec3)
  96967. * @param uniform defines the webGL uniform location where to store the value
  96968. * @param array defines the array of number to store
  96969. */
  96970. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96971. /**
  96972. * Set the value of an uniform to an array of number (stored as vec4)
  96973. * @param uniform defines the webGL uniform location where to store the value
  96974. * @param array defines the array of number to store
  96975. */
  96976. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96977. /**
  96978. * Set the value of an uniform to an array of float32 (stored as matrices)
  96979. * @param uniform defines the webGL uniform location where to store the value
  96980. * @param matrices defines the array of float32 to store
  96981. */
  96982. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  96983. /**
  96984. * Set the value of an uniform to a matrix (3x3)
  96985. * @param uniform defines the webGL uniform location where to store the value
  96986. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  96987. */
  96988. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96989. /**
  96990. * Set the value of an uniform to a matrix (2x2)
  96991. * @param uniform defines the webGL uniform location where to store the value
  96992. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  96993. */
  96994. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96995. /**
  96996. * Set the value of an uniform to a number (int)
  96997. * @param uniform defines the webGL uniform location where to store the value
  96998. * @param value defines the int number to store
  96999. */
  97000. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  97001. /**
  97002. * Set the value of an uniform to a number (float)
  97003. * @param uniform defines the webGL uniform location where to store the value
  97004. * @param value defines the float number to store
  97005. */
  97006. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  97007. /**
  97008. * Set the value of an uniform to a vec2
  97009. * @param uniform defines the webGL uniform location where to store the value
  97010. * @param x defines the 1st component of the value
  97011. * @param y defines the 2nd component of the value
  97012. */
  97013. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  97014. /**
  97015. * Set the value of an uniform to a vec3
  97016. * @param uniform defines the webGL uniform location where to store the value
  97017. * @param x defines the 1st component of the value
  97018. * @param y defines the 2nd component of the value
  97019. * @param z defines the 3rd component of the value
  97020. */
  97021. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  97022. /**
  97023. * Set the value of an uniform to a boolean
  97024. * @param uniform defines the webGL uniform location where to store the value
  97025. * @param bool defines the boolean to store
  97026. */
  97027. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  97028. /**
  97029. * Set the value of an uniform to a vec4
  97030. * @param uniform defines the webGL uniform location where to store the value
  97031. * @param x defines the 1st component of the value
  97032. * @param y defines the 2nd component of the value
  97033. * @param z defines the 3rd component of the value
  97034. * @param w defines the 4th component of the value
  97035. */
  97036. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  97037. /**
  97038. * Sets a Color4 on a uniform variable
  97039. * @param uniform defines the uniform location
  97040. * @param color4 defines the value to be set
  97041. */
  97042. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  97043. /**
  97044. * Set various states to the webGL context
  97045. * @param culling defines backface culling state
  97046. * @param zOffset defines the value to apply to zOffset (0 by default)
  97047. * @param force defines if states must be applied even if cache is up to date
  97048. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  97049. */
  97050. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  97051. /**
  97052. * Set the z offset to apply to current rendering
  97053. * @param value defines the offset to apply
  97054. */
  97055. setZOffset(value: number): void;
  97056. /**
  97057. * Gets the current value of the zOffset
  97058. * @returns the current zOffset state
  97059. */
  97060. getZOffset(): number;
  97061. /**
  97062. * Enable or disable depth buffering
  97063. * @param enable defines the state to set
  97064. */
  97065. setDepthBuffer(enable: boolean): void;
  97066. /**
  97067. * Gets a boolean indicating if depth writing is enabled
  97068. * @returns the current depth writing state
  97069. */
  97070. getDepthWrite(): boolean;
  97071. /**
  97072. * Enable or disable depth writing
  97073. * @param enable defines the state to set
  97074. */
  97075. setDepthWrite(enable: boolean): void;
  97076. /**
  97077. * Enable or disable color writing
  97078. * @param enable defines the state to set
  97079. */
  97080. setColorWrite(enable: boolean): void;
  97081. /**
  97082. * Gets a boolean indicating if color writing is enabled
  97083. * @returns the current color writing state
  97084. */
  97085. getColorWrite(): boolean;
  97086. /**
  97087. * Sets alpha constants used by some alpha blending modes
  97088. * @param r defines the red component
  97089. * @param g defines the green component
  97090. * @param b defines the blue component
  97091. * @param a defines the alpha component
  97092. */
  97093. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  97094. /**
  97095. * Sets the current alpha mode
  97096. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  97097. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  97098. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  97099. */
  97100. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  97101. /**
  97102. * Gets the current alpha mode
  97103. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  97104. * @returns the current alpha mode
  97105. */
  97106. getAlphaMode(): number;
  97107. /**
  97108. * Clears the list of texture accessible through engine.
  97109. * This can help preventing texture load conflict due to name collision.
  97110. */
  97111. clearInternalTexturesCache(): void;
  97112. /**
  97113. * Force the entire cache to be cleared
  97114. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  97115. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  97116. */
  97117. wipeCaches(bruteForce?: boolean): void;
  97118. /**
  97119. * Set the compressed texture format to use, based on the formats you have, and the formats
  97120. * supported by the hardware / browser.
  97121. *
  97122. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  97123. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  97124. * to API arguments needed to compressed textures. This puts the burden on the container
  97125. * generator to house the arcane code for determining these for current & future formats.
  97126. *
  97127. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  97128. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  97129. *
  97130. * Note: The result of this call is not taken into account when a texture is base64.
  97131. *
  97132. * @param formatsAvailable defines the list of those format families you have created
  97133. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  97134. *
  97135. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  97136. * @returns The extension selected.
  97137. */
  97138. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  97139. /** @hidden */
  97140. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  97141. min: number;
  97142. mag: number;
  97143. };
  97144. /** @hidden */
  97145. _createTexture(): WebGLTexture;
  97146. /**
  97147. * Usually called from Texture.ts.
  97148. * Passed information to create a WebGLTexture
  97149. * @param urlArg defines a value which contains one of the following:
  97150. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  97151. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  97152. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  97153. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  97154. * @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)
  97155. * @param scene needed for loading to the correct scene
  97156. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  97157. * @param onLoad optional callback to be called upon successful completion
  97158. * @param onError optional callback to be called upon failure
  97159. * @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
  97160. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  97161. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  97162. * @param forcedExtension defines the extension to use to pick the right loader
  97163. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  97164. * @returns a InternalTexture for assignment back into BABYLON.Texture
  97165. */
  97166. 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 | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  97167. /**
  97168. * @hidden
  97169. * Rescales a texture
  97170. * @param source input texutre
  97171. * @param destination destination texture
  97172. * @param scene scene to use to render the resize
  97173. * @param internalFormat format to use when resizing
  97174. * @param onComplete callback to be called when resize has completed
  97175. */
  97176. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  97177. private _unpackFlipYCached;
  97178. /**
  97179. * In case you are sharing the context with other applications, it might
  97180. * be interested to not cache the unpack flip y state to ensure a consistent
  97181. * value would be set.
  97182. */
  97183. enableUnpackFlipYCached: boolean;
  97184. /** @hidden */
  97185. _unpackFlipY(value: boolean): void;
  97186. /** @hidden */
  97187. _getUnpackAlignement(): number;
  97188. /**
  97189. * Creates a dynamic texture
  97190. * @param width defines the width of the texture
  97191. * @param height defines the height of the texture
  97192. * @param generateMipMaps defines if the engine should generate the mip levels
  97193. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  97194. * @returns the dynamic texture inside an InternalTexture
  97195. */
  97196. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  97197. /**
  97198. * Update the sampling mode of a given texture
  97199. * @param samplingMode defines the required sampling mode
  97200. * @param texture defines the texture to update
  97201. */
  97202. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  97203. /**
  97204. * Update the content of a dynamic texture
  97205. * @param texture defines the texture to update
  97206. * @param canvas defines the canvas containing the source
  97207. * @param invertY defines if data must be stored with Y axis inverted
  97208. * @param premulAlpha defines if alpha is stored as premultiplied
  97209. * @param format defines the format of the data
  97210. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  97211. */
  97212. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  97213. /**
  97214. * Update a video texture
  97215. * @param texture defines the texture to update
  97216. * @param video defines the video element to use
  97217. * @param invertY defines if data must be stored with Y axis inverted
  97218. */
  97219. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  97220. /**
  97221. * Updates a depth texture Comparison Mode and Function.
  97222. * If the comparison Function is equal to 0, the mode will be set to none.
  97223. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  97224. * @param texture The texture to set the comparison function for
  97225. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  97226. */
  97227. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  97228. /** @hidden */
  97229. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  97230. width: number;
  97231. height: number;
  97232. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  97233. /**
  97234. * Creates a depth stencil texture.
  97235. * This is only available in WebGL 2 or with the depth texture extension available.
  97236. * @param size The size of face edge in the texture.
  97237. * @param options The options defining the texture.
  97238. * @returns The texture
  97239. */
  97240. createDepthStencilTexture(size: number | {
  97241. width: number;
  97242. height: number;
  97243. }, options: DepthTextureCreationOptions): InternalTexture;
  97244. /**
  97245. * Creates a depth stencil texture.
  97246. * This is only available in WebGL 2 or with the depth texture extension available.
  97247. * @param size The size of face edge in the texture.
  97248. * @param options The options defining the texture.
  97249. * @returns The texture
  97250. */
  97251. private _createDepthStencilTexture;
  97252. /**
  97253. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  97254. * @param renderTarget The render target to set the frame buffer for
  97255. */
  97256. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  97257. /**
  97258. * Creates a new render target texture
  97259. * @param size defines the size of the texture
  97260. * @param options defines the options used to create the texture
  97261. * @returns a new render target texture stored in an InternalTexture
  97262. */
  97263. createRenderTargetTexture(size: number | {
  97264. width: number;
  97265. height: number;
  97266. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  97267. /** @hidden */
  97268. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  97269. /**
  97270. * Updates the sample count of a render target texture
  97271. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  97272. * @param texture defines the texture to update
  97273. * @param samples defines the sample count to set
  97274. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  97275. */
  97276. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  97277. /** @hidden */
  97278. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97279. /** @hidden */
  97280. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  97281. /** @hidden */
  97282. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97283. /** @hidden */
  97284. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  97285. /**
  97286. * @hidden
  97287. */
  97288. _setCubeMapTextureParams(loadMipmap: boolean): void;
  97289. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<Scene>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  97290. private _prepareWebGLTexture;
  97291. /** @hidden */
  97292. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  97293. /** @hidden */
  97294. _releaseFramebufferObjects(texture: InternalTexture): void;
  97295. /** @hidden */
  97296. _releaseTexture(texture: InternalTexture): void;
  97297. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  97298. protected _setProgram(program: WebGLProgram): void;
  97299. protected _boundUniforms: {
  97300. [key: number]: WebGLUniformLocation;
  97301. };
  97302. /**
  97303. * Binds an effect to the webGL context
  97304. * @param effect defines the effect to bind
  97305. */
  97306. bindSamplers(effect: Effect): void;
  97307. private _activateCurrentTexture;
  97308. /** @hidden */
  97309. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  97310. /** @hidden */
  97311. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  97312. /**
  97313. * Sets a texture to the webGL context from a postprocess
  97314. * @param channel defines the channel to use
  97315. * @param postProcess defines the source postprocess
  97316. */
  97317. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  97318. /**
  97319. * Binds the output of the passed in post process to the texture channel specified
  97320. * @param channel The channel the texture should be bound to
  97321. * @param postProcess The post process which's output should be bound
  97322. */
  97323. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  97324. /**
  97325. * Unbind all textures from the webGL context
  97326. */
  97327. unbindAllTextures(): void;
  97328. /**
  97329. * Sets a texture to the according uniform.
  97330. * @param channel The texture channel
  97331. * @param uniform The uniform to set
  97332. * @param texture The texture to apply
  97333. */
  97334. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  97335. /**
  97336. * Sets a depth stencil texture from a render target to the according uniform.
  97337. * @param channel The texture channel
  97338. * @param uniform The uniform to set
  97339. * @param texture The render target texture containing the depth stencil texture to apply
  97340. */
  97341. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  97342. private _bindSamplerUniformToChannel;
  97343. private _getTextureWrapMode;
  97344. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  97345. /**
  97346. * Sets an array of texture to the webGL context
  97347. * @param channel defines the channel where the texture array must be set
  97348. * @param uniform defines the associated uniform location
  97349. * @param textures defines the array of textures to bind
  97350. */
  97351. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  97352. /** @hidden */
  97353. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  97354. private _setTextureParameterFloat;
  97355. private _setTextureParameterInteger;
  97356. /**
  97357. * Reads pixels from the current frame buffer. Please note that this function can be slow
  97358. * @param x defines the x coordinate of the rectangle where pixels must be read
  97359. * @param y defines the y coordinate of the rectangle where pixels must be read
  97360. * @param width defines the width of the rectangle where pixels must be read
  97361. * @param height defines the height of the rectangle where pixels must be read
  97362. * @returns a Uint8Array containing RGBA colors
  97363. */
  97364. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  97365. /**
  97366. * Add an externaly attached data from its key.
  97367. * This method call will fail and return false, if such key already exists.
  97368. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  97369. * @param key the unique key that identifies the data
  97370. * @param data the data object to associate to the key for this Engine instance
  97371. * @return true if no such key were already present and the data was added successfully, false otherwise
  97372. */
  97373. addExternalData<T>(key: string, data: T): boolean;
  97374. /**
  97375. * Get an externaly attached data from its key
  97376. * @param key the unique key that identifies the data
  97377. * @return the associated data, if present (can be null), or undefined if not present
  97378. */
  97379. getExternalData<T>(key: string): T;
  97380. /**
  97381. * Get an externaly attached data from its key, create it using a factory if it's not already present
  97382. * @param key the unique key that identifies the data
  97383. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  97384. * @return the associated data, can be null if the factory returned null.
  97385. */
  97386. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  97387. /**
  97388. * Remove an externaly attached data from the Engine instance
  97389. * @param key the unique key that identifies the data
  97390. * @return true if the data was successfully removed, false if it doesn't exist
  97391. */
  97392. removeExternalData(key: string): boolean;
  97393. /**
  97394. * Unbind all vertex attributes from the webGL context
  97395. */
  97396. unbindAllAttributes(): void;
  97397. /**
  97398. * 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
  97399. */
  97400. releaseEffects(): void;
  97401. /**
  97402. * Dispose and release all associated resources
  97403. */
  97404. dispose(): void;
  97405. /**
  97406. * Display the loading screen
  97407. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97408. */
  97409. displayLoadingUI(): void;
  97410. /**
  97411. * Hide the loading screen
  97412. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97413. */
  97414. hideLoadingUI(): void;
  97415. /**
  97416. * Gets the current loading screen object
  97417. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97418. */
  97419. /**
  97420. * Sets the current loading screen object
  97421. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97422. */
  97423. loadingScreen: ILoadingScreen;
  97424. /**
  97425. * Sets the current loading screen text
  97426. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97427. */
  97428. loadingUIText: string;
  97429. /**
  97430. * Sets the current loading screen background color
  97431. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97432. */
  97433. loadingUIBackgroundColor: string;
  97434. /**
  97435. * Attach a new callback raised when context lost event is fired
  97436. * @param callback defines the callback to call
  97437. */
  97438. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  97439. /**
  97440. * Attach a new callback raised when context restored event is fired
  97441. * @param callback defines the callback to call
  97442. */
  97443. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  97444. /**
  97445. * Gets the source code of the vertex shader associated with a specific webGL program
  97446. * @param program defines the program to use
  97447. * @returns a string containing the source code of the vertex shader associated with the program
  97448. */
  97449. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  97450. /**
  97451. * Gets the source code of the fragment shader associated with a specific webGL program
  97452. * @param program defines the program to use
  97453. * @returns a string containing the source code of the fragment shader associated with the program
  97454. */
  97455. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  97456. /**
  97457. * Get the current error code of the webGL context
  97458. * @returns the error code
  97459. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  97460. */
  97461. getError(): number;
  97462. /**
  97463. * Gets the current framerate
  97464. * @returns a number representing the framerate
  97465. */
  97466. getFps(): number;
  97467. /**
  97468. * Gets the time spent between current and previous frame
  97469. * @returns a number representing the delta time in ms
  97470. */
  97471. getDeltaTime(): number;
  97472. private _measureFps;
  97473. /** @hidden */
  97474. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  97475. private _canRenderToFloatFramebuffer;
  97476. private _canRenderToHalfFloatFramebuffer;
  97477. private _canRenderToFramebuffer;
  97478. /** @hidden */
  97479. _getWebGLTextureType(type: number): number;
  97480. /** @hidden */
  97481. _getInternalFormat(format: number): number;
  97482. /** @hidden */
  97483. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  97484. /** @hidden */
  97485. _getRGBAMultiSampleBufferFormat(type: number): number;
  97486. /** @hidden */
  97487. _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;
  97488. /** @hidden */
  97489. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  97490. /**
  97491. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  97492. * @returns true if the engine can be created
  97493. * @ignorenaming
  97494. */
  97495. static isSupported(): boolean;
  97496. /**
  97497. * Find the next highest power of two.
  97498. * @param x Number to start search from.
  97499. * @return Next highest power of two.
  97500. */
  97501. static CeilingPOT(x: number): number;
  97502. /**
  97503. * Find the next lowest power of two.
  97504. * @param x Number to start search from.
  97505. * @return Next lowest power of two.
  97506. */
  97507. static FloorPOT(x: number): number;
  97508. /**
  97509. * Find the nearest power of two.
  97510. * @param x Number to start search from.
  97511. * @return Next nearest power of two.
  97512. */
  97513. static NearestPOT(x: number): number;
  97514. /**
  97515. * Get the closest exponent of two
  97516. * @param value defines the value to approximate
  97517. * @param max defines the maximum value to return
  97518. * @param mode defines how to define the closest value
  97519. * @returns closest exponent of two of the given value
  97520. */
  97521. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  97522. /**
  97523. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  97524. * @param func - the function to be called
  97525. * @param requester - the object that will request the next frame. Falls back to window.
  97526. * @returns frame number
  97527. */
  97528. static QueueNewFrame(func: () => void, requester?: any): number;
  97529. /**
  97530. * Ask the browser to promote the current element to pointerlock mode
  97531. * @param element defines the DOM element to promote
  97532. */
  97533. static _RequestPointerlock(element: HTMLElement): void;
  97534. /**
  97535. * Asks the browser to exit pointerlock mode
  97536. */
  97537. static _ExitPointerlock(): void;
  97538. /**
  97539. * Ask the browser to promote the current element to fullscreen rendering mode
  97540. * @param element defines the DOM element to promote
  97541. */
  97542. static _RequestFullscreen(element: HTMLElement): void;
  97543. /**
  97544. * Asks the browser to exit fullscreen mode
  97545. */
  97546. static _ExitFullscreen(): void;
  97547. }
  97548. }
  97549. declare module BABYLON {
  97550. /**
  97551. * The engine store class is responsible to hold all the instances of Engine and Scene created
  97552. * during the life time of the application.
  97553. */
  97554. export class EngineStore {
  97555. /** Gets the list of created engines */
  97556. static Instances: Engine[];
  97557. /** @hidden */
  97558. static _LastCreatedScene: Nullable<Scene>;
  97559. /**
  97560. * Gets the latest created engine
  97561. */
  97562. static readonly LastCreatedEngine: Nullable<Engine>;
  97563. /**
  97564. * Gets the latest created scene
  97565. */
  97566. static readonly LastCreatedScene: Nullable<Scene>;
  97567. /**
  97568. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  97569. * @ignorenaming
  97570. */
  97571. static UseFallbackTexture: boolean;
  97572. /**
  97573. * Texture content used if a texture cannot loaded
  97574. * @ignorenaming
  97575. */
  97576. static FallbackTexture: string;
  97577. }
  97578. }
  97579. declare module BABYLON {
  97580. /**
  97581. * Helper class that provides a small promise polyfill
  97582. */
  97583. export class PromisePolyfill {
  97584. /**
  97585. * Static function used to check if the polyfill is required
  97586. * If this is the case then the function will inject the polyfill to window.Promise
  97587. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  97588. */
  97589. static Apply(force?: boolean): void;
  97590. }
  97591. }
  97592. declare module BABYLON {
  97593. /**
  97594. * Interface for screenshot methods with describe argument called `size` as object with options
  97595. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  97596. */
  97597. export interface IScreenshotSize {
  97598. /**
  97599. * number in pixels for canvas height
  97600. */
  97601. height?: number;
  97602. /**
  97603. * multiplier allowing render at a higher or lower resolution
  97604. * If value is defined then height and width will be ignored and taken from camera
  97605. */
  97606. precision?: number;
  97607. /**
  97608. * number in pixels for canvas width
  97609. */
  97610. width?: number;
  97611. }
  97612. }
  97613. declare module BABYLON {
  97614. interface IColor4Like {
  97615. r: float;
  97616. g: float;
  97617. b: float;
  97618. a: float;
  97619. }
  97620. /**
  97621. * Class containing a set of static utilities functions
  97622. */
  97623. export class Tools {
  97624. /**
  97625. * Gets or sets the base URL to use to load assets
  97626. */
  97627. static BaseUrl: string;
  97628. /**
  97629. * Enable/Disable Custom HTTP Request Headers globally.
  97630. * default = false
  97631. * @see CustomRequestHeaders
  97632. */
  97633. static UseCustomRequestHeaders: boolean;
  97634. /**
  97635. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  97636. * i.e. when loading files, where the server/service expects an Authorization header
  97637. */
  97638. static CustomRequestHeaders: {
  97639. [key: string]: string;
  97640. };
  97641. /**
  97642. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  97643. */
  97644. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  97645. /**
  97646. * Default behaviour for cors in the application.
  97647. * It can be a string if the expected behavior is identical in the entire app.
  97648. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  97649. */
  97650. static CorsBehavior: string | ((url: string | string[]) => string);
  97651. /**
  97652. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  97653. * @ignorenaming
  97654. */
  97655. static UseFallbackTexture: boolean;
  97656. /**
  97657. * Use this object to register external classes like custom textures or material
  97658. * to allow the laoders to instantiate them
  97659. */
  97660. static RegisteredExternalClasses: {
  97661. [key: string]: Object;
  97662. };
  97663. /**
  97664. * Texture content used if a texture cannot loaded
  97665. * @ignorenaming
  97666. */
  97667. static fallbackTexture: string;
  97668. /**
  97669. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  97670. * @param u defines the coordinate on X axis
  97671. * @param v defines the coordinate on Y axis
  97672. * @param width defines the width of the source data
  97673. * @param height defines the height of the source data
  97674. * @param pixels defines the source byte array
  97675. * @param color defines the output color
  97676. */
  97677. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  97678. /**
  97679. * Interpolates between a and b via alpha
  97680. * @param a The lower value (returned when alpha = 0)
  97681. * @param b The upper value (returned when alpha = 1)
  97682. * @param alpha The interpolation-factor
  97683. * @return The mixed value
  97684. */
  97685. static Mix(a: number, b: number, alpha: number): number;
  97686. /**
  97687. * Tries to instantiate a new object from a given class name
  97688. * @param className defines the class name to instantiate
  97689. * @returns the new object or null if the system was not able to do the instantiation
  97690. */
  97691. static Instantiate(className: string): any;
  97692. /**
  97693. * Provides a slice function that will work even on IE
  97694. * @param data defines the array to slice
  97695. * @param start defines the start of the data (optional)
  97696. * @param end defines the end of the data (optional)
  97697. * @returns the new sliced array
  97698. */
  97699. static Slice<T>(data: T, start?: number, end?: number): T;
  97700. /**
  97701. * Polyfill for setImmediate
  97702. * @param action defines the action to execute after the current execution block
  97703. */
  97704. static SetImmediate(action: () => void): void;
  97705. /**
  97706. * Function indicating if a number is an exponent of 2
  97707. * @param value defines the value to test
  97708. * @returns true if the value is an exponent of 2
  97709. */
  97710. static IsExponentOfTwo(value: number): boolean;
  97711. private static _tmpFloatArray;
  97712. /**
  97713. * Returns the nearest 32-bit single precision float representation of a Number
  97714. * @param value A Number. If the parameter is of a different type, it will get converted
  97715. * to a number or to NaN if it cannot be converted
  97716. * @returns number
  97717. */
  97718. static FloatRound(value: number): number;
  97719. /**
  97720. * Extracts the filename from a path
  97721. * @param path defines the path to use
  97722. * @returns the filename
  97723. */
  97724. static GetFilename(path: string): string;
  97725. /**
  97726. * Extracts the "folder" part of a path (everything before the filename).
  97727. * @param uri The URI to extract the info from
  97728. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  97729. * @returns The "folder" part of the path
  97730. */
  97731. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  97732. /**
  97733. * Extracts text content from a DOM element hierarchy
  97734. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  97735. */
  97736. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  97737. /**
  97738. * Convert an angle in radians to degrees
  97739. * @param angle defines the angle to convert
  97740. * @returns the angle in degrees
  97741. */
  97742. static ToDegrees(angle: number): number;
  97743. /**
  97744. * Convert an angle in degrees to radians
  97745. * @param angle defines the angle to convert
  97746. * @returns the angle in radians
  97747. */
  97748. static ToRadians(angle: number): number;
  97749. /**
  97750. * Encode a buffer to a base64 string
  97751. * @param buffer defines the buffer to encode
  97752. * @returns the encoded string
  97753. */
  97754. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  97755. /**
  97756. * Returns an array if obj is not an array
  97757. * @param obj defines the object to evaluate as an array
  97758. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  97759. * @returns either obj directly if obj is an array or a new array containing obj
  97760. */
  97761. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  97762. /**
  97763. * Gets the pointer prefix to use
  97764. * @returns "pointer" if touch is enabled. Else returns "mouse"
  97765. */
  97766. static GetPointerPrefix(): string;
  97767. /**
  97768. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  97769. * @param url define the url we are trying
  97770. * @param element define the dom element where to configure the cors policy
  97771. */
  97772. static SetCorsBehavior(url: string | string[], element: {
  97773. crossOrigin: string | null;
  97774. }): void;
  97775. /**
  97776. * Removes unwanted characters from an url
  97777. * @param url defines the url to clean
  97778. * @returns the cleaned url
  97779. */
  97780. static CleanUrl(url: string): string;
  97781. /**
  97782. * Gets or sets a function used to pre-process url before using them to load assets
  97783. */
  97784. static PreprocessUrl: (url: string) => string;
  97785. /**
  97786. * Loads an image as an HTMLImageElement.
  97787. * @param input url string, ArrayBuffer, or Blob to load
  97788. * @param onLoad callback called when the image successfully loads
  97789. * @param onError callback called when the image fails to load
  97790. * @param offlineProvider offline provider for caching
  97791. * @returns the HTMLImageElement of the loaded image
  97792. */
  97793. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  97794. /**
  97795. * Loads a file
  97796. * @param url url string, ArrayBuffer, or Blob to load
  97797. * @param onSuccess callback called when the file successfully loads
  97798. * @param onProgress callback called while file is loading (if the server supports this mode)
  97799. * @param offlineProvider defines the offline provider for caching
  97800. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  97801. * @param onError callback called when the file fails to load
  97802. * @returns a file request object
  97803. */
  97804. 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;
  97805. /**
  97806. * Loads a file from a url
  97807. * @param url the file url to load
  97808. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  97809. */
  97810. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  97811. /**
  97812. * Load a script (identified by an url). When the url returns, the
  97813. * content of this file is added into a new script element, attached to the DOM (body element)
  97814. * @param scriptUrl defines the url of the script to laod
  97815. * @param onSuccess defines the callback called when the script is loaded
  97816. * @param onError defines the callback to call if an error occurs
  97817. * @param scriptId defines the id of the script element
  97818. */
  97819. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  97820. /**
  97821. * Load an asynchronous script (identified by an url). When the url returns, the
  97822. * content of this file is added into a new script element, attached to the DOM (body element)
  97823. * @param scriptUrl defines the url of the script to laod
  97824. * @param scriptId defines the id of the script element
  97825. * @returns a promise request object
  97826. */
  97827. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  97828. /**
  97829. * Loads a file from a blob
  97830. * @param fileToLoad defines the blob to use
  97831. * @param callback defines the callback to call when data is loaded
  97832. * @param progressCallback defines the callback to call during loading process
  97833. * @returns a file request object
  97834. */
  97835. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  97836. /**
  97837. * Loads a file
  97838. * @param fileToLoad defines the file to load
  97839. * @param callback defines the callback to call when data is loaded
  97840. * @param progressCallBack defines the callback to call during loading process
  97841. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  97842. * @returns a file request object
  97843. */
  97844. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  97845. /**
  97846. * Creates a data url from a given string content
  97847. * @param content defines the content to convert
  97848. * @returns the new data url link
  97849. */
  97850. static FileAsURL(content: string): string;
  97851. /**
  97852. * Format the given number to a specific decimal format
  97853. * @param value defines the number to format
  97854. * @param decimals defines the number of decimals to use
  97855. * @returns the formatted string
  97856. */
  97857. static Format(value: number, decimals?: number): string;
  97858. /**
  97859. * Tries to copy an object by duplicating every property
  97860. * @param source defines the source object
  97861. * @param destination defines the target object
  97862. * @param doNotCopyList defines a list of properties to avoid
  97863. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  97864. */
  97865. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  97866. /**
  97867. * Gets a boolean indicating if the given object has no own property
  97868. * @param obj defines the object to test
  97869. * @returns true if object has no own property
  97870. */
  97871. static IsEmpty(obj: any): boolean;
  97872. /**
  97873. * Function used to register events at window level
  97874. * @param windowElement defines the Window object to use
  97875. * @param events defines the events to register
  97876. */
  97877. static RegisterTopRootEvents(windowElement: Window, events: {
  97878. name: string;
  97879. handler: Nullable<(e: FocusEvent) => any>;
  97880. }[]): void;
  97881. /**
  97882. * Function used to unregister events from window level
  97883. * @param windowElement defines the Window object to use
  97884. * @param events defines the events to unregister
  97885. */
  97886. static UnregisterTopRootEvents(windowElement: Window, events: {
  97887. name: string;
  97888. handler: Nullable<(e: FocusEvent) => any>;
  97889. }[]): void;
  97890. /**
  97891. * @ignore
  97892. */
  97893. static _ScreenshotCanvas: HTMLCanvasElement;
  97894. /**
  97895. * Dumps the current bound framebuffer
  97896. * @param width defines the rendering width
  97897. * @param height defines the rendering height
  97898. * @param engine defines the hosting engine
  97899. * @param successCallback defines the callback triggered once the data are available
  97900. * @param mimeType defines the mime type of the result
  97901. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  97902. */
  97903. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  97904. /**
  97905. * Converts the canvas data to blob.
  97906. * This acts as a polyfill for browsers not supporting the to blob function.
  97907. * @param canvas Defines the canvas to extract the data from
  97908. * @param successCallback Defines the callback triggered once the data are available
  97909. * @param mimeType Defines the mime type of the result
  97910. */
  97911. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  97912. /**
  97913. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  97914. * @param successCallback defines the callback triggered once the data are available
  97915. * @param mimeType defines the mime type of the result
  97916. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  97917. */
  97918. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  97919. /**
  97920. * Downloads a blob in the browser
  97921. * @param blob defines the blob to download
  97922. * @param fileName defines the name of the downloaded file
  97923. */
  97924. static Download(blob: Blob, fileName: string): void;
  97925. /**
  97926. * Captures a screenshot of the current rendering
  97927. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97928. * @param engine defines the rendering engine
  97929. * @param camera defines the source camera
  97930. * @param size This parameter can be set to a single number or to an object with the
  97931. * following (optional) properties: precision, width, height. If a single number is passed,
  97932. * it will be used for both width and height. If an object is passed, the screenshot size
  97933. * will be derived from the parameters. The precision property is a multiplier allowing
  97934. * rendering at a higher or lower resolution
  97935. * @param successCallback defines the callback receives a single parameter which contains the
  97936. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  97937. * src parameter of an <img> to display it
  97938. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  97939. * Check your browser for supported MIME types
  97940. */
  97941. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  97942. /**
  97943. * Captures a screenshot of the current rendering
  97944. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97945. * @param engine defines the rendering engine
  97946. * @param camera defines the source camera
  97947. * @param size This parameter can be set to a single number or to an object with the
  97948. * following (optional) properties: precision, width, height. If a single number is passed,
  97949. * it will be used for both width and height. If an object is passed, the screenshot size
  97950. * will be derived from the parameters. The precision property is a multiplier allowing
  97951. * rendering at a higher or lower resolution
  97952. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  97953. * Check your browser for supported MIME types
  97954. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  97955. * to the src parameter of an <img> to display it
  97956. */
  97957. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  97958. /**
  97959. * Generates an image screenshot from the specified camera.
  97960. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97961. * @param engine The engine to use for rendering
  97962. * @param camera The camera to use for rendering
  97963. * @param size This parameter can be set to a single number or to an object with the
  97964. * following (optional) properties: precision, width, height. If a single number is passed,
  97965. * it will be used for both width and height. If an object is passed, the screenshot size
  97966. * will be derived from the parameters. The precision property is a multiplier allowing
  97967. * rendering at a higher or lower resolution
  97968. * @param successCallback The callback receives a single parameter which contains the
  97969. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  97970. * src parameter of an <img> to display it
  97971. * @param mimeType The MIME type of the screenshot image (default: image/png).
  97972. * Check your browser for supported MIME types
  97973. * @param samples Texture samples (default: 1)
  97974. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  97975. * @param fileName A name for for the downloaded file.
  97976. */
  97977. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  97978. /**
  97979. * Generates an image screenshot from the specified camera.
  97980. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97981. * @param engine The engine to use for rendering
  97982. * @param camera The camera to use for rendering
  97983. * @param size This parameter can be set to a single number or to an object with the
  97984. * following (optional) properties: precision, width, height. If a single number is passed,
  97985. * it will be used for both width and height. If an object is passed, the screenshot size
  97986. * will be derived from the parameters. The precision property is a multiplier allowing
  97987. * rendering at a higher or lower resolution
  97988. * @param mimeType The MIME type of the screenshot image (default: image/png).
  97989. * Check your browser for supported MIME types
  97990. * @param samples Texture samples (default: 1)
  97991. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  97992. * @param fileName A name for for the downloaded file.
  97993. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  97994. * to the src parameter of an <img> to display it
  97995. */
  97996. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  97997. /**
  97998. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  97999. * Be aware Math.random() could cause collisions, but:
  98000. * "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"
  98001. * @returns a pseudo random id
  98002. */
  98003. static RandomId(): string;
  98004. /**
  98005. * Test if the given uri is a base64 string
  98006. * @param uri The uri to test
  98007. * @return True if the uri is a base64 string or false otherwise
  98008. */
  98009. static IsBase64(uri: string): boolean;
  98010. /**
  98011. * Decode the given base64 uri.
  98012. * @param uri The uri to decode
  98013. * @return The decoded base64 data.
  98014. */
  98015. static DecodeBase64(uri: string): ArrayBuffer;
  98016. /**
  98017. * Gets the absolute url.
  98018. * @param url the input url
  98019. * @return the absolute url
  98020. */
  98021. static GetAbsoluteUrl(url: string): string;
  98022. /**
  98023. * No log
  98024. */
  98025. static readonly NoneLogLevel: number;
  98026. /**
  98027. * Only message logs
  98028. */
  98029. static readonly MessageLogLevel: number;
  98030. /**
  98031. * Only warning logs
  98032. */
  98033. static readonly WarningLogLevel: number;
  98034. /**
  98035. * Only error logs
  98036. */
  98037. static readonly ErrorLogLevel: number;
  98038. /**
  98039. * All logs
  98040. */
  98041. static readonly AllLogLevel: number;
  98042. /**
  98043. * Gets a value indicating the number of loading errors
  98044. * @ignorenaming
  98045. */
  98046. static readonly errorsCount: number;
  98047. /**
  98048. * Callback called when a new log is added
  98049. */
  98050. static OnNewCacheEntry: (entry: string) => void;
  98051. /**
  98052. * Log a message to the console
  98053. * @param message defines the message to log
  98054. */
  98055. static Log(message: string): void;
  98056. /**
  98057. * Write a warning message to the console
  98058. * @param message defines the message to log
  98059. */
  98060. static Warn(message: string): void;
  98061. /**
  98062. * Write an error message to the console
  98063. * @param message defines the message to log
  98064. */
  98065. static Error(message: string): void;
  98066. /**
  98067. * Gets current log cache (list of logs)
  98068. */
  98069. static readonly LogCache: string;
  98070. /**
  98071. * Clears the log cache
  98072. */
  98073. static ClearLogCache(): void;
  98074. /**
  98075. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  98076. */
  98077. static LogLevels: number;
  98078. /**
  98079. * Checks if the window object exists
  98080. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  98081. */
  98082. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  98083. /**
  98084. * No performance log
  98085. */
  98086. static readonly PerformanceNoneLogLevel: number;
  98087. /**
  98088. * Use user marks to log performance
  98089. */
  98090. static readonly PerformanceUserMarkLogLevel: number;
  98091. /**
  98092. * Log performance to the console
  98093. */
  98094. static readonly PerformanceConsoleLogLevel: number;
  98095. private static _performance;
  98096. /**
  98097. * Sets the current performance log level
  98098. */
  98099. static PerformanceLogLevel: number;
  98100. private static _StartPerformanceCounterDisabled;
  98101. private static _EndPerformanceCounterDisabled;
  98102. private static _StartUserMark;
  98103. private static _EndUserMark;
  98104. private static _StartPerformanceConsole;
  98105. private static _EndPerformanceConsole;
  98106. /**
  98107. * Starts a performance counter
  98108. */
  98109. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  98110. /**
  98111. * Ends a specific performance coutner
  98112. */
  98113. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  98114. /**
  98115. * Gets either window.performance.now() if supported or Date.now() else
  98116. */
  98117. static readonly Now: number;
  98118. /**
  98119. * This method will return the name of the class used to create the instance of the given object.
  98120. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  98121. * @param object the object to get the class name from
  98122. * @param isType defines if the object is actually a type
  98123. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  98124. */
  98125. static GetClassName(object: any, isType?: boolean): string;
  98126. /**
  98127. * Gets the first element of an array satisfying a given predicate
  98128. * @param array defines the array to browse
  98129. * @param predicate defines the predicate to use
  98130. * @returns null if not found or the element
  98131. */
  98132. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  98133. /**
  98134. * This method will return the name of the full name of the class, including its owning module (if any).
  98135. * 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).
  98136. * @param object the object to get the class name from
  98137. * @param isType defines if the object is actually a type
  98138. * @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.
  98139. * @ignorenaming
  98140. */
  98141. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  98142. /**
  98143. * Returns a promise that resolves after the given amount of time.
  98144. * @param delay Number of milliseconds to delay
  98145. * @returns Promise that resolves after the given amount of time
  98146. */
  98147. static DelayAsync(delay: number): Promise<void>;
  98148. }
  98149. /**
  98150. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  98151. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  98152. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  98153. * @param name The name of the class, case should be preserved
  98154. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  98155. */
  98156. export function className(name: string, module?: string): (target: Object) => void;
  98157. /**
  98158. * An implementation of a loop for asynchronous functions.
  98159. */
  98160. export class AsyncLoop {
  98161. /**
  98162. * Defines the number of iterations for the loop
  98163. */
  98164. iterations: number;
  98165. /**
  98166. * Defines the current index of the loop.
  98167. */
  98168. index: number;
  98169. private _done;
  98170. private _fn;
  98171. private _successCallback;
  98172. /**
  98173. * Constructor.
  98174. * @param iterations the number of iterations.
  98175. * @param func the function to run each iteration
  98176. * @param successCallback the callback that will be called upon succesful execution
  98177. * @param offset starting offset.
  98178. */
  98179. constructor(
  98180. /**
  98181. * Defines the number of iterations for the loop
  98182. */
  98183. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  98184. /**
  98185. * Execute the next iteration. Must be called after the last iteration was finished.
  98186. */
  98187. executeNext(): void;
  98188. /**
  98189. * Break the loop and run the success callback.
  98190. */
  98191. breakLoop(): void;
  98192. /**
  98193. * Create and run an async loop.
  98194. * @param iterations the number of iterations.
  98195. * @param fn the function to run each iteration
  98196. * @param successCallback the callback that will be called upon succesful execution
  98197. * @param offset starting offset.
  98198. * @returns the created async loop object
  98199. */
  98200. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  98201. /**
  98202. * A for-loop that will run a given number of iterations synchronous and the rest async.
  98203. * @param iterations total number of iterations
  98204. * @param syncedIterations number of synchronous iterations in each async iteration.
  98205. * @param fn the function to call each iteration.
  98206. * @param callback a success call back that will be called when iterating stops.
  98207. * @param breakFunction a break condition (optional)
  98208. * @param timeout timeout settings for the setTimeout function. default - 0.
  98209. * @returns the created async loop object
  98210. */
  98211. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  98212. }
  98213. }
  98214. declare module BABYLON {
  98215. /** @hidden */
  98216. export interface ICollisionCoordinator {
  98217. createCollider(): Collider;
  98218. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  98219. init(scene: Scene): void;
  98220. }
  98221. /** @hidden */
  98222. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  98223. private _scene;
  98224. private _scaledPosition;
  98225. private _scaledVelocity;
  98226. private _finalPosition;
  98227. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  98228. createCollider(): Collider;
  98229. init(scene: Scene): void;
  98230. private _collideWithWorld;
  98231. }
  98232. }
  98233. declare module BABYLON {
  98234. /**
  98235. * Class used to manage all inputs for the scene.
  98236. */
  98237. export class InputManager {
  98238. /** The distance in pixel that you have to move to prevent some events */
  98239. static DragMovementThreshold: number;
  98240. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  98241. static LongPressDelay: number;
  98242. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  98243. static DoubleClickDelay: number;
  98244. /** If you need to check double click without raising a single click at first click, enable this flag */
  98245. static ExclusiveDoubleClickMode: boolean;
  98246. private _wheelEventName;
  98247. private _onPointerMove;
  98248. private _onPointerDown;
  98249. private _onPointerUp;
  98250. private _initClickEvent;
  98251. private _initActionManager;
  98252. private _delayedSimpleClick;
  98253. private _delayedSimpleClickTimeout;
  98254. private _previousDelayedSimpleClickTimeout;
  98255. private _meshPickProceed;
  98256. private _previousButtonPressed;
  98257. private _currentPickResult;
  98258. private _previousPickResult;
  98259. private _totalPointersPressed;
  98260. private _doubleClickOccured;
  98261. private _pointerOverMesh;
  98262. private _pickedDownMesh;
  98263. private _pickedUpMesh;
  98264. private _pointerX;
  98265. private _pointerY;
  98266. private _unTranslatedPointerX;
  98267. private _unTranslatedPointerY;
  98268. private _startingPointerPosition;
  98269. private _previousStartingPointerPosition;
  98270. private _startingPointerTime;
  98271. private _previousStartingPointerTime;
  98272. private _pointerCaptures;
  98273. private _onKeyDown;
  98274. private _onKeyUp;
  98275. private _onCanvasFocusObserver;
  98276. private _onCanvasBlurObserver;
  98277. private _scene;
  98278. /**
  98279. * Creates a new InputManager
  98280. * @param scene defines the hosting scene
  98281. */
  98282. constructor(scene: Scene);
  98283. /**
  98284. * Gets the mesh that is currently under the pointer
  98285. */
  98286. readonly meshUnderPointer: Nullable<AbstractMesh>;
  98287. /**
  98288. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  98289. */
  98290. readonly unTranslatedPointer: Vector2;
  98291. /**
  98292. * Gets or sets the current on-screen X position of the pointer
  98293. */
  98294. pointerX: number;
  98295. /**
  98296. * Gets or sets the current on-screen Y position of the pointer
  98297. */
  98298. pointerY: number;
  98299. private _updatePointerPosition;
  98300. private _processPointerMove;
  98301. private _setRayOnPointerInfo;
  98302. private _checkPrePointerObservable;
  98303. /**
  98304. * Use this method to simulate a pointer move on a mesh
  98305. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98306. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98307. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98308. */
  98309. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  98310. /**
  98311. * Use this method to simulate a pointer down on a mesh
  98312. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98313. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98314. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98315. */
  98316. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  98317. private _processPointerDown;
  98318. /** @hidden */
  98319. _isPointerSwiping(): boolean;
  98320. /**
  98321. * Use this method to simulate a pointer up on a mesh
  98322. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98323. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98324. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98325. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  98326. */
  98327. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  98328. private _processPointerUp;
  98329. /**
  98330. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  98331. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  98332. * @returns true if the pointer was captured
  98333. */
  98334. isPointerCaptured(pointerId?: number): boolean;
  98335. /**
  98336. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  98337. * @param attachUp defines if you want to attach events to pointerup
  98338. * @param attachDown defines if you want to attach events to pointerdown
  98339. * @param attachMove defines if you want to attach events to pointermove
  98340. */
  98341. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  98342. /**
  98343. * Detaches all event handlers
  98344. */
  98345. detachControl(): void;
  98346. /**
  98347. * Force the value of meshUnderPointer
  98348. * @param mesh defines the mesh to use
  98349. */
  98350. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  98351. /**
  98352. * Gets the mesh under the pointer
  98353. * @returns a Mesh or null if no mesh is under the pointer
  98354. */
  98355. getPointerOverMesh(): Nullable<AbstractMesh>;
  98356. }
  98357. }
  98358. declare module BABYLON {
  98359. /**
  98360. * Helper class used to generate session unique ID
  98361. */
  98362. export class UniqueIdGenerator {
  98363. private static _UniqueIdCounter;
  98364. /**
  98365. * Gets an unique (relatively to the current scene) Id
  98366. */
  98367. static readonly UniqueId: number;
  98368. }
  98369. }
  98370. declare module BABYLON {
  98371. /**
  98372. * This class defines the direct association between an animation and a target
  98373. */
  98374. export class TargetedAnimation {
  98375. /**
  98376. * Animation to perform
  98377. */
  98378. animation: Animation;
  98379. /**
  98380. * Target to animate
  98381. */
  98382. target: any;
  98383. /**
  98384. * Serialize the object
  98385. * @returns the JSON object representing the current entity
  98386. */
  98387. serialize(): any;
  98388. }
  98389. /**
  98390. * Use this class to create coordinated animations on multiple targets
  98391. */
  98392. export class AnimationGroup implements IDisposable {
  98393. /** The name of the animation group */
  98394. name: string;
  98395. private _scene;
  98396. private _targetedAnimations;
  98397. private _animatables;
  98398. private _from;
  98399. private _to;
  98400. private _isStarted;
  98401. private _isPaused;
  98402. private _speedRatio;
  98403. private _loopAnimation;
  98404. /**
  98405. * Gets or sets the unique id of the node
  98406. */
  98407. uniqueId: number;
  98408. /**
  98409. * This observable will notify when one animation have ended
  98410. */
  98411. onAnimationEndObservable: Observable<TargetedAnimation>;
  98412. /**
  98413. * Observer raised when one animation loops
  98414. */
  98415. onAnimationLoopObservable: Observable<TargetedAnimation>;
  98416. /**
  98417. * This observable will notify when all animations have ended.
  98418. */
  98419. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  98420. /**
  98421. * This observable will notify when all animations have paused.
  98422. */
  98423. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  98424. /**
  98425. * This observable will notify when all animations are playing.
  98426. */
  98427. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  98428. /**
  98429. * Gets the first frame
  98430. */
  98431. readonly from: number;
  98432. /**
  98433. * Gets the last frame
  98434. */
  98435. readonly to: number;
  98436. /**
  98437. * Define if the animations are started
  98438. */
  98439. readonly isStarted: boolean;
  98440. /**
  98441. * Gets a value indicating that the current group is playing
  98442. */
  98443. readonly isPlaying: boolean;
  98444. /**
  98445. * Gets or sets the speed ratio to use for all animations
  98446. */
  98447. /**
  98448. * Gets or sets the speed ratio to use for all animations
  98449. */
  98450. speedRatio: number;
  98451. /**
  98452. * Gets or sets if all animations should loop or not
  98453. */
  98454. loopAnimation: boolean;
  98455. /**
  98456. * Gets the targeted animations for this animation group
  98457. */
  98458. readonly targetedAnimations: Array<TargetedAnimation>;
  98459. /**
  98460. * returning the list of animatables controlled by this animation group.
  98461. */
  98462. readonly animatables: Array<Animatable>;
  98463. /**
  98464. * Instantiates a new Animation Group.
  98465. * This helps managing several animations at once.
  98466. * @see http://doc.babylonjs.com/how_to/group
  98467. * @param name Defines the name of the group
  98468. * @param scene Defines the scene the group belongs to
  98469. */
  98470. constructor(
  98471. /** The name of the animation group */
  98472. name: string, scene?: Nullable<Scene>);
  98473. /**
  98474. * Add an animation (with its target) in the group
  98475. * @param animation defines the animation we want to add
  98476. * @param target defines the target of the animation
  98477. * @returns the TargetedAnimation object
  98478. */
  98479. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  98480. /**
  98481. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  98482. * It can add constant keys at begin or end
  98483. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  98484. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  98485. * @returns the animation group
  98486. */
  98487. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  98488. /**
  98489. * Start all animations on given targets
  98490. * @param loop defines if animations must loop
  98491. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  98492. * @param from defines the from key (optional)
  98493. * @param to defines the to key (optional)
  98494. * @returns the current animation group
  98495. */
  98496. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  98497. /**
  98498. * Pause all animations
  98499. * @returns the animation group
  98500. */
  98501. pause(): AnimationGroup;
  98502. /**
  98503. * Play all animations to initial state
  98504. * This function will start() the animations if they were not started or will restart() them if they were paused
  98505. * @param loop defines if animations must loop
  98506. * @returns the animation group
  98507. */
  98508. play(loop?: boolean): AnimationGroup;
  98509. /**
  98510. * Reset all animations to initial state
  98511. * @returns the animation group
  98512. */
  98513. reset(): AnimationGroup;
  98514. /**
  98515. * Restart animations from key 0
  98516. * @returns the animation group
  98517. */
  98518. restart(): AnimationGroup;
  98519. /**
  98520. * Stop all animations
  98521. * @returns the animation group
  98522. */
  98523. stop(): AnimationGroup;
  98524. /**
  98525. * Set animation weight for all animatables
  98526. * @param weight defines the weight to use
  98527. * @return the animationGroup
  98528. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  98529. */
  98530. setWeightForAllAnimatables(weight: number): AnimationGroup;
  98531. /**
  98532. * Synchronize and normalize all animatables with a source animatable
  98533. * @param root defines the root animatable to synchronize with
  98534. * @return the animationGroup
  98535. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  98536. */
  98537. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  98538. /**
  98539. * Goes to a specific frame in this animation group
  98540. * @param frame the frame number to go to
  98541. * @return the animationGroup
  98542. */
  98543. goToFrame(frame: number): AnimationGroup;
  98544. /**
  98545. * Dispose all associated resources
  98546. */
  98547. dispose(): void;
  98548. private _checkAnimationGroupEnded;
  98549. /**
  98550. * Clone the current animation group and returns a copy
  98551. * @param newName defines the name of the new group
  98552. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  98553. * @returns the new aniamtion group
  98554. */
  98555. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  98556. /**
  98557. * Serializes the animationGroup to an object
  98558. * @returns Serialized object
  98559. */
  98560. serialize(): any;
  98561. /**
  98562. * Returns a new AnimationGroup object parsed from the source provided.
  98563. * @param parsedAnimationGroup defines the source
  98564. * @param scene defines the scene that will receive the animationGroup
  98565. * @returns a new AnimationGroup
  98566. */
  98567. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  98568. /**
  98569. * Returns the string "AnimationGroup"
  98570. * @returns "AnimationGroup"
  98571. */
  98572. getClassName(): string;
  98573. /**
  98574. * Creates a detailled string about the object
  98575. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  98576. * @returns a string representing the object
  98577. */
  98578. toString(fullDetails?: boolean): string;
  98579. }
  98580. }
  98581. declare module BABYLON {
  98582. /**
  98583. * Define an interface for all classes that will hold resources
  98584. */
  98585. export interface IDisposable {
  98586. /**
  98587. * Releases all held resources
  98588. */
  98589. dispose(): void;
  98590. }
  98591. /** Interface defining initialization parameters for Scene class */
  98592. export interface SceneOptions {
  98593. /**
  98594. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  98595. * It will improve performance when the number of geometries becomes important.
  98596. */
  98597. useGeometryUniqueIdsMap?: boolean;
  98598. /**
  98599. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  98600. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  98601. */
  98602. useMaterialMeshMap?: boolean;
  98603. /**
  98604. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  98605. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  98606. */
  98607. useClonedMeshhMap?: boolean;
  98608. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  98609. virtual?: boolean;
  98610. }
  98611. /**
  98612. * Represents a scene to be rendered by the engine.
  98613. * @see http://doc.babylonjs.com/features/scene
  98614. */
  98615. export class Scene extends AbstractScene implements IAnimatable {
  98616. /** The fog is deactivated */
  98617. static readonly FOGMODE_NONE: number;
  98618. /** The fog density is following an exponential function */
  98619. static readonly FOGMODE_EXP: number;
  98620. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  98621. static readonly FOGMODE_EXP2: number;
  98622. /** The fog density is following a linear function. */
  98623. static readonly FOGMODE_LINEAR: number;
  98624. /**
  98625. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  98626. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98627. */
  98628. static MinDeltaTime: number;
  98629. /**
  98630. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  98631. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98632. */
  98633. static MaxDeltaTime: number;
  98634. /**
  98635. * Factory used to create the default material.
  98636. * @param name The name of the material to create
  98637. * @param scene The scene to create the material for
  98638. * @returns The default material
  98639. */
  98640. static DefaultMaterialFactory(scene: Scene): Material;
  98641. /**
  98642. * Factory used to create the a collision coordinator.
  98643. * @returns The collision coordinator
  98644. */
  98645. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  98646. /** @hidden */
  98647. _inputManager: InputManager;
  98648. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  98649. cameraToUseForPointers: Nullable<Camera>;
  98650. /** @hidden */
  98651. readonly _isScene: boolean;
  98652. /**
  98653. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  98654. */
  98655. autoClear: boolean;
  98656. /**
  98657. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  98658. */
  98659. autoClearDepthAndStencil: boolean;
  98660. /**
  98661. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  98662. */
  98663. clearColor: Color4;
  98664. /**
  98665. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  98666. */
  98667. ambientColor: Color3;
  98668. /**
  98669. * This is use to store the default BRDF lookup for PBR materials in your scene.
  98670. * It should only be one of the following (if not the default embedded one):
  98671. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  98672. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  98673. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  98674. * The material properties need to be setup according to the type of texture in use.
  98675. */
  98676. environmentBRDFTexture: BaseTexture;
  98677. /** @hidden */
  98678. protected _environmentTexture: Nullable<BaseTexture>;
  98679. /**
  98680. * Texture used in all pbr material as the reflection texture.
  98681. * As in the majority of the scene they are the same (exception for multi room and so on),
  98682. * this is easier to reference from here than from all the materials.
  98683. */
  98684. /**
  98685. * Texture used in all pbr material as the reflection texture.
  98686. * As in the majority of the scene they are the same (exception for multi room and so on),
  98687. * this is easier to set here than in all the materials.
  98688. */
  98689. environmentTexture: Nullable<BaseTexture>;
  98690. /** @hidden */
  98691. protected _environmentIntensity: number;
  98692. /**
  98693. * Intensity of the environment in all pbr material.
  98694. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  98695. * As in the majority of the scene they are the same (exception for multi room and so on),
  98696. * this is easier to reference from here than from all the materials.
  98697. */
  98698. /**
  98699. * Intensity of the environment in all pbr material.
  98700. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  98701. * As in the majority of the scene they are the same (exception for multi room and so on),
  98702. * this is easier to set here than in all the materials.
  98703. */
  98704. environmentIntensity: number;
  98705. /** @hidden */
  98706. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98707. /**
  98708. * Default image processing configuration used either in the rendering
  98709. * Forward main pass or through the imageProcessingPostProcess if present.
  98710. * As in the majority of the scene they are the same (exception for multi camera),
  98711. * this is easier to reference from here than from all the materials and post process.
  98712. *
  98713. * No setter as we it is a shared configuration, you can set the values instead.
  98714. */
  98715. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  98716. private _forceWireframe;
  98717. /**
  98718. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  98719. */
  98720. forceWireframe: boolean;
  98721. private _forcePointsCloud;
  98722. /**
  98723. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  98724. */
  98725. forcePointsCloud: boolean;
  98726. /**
  98727. * Gets or sets the active clipplane 1
  98728. */
  98729. clipPlane: Nullable<Plane>;
  98730. /**
  98731. * Gets or sets the active clipplane 2
  98732. */
  98733. clipPlane2: Nullable<Plane>;
  98734. /**
  98735. * Gets or sets the active clipplane 3
  98736. */
  98737. clipPlane3: Nullable<Plane>;
  98738. /**
  98739. * Gets or sets the active clipplane 4
  98740. */
  98741. clipPlane4: Nullable<Plane>;
  98742. /**
  98743. * Gets or sets a boolean indicating if animations are enabled
  98744. */
  98745. animationsEnabled: boolean;
  98746. private _animationPropertiesOverride;
  98747. /**
  98748. * Gets or sets the animation properties override
  98749. */
  98750. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  98751. /**
  98752. * Gets or sets a boolean indicating if a constant deltatime has to be used
  98753. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  98754. */
  98755. useConstantAnimationDeltaTime: boolean;
  98756. /**
  98757. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  98758. * Please note that it requires to run a ray cast through the scene on every frame
  98759. */
  98760. constantlyUpdateMeshUnderPointer: boolean;
  98761. /**
  98762. * Defines the HTML cursor to use when hovering over interactive elements
  98763. */
  98764. hoverCursor: string;
  98765. /**
  98766. * Defines the HTML default cursor to use (empty by default)
  98767. */
  98768. defaultCursor: string;
  98769. /**
  98770. * This is used to call preventDefault() on pointer down
  98771. * in order to block unwanted artifacts like system double clicks
  98772. */
  98773. preventDefaultOnPointerDown: boolean;
  98774. /**
  98775. * This is used to call preventDefault() on pointer up
  98776. * in order to block unwanted artifacts like system double clicks
  98777. */
  98778. preventDefaultOnPointerUp: boolean;
  98779. /**
  98780. * Gets or sets user defined metadata
  98781. */
  98782. metadata: any;
  98783. /**
  98784. * For internal use only. Please do not use.
  98785. */
  98786. reservedDataStore: any;
  98787. /**
  98788. * Gets the name of the plugin used to load this scene (null by default)
  98789. */
  98790. loadingPluginName: string;
  98791. /**
  98792. * Use this array to add regular expressions used to disable offline support for specific urls
  98793. */
  98794. disableOfflineSupportExceptionRules: RegExp[];
  98795. /**
  98796. * An event triggered when the scene is disposed.
  98797. */
  98798. onDisposeObservable: Observable<Scene>;
  98799. private _onDisposeObserver;
  98800. /** Sets a function to be executed when this scene is disposed. */
  98801. onDispose: () => void;
  98802. /**
  98803. * An event triggered before rendering the scene (right after animations and physics)
  98804. */
  98805. onBeforeRenderObservable: Observable<Scene>;
  98806. private _onBeforeRenderObserver;
  98807. /** Sets a function to be executed before rendering this scene */
  98808. beforeRender: Nullable<() => void>;
  98809. /**
  98810. * An event triggered after rendering the scene
  98811. */
  98812. onAfterRenderObservable: Observable<Scene>;
  98813. /**
  98814. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  98815. */
  98816. onAfterRenderCameraObservable: Observable<Camera>;
  98817. private _onAfterRenderObserver;
  98818. /** Sets a function to be executed after rendering this scene */
  98819. afterRender: Nullable<() => void>;
  98820. /**
  98821. * An event triggered before animating the scene
  98822. */
  98823. onBeforeAnimationsObservable: Observable<Scene>;
  98824. /**
  98825. * An event triggered after animations processing
  98826. */
  98827. onAfterAnimationsObservable: Observable<Scene>;
  98828. /**
  98829. * An event triggered before draw calls are ready to be sent
  98830. */
  98831. onBeforeDrawPhaseObservable: Observable<Scene>;
  98832. /**
  98833. * An event triggered after draw calls have been sent
  98834. */
  98835. onAfterDrawPhaseObservable: Observable<Scene>;
  98836. /**
  98837. * An event triggered when the scene is ready
  98838. */
  98839. onReadyObservable: Observable<Scene>;
  98840. /**
  98841. * An event triggered before rendering a camera
  98842. */
  98843. onBeforeCameraRenderObservable: Observable<Camera>;
  98844. private _onBeforeCameraRenderObserver;
  98845. /** Sets a function to be executed before rendering a camera*/
  98846. beforeCameraRender: () => void;
  98847. /**
  98848. * An event triggered after rendering a camera
  98849. */
  98850. onAfterCameraRenderObservable: Observable<Camera>;
  98851. private _onAfterCameraRenderObserver;
  98852. /** Sets a function to be executed after rendering a camera*/
  98853. afterCameraRender: () => void;
  98854. /**
  98855. * An event triggered when active meshes evaluation is about to start
  98856. */
  98857. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  98858. /**
  98859. * An event triggered when active meshes evaluation is done
  98860. */
  98861. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  98862. /**
  98863. * An event triggered when particles rendering is about to start
  98864. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  98865. */
  98866. onBeforeParticlesRenderingObservable: Observable<Scene>;
  98867. /**
  98868. * An event triggered when particles rendering is done
  98869. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  98870. */
  98871. onAfterParticlesRenderingObservable: Observable<Scene>;
  98872. /**
  98873. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  98874. */
  98875. onDataLoadedObservable: Observable<Scene>;
  98876. /**
  98877. * An event triggered when a camera is created
  98878. */
  98879. onNewCameraAddedObservable: Observable<Camera>;
  98880. /**
  98881. * An event triggered when a camera is removed
  98882. */
  98883. onCameraRemovedObservable: Observable<Camera>;
  98884. /**
  98885. * An event triggered when a light is created
  98886. */
  98887. onNewLightAddedObservable: Observable<Light>;
  98888. /**
  98889. * An event triggered when a light is removed
  98890. */
  98891. onLightRemovedObservable: Observable<Light>;
  98892. /**
  98893. * An event triggered when a geometry is created
  98894. */
  98895. onNewGeometryAddedObservable: Observable<Geometry>;
  98896. /**
  98897. * An event triggered when a geometry is removed
  98898. */
  98899. onGeometryRemovedObservable: Observable<Geometry>;
  98900. /**
  98901. * An event triggered when a transform node is created
  98902. */
  98903. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  98904. /**
  98905. * An event triggered when a transform node is removed
  98906. */
  98907. onTransformNodeRemovedObservable: Observable<TransformNode>;
  98908. /**
  98909. * An event triggered when a mesh is created
  98910. */
  98911. onNewMeshAddedObservable: Observable<AbstractMesh>;
  98912. /**
  98913. * An event triggered when a mesh is removed
  98914. */
  98915. onMeshRemovedObservable: Observable<AbstractMesh>;
  98916. /**
  98917. * An event triggered when a skeleton is created
  98918. */
  98919. onNewSkeletonAddedObservable: Observable<Skeleton>;
  98920. /**
  98921. * An event triggered when a skeleton is removed
  98922. */
  98923. onSkeletonRemovedObservable: Observable<Skeleton>;
  98924. /**
  98925. * An event triggered when a material is created
  98926. */
  98927. onNewMaterialAddedObservable: Observable<Material>;
  98928. /**
  98929. * An event triggered when a material is removed
  98930. */
  98931. onMaterialRemovedObservable: Observable<Material>;
  98932. /**
  98933. * An event triggered when a texture is created
  98934. */
  98935. onNewTextureAddedObservable: Observable<BaseTexture>;
  98936. /**
  98937. * An event triggered when a texture is removed
  98938. */
  98939. onTextureRemovedObservable: Observable<BaseTexture>;
  98940. /**
  98941. * An event triggered when render targets are about to be rendered
  98942. * Can happen multiple times per frame.
  98943. */
  98944. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  98945. /**
  98946. * An event triggered when render targets were rendered.
  98947. * Can happen multiple times per frame.
  98948. */
  98949. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  98950. /**
  98951. * An event triggered before calculating deterministic simulation step
  98952. */
  98953. onBeforeStepObservable: Observable<Scene>;
  98954. /**
  98955. * An event triggered after calculating deterministic simulation step
  98956. */
  98957. onAfterStepObservable: Observable<Scene>;
  98958. /**
  98959. * An event triggered when the activeCamera property is updated
  98960. */
  98961. onActiveCameraChanged: Observable<Scene>;
  98962. /**
  98963. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  98964. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  98965. * 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)
  98966. */
  98967. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  98968. /**
  98969. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  98970. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  98971. * 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)
  98972. */
  98973. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  98974. /**
  98975. * This Observable will when a mesh has been imported into the scene.
  98976. */
  98977. onMeshImportedObservable: Observable<AbstractMesh>;
  98978. /**
  98979. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  98980. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  98981. */
  98982. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  98983. /** @hidden */
  98984. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  98985. /**
  98986. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  98987. */
  98988. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  98989. /**
  98990. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  98991. */
  98992. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  98993. /**
  98994. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  98995. */
  98996. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  98997. /** Callback called when a pointer move is detected */
  98998. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  98999. /** Callback called when a pointer down is detected */
  99000. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  99001. /** Callback called when a pointer up is detected */
  99002. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  99003. /** Callback called when a pointer pick is detected */
  99004. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  99005. /**
  99006. * 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).
  99007. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  99008. */
  99009. onPrePointerObservable: Observable<PointerInfoPre>;
  99010. /**
  99011. * Observable event triggered each time an input event is received from the rendering canvas
  99012. */
  99013. onPointerObservable: Observable<PointerInfo>;
  99014. /**
  99015. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  99016. */
  99017. readonly unTranslatedPointer: Vector2;
  99018. /**
  99019. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  99020. */
  99021. static DragMovementThreshold: number;
  99022. /**
  99023. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  99024. */
  99025. static LongPressDelay: number;
  99026. /**
  99027. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  99028. */
  99029. static DoubleClickDelay: number;
  99030. /** If you need to check double click without raising a single click at first click, enable this flag */
  99031. static ExclusiveDoubleClickMode: boolean;
  99032. /** @hidden */
  99033. _mirroredCameraPosition: Nullable<Vector3>;
  99034. /**
  99035. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  99036. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  99037. */
  99038. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  99039. /**
  99040. * Observable event triggered each time an keyboard event is received from the hosting window
  99041. */
  99042. onKeyboardObservable: Observable<KeyboardInfo>;
  99043. private _useRightHandedSystem;
  99044. /**
  99045. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  99046. */
  99047. useRightHandedSystem: boolean;
  99048. private _timeAccumulator;
  99049. private _currentStepId;
  99050. private _currentInternalStep;
  99051. /**
  99052. * Sets the step Id used by deterministic lock step
  99053. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99054. * @param newStepId defines the step Id
  99055. */
  99056. setStepId(newStepId: number): void;
  99057. /**
  99058. * Gets the step Id used by deterministic lock step
  99059. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99060. * @returns the step Id
  99061. */
  99062. getStepId(): number;
  99063. /**
  99064. * Gets the internal step used by deterministic lock step
  99065. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99066. * @returns the internal step
  99067. */
  99068. getInternalStep(): number;
  99069. private _fogEnabled;
  99070. /**
  99071. * Gets or sets a boolean indicating if fog is enabled on this scene
  99072. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99073. * (Default is true)
  99074. */
  99075. fogEnabled: boolean;
  99076. private _fogMode;
  99077. /**
  99078. * Gets or sets the fog mode to use
  99079. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99080. * | mode | value |
  99081. * | --- | --- |
  99082. * | FOGMODE_NONE | 0 |
  99083. * | FOGMODE_EXP | 1 |
  99084. * | FOGMODE_EXP2 | 2 |
  99085. * | FOGMODE_LINEAR | 3 |
  99086. */
  99087. fogMode: number;
  99088. /**
  99089. * Gets or sets the fog color to use
  99090. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99091. * (Default is Color3(0.2, 0.2, 0.3))
  99092. */
  99093. fogColor: Color3;
  99094. /**
  99095. * Gets or sets the fog density to use
  99096. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99097. * (Default is 0.1)
  99098. */
  99099. fogDensity: number;
  99100. /**
  99101. * Gets or sets the fog start distance to use
  99102. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99103. * (Default is 0)
  99104. */
  99105. fogStart: number;
  99106. /**
  99107. * Gets or sets the fog end distance to use
  99108. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99109. * (Default is 1000)
  99110. */
  99111. fogEnd: number;
  99112. private _shadowsEnabled;
  99113. /**
  99114. * Gets or sets a boolean indicating if shadows are enabled on this scene
  99115. */
  99116. shadowsEnabled: boolean;
  99117. private _lightsEnabled;
  99118. /**
  99119. * Gets or sets a boolean indicating if lights are enabled on this scene
  99120. */
  99121. lightsEnabled: boolean;
  99122. /** All of the active cameras added to this scene. */
  99123. activeCameras: Camera[];
  99124. /** @hidden */
  99125. _activeCamera: Nullable<Camera>;
  99126. /** Gets or sets the current active camera */
  99127. activeCamera: Nullable<Camera>;
  99128. private _defaultMaterial;
  99129. /** The default material used on meshes when no material is affected */
  99130. /** The default material used on meshes when no material is affected */
  99131. defaultMaterial: Material;
  99132. private _texturesEnabled;
  99133. /**
  99134. * Gets or sets a boolean indicating if textures are enabled on this scene
  99135. */
  99136. texturesEnabled: boolean;
  99137. /**
  99138. * Gets or sets a boolean indicating if particles are enabled on this scene
  99139. */
  99140. particlesEnabled: boolean;
  99141. /**
  99142. * Gets or sets a boolean indicating if sprites are enabled on this scene
  99143. */
  99144. spritesEnabled: boolean;
  99145. private _skeletonsEnabled;
  99146. /**
  99147. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  99148. */
  99149. skeletonsEnabled: boolean;
  99150. /**
  99151. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  99152. */
  99153. lensFlaresEnabled: boolean;
  99154. /**
  99155. * Gets or sets a boolean indicating if collisions are enabled on this scene
  99156. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  99157. */
  99158. collisionsEnabled: boolean;
  99159. private _collisionCoordinator;
  99160. /** @hidden */
  99161. readonly collisionCoordinator: ICollisionCoordinator;
  99162. /**
  99163. * Defines the gravity applied to this scene (used only for collisions)
  99164. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  99165. */
  99166. gravity: Vector3;
  99167. /**
  99168. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  99169. */
  99170. postProcessesEnabled: boolean;
  99171. /**
  99172. * The list of postprocesses added to the scene
  99173. */
  99174. postProcesses: PostProcess[];
  99175. /**
  99176. * Gets the current postprocess manager
  99177. */
  99178. postProcessManager: PostProcessManager;
  99179. /**
  99180. * Gets or sets a boolean indicating if render targets are enabled on this scene
  99181. */
  99182. renderTargetsEnabled: boolean;
  99183. /**
  99184. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  99185. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  99186. */
  99187. dumpNextRenderTargets: boolean;
  99188. /**
  99189. * The list of user defined render targets added to the scene
  99190. */
  99191. customRenderTargets: RenderTargetTexture[];
  99192. /**
  99193. * Defines if texture loading must be delayed
  99194. * If true, textures will only be loaded when they need to be rendered
  99195. */
  99196. useDelayedTextureLoading: boolean;
  99197. /**
  99198. * Gets the list of meshes imported to the scene through SceneLoader
  99199. */
  99200. importedMeshesFiles: String[];
  99201. /**
  99202. * Gets or sets a boolean indicating if probes are enabled on this scene
  99203. */
  99204. probesEnabled: boolean;
  99205. /**
  99206. * Gets or sets the current offline provider to use to store scene data
  99207. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  99208. */
  99209. offlineProvider: IOfflineProvider;
  99210. /**
  99211. * Gets or sets the action manager associated with the scene
  99212. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  99213. */
  99214. actionManager: AbstractActionManager;
  99215. private _meshesForIntersections;
  99216. /**
  99217. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  99218. */
  99219. proceduralTexturesEnabled: boolean;
  99220. private _engine;
  99221. private _totalVertices;
  99222. /** @hidden */
  99223. _activeIndices: PerfCounter;
  99224. /** @hidden */
  99225. _activeParticles: PerfCounter;
  99226. /** @hidden */
  99227. _activeBones: PerfCounter;
  99228. private _animationRatio;
  99229. /** @hidden */
  99230. _animationTimeLast: number;
  99231. /** @hidden */
  99232. _animationTime: number;
  99233. /**
  99234. * Gets or sets a general scale for animation speed
  99235. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  99236. */
  99237. animationTimeScale: number;
  99238. /** @hidden */
  99239. _cachedMaterial: Nullable<Material>;
  99240. /** @hidden */
  99241. _cachedEffect: Nullable<Effect>;
  99242. /** @hidden */
  99243. _cachedVisibility: Nullable<number>;
  99244. private _renderId;
  99245. private _frameId;
  99246. private _executeWhenReadyTimeoutId;
  99247. private _intermediateRendering;
  99248. private _viewUpdateFlag;
  99249. private _projectionUpdateFlag;
  99250. /** @hidden */
  99251. _toBeDisposed: Nullable<IDisposable>[];
  99252. private _activeRequests;
  99253. /** @hidden */
  99254. _pendingData: any[];
  99255. private _isDisposed;
  99256. /**
  99257. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  99258. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  99259. */
  99260. dispatchAllSubMeshesOfActiveMeshes: boolean;
  99261. private _activeMeshes;
  99262. private _processedMaterials;
  99263. private _renderTargets;
  99264. /** @hidden */
  99265. _activeParticleSystems: SmartArray<IParticleSystem>;
  99266. private _activeSkeletons;
  99267. private _softwareSkinnedMeshes;
  99268. private _renderingManager;
  99269. /** @hidden */
  99270. _activeAnimatables: Animatable[];
  99271. private _transformMatrix;
  99272. private _sceneUbo;
  99273. /** @hidden */
  99274. _viewMatrix: Matrix;
  99275. private _projectionMatrix;
  99276. /** @hidden */
  99277. _forcedViewPosition: Nullable<Vector3>;
  99278. /** @hidden */
  99279. _frustumPlanes: Plane[];
  99280. /**
  99281. * Gets the list of frustum planes (built from the active camera)
  99282. */
  99283. readonly frustumPlanes: Plane[];
  99284. /**
  99285. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  99286. * This is useful if there are more lights that the maximum simulteanous authorized
  99287. */
  99288. requireLightSorting: boolean;
  99289. /** @hidden */
  99290. readonly useMaterialMeshMap: boolean;
  99291. /** @hidden */
  99292. readonly useClonedMeshhMap: boolean;
  99293. private _externalData;
  99294. private _uid;
  99295. /**
  99296. * @hidden
  99297. * Backing store of defined scene components.
  99298. */
  99299. _components: ISceneComponent[];
  99300. /**
  99301. * @hidden
  99302. * Backing store of defined scene components.
  99303. */
  99304. _serializableComponents: ISceneSerializableComponent[];
  99305. /**
  99306. * List of components to register on the next registration step.
  99307. */
  99308. private _transientComponents;
  99309. /**
  99310. * Registers the transient components if needed.
  99311. */
  99312. private _registerTransientComponents;
  99313. /**
  99314. * @hidden
  99315. * Add a component to the scene.
  99316. * Note that the ccomponent could be registered on th next frame if this is called after
  99317. * the register component stage.
  99318. * @param component Defines the component to add to the scene
  99319. */
  99320. _addComponent(component: ISceneComponent): void;
  99321. /**
  99322. * @hidden
  99323. * Gets a component from the scene.
  99324. * @param name defines the name of the component to retrieve
  99325. * @returns the component or null if not present
  99326. */
  99327. _getComponent(name: string): Nullable<ISceneComponent>;
  99328. /**
  99329. * @hidden
  99330. * Defines the actions happening before camera updates.
  99331. */
  99332. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  99333. /**
  99334. * @hidden
  99335. * Defines the actions happening before clear the canvas.
  99336. */
  99337. _beforeClearStage: Stage<SimpleStageAction>;
  99338. /**
  99339. * @hidden
  99340. * Defines the actions when collecting render targets for the frame.
  99341. */
  99342. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  99343. /**
  99344. * @hidden
  99345. * Defines the actions happening for one camera in the frame.
  99346. */
  99347. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  99348. /**
  99349. * @hidden
  99350. * Defines the actions happening during the per mesh ready checks.
  99351. */
  99352. _isReadyForMeshStage: Stage<MeshStageAction>;
  99353. /**
  99354. * @hidden
  99355. * Defines the actions happening before evaluate active mesh checks.
  99356. */
  99357. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  99358. /**
  99359. * @hidden
  99360. * Defines the actions happening during the evaluate sub mesh checks.
  99361. */
  99362. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  99363. /**
  99364. * @hidden
  99365. * Defines the actions happening during the active mesh stage.
  99366. */
  99367. _activeMeshStage: Stage<ActiveMeshStageAction>;
  99368. /**
  99369. * @hidden
  99370. * Defines the actions happening during the per camera render target step.
  99371. */
  99372. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  99373. /**
  99374. * @hidden
  99375. * Defines the actions happening just before the active camera is drawing.
  99376. */
  99377. _beforeCameraDrawStage: Stage<CameraStageAction>;
  99378. /**
  99379. * @hidden
  99380. * Defines the actions happening just before a render target is drawing.
  99381. */
  99382. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  99383. /**
  99384. * @hidden
  99385. * Defines the actions happening just before a rendering group is drawing.
  99386. */
  99387. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  99388. /**
  99389. * @hidden
  99390. * Defines the actions happening just before a mesh is drawing.
  99391. */
  99392. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  99393. /**
  99394. * @hidden
  99395. * Defines the actions happening just after a mesh has been drawn.
  99396. */
  99397. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  99398. /**
  99399. * @hidden
  99400. * Defines the actions happening just after a rendering group has been drawn.
  99401. */
  99402. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  99403. /**
  99404. * @hidden
  99405. * Defines the actions happening just after the active camera has been drawn.
  99406. */
  99407. _afterCameraDrawStage: Stage<CameraStageAction>;
  99408. /**
  99409. * @hidden
  99410. * Defines the actions happening just after a render target has been drawn.
  99411. */
  99412. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  99413. /**
  99414. * @hidden
  99415. * Defines the actions happening just after rendering all cameras and computing intersections.
  99416. */
  99417. _afterRenderStage: Stage<SimpleStageAction>;
  99418. /**
  99419. * @hidden
  99420. * Defines the actions happening when a pointer move event happens.
  99421. */
  99422. _pointerMoveStage: Stage<PointerMoveStageAction>;
  99423. /**
  99424. * @hidden
  99425. * Defines the actions happening when a pointer down event happens.
  99426. */
  99427. _pointerDownStage: Stage<PointerUpDownStageAction>;
  99428. /**
  99429. * @hidden
  99430. * Defines the actions happening when a pointer up event happens.
  99431. */
  99432. _pointerUpStage: Stage<PointerUpDownStageAction>;
  99433. /**
  99434. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  99435. */
  99436. private geometriesByUniqueId;
  99437. /**
  99438. * Creates a new Scene
  99439. * @param engine defines the engine to use to render this scene
  99440. * @param options defines the scene options
  99441. */
  99442. constructor(engine: Engine, options?: SceneOptions);
  99443. /**
  99444. * Gets a string idenfifying the name of the class
  99445. * @returns "Scene" string
  99446. */
  99447. getClassName(): string;
  99448. private _defaultMeshCandidates;
  99449. /**
  99450. * @hidden
  99451. */
  99452. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  99453. private _defaultSubMeshCandidates;
  99454. /**
  99455. * @hidden
  99456. */
  99457. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  99458. /**
  99459. * Sets the default candidate providers for the scene.
  99460. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  99461. * and getCollidingSubMeshCandidates to their default function
  99462. */
  99463. setDefaultCandidateProviders(): void;
  99464. /**
  99465. * Gets the mesh that is currently under the pointer
  99466. */
  99467. readonly meshUnderPointer: Nullable<AbstractMesh>;
  99468. /**
  99469. * Gets or sets the current on-screen X position of the pointer
  99470. */
  99471. pointerX: number;
  99472. /**
  99473. * Gets or sets the current on-screen Y position of the pointer
  99474. */
  99475. pointerY: number;
  99476. /**
  99477. * Gets the cached material (ie. the latest rendered one)
  99478. * @returns the cached material
  99479. */
  99480. getCachedMaterial(): Nullable<Material>;
  99481. /**
  99482. * Gets the cached effect (ie. the latest rendered one)
  99483. * @returns the cached effect
  99484. */
  99485. getCachedEffect(): Nullable<Effect>;
  99486. /**
  99487. * Gets the cached visibility state (ie. the latest rendered one)
  99488. * @returns the cached visibility state
  99489. */
  99490. getCachedVisibility(): Nullable<number>;
  99491. /**
  99492. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  99493. * @param material defines the current material
  99494. * @param effect defines the current effect
  99495. * @param visibility defines the current visibility state
  99496. * @returns true if one parameter is not cached
  99497. */
  99498. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  99499. /**
  99500. * Gets the engine associated with the scene
  99501. * @returns an Engine
  99502. */
  99503. getEngine(): Engine;
  99504. /**
  99505. * Gets the total number of vertices rendered per frame
  99506. * @returns the total number of vertices rendered per frame
  99507. */
  99508. getTotalVertices(): number;
  99509. /**
  99510. * Gets the performance counter for total vertices
  99511. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99512. */
  99513. readonly totalVerticesPerfCounter: PerfCounter;
  99514. /**
  99515. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  99516. * @returns the total number of active indices rendered per frame
  99517. */
  99518. getActiveIndices(): number;
  99519. /**
  99520. * Gets the performance counter for active indices
  99521. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99522. */
  99523. readonly totalActiveIndicesPerfCounter: PerfCounter;
  99524. /**
  99525. * Gets the total number of active particles rendered per frame
  99526. * @returns the total number of active particles rendered per frame
  99527. */
  99528. getActiveParticles(): number;
  99529. /**
  99530. * Gets the performance counter for active particles
  99531. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99532. */
  99533. readonly activeParticlesPerfCounter: PerfCounter;
  99534. /**
  99535. * Gets the total number of active bones rendered per frame
  99536. * @returns the total number of active bones rendered per frame
  99537. */
  99538. getActiveBones(): number;
  99539. /**
  99540. * Gets the performance counter for active bones
  99541. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99542. */
  99543. readonly activeBonesPerfCounter: PerfCounter;
  99544. /**
  99545. * Gets the array of active meshes
  99546. * @returns an array of AbstractMesh
  99547. */
  99548. getActiveMeshes(): SmartArray<AbstractMesh>;
  99549. /**
  99550. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  99551. * @returns a number
  99552. */
  99553. getAnimationRatio(): number;
  99554. /**
  99555. * Gets an unique Id for the current render phase
  99556. * @returns a number
  99557. */
  99558. getRenderId(): number;
  99559. /**
  99560. * Gets an unique Id for the current frame
  99561. * @returns a number
  99562. */
  99563. getFrameId(): number;
  99564. /** Call this function if you want to manually increment the render Id*/
  99565. incrementRenderId(): void;
  99566. private _createUbo;
  99567. /**
  99568. * Use this method to simulate a pointer move on a mesh
  99569. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99570. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99571. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99572. * @returns the current scene
  99573. */
  99574. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  99575. /**
  99576. * Use this method to simulate a pointer down on a mesh
  99577. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99578. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99579. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99580. * @returns the current scene
  99581. */
  99582. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  99583. /**
  99584. * Use this method to simulate a pointer up on a mesh
  99585. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99586. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99587. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99588. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  99589. * @returns the current scene
  99590. */
  99591. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  99592. /**
  99593. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  99594. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  99595. * @returns true if the pointer was captured
  99596. */
  99597. isPointerCaptured(pointerId?: number): boolean;
  99598. /**
  99599. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  99600. * @param attachUp defines if you want to attach events to pointerup
  99601. * @param attachDown defines if you want to attach events to pointerdown
  99602. * @param attachMove defines if you want to attach events to pointermove
  99603. */
  99604. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  99605. /** Detaches all event handlers*/
  99606. detachControl(): void;
  99607. /**
  99608. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  99609. * Delay loaded resources are not taking in account
  99610. * @return true if all required resources are ready
  99611. */
  99612. isReady(): boolean;
  99613. /** Resets all cached information relative to material (including effect and visibility) */
  99614. resetCachedMaterial(): void;
  99615. /**
  99616. * Registers a function to be called before every frame render
  99617. * @param func defines the function to register
  99618. */
  99619. registerBeforeRender(func: () => void): void;
  99620. /**
  99621. * Unregisters a function called before every frame render
  99622. * @param func defines the function to unregister
  99623. */
  99624. unregisterBeforeRender(func: () => void): void;
  99625. /**
  99626. * Registers a function to be called after every frame render
  99627. * @param func defines the function to register
  99628. */
  99629. registerAfterRender(func: () => void): void;
  99630. /**
  99631. * Unregisters a function called after every frame render
  99632. * @param func defines the function to unregister
  99633. */
  99634. unregisterAfterRender(func: () => void): void;
  99635. private _executeOnceBeforeRender;
  99636. /**
  99637. * The provided function will run before render once and will be disposed afterwards.
  99638. * A timeout delay can be provided so that the function will be executed in N ms.
  99639. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  99640. * @param func The function to be executed.
  99641. * @param timeout optional delay in ms
  99642. */
  99643. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  99644. /** @hidden */
  99645. _addPendingData(data: any): void;
  99646. /** @hidden */
  99647. _removePendingData(data: any): void;
  99648. /**
  99649. * Returns the number of items waiting to be loaded
  99650. * @returns the number of items waiting to be loaded
  99651. */
  99652. getWaitingItemsCount(): number;
  99653. /**
  99654. * Returns a boolean indicating if the scene is still loading data
  99655. */
  99656. readonly isLoading: boolean;
  99657. /**
  99658. * Registers a function to be executed when the scene is ready
  99659. * @param {Function} func - the function to be executed
  99660. */
  99661. executeWhenReady(func: () => void): void;
  99662. /**
  99663. * Returns a promise that resolves when the scene is ready
  99664. * @returns A promise that resolves when the scene is ready
  99665. */
  99666. whenReadyAsync(): Promise<void>;
  99667. /** @hidden */
  99668. _checkIsReady(): void;
  99669. /**
  99670. * Gets all animatable attached to the scene
  99671. */
  99672. readonly animatables: Animatable[];
  99673. /**
  99674. * Resets the last animation time frame.
  99675. * Useful to override when animations start running when loading a scene for the first time.
  99676. */
  99677. resetLastAnimationTimeFrame(): void;
  99678. /**
  99679. * Gets the current view matrix
  99680. * @returns a Matrix
  99681. */
  99682. getViewMatrix(): Matrix;
  99683. /**
  99684. * Gets the current projection matrix
  99685. * @returns a Matrix
  99686. */
  99687. getProjectionMatrix(): Matrix;
  99688. /**
  99689. * Gets the current transform matrix
  99690. * @returns a Matrix made of View * Projection
  99691. */
  99692. getTransformMatrix(): Matrix;
  99693. /**
  99694. * Sets the current transform matrix
  99695. * @param viewL defines the View matrix to use
  99696. * @param projectionL defines the Projection matrix to use
  99697. * @param viewR defines the right View matrix to use (if provided)
  99698. * @param projectionR defines the right Projection matrix to use (if provided)
  99699. */
  99700. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  99701. /**
  99702. * Gets the uniform buffer used to store scene data
  99703. * @returns a UniformBuffer
  99704. */
  99705. getSceneUniformBuffer(): UniformBuffer;
  99706. /**
  99707. * Gets an unique (relatively to the current scene) Id
  99708. * @returns an unique number for the scene
  99709. */
  99710. getUniqueId(): number;
  99711. /**
  99712. * Add a mesh to the list of scene's meshes
  99713. * @param newMesh defines the mesh to add
  99714. * @param recursive if all child meshes should also be added to the scene
  99715. */
  99716. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  99717. /**
  99718. * Remove a mesh for the list of scene's meshes
  99719. * @param toRemove defines the mesh to remove
  99720. * @param recursive if all child meshes should also be removed from the scene
  99721. * @returns the index where the mesh was in the mesh list
  99722. */
  99723. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  99724. /**
  99725. * Add a transform node to the list of scene's transform nodes
  99726. * @param newTransformNode defines the transform node to add
  99727. */
  99728. addTransformNode(newTransformNode: TransformNode): void;
  99729. /**
  99730. * Remove a transform node for the list of scene's transform nodes
  99731. * @param toRemove defines the transform node to remove
  99732. * @returns the index where the transform node was in the transform node list
  99733. */
  99734. removeTransformNode(toRemove: TransformNode): number;
  99735. /**
  99736. * Remove a skeleton for the list of scene's skeletons
  99737. * @param toRemove defines the skeleton to remove
  99738. * @returns the index where the skeleton was in the skeleton list
  99739. */
  99740. removeSkeleton(toRemove: Skeleton): number;
  99741. /**
  99742. * Remove a morph target for the list of scene's morph targets
  99743. * @param toRemove defines the morph target to remove
  99744. * @returns the index where the morph target was in the morph target list
  99745. */
  99746. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  99747. /**
  99748. * Remove a light for the list of scene's lights
  99749. * @param toRemove defines the light to remove
  99750. * @returns the index where the light was in the light list
  99751. */
  99752. removeLight(toRemove: Light): number;
  99753. /**
  99754. * Remove a camera for the list of scene's cameras
  99755. * @param toRemove defines the camera to remove
  99756. * @returns the index where the camera was in the camera list
  99757. */
  99758. removeCamera(toRemove: Camera): number;
  99759. /**
  99760. * Remove a particle system for the list of scene's particle systems
  99761. * @param toRemove defines the particle system to remove
  99762. * @returns the index where the particle system was in the particle system list
  99763. */
  99764. removeParticleSystem(toRemove: IParticleSystem): number;
  99765. /**
  99766. * Remove a animation for the list of scene's animations
  99767. * @param toRemove defines the animation to remove
  99768. * @returns the index where the animation was in the animation list
  99769. */
  99770. removeAnimation(toRemove: Animation): number;
  99771. /**
  99772. * Will stop the animation of the given target
  99773. * @param target - the target
  99774. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  99775. * @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)
  99776. */
  99777. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  99778. /**
  99779. * Removes the given animation group from this scene.
  99780. * @param toRemove The animation group to remove
  99781. * @returns The index of the removed animation group
  99782. */
  99783. removeAnimationGroup(toRemove: AnimationGroup): number;
  99784. /**
  99785. * Removes the given multi-material from this scene.
  99786. * @param toRemove The multi-material to remove
  99787. * @returns The index of the removed multi-material
  99788. */
  99789. removeMultiMaterial(toRemove: MultiMaterial): number;
  99790. /**
  99791. * Removes the given material from this scene.
  99792. * @param toRemove The material to remove
  99793. * @returns The index of the removed material
  99794. */
  99795. removeMaterial(toRemove: Material): number;
  99796. /**
  99797. * Removes the given action manager from this scene.
  99798. * @param toRemove The action manager to remove
  99799. * @returns The index of the removed action manager
  99800. */
  99801. removeActionManager(toRemove: AbstractActionManager): number;
  99802. /**
  99803. * Removes the given texture from this scene.
  99804. * @param toRemove The texture to remove
  99805. * @returns The index of the removed texture
  99806. */
  99807. removeTexture(toRemove: BaseTexture): number;
  99808. /**
  99809. * Adds the given light to this scene
  99810. * @param newLight The light to add
  99811. */
  99812. addLight(newLight: Light): void;
  99813. /**
  99814. * Sorts the list list based on light priorities
  99815. */
  99816. sortLightsByPriority(): void;
  99817. /**
  99818. * Adds the given camera to this scene
  99819. * @param newCamera The camera to add
  99820. */
  99821. addCamera(newCamera: Camera): void;
  99822. /**
  99823. * Adds the given skeleton to this scene
  99824. * @param newSkeleton The skeleton to add
  99825. */
  99826. addSkeleton(newSkeleton: Skeleton): void;
  99827. /**
  99828. * Adds the given particle system to this scene
  99829. * @param newParticleSystem The particle system to add
  99830. */
  99831. addParticleSystem(newParticleSystem: IParticleSystem): void;
  99832. /**
  99833. * Adds the given animation to this scene
  99834. * @param newAnimation The animation to add
  99835. */
  99836. addAnimation(newAnimation: Animation): void;
  99837. /**
  99838. * Adds the given animation group to this scene.
  99839. * @param newAnimationGroup The animation group to add
  99840. */
  99841. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  99842. /**
  99843. * Adds the given multi-material to this scene
  99844. * @param newMultiMaterial The multi-material to add
  99845. */
  99846. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  99847. /**
  99848. * Adds the given material to this scene
  99849. * @param newMaterial The material to add
  99850. */
  99851. addMaterial(newMaterial: Material): void;
  99852. /**
  99853. * Adds the given morph target to this scene
  99854. * @param newMorphTargetManager The morph target to add
  99855. */
  99856. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  99857. /**
  99858. * Adds the given geometry to this scene
  99859. * @param newGeometry The geometry to add
  99860. */
  99861. addGeometry(newGeometry: Geometry): void;
  99862. /**
  99863. * Adds the given action manager to this scene
  99864. * @param newActionManager The action manager to add
  99865. */
  99866. addActionManager(newActionManager: AbstractActionManager): void;
  99867. /**
  99868. * Adds the given texture to this scene.
  99869. * @param newTexture The texture to add
  99870. */
  99871. addTexture(newTexture: BaseTexture): void;
  99872. /**
  99873. * Switch active camera
  99874. * @param newCamera defines the new active camera
  99875. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  99876. */
  99877. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  99878. /**
  99879. * sets the active camera of the scene using its ID
  99880. * @param id defines the camera's ID
  99881. * @return the new active camera or null if none found.
  99882. */
  99883. setActiveCameraByID(id: string): Nullable<Camera>;
  99884. /**
  99885. * sets the active camera of the scene using its name
  99886. * @param name defines the camera's name
  99887. * @returns the new active camera or null if none found.
  99888. */
  99889. setActiveCameraByName(name: string): Nullable<Camera>;
  99890. /**
  99891. * get an animation group using its name
  99892. * @param name defines the material's name
  99893. * @return the animation group or null if none found.
  99894. */
  99895. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  99896. /**
  99897. * Get a material using its unique id
  99898. * @param uniqueId defines the material's unique id
  99899. * @return the material or null if none found.
  99900. */
  99901. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  99902. /**
  99903. * get a material using its id
  99904. * @param id defines the material's ID
  99905. * @return the material or null if none found.
  99906. */
  99907. getMaterialByID(id: string): Nullable<Material>;
  99908. /**
  99909. * Gets a the last added material using a given id
  99910. * @param id defines the material's ID
  99911. * @return the last material with the given id or null if none found.
  99912. */
  99913. getLastMaterialByID(id: string): Nullable<Material>;
  99914. /**
  99915. * Gets a material using its name
  99916. * @param name defines the material's name
  99917. * @return the material or null if none found.
  99918. */
  99919. getMaterialByName(name: string): Nullable<Material>;
  99920. /**
  99921. * Get a texture using its unique id
  99922. * @param uniqueId defines the texture's unique id
  99923. * @return the texture or null if none found.
  99924. */
  99925. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  99926. /**
  99927. * Gets a camera using its id
  99928. * @param id defines the id to look for
  99929. * @returns the camera or null if not found
  99930. */
  99931. getCameraByID(id: string): Nullable<Camera>;
  99932. /**
  99933. * Gets a camera using its unique id
  99934. * @param uniqueId defines the unique id to look for
  99935. * @returns the camera or null if not found
  99936. */
  99937. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  99938. /**
  99939. * Gets a camera using its name
  99940. * @param name defines the camera's name
  99941. * @return the camera or null if none found.
  99942. */
  99943. getCameraByName(name: string): Nullable<Camera>;
  99944. /**
  99945. * Gets a bone using its id
  99946. * @param id defines the bone's id
  99947. * @return the bone or null if not found
  99948. */
  99949. getBoneByID(id: string): Nullable<Bone>;
  99950. /**
  99951. * Gets a bone using its id
  99952. * @param name defines the bone's name
  99953. * @return the bone or null if not found
  99954. */
  99955. getBoneByName(name: string): Nullable<Bone>;
  99956. /**
  99957. * Gets a light node using its name
  99958. * @param name defines the the light's name
  99959. * @return the light or null if none found.
  99960. */
  99961. getLightByName(name: string): Nullable<Light>;
  99962. /**
  99963. * Gets a light node using its id
  99964. * @param id defines the light's id
  99965. * @return the light or null if none found.
  99966. */
  99967. getLightByID(id: string): Nullable<Light>;
  99968. /**
  99969. * Gets a light node using its scene-generated unique ID
  99970. * @param uniqueId defines the light's unique id
  99971. * @return the light or null if none found.
  99972. */
  99973. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  99974. /**
  99975. * Gets a particle system by id
  99976. * @param id defines the particle system id
  99977. * @return the corresponding system or null if none found
  99978. */
  99979. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  99980. /**
  99981. * Gets a geometry using its ID
  99982. * @param id defines the geometry's id
  99983. * @return the geometry or null if none found.
  99984. */
  99985. getGeometryByID(id: string): Nullable<Geometry>;
  99986. private _getGeometryByUniqueID;
  99987. /**
  99988. * Add a new geometry to this scene
  99989. * @param geometry defines the geometry to be added to the scene.
  99990. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  99991. * @return a boolean defining if the geometry was added or not
  99992. */
  99993. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  99994. /**
  99995. * Removes an existing geometry
  99996. * @param geometry defines the geometry to be removed from the scene
  99997. * @return a boolean defining if the geometry was removed or not
  99998. */
  99999. removeGeometry(geometry: Geometry): boolean;
  100000. /**
  100001. * Gets the list of geometries attached to the scene
  100002. * @returns an array of Geometry
  100003. */
  100004. getGeometries(): Geometry[];
  100005. /**
  100006. * Gets the first added mesh found of a given ID
  100007. * @param id defines the id to search for
  100008. * @return the mesh found or null if not found at all
  100009. */
  100010. getMeshByID(id: string): Nullable<AbstractMesh>;
  100011. /**
  100012. * Gets a list of meshes using their id
  100013. * @param id defines the id to search for
  100014. * @returns a list of meshes
  100015. */
  100016. getMeshesByID(id: string): Array<AbstractMesh>;
  100017. /**
  100018. * Gets the first added transform node found of a given ID
  100019. * @param id defines the id to search for
  100020. * @return the found transform node or null if not found at all.
  100021. */
  100022. getTransformNodeByID(id: string): Nullable<TransformNode>;
  100023. /**
  100024. * Gets a transform node with its auto-generated unique id
  100025. * @param uniqueId efines the unique id to search for
  100026. * @return the found transform node or null if not found at all.
  100027. */
  100028. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  100029. /**
  100030. * Gets a list of transform nodes using their id
  100031. * @param id defines the id to search for
  100032. * @returns a list of transform nodes
  100033. */
  100034. getTransformNodesByID(id: string): Array<TransformNode>;
  100035. /**
  100036. * Gets a mesh with its auto-generated unique id
  100037. * @param uniqueId defines the unique id to search for
  100038. * @return the found mesh or null if not found at all.
  100039. */
  100040. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  100041. /**
  100042. * Gets a the last added mesh using a given id
  100043. * @param id defines the id to search for
  100044. * @return the found mesh or null if not found at all.
  100045. */
  100046. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  100047. /**
  100048. * Gets a the last added node (Mesh, Camera, Light) using a given id
  100049. * @param id defines the id to search for
  100050. * @return the found node or null if not found at all
  100051. */
  100052. getLastEntryByID(id: string): Nullable<Node>;
  100053. /**
  100054. * Gets a node (Mesh, Camera, Light) using a given id
  100055. * @param id defines the id to search for
  100056. * @return the found node or null if not found at all
  100057. */
  100058. getNodeByID(id: string): Nullable<Node>;
  100059. /**
  100060. * Gets a node (Mesh, Camera, Light) using a given name
  100061. * @param name defines the name to search for
  100062. * @return the found node or null if not found at all.
  100063. */
  100064. getNodeByName(name: string): Nullable<Node>;
  100065. /**
  100066. * Gets a mesh using a given name
  100067. * @param name defines the name to search for
  100068. * @return the found mesh or null if not found at all.
  100069. */
  100070. getMeshByName(name: string): Nullable<AbstractMesh>;
  100071. /**
  100072. * Gets a transform node using a given name
  100073. * @param name defines the name to search for
  100074. * @return the found transform node or null if not found at all.
  100075. */
  100076. getTransformNodeByName(name: string): Nullable<TransformNode>;
  100077. /**
  100078. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  100079. * @param id defines the id to search for
  100080. * @return the found skeleton or null if not found at all.
  100081. */
  100082. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  100083. /**
  100084. * Gets a skeleton using a given auto generated unique id
  100085. * @param uniqueId defines the unique id to search for
  100086. * @return the found skeleton or null if not found at all.
  100087. */
  100088. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  100089. /**
  100090. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  100091. * @param id defines the id to search for
  100092. * @return the found skeleton or null if not found at all.
  100093. */
  100094. getSkeletonById(id: string): Nullable<Skeleton>;
  100095. /**
  100096. * Gets a skeleton using a given name
  100097. * @param name defines the name to search for
  100098. * @return the found skeleton or null if not found at all.
  100099. */
  100100. getSkeletonByName(name: string): Nullable<Skeleton>;
  100101. /**
  100102. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  100103. * @param id defines the id to search for
  100104. * @return the found morph target manager or null if not found at all.
  100105. */
  100106. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  100107. /**
  100108. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  100109. * @param id defines the id to search for
  100110. * @return the found morph target or null if not found at all.
  100111. */
  100112. getMorphTargetById(id: string): Nullable<MorphTarget>;
  100113. /**
  100114. * Gets a boolean indicating if the given mesh is active
  100115. * @param mesh defines the mesh to look for
  100116. * @returns true if the mesh is in the active list
  100117. */
  100118. isActiveMesh(mesh: AbstractMesh): boolean;
  100119. /**
  100120. * Return a unique id as a string which can serve as an identifier for the scene
  100121. */
  100122. readonly uid: string;
  100123. /**
  100124. * Add an externaly attached data from its key.
  100125. * This method call will fail and return false, if such key already exists.
  100126. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  100127. * @param key the unique key that identifies the data
  100128. * @param data the data object to associate to the key for this Engine instance
  100129. * @return true if no such key were already present and the data was added successfully, false otherwise
  100130. */
  100131. addExternalData<T>(key: string, data: T): boolean;
  100132. /**
  100133. * Get an externaly attached data from its key
  100134. * @param key the unique key that identifies the data
  100135. * @return the associated data, if present (can be null), or undefined if not present
  100136. */
  100137. getExternalData<T>(key: string): Nullable<T>;
  100138. /**
  100139. * Get an externaly attached data from its key, create it using a factory if it's not already present
  100140. * @param key the unique key that identifies the data
  100141. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  100142. * @return the associated data, can be null if the factory returned null.
  100143. */
  100144. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  100145. /**
  100146. * Remove an externaly attached data from the Engine instance
  100147. * @param key the unique key that identifies the data
  100148. * @return true if the data was successfully removed, false if it doesn't exist
  100149. */
  100150. removeExternalData(key: string): boolean;
  100151. private _evaluateSubMesh;
  100152. /**
  100153. * Clear the processed materials smart array preventing retention point in material dispose.
  100154. */
  100155. freeProcessedMaterials(): void;
  100156. private _preventFreeActiveMeshesAndRenderingGroups;
  100157. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  100158. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  100159. * when disposing several meshes in a row or a hierarchy of meshes.
  100160. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  100161. */
  100162. blockfreeActiveMeshesAndRenderingGroups: boolean;
  100163. /**
  100164. * Clear the active meshes smart array preventing retention point in mesh dispose.
  100165. */
  100166. freeActiveMeshes(): void;
  100167. /**
  100168. * Clear the info related to rendering groups preventing retention points during dispose.
  100169. */
  100170. freeRenderingGroups(): void;
  100171. /** @hidden */
  100172. _isInIntermediateRendering(): boolean;
  100173. /**
  100174. * Lambda returning the list of potentially active meshes.
  100175. */
  100176. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  100177. /**
  100178. * Lambda returning the list of potentially active sub meshes.
  100179. */
  100180. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  100181. /**
  100182. * Lambda returning the list of potentially intersecting sub meshes.
  100183. */
  100184. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  100185. /**
  100186. * Lambda returning the list of potentially colliding sub meshes.
  100187. */
  100188. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  100189. private _activeMeshesFrozen;
  100190. /**
  100191. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  100192. * @returns the current scene
  100193. */
  100194. freezeActiveMeshes(): Scene;
  100195. /**
  100196. * Use this function to restart evaluating active meshes on every frame
  100197. * @returns the current scene
  100198. */
  100199. unfreezeActiveMeshes(): Scene;
  100200. private _evaluateActiveMeshes;
  100201. private _activeMesh;
  100202. /**
  100203. * Update the transform matrix to update from the current active camera
  100204. * @param force defines a boolean used to force the update even if cache is up to date
  100205. */
  100206. updateTransformMatrix(force?: boolean): void;
  100207. private _bindFrameBuffer;
  100208. /** @hidden */
  100209. _allowPostProcessClearColor: boolean;
  100210. /** @hidden */
  100211. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  100212. private _processSubCameras;
  100213. private _checkIntersections;
  100214. /** @hidden */
  100215. _advancePhysicsEngineStep(step: number): void;
  100216. /**
  100217. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  100218. */
  100219. getDeterministicFrameTime: () => number;
  100220. /** @hidden */
  100221. _animate(): void;
  100222. /** Execute all animations (for a frame) */
  100223. animate(): void;
  100224. /**
  100225. * Render the scene
  100226. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  100227. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  100228. */
  100229. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  100230. /**
  100231. * Freeze all materials
  100232. * A frozen material will not be updatable but should be faster to render
  100233. */
  100234. freezeMaterials(): void;
  100235. /**
  100236. * Unfreeze all materials
  100237. * A frozen material will not be updatable but should be faster to render
  100238. */
  100239. unfreezeMaterials(): void;
  100240. /**
  100241. * Releases all held ressources
  100242. */
  100243. dispose(): void;
  100244. /**
  100245. * Gets if the scene is already disposed
  100246. */
  100247. readonly isDisposed: boolean;
  100248. /**
  100249. * Call this function to reduce memory footprint of the scene.
  100250. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  100251. */
  100252. clearCachedVertexData(): void;
  100253. /**
  100254. * This function will remove the local cached buffer data from texture.
  100255. * It will save memory but will prevent the texture from being rebuilt
  100256. */
  100257. cleanCachedTextureBuffer(): void;
  100258. /**
  100259. * Get the world extend vectors with an optional filter
  100260. *
  100261. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  100262. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  100263. */
  100264. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  100265. min: Vector3;
  100266. max: Vector3;
  100267. };
  100268. /**
  100269. * Creates a ray that can be used to pick in the scene
  100270. * @param x defines the x coordinate of the origin (on-screen)
  100271. * @param y defines the y coordinate of the origin (on-screen)
  100272. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  100273. * @param camera defines the camera to use for the picking
  100274. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  100275. * @returns a Ray
  100276. */
  100277. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  100278. /**
  100279. * Creates a ray that can be used to pick in the scene
  100280. * @param x defines the x coordinate of the origin (on-screen)
  100281. * @param y defines the y coordinate of the origin (on-screen)
  100282. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  100283. * @param result defines the ray where to store the picking ray
  100284. * @param camera defines the camera to use for the picking
  100285. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  100286. * @returns the current scene
  100287. */
  100288. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  100289. /**
  100290. * Creates a ray that can be used to pick in the scene
  100291. * @param x defines the x coordinate of the origin (on-screen)
  100292. * @param y defines the y coordinate of the origin (on-screen)
  100293. * @param camera defines the camera to use for the picking
  100294. * @returns a Ray
  100295. */
  100296. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  100297. /**
  100298. * Creates a ray that can be used to pick in the scene
  100299. * @param x defines the x coordinate of the origin (on-screen)
  100300. * @param y defines the y coordinate of the origin (on-screen)
  100301. * @param result defines the ray where to store the picking ray
  100302. * @param camera defines the camera to use for the picking
  100303. * @returns the current scene
  100304. */
  100305. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  100306. /** Launch a ray to try to pick a mesh in the scene
  100307. * @param x position on screen
  100308. * @param y position on screen
  100309. * @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
  100310. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  100311. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  100312. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  100313. * @returns a PickingInfo
  100314. */
  100315. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  100316. /** Use the given ray to pick a mesh in the scene
  100317. * @param ray The ray to use to pick meshes
  100318. * @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
  100319. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  100320. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  100321. * @returns a PickingInfo
  100322. */
  100323. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  100324. /**
  100325. * Launch a ray to try to pick a mesh in the scene
  100326. * @param x X position on screen
  100327. * @param y Y position on screen
  100328. * @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
  100329. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  100330. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  100331. * @returns an array of PickingInfo
  100332. */
  100333. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  100334. /**
  100335. * Launch a ray to try to pick a mesh in the scene
  100336. * @param ray Ray to use
  100337. * @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
  100338. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  100339. * @returns an array of PickingInfo
  100340. */
  100341. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  100342. /**
  100343. * Force the value of meshUnderPointer
  100344. * @param mesh defines the mesh to use
  100345. */
  100346. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  100347. /**
  100348. * Gets the mesh under the pointer
  100349. * @returns a Mesh or null if no mesh is under the pointer
  100350. */
  100351. getPointerOverMesh(): Nullable<AbstractMesh>;
  100352. /** @hidden */
  100353. _rebuildGeometries(): void;
  100354. /** @hidden */
  100355. _rebuildTextures(): void;
  100356. private _getByTags;
  100357. /**
  100358. * Get a list of meshes by tags
  100359. * @param tagsQuery defines the tags query to use
  100360. * @param forEach defines a predicate used to filter results
  100361. * @returns an array of Mesh
  100362. */
  100363. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  100364. /**
  100365. * Get a list of cameras by tags
  100366. * @param tagsQuery defines the tags query to use
  100367. * @param forEach defines a predicate used to filter results
  100368. * @returns an array of Camera
  100369. */
  100370. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  100371. /**
  100372. * Get a list of lights by tags
  100373. * @param tagsQuery defines the tags query to use
  100374. * @param forEach defines a predicate used to filter results
  100375. * @returns an array of Light
  100376. */
  100377. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  100378. /**
  100379. * Get a list of materials by tags
  100380. * @param tagsQuery defines the tags query to use
  100381. * @param forEach defines a predicate used to filter results
  100382. * @returns an array of Material
  100383. */
  100384. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  100385. /**
  100386. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  100387. * This allowed control for front to back rendering or reversly depending of the special needs.
  100388. *
  100389. * @param renderingGroupId The rendering group id corresponding to its index
  100390. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  100391. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  100392. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  100393. */
  100394. 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;
  100395. /**
  100396. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  100397. *
  100398. * @param renderingGroupId The rendering group id corresponding to its index
  100399. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  100400. * @param depth Automatically clears depth between groups if true and autoClear is true.
  100401. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  100402. */
  100403. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  100404. /**
  100405. * Gets the current auto clear configuration for one rendering group of the rendering
  100406. * manager.
  100407. * @param index the rendering group index to get the information for
  100408. * @returns The auto clear setup for the requested rendering group
  100409. */
  100410. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  100411. private _blockMaterialDirtyMechanism;
  100412. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  100413. blockMaterialDirtyMechanism: boolean;
  100414. /**
  100415. * Will flag all materials as dirty to trigger new shader compilation
  100416. * @param flag defines the flag used to specify which material part must be marked as dirty
  100417. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  100418. */
  100419. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  100420. /** @hidden */
  100421. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  100422. /** @hidden */
  100423. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  100424. }
  100425. }
  100426. declare module BABYLON {
  100427. /**
  100428. * Set of assets to keep when moving a scene into an asset container.
  100429. */
  100430. export class KeepAssets extends AbstractScene {
  100431. }
  100432. /**
  100433. * Container with a set of assets that can be added or removed from a scene.
  100434. */
  100435. export class AssetContainer extends AbstractScene {
  100436. /**
  100437. * The scene the AssetContainer belongs to.
  100438. */
  100439. scene: Scene;
  100440. /**
  100441. * Instantiates an AssetContainer.
  100442. * @param scene The scene the AssetContainer belongs to.
  100443. */
  100444. constructor(scene: Scene);
  100445. /**
  100446. * Adds all the assets from the container to the scene.
  100447. */
  100448. addAllToScene(): void;
  100449. /**
  100450. * Removes all the assets in the container from the scene
  100451. */
  100452. removeAllFromScene(): void;
  100453. /**
  100454. * Disposes all the assets in the container
  100455. */
  100456. dispose(): void;
  100457. private _moveAssets;
  100458. /**
  100459. * Removes all the assets contained in the scene and adds them to the container.
  100460. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  100461. */
  100462. moveAllFromScene(keepAssets?: KeepAssets): void;
  100463. /**
  100464. * 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.
  100465. * @returns the root mesh
  100466. */
  100467. createRootMesh(): Mesh;
  100468. }
  100469. }
  100470. declare module BABYLON {
  100471. /**
  100472. * Defines how the parser contract is defined.
  100473. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  100474. */
  100475. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  100476. /**
  100477. * Defines how the individual parser contract is defined.
  100478. * These parser can parse an individual asset
  100479. */
  100480. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  100481. /**
  100482. * Base class of the scene acting as a container for the different elements composing a scene.
  100483. * This class is dynamically extended by the different components of the scene increasing
  100484. * flexibility and reducing coupling
  100485. */
  100486. export abstract class AbstractScene {
  100487. /**
  100488. * Stores the list of available parsers in the application.
  100489. */
  100490. private static _BabylonFileParsers;
  100491. /**
  100492. * Stores the list of available individual parsers in the application.
  100493. */
  100494. private static _IndividualBabylonFileParsers;
  100495. /**
  100496. * Adds a parser in the list of available ones
  100497. * @param name Defines the name of the parser
  100498. * @param parser Defines the parser to add
  100499. */
  100500. static AddParser(name: string, parser: BabylonFileParser): void;
  100501. /**
  100502. * Gets a general parser from the list of avaialble ones
  100503. * @param name Defines the name of the parser
  100504. * @returns the requested parser or null
  100505. */
  100506. static GetParser(name: string): Nullable<BabylonFileParser>;
  100507. /**
  100508. * Adds n individual parser in the list of available ones
  100509. * @param name Defines the name of the parser
  100510. * @param parser Defines the parser to add
  100511. */
  100512. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  100513. /**
  100514. * Gets an individual parser from the list of avaialble ones
  100515. * @param name Defines the name of the parser
  100516. * @returns the requested parser or null
  100517. */
  100518. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  100519. /**
  100520. * Parser json data and populate both a scene and its associated container object
  100521. * @param jsonData Defines the data to parse
  100522. * @param scene Defines the scene to parse the data for
  100523. * @param container Defines the container attached to the parsing sequence
  100524. * @param rootUrl Defines the root url of the data
  100525. */
  100526. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  100527. /**
  100528. * Gets the list of root nodes (ie. nodes with no parent)
  100529. */
  100530. rootNodes: Node[];
  100531. /** All of the cameras added to this scene
  100532. * @see http://doc.babylonjs.com/babylon101/cameras
  100533. */
  100534. cameras: Camera[];
  100535. /**
  100536. * All of the lights added to this scene
  100537. * @see http://doc.babylonjs.com/babylon101/lights
  100538. */
  100539. lights: Light[];
  100540. /**
  100541. * All of the (abstract) meshes added to this scene
  100542. */
  100543. meshes: AbstractMesh[];
  100544. /**
  100545. * The list of skeletons added to the scene
  100546. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  100547. */
  100548. skeletons: Skeleton[];
  100549. /**
  100550. * All of the particle systems added to this scene
  100551. * @see http://doc.babylonjs.com/babylon101/particles
  100552. */
  100553. particleSystems: IParticleSystem[];
  100554. /**
  100555. * Gets a list of Animations associated with the scene
  100556. */
  100557. animations: Animation[];
  100558. /**
  100559. * All of the animation groups added to this scene
  100560. * @see http://doc.babylonjs.com/how_to/group
  100561. */
  100562. animationGroups: AnimationGroup[];
  100563. /**
  100564. * All of the multi-materials added to this scene
  100565. * @see http://doc.babylonjs.com/how_to/multi_materials
  100566. */
  100567. multiMaterials: MultiMaterial[];
  100568. /**
  100569. * All of the materials added to this scene
  100570. * In the context of a Scene, it is not supposed to be modified manually.
  100571. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  100572. * Note also that the order of the Material wihin the array is not significant and might change.
  100573. * @see http://doc.babylonjs.com/babylon101/materials
  100574. */
  100575. materials: Material[];
  100576. /**
  100577. * The list of morph target managers added to the scene
  100578. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  100579. */
  100580. morphTargetManagers: MorphTargetManager[];
  100581. /**
  100582. * The list of geometries used in the scene.
  100583. */
  100584. geometries: Geometry[];
  100585. /**
  100586. * All of the tranform nodes added to this scene
  100587. * In the context of a Scene, it is not supposed to be modified manually.
  100588. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  100589. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  100590. * @see http://doc.babylonjs.com/how_to/transformnode
  100591. */
  100592. transformNodes: TransformNode[];
  100593. /**
  100594. * ActionManagers available on the scene.
  100595. */
  100596. actionManagers: AbstractActionManager[];
  100597. /**
  100598. * Textures to keep.
  100599. */
  100600. textures: BaseTexture[];
  100601. /**
  100602. * Environment texture for the scene
  100603. */
  100604. environmentTexture: Nullable<BaseTexture>;
  100605. }
  100606. }
  100607. declare module BABYLON {
  100608. /**
  100609. * Interface used to define options for Sound class
  100610. */
  100611. export interface ISoundOptions {
  100612. /**
  100613. * Does the sound autoplay once loaded.
  100614. */
  100615. autoplay?: boolean;
  100616. /**
  100617. * Does the sound loop after it finishes playing once.
  100618. */
  100619. loop?: boolean;
  100620. /**
  100621. * Sound's volume
  100622. */
  100623. volume?: number;
  100624. /**
  100625. * Is it a spatial sound?
  100626. */
  100627. spatialSound?: boolean;
  100628. /**
  100629. * Maximum distance to hear that sound
  100630. */
  100631. maxDistance?: number;
  100632. /**
  100633. * Uses user defined attenuation function
  100634. */
  100635. useCustomAttenuation?: boolean;
  100636. /**
  100637. * Define the roll off factor of spatial sounds.
  100638. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100639. */
  100640. rolloffFactor?: number;
  100641. /**
  100642. * Define the reference distance the sound should be heard perfectly.
  100643. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100644. */
  100645. refDistance?: number;
  100646. /**
  100647. * Define the distance attenuation model the sound will follow.
  100648. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100649. */
  100650. distanceModel?: string;
  100651. /**
  100652. * Defines the playback speed (1 by default)
  100653. */
  100654. playbackRate?: number;
  100655. /**
  100656. * Defines if the sound is from a streaming source
  100657. */
  100658. streaming?: boolean;
  100659. /**
  100660. * Defines an optional length (in seconds) inside the sound file
  100661. */
  100662. length?: number;
  100663. /**
  100664. * Defines an optional offset (in seconds) inside the sound file
  100665. */
  100666. offset?: number;
  100667. /**
  100668. * If true, URLs will not be required to state the audio file codec to use.
  100669. */
  100670. skipCodecCheck?: boolean;
  100671. }
  100672. /**
  100673. * Defines a sound that can be played in the application.
  100674. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  100675. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100676. */
  100677. export class Sound {
  100678. /**
  100679. * The name of the sound in the scene.
  100680. */
  100681. name: string;
  100682. /**
  100683. * Does the sound autoplay once loaded.
  100684. */
  100685. autoplay: boolean;
  100686. /**
  100687. * Does the sound loop after it finishes playing once.
  100688. */
  100689. loop: boolean;
  100690. /**
  100691. * Does the sound use a custom attenuation curve to simulate the falloff
  100692. * happening when the source gets further away from the camera.
  100693. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  100694. */
  100695. useCustomAttenuation: boolean;
  100696. /**
  100697. * The sound track id this sound belongs to.
  100698. */
  100699. soundTrackId: number;
  100700. /**
  100701. * Is this sound currently played.
  100702. */
  100703. isPlaying: boolean;
  100704. /**
  100705. * Is this sound currently paused.
  100706. */
  100707. isPaused: boolean;
  100708. /**
  100709. * Does this sound enables spatial sound.
  100710. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100711. */
  100712. spatialSound: boolean;
  100713. /**
  100714. * Define the reference distance the sound should be heard perfectly.
  100715. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100716. */
  100717. refDistance: number;
  100718. /**
  100719. * Define the roll off factor of spatial sounds.
  100720. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100721. */
  100722. rolloffFactor: number;
  100723. /**
  100724. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  100725. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100726. */
  100727. maxDistance: number;
  100728. /**
  100729. * Define the distance attenuation model the sound will follow.
  100730. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100731. */
  100732. distanceModel: string;
  100733. /**
  100734. * @hidden
  100735. * Back Compat
  100736. **/
  100737. onended: () => any;
  100738. /**
  100739. * Observable event when the current playing sound finishes.
  100740. */
  100741. onEndedObservable: Observable<Sound>;
  100742. private _panningModel;
  100743. private _playbackRate;
  100744. private _streaming;
  100745. private _startTime;
  100746. private _startOffset;
  100747. private _position;
  100748. /** @hidden */
  100749. _positionInEmitterSpace: boolean;
  100750. private _localDirection;
  100751. private _volume;
  100752. private _isReadyToPlay;
  100753. private _isDirectional;
  100754. private _readyToPlayCallback;
  100755. private _audioBuffer;
  100756. private _soundSource;
  100757. private _streamingSource;
  100758. private _soundPanner;
  100759. private _soundGain;
  100760. private _inputAudioNode;
  100761. private _outputAudioNode;
  100762. private _coneInnerAngle;
  100763. private _coneOuterAngle;
  100764. private _coneOuterGain;
  100765. private _scene;
  100766. private _connectedTransformNode;
  100767. private _customAttenuationFunction;
  100768. private _registerFunc;
  100769. private _isOutputConnected;
  100770. private _htmlAudioElement;
  100771. private _urlType;
  100772. private _length?;
  100773. private _offset?;
  100774. /** @hidden */
  100775. static _SceneComponentInitialization: (scene: Scene) => void;
  100776. /**
  100777. * Create a sound and attach it to a scene
  100778. * @param name Name of your sound
  100779. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  100780. * @param scene defines the scene the sound belongs to
  100781. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  100782. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  100783. */
  100784. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  100785. /**
  100786. * Release the sound and its associated resources
  100787. */
  100788. dispose(): void;
  100789. /**
  100790. * Gets if the sounds is ready to be played or not.
  100791. * @returns true if ready, otherwise false
  100792. */
  100793. isReady(): boolean;
  100794. private _soundLoaded;
  100795. /**
  100796. * Sets the data of the sound from an audiobuffer
  100797. * @param audioBuffer The audioBuffer containing the data
  100798. */
  100799. setAudioBuffer(audioBuffer: AudioBuffer): void;
  100800. /**
  100801. * Updates the current sounds options such as maxdistance, loop...
  100802. * @param options A JSON object containing values named as the object properties
  100803. */
  100804. updateOptions(options: ISoundOptions): void;
  100805. private _createSpatialParameters;
  100806. private _updateSpatialParameters;
  100807. /**
  100808. * Switch the panning model to HRTF:
  100809. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  100810. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100811. */
  100812. switchPanningModelToHRTF(): void;
  100813. /**
  100814. * Switch the panning model to Equal Power:
  100815. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  100816. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100817. */
  100818. switchPanningModelToEqualPower(): void;
  100819. private _switchPanningModel;
  100820. /**
  100821. * Connect this sound to a sound track audio node like gain...
  100822. * @param soundTrackAudioNode the sound track audio node to connect to
  100823. */
  100824. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  100825. /**
  100826. * Transform this sound into a directional source
  100827. * @param coneInnerAngle Size of the inner cone in degree
  100828. * @param coneOuterAngle Size of the outer cone in degree
  100829. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  100830. */
  100831. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  100832. /**
  100833. * Gets or sets the inner angle for the directional cone.
  100834. */
  100835. /**
  100836. * Gets or sets the inner angle for the directional cone.
  100837. */
  100838. directionalConeInnerAngle: number;
  100839. /**
  100840. * Gets or sets the outer angle for the directional cone.
  100841. */
  100842. /**
  100843. * Gets or sets the outer angle for the directional cone.
  100844. */
  100845. directionalConeOuterAngle: number;
  100846. /**
  100847. * Sets the position of the emitter if spatial sound is enabled
  100848. * @param newPosition Defines the new posisiton
  100849. */
  100850. setPosition(newPosition: Vector3): void;
  100851. /**
  100852. * Sets the local direction of the emitter if spatial sound is enabled
  100853. * @param newLocalDirection Defines the new local direction
  100854. */
  100855. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  100856. private _updateDirection;
  100857. /** @hidden */
  100858. updateDistanceFromListener(): void;
  100859. /**
  100860. * Sets a new custom attenuation function for the sound.
  100861. * @param callback Defines the function used for the attenuation
  100862. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  100863. */
  100864. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  100865. /**
  100866. * Play the sound
  100867. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  100868. * @param offset (optional) Start the sound at a specific time in seconds
  100869. * @param length (optional) Sound duration (in seconds)
  100870. */
  100871. play(time?: number, offset?: number, length?: number): void;
  100872. private _onended;
  100873. /**
  100874. * Stop the sound
  100875. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  100876. */
  100877. stop(time?: number): void;
  100878. /**
  100879. * Put the sound in pause
  100880. */
  100881. pause(): void;
  100882. /**
  100883. * Sets a dedicated volume for this sounds
  100884. * @param newVolume Define the new volume of the sound
  100885. * @param time Define time for gradual change to new volume
  100886. */
  100887. setVolume(newVolume: number, time?: number): void;
  100888. /**
  100889. * Set the sound play back rate
  100890. * @param newPlaybackRate Define the playback rate the sound should be played at
  100891. */
  100892. setPlaybackRate(newPlaybackRate: number): void;
  100893. /**
  100894. * Gets the volume of the sound.
  100895. * @returns the volume of the sound
  100896. */
  100897. getVolume(): number;
  100898. /**
  100899. * Attach the sound to a dedicated mesh
  100900. * @param transformNode The transform node to connect the sound with
  100901. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  100902. */
  100903. attachToMesh(transformNode: TransformNode): void;
  100904. /**
  100905. * Detach the sound from the previously attached mesh
  100906. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  100907. */
  100908. detachFromMesh(): void;
  100909. private _onRegisterAfterWorldMatrixUpdate;
  100910. /**
  100911. * Clone the current sound in the scene.
  100912. * @returns the new sound clone
  100913. */
  100914. clone(): Nullable<Sound>;
  100915. /**
  100916. * Gets the current underlying audio buffer containing the data
  100917. * @returns the audio buffer
  100918. */
  100919. getAudioBuffer(): Nullable<AudioBuffer>;
  100920. /**
  100921. * Serializes the Sound in a JSON representation
  100922. * @returns the JSON representation of the sound
  100923. */
  100924. serialize(): any;
  100925. /**
  100926. * Parse a JSON representation of a sound to innstantiate in a given scene
  100927. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  100928. * @param scene Define the scene the new parsed sound should be created in
  100929. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  100930. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  100931. * @returns the newly parsed sound
  100932. */
  100933. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  100934. }
  100935. }
  100936. declare module BABYLON {
  100937. /**
  100938. * This defines an action helpful to play a defined sound on a triggered action.
  100939. */
  100940. export class PlaySoundAction extends Action {
  100941. private _sound;
  100942. /**
  100943. * Instantiate the action
  100944. * @param triggerOptions defines the trigger options
  100945. * @param sound defines the sound to play
  100946. * @param condition defines the trigger related conditions
  100947. */
  100948. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  100949. /** @hidden */
  100950. _prepare(): void;
  100951. /**
  100952. * Execute the action and play the sound.
  100953. */
  100954. execute(): void;
  100955. /**
  100956. * Serializes the actions and its related information.
  100957. * @param parent defines the object to serialize in
  100958. * @returns the serialized object
  100959. */
  100960. serialize(parent: any): any;
  100961. }
  100962. /**
  100963. * This defines an action helpful to stop a defined sound on a triggered action.
  100964. */
  100965. export class StopSoundAction extends Action {
  100966. private _sound;
  100967. /**
  100968. * Instantiate the action
  100969. * @param triggerOptions defines the trigger options
  100970. * @param sound defines the sound to stop
  100971. * @param condition defines the trigger related conditions
  100972. */
  100973. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  100974. /** @hidden */
  100975. _prepare(): void;
  100976. /**
  100977. * Execute the action and stop the sound.
  100978. */
  100979. execute(): void;
  100980. /**
  100981. * Serializes the actions and its related information.
  100982. * @param parent defines the object to serialize in
  100983. * @returns the serialized object
  100984. */
  100985. serialize(parent: any): any;
  100986. }
  100987. }
  100988. declare module BABYLON {
  100989. /**
  100990. * This defines an action responsible to change the value of a property
  100991. * by interpolating between its current value and the newly set one once triggered.
  100992. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  100993. */
  100994. export class InterpolateValueAction extends Action {
  100995. /**
  100996. * Defines the path of the property where the value should be interpolated
  100997. */
  100998. propertyPath: string;
  100999. /**
  101000. * Defines the target value at the end of the interpolation.
  101001. */
  101002. value: any;
  101003. /**
  101004. * Defines the time it will take for the property to interpolate to the value.
  101005. */
  101006. duration: number;
  101007. /**
  101008. * Defines if the other scene animations should be stopped when the action has been triggered
  101009. */
  101010. stopOtherAnimations?: boolean;
  101011. /**
  101012. * Defines a callback raised once the interpolation animation has been done.
  101013. */
  101014. onInterpolationDone?: () => void;
  101015. /**
  101016. * Observable triggered once the interpolation animation has been done.
  101017. */
  101018. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  101019. private _target;
  101020. private _effectiveTarget;
  101021. private _property;
  101022. /**
  101023. * Instantiate the action
  101024. * @param triggerOptions defines the trigger options
  101025. * @param target defines the object containing the value to interpolate
  101026. * @param propertyPath defines the path to the property in the target object
  101027. * @param value defines the target value at the end of the interpolation
  101028. * @param duration deines the time it will take for the property to interpolate to the value.
  101029. * @param condition defines the trigger related conditions
  101030. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  101031. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  101032. */
  101033. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  101034. /** @hidden */
  101035. _prepare(): void;
  101036. /**
  101037. * Execute the action starts the value interpolation.
  101038. */
  101039. execute(): void;
  101040. /**
  101041. * Serializes the actions and its related information.
  101042. * @param parent defines the object to serialize in
  101043. * @returns the serialized object
  101044. */
  101045. serialize(parent: any): any;
  101046. }
  101047. }
  101048. declare module BABYLON {
  101049. /**
  101050. * Options allowed during the creation of a sound track.
  101051. */
  101052. export interface ISoundTrackOptions {
  101053. /**
  101054. * The volume the sound track should take during creation
  101055. */
  101056. volume?: number;
  101057. /**
  101058. * Define if the sound track is the main sound track of the scene
  101059. */
  101060. mainTrack?: boolean;
  101061. }
  101062. /**
  101063. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  101064. * It will be also used in a future release to apply effects on a specific track.
  101065. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  101066. */
  101067. export class SoundTrack {
  101068. /**
  101069. * The unique identifier of the sound track in the scene.
  101070. */
  101071. id: number;
  101072. /**
  101073. * The list of sounds included in the sound track.
  101074. */
  101075. soundCollection: Array<Sound>;
  101076. private _outputAudioNode;
  101077. private _scene;
  101078. private _isMainTrack;
  101079. private _connectedAnalyser;
  101080. private _options;
  101081. private _isInitialized;
  101082. /**
  101083. * Creates a new sound track.
  101084. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  101085. * @param scene Define the scene the sound track belongs to
  101086. * @param options
  101087. */
  101088. constructor(scene: Scene, options?: ISoundTrackOptions);
  101089. private _initializeSoundTrackAudioGraph;
  101090. /**
  101091. * Release the sound track and its associated resources
  101092. */
  101093. dispose(): void;
  101094. /**
  101095. * Adds a sound to this sound track
  101096. * @param sound define the cound to add
  101097. * @ignoreNaming
  101098. */
  101099. AddSound(sound: Sound): void;
  101100. /**
  101101. * Removes a sound to this sound track
  101102. * @param sound define the cound to remove
  101103. * @ignoreNaming
  101104. */
  101105. RemoveSound(sound: Sound): void;
  101106. /**
  101107. * Set a global volume for the full sound track.
  101108. * @param newVolume Define the new volume of the sound track
  101109. */
  101110. setVolume(newVolume: number): void;
  101111. /**
  101112. * Switch the panning model to HRTF:
  101113. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  101114. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101115. */
  101116. switchPanningModelToHRTF(): void;
  101117. /**
  101118. * Switch the panning model to Equal Power:
  101119. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  101120. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101121. */
  101122. switchPanningModelToEqualPower(): void;
  101123. /**
  101124. * Connect the sound track to an audio analyser allowing some amazing
  101125. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  101126. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  101127. * @param analyser The analyser to connect to the engine
  101128. */
  101129. connectToAnalyser(analyser: Analyser): void;
  101130. }
  101131. }
  101132. declare module BABYLON {
  101133. interface AbstractScene {
  101134. /**
  101135. * The list of sounds used in the scene.
  101136. */
  101137. sounds: Nullable<Array<Sound>>;
  101138. }
  101139. interface Scene {
  101140. /**
  101141. * @hidden
  101142. * Backing field
  101143. */
  101144. _mainSoundTrack: SoundTrack;
  101145. /**
  101146. * The main sound track played by the scene.
  101147. * It cotains your primary collection of sounds.
  101148. */
  101149. mainSoundTrack: SoundTrack;
  101150. /**
  101151. * The list of sound tracks added to the scene
  101152. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101153. */
  101154. soundTracks: Nullable<Array<SoundTrack>>;
  101155. /**
  101156. * Gets a sound using a given name
  101157. * @param name defines the name to search for
  101158. * @return the found sound or null if not found at all.
  101159. */
  101160. getSoundByName(name: string): Nullable<Sound>;
  101161. /**
  101162. * Gets or sets if audio support is enabled
  101163. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101164. */
  101165. audioEnabled: boolean;
  101166. /**
  101167. * Gets or sets if audio will be output to headphones
  101168. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101169. */
  101170. headphone: boolean;
  101171. /**
  101172. * Gets or sets custom audio listener position provider
  101173. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101174. */
  101175. audioListenerPositionProvider: Nullable<() => Vector3>;
  101176. }
  101177. /**
  101178. * Defines the sound scene component responsible to manage any sounds
  101179. * in a given scene.
  101180. */
  101181. export class AudioSceneComponent implements ISceneSerializableComponent {
  101182. /**
  101183. * The component name helpfull to identify the component in the list of scene components.
  101184. */
  101185. readonly name: string;
  101186. /**
  101187. * The scene the component belongs to.
  101188. */
  101189. scene: Scene;
  101190. private _audioEnabled;
  101191. /**
  101192. * Gets whether audio is enabled or not.
  101193. * Please use related enable/disable method to switch state.
  101194. */
  101195. readonly audioEnabled: boolean;
  101196. private _headphone;
  101197. /**
  101198. * Gets whether audio is outputing to headphone or not.
  101199. * Please use the according Switch methods to change output.
  101200. */
  101201. readonly headphone: boolean;
  101202. private _audioListenerPositionProvider;
  101203. /**
  101204. * Gets the current audio listener position provider
  101205. */
  101206. /**
  101207. * Sets a custom listener position for all sounds in the scene
  101208. * By default, this is the position of the first active camera
  101209. */
  101210. audioListenerPositionProvider: Nullable<() => Vector3>;
  101211. /**
  101212. * Creates a new instance of the component for the given scene
  101213. * @param scene Defines the scene to register the component in
  101214. */
  101215. constructor(scene: Scene);
  101216. /**
  101217. * Registers the component in a given scene
  101218. */
  101219. register(): void;
  101220. /**
  101221. * Rebuilds the elements related to this component in case of
  101222. * context lost for instance.
  101223. */
  101224. rebuild(): void;
  101225. /**
  101226. * Serializes the component data to the specified json object
  101227. * @param serializationObject The object to serialize to
  101228. */
  101229. serialize(serializationObject: any): void;
  101230. /**
  101231. * Adds all the elements from the container to the scene
  101232. * @param container the container holding the elements
  101233. */
  101234. addFromContainer(container: AbstractScene): void;
  101235. /**
  101236. * Removes all the elements in the container from the scene
  101237. * @param container contains the elements to remove
  101238. * @param dispose if the removed element should be disposed (default: false)
  101239. */
  101240. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  101241. /**
  101242. * Disposes the component and the associated ressources.
  101243. */
  101244. dispose(): void;
  101245. /**
  101246. * Disables audio in the associated scene.
  101247. */
  101248. disableAudio(): void;
  101249. /**
  101250. * Enables audio in the associated scene.
  101251. */
  101252. enableAudio(): void;
  101253. /**
  101254. * Switch audio to headphone output.
  101255. */
  101256. switchAudioModeForHeadphones(): void;
  101257. /**
  101258. * Switch audio to normal speakers.
  101259. */
  101260. switchAudioModeForNormalSpeakers(): void;
  101261. private _afterRender;
  101262. }
  101263. }
  101264. declare module BABYLON {
  101265. /**
  101266. * Wraps one or more Sound objects and selects one with random weight for playback.
  101267. */
  101268. export class WeightedSound {
  101269. /** When true a Sound will be selected and played when the current playing Sound completes. */
  101270. loop: boolean;
  101271. private _coneInnerAngle;
  101272. private _coneOuterAngle;
  101273. private _volume;
  101274. /** A Sound is currently playing. */
  101275. isPlaying: boolean;
  101276. /** A Sound is currently paused. */
  101277. isPaused: boolean;
  101278. private _sounds;
  101279. private _weights;
  101280. private _currentIndex?;
  101281. /**
  101282. * Creates a new WeightedSound from the list of sounds given.
  101283. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  101284. * @param sounds Array of Sounds that will be selected from.
  101285. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  101286. */
  101287. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  101288. /**
  101289. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  101290. */
  101291. /**
  101292. * The size of cone in degress for a directional sound in which there will be no attenuation.
  101293. */
  101294. directionalConeInnerAngle: number;
  101295. /**
  101296. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  101297. * Listener angles between innerAngle and outerAngle will falloff linearly.
  101298. */
  101299. /**
  101300. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  101301. * Listener angles between innerAngle and outerAngle will falloff linearly.
  101302. */
  101303. directionalConeOuterAngle: number;
  101304. /**
  101305. * Playback volume.
  101306. */
  101307. /**
  101308. * Playback volume.
  101309. */
  101310. volume: number;
  101311. private _onended;
  101312. /**
  101313. * Suspend playback
  101314. */
  101315. pause(): void;
  101316. /**
  101317. * Stop playback
  101318. */
  101319. stop(): void;
  101320. /**
  101321. * Start playback.
  101322. * @param startOffset Position the clip head at a specific time in seconds.
  101323. */
  101324. play(startOffset?: number): void;
  101325. }
  101326. }
  101327. declare module BABYLON {
  101328. /**
  101329. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  101330. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  101331. */
  101332. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  101333. /**
  101334. * Gets the name of the behavior.
  101335. */
  101336. readonly name: string;
  101337. /**
  101338. * The easing function used by animations
  101339. */
  101340. static EasingFunction: BackEase;
  101341. /**
  101342. * The easing mode used by animations
  101343. */
  101344. static EasingMode: number;
  101345. /**
  101346. * The duration of the animation, in milliseconds
  101347. */
  101348. transitionDuration: number;
  101349. /**
  101350. * Length of the distance animated by the transition when lower radius is reached
  101351. */
  101352. lowerRadiusTransitionRange: number;
  101353. /**
  101354. * Length of the distance animated by the transition when upper radius is reached
  101355. */
  101356. upperRadiusTransitionRange: number;
  101357. private _autoTransitionRange;
  101358. /**
  101359. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  101360. */
  101361. /**
  101362. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  101363. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  101364. */
  101365. autoTransitionRange: boolean;
  101366. private _attachedCamera;
  101367. private _onAfterCheckInputsObserver;
  101368. private _onMeshTargetChangedObserver;
  101369. /**
  101370. * Initializes the behavior.
  101371. */
  101372. init(): void;
  101373. /**
  101374. * Attaches the behavior to its arc rotate camera.
  101375. * @param camera Defines the camera to attach the behavior to
  101376. */
  101377. attach(camera: ArcRotateCamera): void;
  101378. /**
  101379. * Detaches the behavior from its current arc rotate camera.
  101380. */
  101381. detach(): void;
  101382. private _radiusIsAnimating;
  101383. private _radiusBounceTransition;
  101384. private _animatables;
  101385. private _cachedWheelPrecision;
  101386. /**
  101387. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  101388. * @param radiusLimit The limit to check against.
  101389. * @return Bool to indicate if at limit.
  101390. */
  101391. private _isRadiusAtLimit;
  101392. /**
  101393. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  101394. * @param radiusDelta The delta by which to animate to. Can be negative.
  101395. */
  101396. private _applyBoundRadiusAnimation;
  101397. /**
  101398. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  101399. */
  101400. protected _clearAnimationLocks(): void;
  101401. /**
  101402. * Stops and removes all animations that have been applied to the camera
  101403. */
  101404. stopAllAnimations(): void;
  101405. }
  101406. }
  101407. declare module BABYLON {
  101408. /**
  101409. * 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.
  101410. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  101411. */
  101412. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  101413. /**
  101414. * Gets the name of the behavior.
  101415. */
  101416. readonly name: string;
  101417. private _mode;
  101418. private _radiusScale;
  101419. private _positionScale;
  101420. private _defaultElevation;
  101421. private _elevationReturnTime;
  101422. private _elevationReturnWaitTime;
  101423. private _zoomStopsAnimation;
  101424. private _framingTime;
  101425. /**
  101426. * The easing function used by animations
  101427. */
  101428. static EasingFunction: ExponentialEase;
  101429. /**
  101430. * The easing mode used by animations
  101431. */
  101432. static EasingMode: number;
  101433. /**
  101434. * Sets the current mode used by the behavior
  101435. */
  101436. /**
  101437. * Gets current mode used by the behavior.
  101438. */
  101439. mode: number;
  101440. /**
  101441. * Sets the scale applied to the radius (1 by default)
  101442. */
  101443. /**
  101444. * Gets the scale applied to the radius
  101445. */
  101446. radiusScale: number;
  101447. /**
  101448. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  101449. */
  101450. /**
  101451. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  101452. */
  101453. positionScale: number;
  101454. /**
  101455. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  101456. * behaviour is triggered, in radians.
  101457. */
  101458. /**
  101459. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  101460. * behaviour is triggered, in radians.
  101461. */
  101462. defaultElevation: number;
  101463. /**
  101464. * Sets the time (in milliseconds) taken to return to the default beta position.
  101465. * Negative value indicates camera should not return to default.
  101466. */
  101467. /**
  101468. * Gets the time (in milliseconds) taken to return to the default beta position.
  101469. * Negative value indicates camera should not return to default.
  101470. */
  101471. elevationReturnTime: number;
  101472. /**
  101473. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  101474. */
  101475. /**
  101476. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  101477. */
  101478. elevationReturnWaitTime: number;
  101479. /**
  101480. * Sets the flag that indicates if user zooming should stop animation.
  101481. */
  101482. /**
  101483. * Gets the flag that indicates if user zooming should stop animation.
  101484. */
  101485. zoomStopsAnimation: boolean;
  101486. /**
  101487. * Sets the transition time when framing the mesh, in milliseconds
  101488. */
  101489. /**
  101490. * Gets the transition time when framing the mesh, in milliseconds
  101491. */
  101492. framingTime: number;
  101493. /**
  101494. * Define if the behavior should automatically change the configured
  101495. * camera limits and sensibilities.
  101496. */
  101497. autoCorrectCameraLimitsAndSensibility: boolean;
  101498. private _onPrePointerObservableObserver;
  101499. private _onAfterCheckInputsObserver;
  101500. private _onMeshTargetChangedObserver;
  101501. private _attachedCamera;
  101502. private _isPointerDown;
  101503. private _lastInteractionTime;
  101504. /**
  101505. * Initializes the behavior.
  101506. */
  101507. init(): void;
  101508. /**
  101509. * Attaches the behavior to its arc rotate camera.
  101510. * @param camera Defines the camera to attach the behavior to
  101511. */
  101512. attach(camera: ArcRotateCamera): void;
  101513. /**
  101514. * Detaches the behavior from its current arc rotate camera.
  101515. */
  101516. detach(): void;
  101517. private _animatables;
  101518. private _betaIsAnimating;
  101519. private _betaTransition;
  101520. private _radiusTransition;
  101521. private _vectorTransition;
  101522. /**
  101523. * Targets the given mesh and updates zoom level accordingly.
  101524. * @param mesh The mesh to target.
  101525. * @param radius Optional. If a cached radius position already exists, overrides default.
  101526. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  101527. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101528. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101529. */
  101530. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101531. /**
  101532. * Targets the given mesh with its children and updates zoom level accordingly.
  101533. * @param mesh The mesh to target.
  101534. * @param radius Optional. If a cached radius position already exists, overrides default.
  101535. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  101536. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101537. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101538. */
  101539. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101540. /**
  101541. * Targets the given meshes with their children and updates zoom level accordingly.
  101542. * @param meshes The mesh to target.
  101543. * @param radius Optional. If a cached radius position already exists, overrides default.
  101544. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  101545. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101546. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101547. */
  101548. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101549. /**
  101550. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  101551. * @param minimumWorld Determines the smaller position of the bounding box extend
  101552. * @param maximumWorld Determines the bigger position of the bounding box extend
  101553. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101554. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101555. */
  101556. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101557. /**
  101558. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  101559. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  101560. * frustum width.
  101561. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  101562. * to fully enclose the mesh in the viewing frustum.
  101563. */
  101564. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  101565. /**
  101566. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  101567. * is automatically returned to its default position (expected to be above ground plane).
  101568. */
  101569. private _maintainCameraAboveGround;
  101570. /**
  101571. * Returns the frustum slope based on the canvas ratio and camera FOV
  101572. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  101573. */
  101574. private _getFrustumSlope;
  101575. /**
  101576. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  101577. */
  101578. private _clearAnimationLocks;
  101579. /**
  101580. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  101581. */
  101582. private _applyUserInteraction;
  101583. /**
  101584. * Stops and removes all animations that have been applied to the camera
  101585. */
  101586. stopAllAnimations(): void;
  101587. /**
  101588. * Gets a value indicating if the user is moving the camera
  101589. */
  101590. readonly isUserIsMoving: boolean;
  101591. /**
  101592. * The camera can move all the way towards the mesh.
  101593. */
  101594. static IgnoreBoundsSizeMode: number;
  101595. /**
  101596. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  101597. */
  101598. static FitFrustumSidesMode: number;
  101599. }
  101600. }
  101601. declare module BABYLON {
  101602. /**
  101603. * Base class for Camera Pointer Inputs.
  101604. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  101605. * for example usage.
  101606. */
  101607. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  101608. /**
  101609. * Defines the camera the input is attached to.
  101610. */
  101611. abstract camera: Camera;
  101612. /**
  101613. * Whether keyboard modifier keys are pressed at time of last mouse event.
  101614. */
  101615. protected _altKey: boolean;
  101616. protected _ctrlKey: boolean;
  101617. protected _metaKey: boolean;
  101618. protected _shiftKey: boolean;
  101619. /**
  101620. * Which mouse buttons were pressed at time of last mouse event.
  101621. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  101622. */
  101623. protected _buttonsPressed: number;
  101624. /**
  101625. * Defines the buttons associated with the input to handle camera move.
  101626. */
  101627. buttons: number[];
  101628. /**
  101629. * Attach the input controls to a specific dom element to get the input from.
  101630. * @param element Defines the element the controls should be listened from
  101631. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101632. */
  101633. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101634. /**
  101635. * Detach the current controls from the specified dom element.
  101636. * @param element Defines the element to stop listening the inputs from
  101637. */
  101638. detachControl(element: Nullable<HTMLElement>): void;
  101639. /**
  101640. * Gets the class name of the current input.
  101641. * @returns the class name
  101642. */
  101643. getClassName(): string;
  101644. /**
  101645. * Get the friendly name associated with the input class.
  101646. * @returns the input friendly name
  101647. */
  101648. getSimpleName(): string;
  101649. /**
  101650. * Called on pointer POINTERDOUBLETAP event.
  101651. * Override this method to provide functionality on POINTERDOUBLETAP event.
  101652. */
  101653. protected onDoubleTap(type: string): void;
  101654. /**
  101655. * Called on pointer POINTERMOVE event if only a single touch is active.
  101656. * Override this method to provide functionality.
  101657. */
  101658. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  101659. /**
  101660. * Called on pointer POINTERMOVE event if multiple touches are active.
  101661. * Override this method to provide functionality.
  101662. */
  101663. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  101664. /**
  101665. * Called on JS contextmenu event.
  101666. * Override this method to provide functionality.
  101667. */
  101668. protected onContextMenu(evt: PointerEvent): void;
  101669. /**
  101670. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  101671. * press.
  101672. * Override this method to provide functionality.
  101673. */
  101674. protected onButtonDown(evt: PointerEvent): void;
  101675. /**
  101676. * Called each time a new POINTERUP event occurs. Ie, for each button
  101677. * release.
  101678. * Override this method to provide functionality.
  101679. */
  101680. protected onButtonUp(evt: PointerEvent): void;
  101681. /**
  101682. * Called when window becomes inactive.
  101683. * Override this method to provide functionality.
  101684. */
  101685. protected onLostFocus(): void;
  101686. private _pointerInput;
  101687. private _observer;
  101688. private _onLostFocus;
  101689. private pointA;
  101690. private pointB;
  101691. }
  101692. }
  101693. declare module BABYLON {
  101694. /**
  101695. * Manage the pointers inputs to control an arc rotate camera.
  101696. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101697. */
  101698. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  101699. /**
  101700. * Defines the camera the input is attached to.
  101701. */
  101702. camera: ArcRotateCamera;
  101703. /**
  101704. * Gets the class name of the current input.
  101705. * @returns the class name
  101706. */
  101707. getClassName(): string;
  101708. /**
  101709. * Defines the buttons associated with the input to handle camera move.
  101710. */
  101711. buttons: number[];
  101712. /**
  101713. * Defines the pointer angular sensibility along the X axis or how fast is
  101714. * the camera rotating.
  101715. */
  101716. angularSensibilityX: number;
  101717. /**
  101718. * Defines the pointer angular sensibility along the Y axis or how fast is
  101719. * the camera rotating.
  101720. */
  101721. angularSensibilityY: number;
  101722. /**
  101723. * Defines the pointer pinch precision or how fast is the camera zooming.
  101724. */
  101725. pinchPrecision: number;
  101726. /**
  101727. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  101728. * from 0.
  101729. * It defines the percentage of current camera.radius to use as delta when
  101730. * pinch zoom is used.
  101731. */
  101732. pinchDeltaPercentage: number;
  101733. /**
  101734. * Defines the pointer panning sensibility or how fast is the camera moving.
  101735. */
  101736. panningSensibility: number;
  101737. /**
  101738. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  101739. */
  101740. multiTouchPanning: boolean;
  101741. /**
  101742. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  101743. * zoom (pinch) through multitouch.
  101744. */
  101745. multiTouchPanAndZoom: boolean;
  101746. /**
  101747. * Revers pinch action direction.
  101748. */
  101749. pinchInwards: boolean;
  101750. private _isPanClick;
  101751. private _twoFingerActivityCount;
  101752. private _isPinching;
  101753. /**
  101754. * Called on pointer POINTERMOVE event if only a single touch is active.
  101755. */
  101756. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  101757. /**
  101758. * Called on pointer POINTERDOUBLETAP event.
  101759. */
  101760. protected onDoubleTap(type: string): void;
  101761. /**
  101762. * Called on pointer POINTERMOVE event if multiple touches are active.
  101763. */
  101764. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  101765. /**
  101766. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  101767. * press.
  101768. */
  101769. protected onButtonDown(evt: PointerEvent): void;
  101770. /**
  101771. * Called each time a new POINTERUP event occurs. Ie, for each button
  101772. * release.
  101773. */
  101774. protected onButtonUp(evt: PointerEvent): void;
  101775. /**
  101776. * Called when window becomes inactive.
  101777. */
  101778. protected onLostFocus(): void;
  101779. }
  101780. }
  101781. declare module BABYLON {
  101782. /**
  101783. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  101784. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101785. */
  101786. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  101787. /**
  101788. * Defines the camera the input is attached to.
  101789. */
  101790. camera: ArcRotateCamera;
  101791. /**
  101792. * Defines the list of key codes associated with the up action (increase alpha)
  101793. */
  101794. keysUp: number[];
  101795. /**
  101796. * Defines the list of key codes associated with the down action (decrease alpha)
  101797. */
  101798. keysDown: number[];
  101799. /**
  101800. * Defines the list of key codes associated with the left action (increase beta)
  101801. */
  101802. keysLeft: number[];
  101803. /**
  101804. * Defines the list of key codes associated with the right action (decrease beta)
  101805. */
  101806. keysRight: number[];
  101807. /**
  101808. * Defines the list of key codes associated with the reset action.
  101809. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  101810. */
  101811. keysReset: number[];
  101812. /**
  101813. * Defines the panning sensibility of the inputs.
  101814. * (How fast is the camera paning)
  101815. */
  101816. panningSensibility: number;
  101817. /**
  101818. * Defines the zooming sensibility of the inputs.
  101819. * (How fast is the camera zooming)
  101820. */
  101821. zoomingSensibility: number;
  101822. /**
  101823. * Defines wether maintaining the alt key down switch the movement mode from
  101824. * orientation to zoom.
  101825. */
  101826. useAltToZoom: boolean;
  101827. /**
  101828. * Rotation speed of the camera
  101829. */
  101830. angularSpeed: number;
  101831. private _keys;
  101832. private _ctrlPressed;
  101833. private _altPressed;
  101834. private _onCanvasBlurObserver;
  101835. private _onKeyboardObserver;
  101836. private _engine;
  101837. private _scene;
  101838. /**
  101839. * Attach the input controls to a specific dom element to get the input from.
  101840. * @param element Defines the element the controls should be listened from
  101841. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101842. */
  101843. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101844. /**
  101845. * Detach the current controls from the specified dom element.
  101846. * @param element Defines the element to stop listening the inputs from
  101847. */
  101848. detachControl(element: Nullable<HTMLElement>): void;
  101849. /**
  101850. * Update the current camera state depending on the inputs that have been used this frame.
  101851. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101852. */
  101853. checkInputs(): void;
  101854. /**
  101855. * Gets the class name of the current intput.
  101856. * @returns the class name
  101857. */
  101858. getClassName(): string;
  101859. /**
  101860. * Get the friendly name associated with the input class.
  101861. * @returns the input friendly name
  101862. */
  101863. getSimpleName(): string;
  101864. }
  101865. }
  101866. declare module BABYLON {
  101867. /**
  101868. * Manage the mouse wheel inputs to control an arc rotate camera.
  101869. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101870. */
  101871. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  101872. /**
  101873. * Defines the camera the input is attached to.
  101874. */
  101875. camera: ArcRotateCamera;
  101876. /**
  101877. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  101878. */
  101879. wheelPrecision: number;
  101880. /**
  101881. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  101882. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  101883. */
  101884. wheelDeltaPercentage: number;
  101885. private _wheel;
  101886. private _observer;
  101887. private computeDeltaFromMouseWheelLegacyEvent;
  101888. /**
  101889. * Attach the input controls to a specific dom element to get the input from.
  101890. * @param element Defines the element the controls should be listened from
  101891. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101892. */
  101893. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101894. /**
  101895. * Detach the current controls from the specified dom element.
  101896. * @param element Defines the element to stop listening the inputs from
  101897. */
  101898. detachControl(element: Nullable<HTMLElement>): void;
  101899. /**
  101900. * Gets the class name of the current intput.
  101901. * @returns the class name
  101902. */
  101903. getClassName(): string;
  101904. /**
  101905. * Get the friendly name associated with the input class.
  101906. * @returns the input friendly name
  101907. */
  101908. getSimpleName(): string;
  101909. }
  101910. }
  101911. declare module BABYLON {
  101912. /**
  101913. * Default Inputs manager for the ArcRotateCamera.
  101914. * It groups all the default supported inputs for ease of use.
  101915. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101916. */
  101917. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  101918. /**
  101919. * Instantiates a new ArcRotateCameraInputsManager.
  101920. * @param camera Defines the camera the inputs belong to
  101921. */
  101922. constructor(camera: ArcRotateCamera);
  101923. /**
  101924. * Add mouse wheel input support to the input manager.
  101925. * @returns the current input manager
  101926. */
  101927. addMouseWheel(): ArcRotateCameraInputsManager;
  101928. /**
  101929. * Add pointers input support to the input manager.
  101930. * @returns the current input manager
  101931. */
  101932. addPointers(): ArcRotateCameraInputsManager;
  101933. /**
  101934. * Add keyboard input support to the input manager.
  101935. * @returns the current input manager
  101936. */
  101937. addKeyboard(): ArcRotateCameraInputsManager;
  101938. }
  101939. }
  101940. declare module BABYLON {
  101941. /**
  101942. * This represents an orbital type of camera.
  101943. *
  101944. * 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.
  101945. * 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.
  101946. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  101947. */
  101948. export class ArcRotateCamera extends TargetCamera {
  101949. /**
  101950. * Defines the rotation angle of the camera along the longitudinal axis.
  101951. */
  101952. alpha: number;
  101953. /**
  101954. * Defines the rotation angle of the camera along the latitudinal axis.
  101955. */
  101956. beta: number;
  101957. /**
  101958. * Defines the radius of the camera from it s target point.
  101959. */
  101960. radius: number;
  101961. protected _target: Vector3;
  101962. protected _targetHost: Nullable<AbstractMesh>;
  101963. /**
  101964. * Defines the target point of the camera.
  101965. * The camera looks towards it form the radius distance.
  101966. */
  101967. target: Vector3;
  101968. /**
  101969. * Define the current local position of the camera in the scene
  101970. */
  101971. position: Vector3;
  101972. protected _upVector: Vector3;
  101973. protected _upToYMatrix: Matrix;
  101974. protected _YToUpMatrix: Matrix;
  101975. /**
  101976. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  101977. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  101978. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  101979. */
  101980. upVector: Vector3;
  101981. /**
  101982. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  101983. */
  101984. setMatUp(): void;
  101985. /**
  101986. * Current inertia value on the longitudinal axis.
  101987. * The bigger this number the longer it will take for the camera to stop.
  101988. */
  101989. inertialAlphaOffset: number;
  101990. /**
  101991. * Current inertia value on the latitudinal axis.
  101992. * The bigger this number the longer it will take for the camera to stop.
  101993. */
  101994. inertialBetaOffset: number;
  101995. /**
  101996. * Current inertia value on the radius axis.
  101997. * The bigger this number the longer it will take for the camera to stop.
  101998. */
  101999. inertialRadiusOffset: number;
  102000. /**
  102001. * Minimum allowed angle on the longitudinal axis.
  102002. * This can help limiting how the Camera is able to move in the scene.
  102003. */
  102004. lowerAlphaLimit: Nullable<number>;
  102005. /**
  102006. * Maximum allowed angle on the longitudinal axis.
  102007. * This can help limiting how the Camera is able to move in the scene.
  102008. */
  102009. upperAlphaLimit: Nullable<number>;
  102010. /**
  102011. * Minimum allowed angle on the latitudinal axis.
  102012. * This can help limiting how the Camera is able to move in the scene.
  102013. */
  102014. lowerBetaLimit: number;
  102015. /**
  102016. * Maximum allowed angle on the latitudinal axis.
  102017. * This can help limiting how the Camera is able to move in the scene.
  102018. */
  102019. upperBetaLimit: number;
  102020. /**
  102021. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  102022. * This can help limiting how the Camera is able to move in the scene.
  102023. */
  102024. lowerRadiusLimit: Nullable<number>;
  102025. /**
  102026. * Maximum allowed distance of the camera to the target (The camera can not get further).
  102027. * This can help limiting how the Camera is able to move in the scene.
  102028. */
  102029. upperRadiusLimit: Nullable<number>;
  102030. /**
  102031. * Defines the current inertia value used during panning of the camera along the X axis.
  102032. */
  102033. inertialPanningX: number;
  102034. /**
  102035. * Defines the current inertia value used during panning of the camera along the Y axis.
  102036. */
  102037. inertialPanningY: number;
  102038. /**
  102039. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  102040. * Basically if your fingers moves away from more than this distance you will be considered
  102041. * in pinch mode.
  102042. */
  102043. pinchToPanMaxDistance: number;
  102044. /**
  102045. * Defines the maximum distance the camera can pan.
  102046. * This could help keeping the cammera always in your scene.
  102047. */
  102048. panningDistanceLimit: Nullable<number>;
  102049. /**
  102050. * Defines the target of the camera before paning.
  102051. */
  102052. panningOriginTarget: Vector3;
  102053. /**
  102054. * Defines the value of the inertia used during panning.
  102055. * 0 would mean stop inertia and one would mean no decelleration at all.
  102056. */
  102057. panningInertia: number;
  102058. /**
  102059. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  102060. */
  102061. angularSensibilityX: number;
  102062. /**
  102063. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  102064. */
  102065. angularSensibilityY: number;
  102066. /**
  102067. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  102068. */
  102069. pinchPrecision: number;
  102070. /**
  102071. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  102072. * It will be used instead of pinchDeltaPrecision if different from 0.
  102073. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  102074. */
  102075. pinchDeltaPercentage: number;
  102076. /**
  102077. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  102078. */
  102079. panningSensibility: number;
  102080. /**
  102081. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  102082. */
  102083. keysUp: number[];
  102084. /**
  102085. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  102086. */
  102087. keysDown: number[];
  102088. /**
  102089. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  102090. */
  102091. keysLeft: number[];
  102092. /**
  102093. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  102094. */
  102095. keysRight: number[];
  102096. /**
  102097. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  102098. */
  102099. wheelPrecision: number;
  102100. /**
  102101. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  102102. * It will be used instead of pinchDeltaPrecision if different from 0.
  102103. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  102104. */
  102105. wheelDeltaPercentage: number;
  102106. /**
  102107. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  102108. */
  102109. zoomOnFactor: number;
  102110. /**
  102111. * Defines a screen offset for the camera position.
  102112. */
  102113. targetScreenOffset: Vector2;
  102114. /**
  102115. * Allows the camera to be completely reversed.
  102116. * If false the camera can not arrive upside down.
  102117. */
  102118. allowUpsideDown: boolean;
  102119. /**
  102120. * Define if double tap/click is used to restore the previously saved state of the camera.
  102121. */
  102122. useInputToRestoreState: boolean;
  102123. /** @hidden */
  102124. _viewMatrix: Matrix;
  102125. /** @hidden */
  102126. _useCtrlForPanning: boolean;
  102127. /** @hidden */
  102128. _panningMouseButton: number;
  102129. /**
  102130. * Defines the input associated to the camera.
  102131. */
  102132. inputs: ArcRotateCameraInputsManager;
  102133. /** @hidden */
  102134. _reset: () => void;
  102135. /**
  102136. * Defines the allowed panning axis.
  102137. */
  102138. panningAxis: Vector3;
  102139. protected _localDirection: Vector3;
  102140. protected _transformedDirection: Vector3;
  102141. private _bouncingBehavior;
  102142. /**
  102143. * Gets the bouncing behavior of the camera if it has been enabled.
  102144. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  102145. */
  102146. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  102147. /**
  102148. * Defines if the bouncing behavior of the camera is enabled on the camera.
  102149. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  102150. */
  102151. useBouncingBehavior: boolean;
  102152. private _framingBehavior;
  102153. /**
  102154. * Gets the framing behavior of the camera if it has been enabled.
  102155. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  102156. */
  102157. readonly framingBehavior: Nullable<FramingBehavior>;
  102158. /**
  102159. * Defines if the framing behavior of the camera is enabled on the camera.
  102160. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  102161. */
  102162. useFramingBehavior: boolean;
  102163. private _autoRotationBehavior;
  102164. /**
  102165. * Gets the auto rotation behavior of the camera if it has been enabled.
  102166. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  102167. */
  102168. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  102169. /**
  102170. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  102171. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  102172. */
  102173. useAutoRotationBehavior: boolean;
  102174. /**
  102175. * Observable triggered when the mesh target has been changed on the camera.
  102176. */
  102177. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  102178. /**
  102179. * Event raised when the camera is colliding with a mesh.
  102180. */
  102181. onCollide: (collidedMesh: AbstractMesh) => void;
  102182. /**
  102183. * Defines whether the camera should check collision with the objects oh the scene.
  102184. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  102185. */
  102186. checkCollisions: boolean;
  102187. /**
  102188. * Defines the collision radius of the camera.
  102189. * This simulates a sphere around the camera.
  102190. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  102191. */
  102192. collisionRadius: Vector3;
  102193. protected _collider: Collider;
  102194. protected _previousPosition: Vector3;
  102195. protected _collisionVelocity: Vector3;
  102196. protected _newPosition: Vector3;
  102197. protected _previousAlpha: number;
  102198. protected _previousBeta: number;
  102199. protected _previousRadius: number;
  102200. protected _collisionTriggered: boolean;
  102201. protected _targetBoundingCenter: Nullable<Vector3>;
  102202. private _computationVector;
  102203. /**
  102204. * Instantiates a new ArcRotateCamera in a given scene
  102205. * @param name Defines the name of the camera
  102206. * @param alpha Defines the camera rotation along the logitudinal axis
  102207. * @param beta Defines the camera rotation along the latitudinal axis
  102208. * @param radius Defines the camera distance from its target
  102209. * @param target Defines the camera target
  102210. * @param scene Defines the scene the camera belongs to
  102211. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  102212. */
  102213. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  102214. /** @hidden */
  102215. _initCache(): void;
  102216. /** @hidden */
  102217. _updateCache(ignoreParentClass?: boolean): void;
  102218. protected _getTargetPosition(): Vector3;
  102219. private _storedAlpha;
  102220. private _storedBeta;
  102221. private _storedRadius;
  102222. private _storedTarget;
  102223. private _storedTargetScreenOffset;
  102224. /**
  102225. * Stores the current state of the camera (alpha, beta, radius and target)
  102226. * @returns the camera itself
  102227. */
  102228. storeState(): Camera;
  102229. /**
  102230. * @hidden
  102231. * Restored camera state. You must call storeState() first
  102232. */
  102233. _restoreStateValues(): boolean;
  102234. /** @hidden */
  102235. _isSynchronizedViewMatrix(): boolean;
  102236. /**
  102237. * Attached controls to the current camera.
  102238. * @param element Defines the element the controls should be listened from
  102239. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102240. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  102241. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  102242. */
  102243. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  102244. /**
  102245. * Detach the current controls from the camera.
  102246. * The camera will stop reacting to inputs.
  102247. * @param element Defines the element to stop listening the inputs from
  102248. */
  102249. detachControl(element: HTMLElement): void;
  102250. /** @hidden */
  102251. _checkInputs(): void;
  102252. protected _checkLimits(): void;
  102253. /**
  102254. * Rebuilds angles (alpha, beta) and radius from the give position and target
  102255. */
  102256. rebuildAnglesAndRadius(): void;
  102257. /**
  102258. * Use a position to define the current camera related information like aplha, beta and radius
  102259. * @param position Defines the position to set the camera at
  102260. */
  102261. setPosition(position: Vector3): void;
  102262. /**
  102263. * Defines the target the camera should look at.
  102264. * This will automatically adapt alpha beta and radius to fit within the new target.
  102265. * @param target Defines the new target as a Vector or a mesh
  102266. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  102267. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  102268. */
  102269. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  102270. /** @hidden */
  102271. _getViewMatrix(): Matrix;
  102272. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  102273. /**
  102274. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  102275. * @param meshes Defines the mesh to zoom on
  102276. * @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)
  102277. */
  102278. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  102279. /**
  102280. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  102281. * The target will be changed but the radius
  102282. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  102283. * @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)
  102284. */
  102285. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  102286. min: Vector3;
  102287. max: Vector3;
  102288. distance: number;
  102289. }, doNotUpdateMaxZ?: boolean): void;
  102290. /**
  102291. * @override
  102292. * Override Camera.createRigCamera
  102293. */
  102294. createRigCamera(name: string, cameraIndex: number): Camera;
  102295. /**
  102296. * @hidden
  102297. * @override
  102298. * Override Camera._updateRigCameras
  102299. */
  102300. _updateRigCameras(): void;
  102301. /**
  102302. * Destroy the camera and release the current resources hold by it.
  102303. */
  102304. dispose(): void;
  102305. /**
  102306. * Gets the current object class name.
  102307. * @return the class name
  102308. */
  102309. getClassName(): string;
  102310. }
  102311. }
  102312. declare module BABYLON {
  102313. /**
  102314. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  102315. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  102316. */
  102317. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  102318. /**
  102319. * Gets the name of the behavior.
  102320. */
  102321. readonly name: string;
  102322. private _zoomStopsAnimation;
  102323. private _idleRotationSpeed;
  102324. private _idleRotationWaitTime;
  102325. private _idleRotationSpinupTime;
  102326. /**
  102327. * Sets the flag that indicates if user zooming should stop animation.
  102328. */
  102329. /**
  102330. * Gets the flag that indicates if user zooming should stop animation.
  102331. */
  102332. zoomStopsAnimation: boolean;
  102333. /**
  102334. * Sets the default speed at which the camera rotates around the model.
  102335. */
  102336. /**
  102337. * Gets the default speed at which the camera rotates around the model.
  102338. */
  102339. idleRotationSpeed: number;
  102340. /**
  102341. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  102342. */
  102343. /**
  102344. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  102345. */
  102346. idleRotationWaitTime: number;
  102347. /**
  102348. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  102349. */
  102350. /**
  102351. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  102352. */
  102353. idleRotationSpinupTime: number;
  102354. /**
  102355. * Gets a value indicating if the camera is currently rotating because of this behavior
  102356. */
  102357. readonly rotationInProgress: boolean;
  102358. private _onPrePointerObservableObserver;
  102359. private _onAfterCheckInputsObserver;
  102360. private _attachedCamera;
  102361. private _isPointerDown;
  102362. private _lastFrameTime;
  102363. private _lastInteractionTime;
  102364. private _cameraRotationSpeed;
  102365. /**
  102366. * Initializes the behavior.
  102367. */
  102368. init(): void;
  102369. /**
  102370. * Attaches the behavior to its arc rotate camera.
  102371. * @param camera Defines the camera to attach the behavior to
  102372. */
  102373. attach(camera: ArcRotateCamera): void;
  102374. /**
  102375. * Detaches the behavior from its current arc rotate camera.
  102376. */
  102377. detach(): void;
  102378. /**
  102379. * Returns true if user is scrolling.
  102380. * @return true if user is scrolling.
  102381. */
  102382. private _userIsZooming;
  102383. private _lastFrameRadius;
  102384. private _shouldAnimationStopForInteraction;
  102385. /**
  102386. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  102387. */
  102388. private _applyUserInteraction;
  102389. private _userIsMoving;
  102390. }
  102391. }
  102392. declare module BABYLON {
  102393. /**
  102394. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  102395. */
  102396. export class AttachToBoxBehavior implements Behavior<Mesh> {
  102397. private ui;
  102398. /**
  102399. * The name of the behavior
  102400. */
  102401. name: string;
  102402. /**
  102403. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  102404. */
  102405. distanceAwayFromFace: number;
  102406. /**
  102407. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  102408. */
  102409. distanceAwayFromBottomOfFace: number;
  102410. private _faceVectors;
  102411. private _target;
  102412. private _scene;
  102413. private _onRenderObserver;
  102414. private _tmpMatrix;
  102415. private _tmpVector;
  102416. /**
  102417. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  102418. * @param ui The transform node that should be attched to the mesh
  102419. */
  102420. constructor(ui: TransformNode);
  102421. /**
  102422. * Initializes the behavior
  102423. */
  102424. init(): void;
  102425. private _closestFace;
  102426. private _zeroVector;
  102427. private _lookAtTmpMatrix;
  102428. private _lookAtToRef;
  102429. /**
  102430. * Attaches the AttachToBoxBehavior to the passed in mesh
  102431. * @param target The mesh that the specified node will be attached to
  102432. */
  102433. attach(target: Mesh): void;
  102434. /**
  102435. * Detaches the behavior from the mesh
  102436. */
  102437. detach(): void;
  102438. }
  102439. }
  102440. declare module BABYLON {
  102441. /**
  102442. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  102443. */
  102444. export class FadeInOutBehavior implements Behavior<Mesh> {
  102445. /**
  102446. * Time in milliseconds to delay before fading in (Default: 0)
  102447. */
  102448. delay: number;
  102449. /**
  102450. * Time in milliseconds for the mesh to fade in (Default: 300)
  102451. */
  102452. fadeInTime: number;
  102453. private _millisecondsPerFrame;
  102454. private _hovered;
  102455. private _hoverValue;
  102456. private _ownerNode;
  102457. /**
  102458. * Instatiates the FadeInOutBehavior
  102459. */
  102460. constructor();
  102461. /**
  102462. * The name of the behavior
  102463. */
  102464. readonly name: string;
  102465. /**
  102466. * Initializes the behavior
  102467. */
  102468. init(): void;
  102469. /**
  102470. * Attaches the fade behavior on the passed in mesh
  102471. * @param ownerNode The mesh that will be faded in/out once attached
  102472. */
  102473. attach(ownerNode: Mesh): void;
  102474. /**
  102475. * Detaches the behavior from the mesh
  102476. */
  102477. detach(): void;
  102478. /**
  102479. * Triggers the mesh to begin fading in or out
  102480. * @param value if the object should fade in or out (true to fade in)
  102481. */
  102482. fadeIn(value: boolean): void;
  102483. private _update;
  102484. private _setAllVisibility;
  102485. }
  102486. }
  102487. declare module BABYLON {
  102488. /**
  102489. * Class containing a set of static utilities functions for managing Pivots
  102490. * @hidden
  102491. */
  102492. export class PivotTools {
  102493. private static _PivotCached;
  102494. private static _OldPivotPoint;
  102495. private static _PivotTranslation;
  102496. private static _PivotTmpVector;
  102497. /** @hidden */
  102498. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  102499. /** @hidden */
  102500. static _RestorePivotPoint(mesh: AbstractMesh): void;
  102501. }
  102502. }
  102503. declare module BABYLON {
  102504. /**
  102505. * Class containing static functions to help procedurally build meshes
  102506. */
  102507. export class PlaneBuilder {
  102508. /**
  102509. * Creates a plane mesh
  102510. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  102511. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  102512. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  102513. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102514. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102515. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102516. * @param name defines the name of the mesh
  102517. * @param options defines the options used to create the mesh
  102518. * @param scene defines the hosting scene
  102519. * @returns the plane mesh
  102520. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  102521. */
  102522. static CreatePlane(name: string, options: {
  102523. size?: number;
  102524. width?: number;
  102525. height?: number;
  102526. sideOrientation?: number;
  102527. frontUVs?: Vector4;
  102528. backUVs?: Vector4;
  102529. updatable?: boolean;
  102530. sourcePlane?: Plane;
  102531. }, scene?: Nullable<Scene>): Mesh;
  102532. }
  102533. }
  102534. declare module BABYLON {
  102535. /**
  102536. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  102537. */
  102538. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  102539. private static _AnyMouseID;
  102540. /**
  102541. * Abstract mesh the behavior is set on
  102542. */
  102543. attachedNode: AbstractMesh;
  102544. private _dragPlane;
  102545. private _scene;
  102546. private _pointerObserver;
  102547. private _beforeRenderObserver;
  102548. private static _planeScene;
  102549. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  102550. /**
  102551. * 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)
  102552. */
  102553. maxDragAngle: number;
  102554. /**
  102555. * @hidden
  102556. */
  102557. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  102558. /**
  102559. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  102560. */
  102561. currentDraggingPointerID: number;
  102562. /**
  102563. * The last position where the pointer hit the drag plane in world space
  102564. */
  102565. lastDragPosition: Vector3;
  102566. /**
  102567. * If the behavior is currently in a dragging state
  102568. */
  102569. dragging: boolean;
  102570. /**
  102571. * 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)
  102572. */
  102573. dragDeltaRatio: number;
  102574. /**
  102575. * If the drag plane orientation should be updated during the dragging (Default: true)
  102576. */
  102577. updateDragPlane: boolean;
  102578. private _debugMode;
  102579. private _moving;
  102580. /**
  102581. * Fires each time the attached mesh is dragged with the pointer
  102582. * * delta between last drag position and current drag position in world space
  102583. * * dragDistance along the drag axis
  102584. * * dragPlaneNormal normal of the current drag plane used during the drag
  102585. * * dragPlanePoint in world space where the drag intersects the drag plane
  102586. */
  102587. onDragObservable: Observable<{
  102588. delta: Vector3;
  102589. dragPlanePoint: Vector3;
  102590. dragPlaneNormal: Vector3;
  102591. dragDistance: number;
  102592. pointerId: number;
  102593. }>;
  102594. /**
  102595. * Fires each time a drag begins (eg. mouse down on mesh)
  102596. */
  102597. onDragStartObservable: Observable<{
  102598. dragPlanePoint: Vector3;
  102599. pointerId: number;
  102600. }>;
  102601. /**
  102602. * Fires each time a drag ends (eg. mouse release after drag)
  102603. */
  102604. onDragEndObservable: Observable<{
  102605. dragPlanePoint: Vector3;
  102606. pointerId: number;
  102607. }>;
  102608. /**
  102609. * If the attached mesh should be moved when dragged
  102610. */
  102611. moveAttached: boolean;
  102612. /**
  102613. * If the drag behavior will react to drag events (Default: true)
  102614. */
  102615. enabled: boolean;
  102616. /**
  102617. * If pointer events should start and release the drag (Default: true)
  102618. */
  102619. startAndReleaseDragOnPointerEvents: boolean;
  102620. /**
  102621. * If camera controls should be detached during the drag
  102622. */
  102623. detachCameraControls: boolean;
  102624. /**
  102625. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  102626. */
  102627. useObjectOrienationForDragging: boolean;
  102628. private _options;
  102629. /**
  102630. * Creates a pointer drag behavior that can be attached to a mesh
  102631. * @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)
  102632. */
  102633. constructor(options?: {
  102634. dragAxis?: Vector3;
  102635. dragPlaneNormal?: Vector3;
  102636. });
  102637. /**
  102638. * Predicate to determine if it is valid to move the object to a new position when it is moved
  102639. */
  102640. validateDrag: (targetPosition: Vector3) => boolean;
  102641. /**
  102642. * The name of the behavior
  102643. */
  102644. readonly name: string;
  102645. /**
  102646. * Initializes the behavior
  102647. */
  102648. init(): void;
  102649. private _tmpVector;
  102650. private _alternatePickedPoint;
  102651. private _worldDragAxis;
  102652. private _targetPosition;
  102653. private _attachedElement;
  102654. /**
  102655. * Attaches the drag behavior the passed in mesh
  102656. * @param ownerNode The mesh that will be dragged around once attached
  102657. * @param predicate Predicate to use for pick filtering
  102658. */
  102659. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  102660. /**
  102661. * Force relase the drag action by code.
  102662. */
  102663. releaseDrag(): void;
  102664. private _startDragRay;
  102665. private _lastPointerRay;
  102666. /**
  102667. * Simulates the start of a pointer drag event on the behavior
  102668. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  102669. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  102670. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  102671. */
  102672. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  102673. private _startDrag;
  102674. private _dragDelta;
  102675. private _moveDrag;
  102676. private _pickWithRayOnDragPlane;
  102677. private _pointA;
  102678. private _pointB;
  102679. private _pointC;
  102680. private _lineA;
  102681. private _lineB;
  102682. private _localAxis;
  102683. private _lookAt;
  102684. private _updateDragPlanePosition;
  102685. /**
  102686. * Detaches the behavior from the mesh
  102687. */
  102688. detach(): void;
  102689. }
  102690. }
  102691. declare module BABYLON {
  102692. /**
  102693. * A behavior that when attached to a mesh will allow the mesh to be scaled
  102694. */
  102695. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  102696. private _dragBehaviorA;
  102697. private _dragBehaviorB;
  102698. private _startDistance;
  102699. private _initialScale;
  102700. private _targetScale;
  102701. private _ownerNode;
  102702. private _sceneRenderObserver;
  102703. /**
  102704. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  102705. */
  102706. constructor();
  102707. /**
  102708. * The name of the behavior
  102709. */
  102710. readonly name: string;
  102711. /**
  102712. * Initializes the behavior
  102713. */
  102714. init(): void;
  102715. private _getCurrentDistance;
  102716. /**
  102717. * Attaches the scale behavior the passed in mesh
  102718. * @param ownerNode The mesh that will be scaled around once attached
  102719. */
  102720. attach(ownerNode: Mesh): void;
  102721. /**
  102722. * Detaches the behavior from the mesh
  102723. */
  102724. detach(): void;
  102725. }
  102726. }
  102727. declare module BABYLON {
  102728. /**
  102729. * 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
  102730. */
  102731. export class SixDofDragBehavior implements Behavior<Mesh> {
  102732. private static _virtualScene;
  102733. private _ownerNode;
  102734. private _sceneRenderObserver;
  102735. private _scene;
  102736. private _targetPosition;
  102737. private _virtualOriginMesh;
  102738. private _virtualDragMesh;
  102739. private _pointerObserver;
  102740. private _moving;
  102741. private _startingOrientation;
  102742. /**
  102743. * 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)
  102744. */
  102745. private zDragFactor;
  102746. /**
  102747. * If the object should rotate to face the drag origin
  102748. */
  102749. rotateDraggedObject: boolean;
  102750. /**
  102751. * If the behavior is currently in a dragging state
  102752. */
  102753. dragging: boolean;
  102754. /**
  102755. * 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)
  102756. */
  102757. dragDeltaRatio: number;
  102758. /**
  102759. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  102760. */
  102761. currentDraggingPointerID: number;
  102762. /**
  102763. * If camera controls should be detached during the drag
  102764. */
  102765. detachCameraControls: boolean;
  102766. /**
  102767. * Fires each time a drag starts
  102768. */
  102769. onDragStartObservable: Observable<{}>;
  102770. /**
  102771. * Fires each time a drag ends (eg. mouse release after drag)
  102772. */
  102773. onDragEndObservable: Observable<{}>;
  102774. /**
  102775. * 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
  102776. */
  102777. constructor();
  102778. /**
  102779. * The name of the behavior
  102780. */
  102781. readonly name: string;
  102782. /**
  102783. * Initializes the behavior
  102784. */
  102785. init(): void;
  102786. /**
  102787. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  102788. */
  102789. private readonly _pointerCamera;
  102790. /**
  102791. * Attaches the scale behavior the passed in mesh
  102792. * @param ownerNode The mesh that will be scaled around once attached
  102793. */
  102794. attach(ownerNode: Mesh): void;
  102795. /**
  102796. * Detaches the behavior from the mesh
  102797. */
  102798. detach(): void;
  102799. }
  102800. }
  102801. declare module BABYLON {
  102802. /**
  102803. * Class used to apply inverse kinematics to bones
  102804. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  102805. */
  102806. export class BoneIKController {
  102807. private static _tmpVecs;
  102808. private static _tmpQuat;
  102809. private static _tmpMats;
  102810. /**
  102811. * Gets or sets the target mesh
  102812. */
  102813. targetMesh: AbstractMesh;
  102814. /** Gets or sets the mesh used as pole */
  102815. poleTargetMesh: AbstractMesh;
  102816. /**
  102817. * Gets or sets the bone used as pole
  102818. */
  102819. poleTargetBone: Nullable<Bone>;
  102820. /**
  102821. * Gets or sets the target position
  102822. */
  102823. targetPosition: Vector3;
  102824. /**
  102825. * Gets or sets the pole target position
  102826. */
  102827. poleTargetPosition: Vector3;
  102828. /**
  102829. * Gets or sets the pole target local offset
  102830. */
  102831. poleTargetLocalOffset: Vector3;
  102832. /**
  102833. * Gets or sets the pole angle
  102834. */
  102835. poleAngle: number;
  102836. /**
  102837. * Gets or sets the mesh associated with the controller
  102838. */
  102839. mesh: AbstractMesh;
  102840. /**
  102841. * 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)
  102842. */
  102843. slerpAmount: number;
  102844. private _bone1Quat;
  102845. private _bone1Mat;
  102846. private _bone2Ang;
  102847. private _bone1;
  102848. private _bone2;
  102849. private _bone1Length;
  102850. private _bone2Length;
  102851. private _maxAngle;
  102852. private _maxReach;
  102853. private _rightHandedSystem;
  102854. private _bendAxis;
  102855. private _slerping;
  102856. private _adjustRoll;
  102857. /**
  102858. * Gets or sets maximum allowed angle
  102859. */
  102860. maxAngle: number;
  102861. /**
  102862. * Creates a new BoneIKController
  102863. * @param mesh defines the mesh to control
  102864. * @param bone defines the bone to control
  102865. * @param options defines options to set up the controller
  102866. */
  102867. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  102868. targetMesh?: AbstractMesh;
  102869. poleTargetMesh?: AbstractMesh;
  102870. poleTargetBone?: Bone;
  102871. poleTargetLocalOffset?: Vector3;
  102872. poleAngle?: number;
  102873. bendAxis?: Vector3;
  102874. maxAngle?: number;
  102875. slerpAmount?: number;
  102876. });
  102877. private _setMaxAngle;
  102878. /**
  102879. * Force the controller to update the bones
  102880. */
  102881. update(): void;
  102882. }
  102883. }
  102884. declare module BABYLON {
  102885. /**
  102886. * Class used to make a bone look toward a point in space
  102887. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  102888. */
  102889. export class BoneLookController {
  102890. private static _tmpVecs;
  102891. private static _tmpQuat;
  102892. private static _tmpMats;
  102893. /**
  102894. * The target Vector3 that the bone will look at
  102895. */
  102896. target: Vector3;
  102897. /**
  102898. * The mesh that the bone is attached to
  102899. */
  102900. mesh: AbstractMesh;
  102901. /**
  102902. * The bone that will be looking to the target
  102903. */
  102904. bone: Bone;
  102905. /**
  102906. * The up axis of the coordinate system that is used when the bone is rotated
  102907. */
  102908. upAxis: Vector3;
  102909. /**
  102910. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  102911. */
  102912. upAxisSpace: Space;
  102913. /**
  102914. * Used to make an adjustment to the yaw of the bone
  102915. */
  102916. adjustYaw: number;
  102917. /**
  102918. * Used to make an adjustment to the pitch of the bone
  102919. */
  102920. adjustPitch: number;
  102921. /**
  102922. * Used to make an adjustment to the roll of the bone
  102923. */
  102924. adjustRoll: number;
  102925. /**
  102926. * 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)
  102927. */
  102928. slerpAmount: number;
  102929. private _minYaw;
  102930. private _maxYaw;
  102931. private _minPitch;
  102932. private _maxPitch;
  102933. private _minYawSin;
  102934. private _minYawCos;
  102935. private _maxYawSin;
  102936. private _maxYawCos;
  102937. private _midYawConstraint;
  102938. private _minPitchTan;
  102939. private _maxPitchTan;
  102940. private _boneQuat;
  102941. private _slerping;
  102942. private _transformYawPitch;
  102943. private _transformYawPitchInv;
  102944. private _firstFrameSkipped;
  102945. private _yawRange;
  102946. private _fowardAxis;
  102947. /**
  102948. * Gets or sets the minimum yaw angle that the bone can look to
  102949. */
  102950. minYaw: number;
  102951. /**
  102952. * Gets or sets the maximum yaw angle that the bone can look to
  102953. */
  102954. maxYaw: number;
  102955. /**
  102956. * Gets or sets the minimum pitch angle that the bone can look to
  102957. */
  102958. minPitch: number;
  102959. /**
  102960. * Gets or sets the maximum pitch angle that the bone can look to
  102961. */
  102962. maxPitch: number;
  102963. /**
  102964. * Create a BoneLookController
  102965. * @param mesh the mesh that the bone belongs to
  102966. * @param bone the bone that will be looking to the target
  102967. * @param target the target Vector3 to look at
  102968. * @param options optional settings:
  102969. * * maxYaw: the maximum angle the bone will yaw to
  102970. * * minYaw: the minimum angle the bone will yaw to
  102971. * * maxPitch: the maximum angle the bone will pitch to
  102972. * * minPitch: the minimum angle the bone will yaw to
  102973. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  102974. * * upAxis: the up axis of the coordinate system
  102975. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  102976. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  102977. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  102978. * * adjustYaw: used to make an adjustment to the yaw of the bone
  102979. * * adjustPitch: used to make an adjustment to the pitch of the bone
  102980. * * adjustRoll: used to make an adjustment to the roll of the bone
  102981. **/
  102982. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  102983. maxYaw?: number;
  102984. minYaw?: number;
  102985. maxPitch?: number;
  102986. minPitch?: number;
  102987. slerpAmount?: number;
  102988. upAxis?: Vector3;
  102989. upAxisSpace?: Space;
  102990. yawAxis?: Vector3;
  102991. pitchAxis?: Vector3;
  102992. adjustYaw?: number;
  102993. adjustPitch?: number;
  102994. adjustRoll?: number;
  102995. });
  102996. /**
  102997. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  102998. */
  102999. update(): void;
  103000. private _getAngleDiff;
  103001. private _getAngleBetween;
  103002. private _isAngleBetween;
  103003. }
  103004. }
  103005. declare module BABYLON {
  103006. /**
  103007. * Manage the gamepad inputs to control an arc rotate camera.
  103008. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103009. */
  103010. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  103011. /**
  103012. * Defines the camera the input is attached to.
  103013. */
  103014. camera: ArcRotateCamera;
  103015. /**
  103016. * Defines the gamepad the input is gathering event from.
  103017. */
  103018. gamepad: Nullable<Gamepad>;
  103019. /**
  103020. * Defines the gamepad rotation sensiblity.
  103021. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  103022. */
  103023. gamepadRotationSensibility: number;
  103024. /**
  103025. * Defines the gamepad move sensiblity.
  103026. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  103027. */
  103028. gamepadMoveSensibility: number;
  103029. private _onGamepadConnectedObserver;
  103030. private _onGamepadDisconnectedObserver;
  103031. /**
  103032. * Attach the input controls to a specific dom element to get the input from.
  103033. * @param element Defines the element the controls should be listened from
  103034. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103035. */
  103036. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103037. /**
  103038. * Detach the current controls from the specified dom element.
  103039. * @param element Defines the element to stop listening the inputs from
  103040. */
  103041. detachControl(element: Nullable<HTMLElement>): void;
  103042. /**
  103043. * Update the current camera state depending on the inputs that have been used this frame.
  103044. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103045. */
  103046. checkInputs(): void;
  103047. /**
  103048. * Gets the class name of the current intput.
  103049. * @returns the class name
  103050. */
  103051. getClassName(): string;
  103052. /**
  103053. * Get the friendly name associated with the input class.
  103054. * @returns the input friendly name
  103055. */
  103056. getSimpleName(): string;
  103057. }
  103058. }
  103059. declare module BABYLON {
  103060. interface ArcRotateCameraInputsManager {
  103061. /**
  103062. * Add orientation input support to the input manager.
  103063. * @returns the current input manager
  103064. */
  103065. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  103066. }
  103067. /**
  103068. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  103069. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103070. */
  103071. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  103072. /**
  103073. * Defines the camera the input is attached to.
  103074. */
  103075. camera: ArcRotateCamera;
  103076. /**
  103077. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  103078. */
  103079. alphaCorrection: number;
  103080. /**
  103081. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  103082. */
  103083. gammaCorrection: number;
  103084. private _alpha;
  103085. private _gamma;
  103086. private _dirty;
  103087. private _deviceOrientationHandler;
  103088. /**
  103089. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  103090. */
  103091. constructor();
  103092. /**
  103093. * Attach the input controls to a specific dom element to get the input from.
  103094. * @param element Defines the element the controls should be listened from
  103095. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103096. */
  103097. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103098. /** @hidden */
  103099. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  103100. /**
  103101. * Update the current camera state depending on the inputs that have been used this frame.
  103102. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103103. */
  103104. checkInputs(): void;
  103105. /**
  103106. * Detach the current controls from the specified dom element.
  103107. * @param element Defines the element to stop listening the inputs from
  103108. */
  103109. detachControl(element: Nullable<HTMLElement>): void;
  103110. /**
  103111. * Gets the class name of the current intput.
  103112. * @returns the class name
  103113. */
  103114. getClassName(): string;
  103115. /**
  103116. * Get the friendly name associated with the input class.
  103117. * @returns the input friendly name
  103118. */
  103119. getSimpleName(): string;
  103120. }
  103121. }
  103122. declare module BABYLON {
  103123. /**
  103124. * Listen to mouse events to control the camera.
  103125. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103126. */
  103127. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  103128. /**
  103129. * Defines the camera the input is attached to.
  103130. */
  103131. camera: FlyCamera;
  103132. /**
  103133. * Defines if touch is enabled. (Default is true.)
  103134. */
  103135. touchEnabled: boolean;
  103136. /**
  103137. * Defines the buttons associated with the input to handle camera rotation.
  103138. */
  103139. buttons: number[];
  103140. /**
  103141. * Assign buttons for Yaw control.
  103142. */
  103143. buttonsYaw: number[];
  103144. /**
  103145. * Assign buttons for Pitch control.
  103146. */
  103147. buttonsPitch: number[];
  103148. /**
  103149. * Assign buttons for Roll control.
  103150. */
  103151. buttonsRoll: number[];
  103152. /**
  103153. * Detect if any button is being pressed while mouse is moved.
  103154. * -1 = Mouse locked.
  103155. * 0 = Left button.
  103156. * 1 = Middle Button.
  103157. * 2 = Right Button.
  103158. */
  103159. activeButton: number;
  103160. /**
  103161. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  103162. * Higher values reduce its sensitivity.
  103163. */
  103164. angularSensibility: number;
  103165. private _mousemoveCallback;
  103166. private _observer;
  103167. private _rollObserver;
  103168. private previousPosition;
  103169. private noPreventDefault;
  103170. private element;
  103171. /**
  103172. * Listen to mouse events to control the camera.
  103173. * @param touchEnabled Define if touch is enabled. (Default is true.)
  103174. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103175. */
  103176. constructor(touchEnabled?: boolean);
  103177. /**
  103178. * Attach the mouse control to the HTML DOM element.
  103179. * @param element Defines the element that listens to the input events.
  103180. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  103181. */
  103182. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103183. /**
  103184. * Detach the current controls from the specified dom element.
  103185. * @param element Defines the element to stop listening the inputs from
  103186. */
  103187. detachControl(element: Nullable<HTMLElement>): void;
  103188. /**
  103189. * Gets the class name of the current input.
  103190. * @returns the class name.
  103191. */
  103192. getClassName(): string;
  103193. /**
  103194. * Get the friendly name associated with the input class.
  103195. * @returns the input's friendly name.
  103196. */
  103197. getSimpleName(): string;
  103198. private _pointerInput;
  103199. private _onMouseMove;
  103200. /**
  103201. * Rotate camera by mouse offset.
  103202. */
  103203. private rotateCamera;
  103204. }
  103205. }
  103206. declare module BABYLON {
  103207. /**
  103208. * Default Inputs manager for the FlyCamera.
  103209. * It groups all the default supported inputs for ease of use.
  103210. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103211. */
  103212. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  103213. /**
  103214. * Instantiates a new FlyCameraInputsManager.
  103215. * @param camera Defines the camera the inputs belong to.
  103216. */
  103217. constructor(camera: FlyCamera);
  103218. /**
  103219. * Add keyboard input support to the input manager.
  103220. * @returns the new FlyCameraKeyboardMoveInput().
  103221. */
  103222. addKeyboard(): FlyCameraInputsManager;
  103223. /**
  103224. * Add mouse input support to the input manager.
  103225. * @param touchEnabled Enable touch screen support.
  103226. * @returns the new FlyCameraMouseInput().
  103227. */
  103228. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  103229. }
  103230. }
  103231. declare module BABYLON {
  103232. /**
  103233. * This is a flying camera, designed for 3D movement and rotation in all directions,
  103234. * such as in a 3D Space Shooter or a Flight Simulator.
  103235. */
  103236. export class FlyCamera extends TargetCamera {
  103237. /**
  103238. * Define the collision ellipsoid of the camera.
  103239. * This is helpful for simulating a camera body, like a player's body.
  103240. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  103241. */
  103242. ellipsoid: Vector3;
  103243. /**
  103244. * Define an offset for the position of the ellipsoid around the camera.
  103245. * This can be helpful if the camera is attached away from the player's body center,
  103246. * such as at its head.
  103247. */
  103248. ellipsoidOffset: Vector3;
  103249. /**
  103250. * Enable or disable collisions of the camera with the rest of the scene objects.
  103251. */
  103252. checkCollisions: boolean;
  103253. /**
  103254. * Enable or disable gravity on the camera.
  103255. */
  103256. applyGravity: boolean;
  103257. /**
  103258. * Define the current direction the camera is moving to.
  103259. */
  103260. cameraDirection: Vector3;
  103261. /**
  103262. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  103263. * This overrides and empties cameraRotation.
  103264. */
  103265. rotationQuaternion: Quaternion;
  103266. /**
  103267. * Track Roll to maintain the wanted Rolling when looking around.
  103268. */
  103269. _trackRoll: number;
  103270. /**
  103271. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  103272. */
  103273. rollCorrect: number;
  103274. /**
  103275. * Mimic a banked turn, Rolling the camera when Yawing.
  103276. * It's recommended to use rollCorrect = 10 for faster banking correction.
  103277. */
  103278. bankedTurn: boolean;
  103279. /**
  103280. * Limit in radians for how much Roll banking will add. (Default: 90°)
  103281. */
  103282. bankedTurnLimit: number;
  103283. /**
  103284. * Value of 0 disables the banked Roll.
  103285. * Value of 1 is equal to the Yaw angle in radians.
  103286. */
  103287. bankedTurnMultiplier: number;
  103288. /**
  103289. * The inputs manager loads all the input sources, such as keyboard and mouse.
  103290. */
  103291. inputs: FlyCameraInputsManager;
  103292. /**
  103293. * Gets the input sensibility for mouse input.
  103294. * Higher values reduce sensitivity.
  103295. */
  103296. /**
  103297. * Sets the input sensibility for a mouse input.
  103298. * Higher values reduce sensitivity.
  103299. */
  103300. angularSensibility: number;
  103301. /**
  103302. * Get the keys for camera movement forward.
  103303. */
  103304. /**
  103305. * Set the keys for camera movement forward.
  103306. */
  103307. keysForward: number[];
  103308. /**
  103309. * Get the keys for camera movement backward.
  103310. */
  103311. keysBackward: number[];
  103312. /**
  103313. * Get the keys for camera movement up.
  103314. */
  103315. /**
  103316. * Set the keys for camera movement up.
  103317. */
  103318. keysUp: number[];
  103319. /**
  103320. * Get the keys for camera movement down.
  103321. */
  103322. /**
  103323. * Set the keys for camera movement down.
  103324. */
  103325. keysDown: number[];
  103326. /**
  103327. * Get the keys for camera movement left.
  103328. */
  103329. /**
  103330. * Set the keys for camera movement left.
  103331. */
  103332. keysLeft: number[];
  103333. /**
  103334. * Set the keys for camera movement right.
  103335. */
  103336. /**
  103337. * Set the keys for camera movement right.
  103338. */
  103339. keysRight: number[];
  103340. /**
  103341. * Event raised when the camera collides with a mesh in the scene.
  103342. */
  103343. onCollide: (collidedMesh: AbstractMesh) => void;
  103344. private _collider;
  103345. private _needMoveForGravity;
  103346. private _oldPosition;
  103347. private _diffPosition;
  103348. private _newPosition;
  103349. /** @hidden */
  103350. _localDirection: Vector3;
  103351. /** @hidden */
  103352. _transformedDirection: Vector3;
  103353. /**
  103354. * Instantiates a FlyCamera.
  103355. * This is a flying camera, designed for 3D movement and rotation in all directions,
  103356. * such as in a 3D Space Shooter or a Flight Simulator.
  103357. * @param name Define the name of the camera in the scene.
  103358. * @param position Define the starting position of the camera in the scene.
  103359. * @param scene Define the scene the camera belongs to.
  103360. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  103361. */
  103362. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  103363. /**
  103364. * Attach a control to the HTML DOM element.
  103365. * @param element Defines the element that listens to the input events.
  103366. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  103367. */
  103368. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103369. /**
  103370. * Detach a control from the HTML DOM element.
  103371. * The camera will stop reacting to that input.
  103372. * @param element Defines the element that listens to the input events.
  103373. */
  103374. detachControl(element: HTMLElement): void;
  103375. private _collisionMask;
  103376. /**
  103377. * Get the mask that the camera ignores in collision events.
  103378. */
  103379. /**
  103380. * Set the mask that the camera ignores in collision events.
  103381. */
  103382. collisionMask: number;
  103383. /** @hidden */
  103384. _collideWithWorld(displacement: Vector3): void;
  103385. /** @hidden */
  103386. private _onCollisionPositionChange;
  103387. /** @hidden */
  103388. _checkInputs(): void;
  103389. /** @hidden */
  103390. _decideIfNeedsToMove(): boolean;
  103391. /** @hidden */
  103392. _updatePosition(): void;
  103393. /**
  103394. * Restore the Roll to its target value at the rate specified.
  103395. * @param rate - Higher means slower restoring.
  103396. * @hidden
  103397. */
  103398. restoreRoll(rate: number): void;
  103399. /**
  103400. * Destroy the camera and release the current resources held by it.
  103401. */
  103402. dispose(): void;
  103403. /**
  103404. * Get the current object class name.
  103405. * @returns the class name.
  103406. */
  103407. getClassName(): string;
  103408. }
  103409. }
  103410. declare module BABYLON {
  103411. /**
  103412. * Listen to keyboard events to control the camera.
  103413. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103414. */
  103415. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  103416. /**
  103417. * Defines the camera the input is attached to.
  103418. */
  103419. camera: FlyCamera;
  103420. /**
  103421. * The list of keyboard keys used to control the forward move of the camera.
  103422. */
  103423. keysForward: number[];
  103424. /**
  103425. * The list of keyboard keys used to control the backward move of the camera.
  103426. */
  103427. keysBackward: number[];
  103428. /**
  103429. * The list of keyboard keys used to control the forward move of the camera.
  103430. */
  103431. keysUp: number[];
  103432. /**
  103433. * The list of keyboard keys used to control the backward move of the camera.
  103434. */
  103435. keysDown: number[];
  103436. /**
  103437. * The list of keyboard keys used to control the right strafe move of the camera.
  103438. */
  103439. keysRight: number[];
  103440. /**
  103441. * The list of keyboard keys used to control the left strafe move of the camera.
  103442. */
  103443. keysLeft: number[];
  103444. private _keys;
  103445. private _onCanvasBlurObserver;
  103446. private _onKeyboardObserver;
  103447. private _engine;
  103448. private _scene;
  103449. /**
  103450. * Attach the input controls to a specific dom element to get the input from.
  103451. * @param element Defines the element the controls should be listened from
  103452. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103453. */
  103454. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103455. /**
  103456. * Detach the current controls from the specified dom element.
  103457. * @param element Defines the element to stop listening the inputs from
  103458. */
  103459. detachControl(element: Nullable<HTMLElement>): void;
  103460. /**
  103461. * Gets the class name of the current intput.
  103462. * @returns the class name
  103463. */
  103464. getClassName(): string;
  103465. /** @hidden */
  103466. _onLostFocus(e: FocusEvent): void;
  103467. /**
  103468. * Get the friendly name associated with the input class.
  103469. * @returns the input friendly name
  103470. */
  103471. getSimpleName(): string;
  103472. /**
  103473. * Update the current camera state depending on the inputs that have been used this frame.
  103474. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103475. */
  103476. checkInputs(): void;
  103477. }
  103478. }
  103479. declare module BABYLON {
  103480. /**
  103481. * Manage the mouse wheel inputs to control a follow camera.
  103482. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103483. */
  103484. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  103485. /**
  103486. * Defines the camera the input is attached to.
  103487. */
  103488. camera: FollowCamera;
  103489. /**
  103490. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  103491. */
  103492. axisControlRadius: boolean;
  103493. /**
  103494. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  103495. */
  103496. axisControlHeight: boolean;
  103497. /**
  103498. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  103499. */
  103500. axisControlRotation: boolean;
  103501. /**
  103502. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  103503. * relation to mouseWheel events.
  103504. */
  103505. wheelPrecision: number;
  103506. /**
  103507. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  103508. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  103509. */
  103510. wheelDeltaPercentage: number;
  103511. private _wheel;
  103512. private _observer;
  103513. /**
  103514. * Attach the input controls to a specific dom element to get the input from.
  103515. * @param element Defines the element the controls should be listened from
  103516. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103517. */
  103518. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103519. /**
  103520. * Detach the current controls from the specified dom element.
  103521. * @param element Defines the element to stop listening the inputs from
  103522. */
  103523. detachControl(element: Nullable<HTMLElement>): void;
  103524. /**
  103525. * Gets the class name of the current intput.
  103526. * @returns the class name
  103527. */
  103528. getClassName(): string;
  103529. /**
  103530. * Get the friendly name associated with the input class.
  103531. * @returns the input friendly name
  103532. */
  103533. getSimpleName(): string;
  103534. }
  103535. }
  103536. declare module BABYLON {
  103537. /**
  103538. * Manage the pointers inputs to control an follow camera.
  103539. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103540. */
  103541. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  103542. /**
  103543. * Defines the camera the input is attached to.
  103544. */
  103545. camera: FollowCamera;
  103546. /**
  103547. * Gets the class name of the current input.
  103548. * @returns the class name
  103549. */
  103550. getClassName(): string;
  103551. /**
  103552. * Defines the pointer angular sensibility along the X axis or how fast is
  103553. * the camera rotating.
  103554. * A negative number will reverse the axis direction.
  103555. */
  103556. angularSensibilityX: number;
  103557. /**
  103558. * Defines the pointer angular sensibility along the Y axis or how fast is
  103559. * the camera rotating.
  103560. * A negative number will reverse the axis direction.
  103561. */
  103562. angularSensibilityY: number;
  103563. /**
  103564. * Defines the pointer pinch precision or how fast is the camera zooming.
  103565. * A negative number will reverse the axis direction.
  103566. */
  103567. pinchPrecision: number;
  103568. /**
  103569. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  103570. * from 0.
  103571. * It defines the percentage of current camera.radius to use as delta when
  103572. * pinch zoom is used.
  103573. */
  103574. pinchDeltaPercentage: number;
  103575. /**
  103576. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  103577. */
  103578. axisXControlRadius: boolean;
  103579. /**
  103580. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  103581. */
  103582. axisXControlHeight: boolean;
  103583. /**
  103584. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  103585. */
  103586. axisXControlRotation: boolean;
  103587. /**
  103588. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  103589. */
  103590. axisYControlRadius: boolean;
  103591. /**
  103592. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  103593. */
  103594. axisYControlHeight: boolean;
  103595. /**
  103596. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  103597. */
  103598. axisYControlRotation: boolean;
  103599. /**
  103600. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  103601. */
  103602. axisPinchControlRadius: boolean;
  103603. /**
  103604. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  103605. */
  103606. axisPinchControlHeight: boolean;
  103607. /**
  103608. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  103609. */
  103610. axisPinchControlRotation: boolean;
  103611. /**
  103612. * Log error messages if basic misconfiguration has occurred.
  103613. */
  103614. warningEnable: boolean;
  103615. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  103616. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  103617. private _warningCounter;
  103618. private _warning;
  103619. }
  103620. }
  103621. declare module BABYLON {
  103622. /**
  103623. * Default Inputs manager for the FollowCamera.
  103624. * It groups all the default supported inputs for ease of use.
  103625. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103626. */
  103627. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  103628. /**
  103629. * Instantiates a new FollowCameraInputsManager.
  103630. * @param camera Defines the camera the inputs belong to
  103631. */
  103632. constructor(camera: FollowCamera);
  103633. /**
  103634. * Add keyboard input support to the input manager.
  103635. * @returns the current input manager
  103636. */
  103637. addKeyboard(): FollowCameraInputsManager;
  103638. /**
  103639. * Add mouse wheel input support to the input manager.
  103640. * @returns the current input manager
  103641. */
  103642. addMouseWheel(): FollowCameraInputsManager;
  103643. /**
  103644. * Add pointers input support to the input manager.
  103645. * @returns the current input manager
  103646. */
  103647. addPointers(): FollowCameraInputsManager;
  103648. /**
  103649. * Add orientation input support to the input manager.
  103650. * @returns the current input manager
  103651. */
  103652. addVRDeviceOrientation(): FollowCameraInputsManager;
  103653. }
  103654. }
  103655. declare module BABYLON {
  103656. /**
  103657. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  103658. * an arc rotate version arcFollowCamera are available.
  103659. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103660. */
  103661. export class FollowCamera extends TargetCamera {
  103662. /**
  103663. * Distance the follow camera should follow an object at
  103664. */
  103665. radius: number;
  103666. /**
  103667. * Minimum allowed distance of the camera to the axis of rotation
  103668. * (The camera can not get closer).
  103669. * This can help limiting how the Camera is able to move in the scene.
  103670. */
  103671. lowerRadiusLimit: Nullable<number>;
  103672. /**
  103673. * Maximum allowed distance of the camera to the axis of rotation
  103674. * (The camera can not get further).
  103675. * This can help limiting how the Camera is able to move in the scene.
  103676. */
  103677. upperRadiusLimit: Nullable<number>;
  103678. /**
  103679. * Define a rotation offset between the camera and the object it follows
  103680. */
  103681. rotationOffset: number;
  103682. /**
  103683. * Minimum allowed angle to camera position relative to target object.
  103684. * This can help limiting how the Camera is able to move in the scene.
  103685. */
  103686. lowerRotationOffsetLimit: Nullable<number>;
  103687. /**
  103688. * Maximum allowed angle to camera position relative to target object.
  103689. * This can help limiting how the Camera is able to move in the scene.
  103690. */
  103691. upperRotationOffsetLimit: Nullable<number>;
  103692. /**
  103693. * Define a height offset between the camera and the object it follows.
  103694. * It can help following an object from the top (like a car chaing a plane)
  103695. */
  103696. heightOffset: number;
  103697. /**
  103698. * Minimum allowed height of camera position relative to target object.
  103699. * This can help limiting how the Camera is able to move in the scene.
  103700. */
  103701. lowerHeightOffsetLimit: Nullable<number>;
  103702. /**
  103703. * Maximum allowed height of camera position relative to target object.
  103704. * This can help limiting how the Camera is able to move in the scene.
  103705. */
  103706. upperHeightOffsetLimit: Nullable<number>;
  103707. /**
  103708. * Define how fast the camera can accelerate to follow it s target.
  103709. */
  103710. cameraAcceleration: number;
  103711. /**
  103712. * Define the speed limit of the camera following an object.
  103713. */
  103714. maxCameraSpeed: number;
  103715. /**
  103716. * Define the target of the camera.
  103717. */
  103718. lockedTarget: Nullable<AbstractMesh>;
  103719. /**
  103720. * Defines the input associated with the camera.
  103721. */
  103722. inputs: FollowCameraInputsManager;
  103723. /**
  103724. * Instantiates the follow camera.
  103725. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103726. * @param name Define the name of the camera in the scene
  103727. * @param position Define the position of the camera
  103728. * @param scene Define the scene the camera belong to
  103729. * @param lockedTarget Define the target of the camera
  103730. */
  103731. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  103732. private _follow;
  103733. /**
  103734. * Attached controls to the current camera.
  103735. * @param element Defines the element the controls should be listened from
  103736. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103737. */
  103738. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103739. /**
  103740. * Detach the current controls from the camera.
  103741. * The camera will stop reacting to inputs.
  103742. * @param element Defines the element to stop listening the inputs from
  103743. */
  103744. detachControl(element: HTMLElement): void;
  103745. /** @hidden */
  103746. _checkInputs(): void;
  103747. private _checkLimits;
  103748. /**
  103749. * Gets the camera class name.
  103750. * @returns the class name
  103751. */
  103752. getClassName(): string;
  103753. }
  103754. /**
  103755. * Arc Rotate version of the follow camera.
  103756. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  103757. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103758. */
  103759. export class ArcFollowCamera extends TargetCamera {
  103760. /** The longitudinal angle of the camera */
  103761. alpha: number;
  103762. /** The latitudinal angle of the camera */
  103763. beta: number;
  103764. /** The radius of the camera from its target */
  103765. radius: number;
  103766. /** Define the camera target (the messh it should follow) */
  103767. target: Nullable<AbstractMesh>;
  103768. private _cartesianCoordinates;
  103769. /**
  103770. * Instantiates a new ArcFollowCamera
  103771. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103772. * @param name Define the name of the camera
  103773. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  103774. * @param beta Define the rotation angle of the camera around the elevation axis
  103775. * @param radius Define the radius of the camera from its target point
  103776. * @param target Define the target of the camera
  103777. * @param scene Define the scene the camera belongs to
  103778. */
  103779. constructor(name: string,
  103780. /** The longitudinal angle of the camera */
  103781. alpha: number,
  103782. /** The latitudinal angle of the camera */
  103783. beta: number,
  103784. /** The radius of the camera from its target */
  103785. radius: number,
  103786. /** Define the camera target (the messh it should follow) */
  103787. target: Nullable<AbstractMesh>, scene: Scene);
  103788. private _follow;
  103789. /** @hidden */
  103790. _checkInputs(): void;
  103791. /**
  103792. * Returns the class name of the object.
  103793. * It is mostly used internally for serialization purposes.
  103794. */
  103795. getClassName(): string;
  103796. }
  103797. }
  103798. declare module BABYLON {
  103799. /**
  103800. * Manage the keyboard inputs to control the movement of a follow camera.
  103801. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103802. */
  103803. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  103804. /**
  103805. * Defines the camera the input is attached to.
  103806. */
  103807. camera: FollowCamera;
  103808. /**
  103809. * Defines the list of key codes associated with the up action (increase heightOffset)
  103810. */
  103811. keysHeightOffsetIncr: number[];
  103812. /**
  103813. * Defines the list of key codes associated with the down action (decrease heightOffset)
  103814. */
  103815. keysHeightOffsetDecr: number[];
  103816. /**
  103817. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  103818. */
  103819. keysHeightOffsetModifierAlt: boolean;
  103820. /**
  103821. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  103822. */
  103823. keysHeightOffsetModifierCtrl: boolean;
  103824. /**
  103825. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  103826. */
  103827. keysHeightOffsetModifierShift: boolean;
  103828. /**
  103829. * Defines the list of key codes associated with the left action (increase rotationOffset)
  103830. */
  103831. keysRotationOffsetIncr: number[];
  103832. /**
  103833. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  103834. */
  103835. keysRotationOffsetDecr: number[];
  103836. /**
  103837. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  103838. */
  103839. keysRotationOffsetModifierAlt: boolean;
  103840. /**
  103841. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  103842. */
  103843. keysRotationOffsetModifierCtrl: boolean;
  103844. /**
  103845. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  103846. */
  103847. keysRotationOffsetModifierShift: boolean;
  103848. /**
  103849. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  103850. */
  103851. keysRadiusIncr: number[];
  103852. /**
  103853. * Defines the list of key codes associated with the zoom-out action (increase radius)
  103854. */
  103855. keysRadiusDecr: number[];
  103856. /**
  103857. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  103858. */
  103859. keysRadiusModifierAlt: boolean;
  103860. /**
  103861. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  103862. */
  103863. keysRadiusModifierCtrl: boolean;
  103864. /**
  103865. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  103866. */
  103867. keysRadiusModifierShift: boolean;
  103868. /**
  103869. * Defines the rate of change of heightOffset.
  103870. */
  103871. heightSensibility: number;
  103872. /**
  103873. * Defines the rate of change of rotationOffset.
  103874. */
  103875. rotationSensibility: number;
  103876. /**
  103877. * Defines the rate of change of radius.
  103878. */
  103879. radiusSensibility: number;
  103880. private _keys;
  103881. private _ctrlPressed;
  103882. private _altPressed;
  103883. private _shiftPressed;
  103884. private _onCanvasBlurObserver;
  103885. private _onKeyboardObserver;
  103886. private _engine;
  103887. private _scene;
  103888. /**
  103889. * Attach the input controls to a specific dom element to get the input from.
  103890. * @param element Defines the element the controls should be listened from
  103891. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103892. */
  103893. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103894. /**
  103895. * Detach the current controls from the specified dom element.
  103896. * @param element Defines the element to stop listening the inputs from
  103897. */
  103898. detachControl(element: Nullable<HTMLElement>): void;
  103899. /**
  103900. * Update the current camera state depending on the inputs that have been used this frame.
  103901. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103902. */
  103903. checkInputs(): void;
  103904. /**
  103905. * Gets the class name of the current input.
  103906. * @returns the class name
  103907. */
  103908. getClassName(): string;
  103909. /**
  103910. * Get the friendly name associated with the input class.
  103911. * @returns the input friendly name
  103912. */
  103913. getSimpleName(): string;
  103914. /**
  103915. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  103916. * allow modification of the heightOffset value.
  103917. */
  103918. private _modifierHeightOffset;
  103919. /**
  103920. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  103921. * allow modification of the rotationOffset value.
  103922. */
  103923. private _modifierRotationOffset;
  103924. /**
  103925. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  103926. * allow modification of the radius value.
  103927. */
  103928. private _modifierRadius;
  103929. }
  103930. }
  103931. declare module BABYLON {
  103932. interface FreeCameraInputsManager {
  103933. /**
  103934. * @hidden
  103935. */
  103936. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  103937. /**
  103938. * Add orientation input support to the input manager.
  103939. * @returns the current input manager
  103940. */
  103941. addDeviceOrientation(): FreeCameraInputsManager;
  103942. }
  103943. /**
  103944. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  103945. * Screen rotation is taken into account.
  103946. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103947. */
  103948. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  103949. private _camera;
  103950. private _screenOrientationAngle;
  103951. private _constantTranform;
  103952. private _screenQuaternion;
  103953. private _alpha;
  103954. private _beta;
  103955. private _gamma;
  103956. /**
  103957. * Can be used to detect if a device orientation sensor is availible on a device
  103958. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  103959. * @returns a promise that will resolve on orientation change
  103960. */
  103961. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  103962. /**
  103963. * @hidden
  103964. */
  103965. _onDeviceOrientationChangedObservable: Observable<void>;
  103966. /**
  103967. * Instantiates a new input
  103968. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103969. */
  103970. constructor();
  103971. /**
  103972. * Define the camera controlled by the input.
  103973. */
  103974. camera: FreeCamera;
  103975. /**
  103976. * Attach the input controls to a specific dom element to get the input from.
  103977. * @param element Defines the element the controls should be listened from
  103978. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103979. */
  103980. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103981. private _orientationChanged;
  103982. private _deviceOrientation;
  103983. /**
  103984. * Detach the current controls from the specified dom element.
  103985. * @param element Defines the element to stop listening the inputs from
  103986. */
  103987. detachControl(element: Nullable<HTMLElement>): void;
  103988. /**
  103989. * Update the current camera state depending on the inputs that have been used this frame.
  103990. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103991. */
  103992. checkInputs(): void;
  103993. /**
  103994. * Gets the class name of the current intput.
  103995. * @returns the class name
  103996. */
  103997. getClassName(): string;
  103998. /**
  103999. * Get the friendly name associated with the input class.
  104000. * @returns the input friendly name
  104001. */
  104002. getSimpleName(): string;
  104003. }
  104004. }
  104005. declare module BABYLON {
  104006. /**
  104007. * Manage the gamepad inputs to control a free camera.
  104008. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104009. */
  104010. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  104011. /**
  104012. * Define the camera the input is attached to.
  104013. */
  104014. camera: FreeCamera;
  104015. /**
  104016. * Define the Gamepad controlling the input
  104017. */
  104018. gamepad: Nullable<Gamepad>;
  104019. /**
  104020. * Defines the gamepad rotation sensiblity.
  104021. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  104022. */
  104023. gamepadAngularSensibility: number;
  104024. /**
  104025. * Defines the gamepad move sensiblity.
  104026. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  104027. */
  104028. gamepadMoveSensibility: number;
  104029. private _onGamepadConnectedObserver;
  104030. private _onGamepadDisconnectedObserver;
  104031. private _cameraTransform;
  104032. private _deltaTransform;
  104033. private _vector3;
  104034. private _vector2;
  104035. /**
  104036. * Attach the input controls to a specific dom element to get the input from.
  104037. * @param element Defines the element the controls should be listened from
  104038. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104039. */
  104040. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104041. /**
  104042. * Detach the current controls from the specified dom element.
  104043. * @param element Defines the element to stop listening the inputs from
  104044. */
  104045. detachControl(element: Nullable<HTMLElement>): void;
  104046. /**
  104047. * Update the current camera state depending on the inputs that have been used this frame.
  104048. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104049. */
  104050. checkInputs(): void;
  104051. /**
  104052. * Gets the class name of the current intput.
  104053. * @returns the class name
  104054. */
  104055. getClassName(): string;
  104056. /**
  104057. * Get the friendly name associated with the input class.
  104058. * @returns the input friendly name
  104059. */
  104060. getSimpleName(): string;
  104061. }
  104062. }
  104063. declare module BABYLON {
  104064. /**
  104065. * Defines the potential axis of a Joystick
  104066. */
  104067. export enum JoystickAxis {
  104068. /** X axis */
  104069. X = 0,
  104070. /** Y axis */
  104071. Y = 1,
  104072. /** Z axis */
  104073. Z = 2
  104074. }
  104075. /**
  104076. * Class used to define virtual joystick (used in touch mode)
  104077. */
  104078. export class VirtualJoystick {
  104079. /**
  104080. * Gets or sets a boolean indicating that left and right values must be inverted
  104081. */
  104082. reverseLeftRight: boolean;
  104083. /**
  104084. * Gets or sets a boolean indicating that up and down values must be inverted
  104085. */
  104086. reverseUpDown: boolean;
  104087. /**
  104088. * Gets the offset value for the position (ie. the change of the position value)
  104089. */
  104090. deltaPosition: Vector3;
  104091. /**
  104092. * Gets a boolean indicating if the virtual joystick was pressed
  104093. */
  104094. pressed: boolean;
  104095. /**
  104096. * Canvas the virtual joystick will render onto, default z-index of this is 5
  104097. */
  104098. static Canvas: Nullable<HTMLCanvasElement>;
  104099. private static _globalJoystickIndex;
  104100. private static vjCanvasContext;
  104101. private static vjCanvasWidth;
  104102. private static vjCanvasHeight;
  104103. private static halfWidth;
  104104. private _action;
  104105. private _axisTargetedByLeftAndRight;
  104106. private _axisTargetedByUpAndDown;
  104107. private _joystickSensibility;
  104108. private _inversedSensibility;
  104109. private _joystickPointerID;
  104110. private _joystickColor;
  104111. private _joystickPointerPos;
  104112. private _joystickPreviousPointerPos;
  104113. private _joystickPointerStartPos;
  104114. private _deltaJoystickVector;
  104115. private _leftJoystick;
  104116. private _touches;
  104117. private _onPointerDownHandlerRef;
  104118. private _onPointerMoveHandlerRef;
  104119. private _onPointerUpHandlerRef;
  104120. private _onResize;
  104121. /**
  104122. * Creates a new virtual joystick
  104123. * @param leftJoystick defines that the joystick is for left hand (false by default)
  104124. */
  104125. constructor(leftJoystick?: boolean);
  104126. /**
  104127. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  104128. * @param newJoystickSensibility defines the new sensibility
  104129. */
  104130. setJoystickSensibility(newJoystickSensibility: number): void;
  104131. private _onPointerDown;
  104132. private _onPointerMove;
  104133. private _onPointerUp;
  104134. /**
  104135. * Change the color of the virtual joystick
  104136. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  104137. */
  104138. setJoystickColor(newColor: string): void;
  104139. /**
  104140. * Defines a callback to call when the joystick is touched
  104141. * @param action defines the callback
  104142. */
  104143. setActionOnTouch(action: () => any): void;
  104144. /**
  104145. * Defines which axis you'd like to control for left & right
  104146. * @param axis defines the axis to use
  104147. */
  104148. setAxisForLeftRight(axis: JoystickAxis): void;
  104149. /**
  104150. * Defines which axis you'd like to control for up & down
  104151. * @param axis defines the axis to use
  104152. */
  104153. setAxisForUpDown(axis: JoystickAxis): void;
  104154. private _drawVirtualJoystick;
  104155. /**
  104156. * Release internal HTML canvas
  104157. */
  104158. releaseCanvas(): void;
  104159. }
  104160. }
  104161. declare module BABYLON {
  104162. interface FreeCameraInputsManager {
  104163. /**
  104164. * Add virtual joystick input support to the input manager.
  104165. * @returns the current input manager
  104166. */
  104167. addVirtualJoystick(): FreeCameraInputsManager;
  104168. }
  104169. /**
  104170. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  104171. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104172. */
  104173. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  104174. /**
  104175. * Defines the camera the input is attached to.
  104176. */
  104177. camera: FreeCamera;
  104178. private _leftjoystick;
  104179. private _rightjoystick;
  104180. /**
  104181. * Gets the left stick of the virtual joystick.
  104182. * @returns The virtual Joystick
  104183. */
  104184. getLeftJoystick(): VirtualJoystick;
  104185. /**
  104186. * Gets the right stick of the virtual joystick.
  104187. * @returns The virtual Joystick
  104188. */
  104189. getRightJoystick(): VirtualJoystick;
  104190. /**
  104191. * Update the current camera state depending on the inputs that have been used this frame.
  104192. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104193. */
  104194. checkInputs(): void;
  104195. /**
  104196. * Attach the input controls to a specific dom element to get the input from.
  104197. * @param element Defines the element the controls should be listened from
  104198. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104199. */
  104200. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104201. /**
  104202. * Detach the current controls from the specified dom element.
  104203. * @param element Defines the element to stop listening the inputs from
  104204. */
  104205. detachControl(element: Nullable<HTMLElement>): void;
  104206. /**
  104207. * Gets the class name of the current intput.
  104208. * @returns the class name
  104209. */
  104210. getClassName(): string;
  104211. /**
  104212. * Get the friendly name associated with the input class.
  104213. * @returns the input friendly name
  104214. */
  104215. getSimpleName(): string;
  104216. }
  104217. }
  104218. declare module BABYLON {
  104219. /**
  104220. * This represents a FPS type of camera controlled by touch.
  104221. * This is like a universal camera minus the Gamepad controls.
  104222. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104223. */
  104224. export class TouchCamera extends FreeCamera {
  104225. /**
  104226. * Defines the touch sensibility for rotation.
  104227. * The higher the faster.
  104228. */
  104229. touchAngularSensibility: number;
  104230. /**
  104231. * Defines the touch sensibility for move.
  104232. * The higher the faster.
  104233. */
  104234. touchMoveSensibility: number;
  104235. /**
  104236. * Instantiates a new touch camera.
  104237. * This represents a FPS type of camera controlled by touch.
  104238. * This is like a universal camera minus the Gamepad controls.
  104239. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104240. * @param name Define the name of the camera in the scene
  104241. * @param position Define the start position of the camera in the scene
  104242. * @param scene Define the scene the camera belongs to
  104243. */
  104244. constructor(name: string, position: Vector3, scene: Scene);
  104245. /**
  104246. * Gets the current object class name.
  104247. * @return the class name
  104248. */
  104249. getClassName(): string;
  104250. /** @hidden */
  104251. _setupInputs(): void;
  104252. }
  104253. }
  104254. declare module BABYLON {
  104255. /**
  104256. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  104257. * being tilted forward or back and left or right.
  104258. */
  104259. export class DeviceOrientationCamera extends FreeCamera {
  104260. private _initialQuaternion;
  104261. private _quaternionCache;
  104262. private _tmpDragQuaternion;
  104263. private _disablePointerInputWhenUsingDeviceOrientation;
  104264. /**
  104265. * Creates a new device orientation camera
  104266. * @param name The name of the camera
  104267. * @param position The start position camera
  104268. * @param scene The scene the camera belongs to
  104269. */
  104270. constructor(name: string, position: Vector3, scene: Scene);
  104271. /**
  104272. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  104273. */
  104274. disablePointerInputWhenUsingDeviceOrientation: boolean;
  104275. private _dragFactor;
  104276. /**
  104277. * Enabled turning on the y axis when the orientation sensor is active
  104278. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  104279. */
  104280. enableHorizontalDragging(dragFactor?: number): void;
  104281. /**
  104282. * Gets the current instance class name ("DeviceOrientationCamera").
  104283. * This helps avoiding instanceof at run time.
  104284. * @returns the class name
  104285. */
  104286. getClassName(): string;
  104287. /**
  104288. * @hidden
  104289. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  104290. */
  104291. _checkInputs(): void;
  104292. /**
  104293. * Reset the camera to its default orientation on the specified axis only.
  104294. * @param axis The axis to reset
  104295. */
  104296. resetToCurrentRotation(axis?: Axis): void;
  104297. }
  104298. }
  104299. declare module BABYLON {
  104300. /**
  104301. * Defines supported buttons for XBox360 compatible gamepads
  104302. */
  104303. export enum Xbox360Button {
  104304. /** A */
  104305. A = 0,
  104306. /** B */
  104307. B = 1,
  104308. /** X */
  104309. X = 2,
  104310. /** Y */
  104311. Y = 3,
  104312. /** Start */
  104313. Start = 4,
  104314. /** Back */
  104315. Back = 5,
  104316. /** Left button */
  104317. LB = 6,
  104318. /** Right button */
  104319. RB = 7,
  104320. /** Left stick */
  104321. LeftStick = 8,
  104322. /** Right stick */
  104323. RightStick = 9
  104324. }
  104325. /** Defines values for XBox360 DPad */
  104326. export enum Xbox360Dpad {
  104327. /** Up */
  104328. Up = 0,
  104329. /** Down */
  104330. Down = 1,
  104331. /** Left */
  104332. Left = 2,
  104333. /** Right */
  104334. Right = 3
  104335. }
  104336. /**
  104337. * Defines a XBox360 gamepad
  104338. */
  104339. export class Xbox360Pad extends Gamepad {
  104340. private _leftTrigger;
  104341. private _rightTrigger;
  104342. private _onlefttriggerchanged;
  104343. private _onrighttriggerchanged;
  104344. private _onbuttondown;
  104345. private _onbuttonup;
  104346. private _ondpaddown;
  104347. private _ondpadup;
  104348. /** Observable raised when a button is pressed */
  104349. onButtonDownObservable: Observable<Xbox360Button>;
  104350. /** Observable raised when a button is released */
  104351. onButtonUpObservable: Observable<Xbox360Button>;
  104352. /** Observable raised when a pad is pressed */
  104353. onPadDownObservable: Observable<Xbox360Dpad>;
  104354. /** Observable raised when a pad is released */
  104355. onPadUpObservable: Observable<Xbox360Dpad>;
  104356. private _buttonA;
  104357. private _buttonB;
  104358. private _buttonX;
  104359. private _buttonY;
  104360. private _buttonBack;
  104361. private _buttonStart;
  104362. private _buttonLB;
  104363. private _buttonRB;
  104364. private _buttonLeftStick;
  104365. private _buttonRightStick;
  104366. private _dPadUp;
  104367. private _dPadDown;
  104368. private _dPadLeft;
  104369. private _dPadRight;
  104370. private _isXboxOnePad;
  104371. /**
  104372. * Creates a new XBox360 gamepad object
  104373. * @param id defines the id of this gamepad
  104374. * @param index defines its index
  104375. * @param gamepad defines the internal HTML gamepad object
  104376. * @param xboxOne defines if it is a XBox One gamepad
  104377. */
  104378. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  104379. /**
  104380. * Defines the callback to call when left trigger is pressed
  104381. * @param callback defines the callback to use
  104382. */
  104383. onlefttriggerchanged(callback: (value: number) => void): void;
  104384. /**
  104385. * Defines the callback to call when right trigger is pressed
  104386. * @param callback defines the callback to use
  104387. */
  104388. onrighttriggerchanged(callback: (value: number) => void): void;
  104389. /**
  104390. * Gets the left trigger value
  104391. */
  104392. /**
  104393. * Sets the left trigger value
  104394. */
  104395. leftTrigger: number;
  104396. /**
  104397. * Gets the right trigger value
  104398. */
  104399. /**
  104400. * Sets the right trigger value
  104401. */
  104402. rightTrigger: number;
  104403. /**
  104404. * Defines the callback to call when a button is pressed
  104405. * @param callback defines the callback to use
  104406. */
  104407. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  104408. /**
  104409. * Defines the callback to call when a button is released
  104410. * @param callback defines the callback to use
  104411. */
  104412. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  104413. /**
  104414. * Defines the callback to call when a pad is pressed
  104415. * @param callback defines the callback to use
  104416. */
  104417. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  104418. /**
  104419. * Defines the callback to call when a pad is released
  104420. * @param callback defines the callback to use
  104421. */
  104422. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  104423. private _setButtonValue;
  104424. private _setDPadValue;
  104425. /**
  104426. * Gets the value of the `A` button
  104427. */
  104428. /**
  104429. * Sets the value of the `A` button
  104430. */
  104431. buttonA: number;
  104432. /**
  104433. * Gets the value of the `B` button
  104434. */
  104435. /**
  104436. * Sets the value of the `B` button
  104437. */
  104438. buttonB: number;
  104439. /**
  104440. * Gets the value of the `X` button
  104441. */
  104442. /**
  104443. * Sets the value of the `X` button
  104444. */
  104445. buttonX: number;
  104446. /**
  104447. * Gets the value of the `Y` button
  104448. */
  104449. /**
  104450. * Sets the value of the `Y` button
  104451. */
  104452. buttonY: number;
  104453. /**
  104454. * Gets the value of the `Start` button
  104455. */
  104456. /**
  104457. * Sets the value of the `Start` button
  104458. */
  104459. buttonStart: number;
  104460. /**
  104461. * Gets the value of the `Back` button
  104462. */
  104463. /**
  104464. * Sets the value of the `Back` button
  104465. */
  104466. buttonBack: number;
  104467. /**
  104468. * Gets the value of the `Left` button
  104469. */
  104470. /**
  104471. * Sets the value of the `Left` button
  104472. */
  104473. buttonLB: number;
  104474. /**
  104475. * Gets the value of the `Right` button
  104476. */
  104477. /**
  104478. * Sets the value of the `Right` button
  104479. */
  104480. buttonRB: number;
  104481. /**
  104482. * Gets the value of the Left joystick
  104483. */
  104484. /**
  104485. * Sets the value of the Left joystick
  104486. */
  104487. buttonLeftStick: number;
  104488. /**
  104489. * Gets the value of the Right joystick
  104490. */
  104491. /**
  104492. * Sets the value of the Right joystick
  104493. */
  104494. buttonRightStick: number;
  104495. /**
  104496. * Gets the value of D-pad up
  104497. */
  104498. /**
  104499. * Sets the value of D-pad up
  104500. */
  104501. dPadUp: number;
  104502. /**
  104503. * Gets the value of D-pad down
  104504. */
  104505. /**
  104506. * Sets the value of D-pad down
  104507. */
  104508. dPadDown: number;
  104509. /**
  104510. * Gets the value of D-pad left
  104511. */
  104512. /**
  104513. * Sets the value of D-pad left
  104514. */
  104515. dPadLeft: number;
  104516. /**
  104517. * Gets the value of D-pad right
  104518. */
  104519. /**
  104520. * Sets the value of D-pad right
  104521. */
  104522. dPadRight: number;
  104523. /**
  104524. * Force the gamepad to synchronize with device values
  104525. */
  104526. update(): void;
  104527. /**
  104528. * Disposes the gamepad
  104529. */
  104530. dispose(): void;
  104531. }
  104532. }
  104533. declare module BABYLON {
  104534. /**
  104535. * Defines supported buttons for DualShock compatible gamepads
  104536. */
  104537. export enum DualShockButton {
  104538. /** Cross */
  104539. Cross = 0,
  104540. /** Circle */
  104541. Circle = 1,
  104542. /** Square */
  104543. Square = 2,
  104544. /** Triangle */
  104545. Triangle = 3,
  104546. /** Options */
  104547. Options = 4,
  104548. /** Share */
  104549. Share = 5,
  104550. /** L1 */
  104551. L1 = 6,
  104552. /** R1 */
  104553. R1 = 7,
  104554. /** Left stick */
  104555. LeftStick = 8,
  104556. /** Right stick */
  104557. RightStick = 9
  104558. }
  104559. /** Defines values for DualShock DPad */
  104560. export enum DualShockDpad {
  104561. /** Up */
  104562. Up = 0,
  104563. /** Down */
  104564. Down = 1,
  104565. /** Left */
  104566. Left = 2,
  104567. /** Right */
  104568. Right = 3
  104569. }
  104570. /**
  104571. * Defines a DualShock gamepad
  104572. */
  104573. export class DualShockPad extends Gamepad {
  104574. private _leftTrigger;
  104575. private _rightTrigger;
  104576. private _onlefttriggerchanged;
  104577. private _onrighttriggerchanged;
  104578. private _onbuttondown;
  104579. private _onbuttonup;
  104580. private _ondpaddown;
  104581. private _ondpadup;
  104582. /** Observable raised when a button is pressed */
  104583. onButtonDownObservable: Observable<DualShockButton>;
  104584. /** Observable raised when a button is released */
  104585. onButtonUpObservable: Observable<DualShockButton>;
  104586. /** Observable raised when a pad is pressed */
  104587. onPadDownObservable: Observable<DualShockDpad>;
  104588. /** Observable raised when a pad is released */
  104589. onPadUpObservable: Observable<DualShockDpad>;
  104590. private _buttonCross;
  104591. private _buttonCircle;
  104592. private _buttonSquare;
  104593. private _buttonTriangle;
  104594. private _buttonShare;
  104595. private _buttonOptions;
  104596. private _buttonL1;
  104597. private _buttonR1;
  104598. private _buttonLeftStick;
  104599. private _buttonRightStick;
  104600. private _dPadUp;
  104601. private _dPadDown;
  104602. private _dPadLeft;
  104603. private _dPadRight;
  104604. /**
  104605. * Creates a new DualShock gamepad object
  104606. * @param id defines the id of this gamepad
  104607. * @param index defines its index
  104608. * @param gamepad defines the internal HTML gamepad object
  104609. */
  104610. constructor(id: string, index: number, gamepad: any);
  104611. /**
  104612. * Defines the callback to call when left trigger is pressed
  104613. * @param callback defines the callback to use
  104614. */
  104615. onlefttriggerchanged(callback: (value: number) => void): void;
  104616. /**
  104617. * Defines the callback to call when right trigger is pressed
  104618. * @param callback defines the callback to use
  104619. */
  104620. onrighttriggerchanged(callback: (value: number) => void): void;
  104621. /**
  104622. * Gets the left trigger value
  104623. */
  104624. /**
  104625. * Sets the left trigger value
  104626. */
  104627. leftTrigger: number;
  104628. /**
  104629. * Gets the right trigger value
  104630. */
  104631. /**
  104632. * Sets the right trigger value
  104633. */
  104634. rightTrigger: number;
  104635. /**
  104636. * Defines the callback to call when a button is pressed
  104637. * @param callback defines the callback to use
  104638. */
  104639. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  104640. /**
  104641. * Defines the callback to call when a button is released
  104642. * @param callback defines the callback to use
  104643. */
  104644. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  104645. /**
  104646. * Defines the callback to call when a pad is pressed
  104647. * @param callback defines the callback to use
  104648. */
  104649. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  104650. /**
  104651. * Defines the callback to call when a pad is released
  104652. * @param callback defines the callback to use
  104653. */
  104654. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  104655. private _setButtonValue;
  104656. private _setDPadValue;
  104657. /**
  104658. * Gets the value of the `Cross` button
  104659. */
  104660. /**
  104661. * Sets the value of the `Cross` button
  104662. */
  104663. buttonCross: number;
  104664. /**
  104665. * Gets the value of the `Circle` button
  104666. */
  104667. /**
  104668. * Sets the value of the `Circle` button
  104669. */
  104670. buttonCircle: number;
  104671. /**
  104672. * Gets the value of the `Square` button
  104673. */
  104674. /**
  104675. * Sets the value of the `Square` button
  104676. */
  104677. buttonSquare: number;
  104678. /**
  104679. * Gets the value of the `Triangle` button
  104680. */
  104681. /**
  104682. * Sets the value of the `Triangle` button
  104683. */
  104684. buttonTriangle: number;
  104685. /**
  104686. * Gets the value of the `Options` button
  104687. */
  104688. /**
  104689. * Sets the value of the `Options` button
  104690. */
  104691. buttonOptions: number;
  104692. /**
  104693. * Gets the value of the `Share` button
  104694. */
  104695. /**
  104696. * Sets the value of the `Share` button
  104697. */
  104698. buttonShare: number;
  104699. /**
  104700. * Gets the value of the `L1` button
  104701. */
  104702. /**
  104703. * Sets the value of the `L1` button
  104704. */
  104705. buttonL1: number;
  104706. /**
  104707. * Gets the value of the `R1` button
  104708. */
  104709. /**
  104710. * Sets the value of the `R1` button
  104711. */
  104712. buttonR1: number;
  104713. /**
  104714. * Gets the value of the Left joystick
  104715. */
  104716. /**
  104717. * Sets the value of the Left joystick
  104718. */
  104719. buttonLeftStick: number;
  104720. /**
  104721. * Gets the value of the Right joystick
  104722. */
  104723. /**
  104724. * Sets the value of the Right joystick
  104725. */
  104726. buttonRightStick: number;
  104727. /**
  104728. * Gets the value of D-pad up
  104729. */
  104730. /**
  104731. * Sets the value of D-pad up
  104732. */
  104733. dPadUp: number;
  104734. /**
  104735. * Gets the value of D-pad down
  104736. */
  104737. /**
  104738. * Sets the value of D-pad down
  104739. */
  104740. dPadDown: number;
  104741. /**
  104742. * Gets the value of D-pad left
  104743. */
  104744. /**
  104745. * Sets the value of D-pad left
  104746. */
  104747. dPadLeft: number;
  104748. /**
  104749. * Gets the value of D-pad right
  104750. */
  104751. /**
  104752. * Sets the value of D-pad right
  104753. */
  104754. dPadRight: number;
  104755. /**
  104756. * Force the gamepad to synchronize with device values
  104757. */
  104758. update(): void;
  104759. /**
  104760. * Disposes the gamepad
  104761. */
  104762. dispose(): void;
  104763. }
  104764. }
  104765. declare module BABYLON {
  104766. /**
  104767. * Manager for handling gamepads
  104768. */
  104769. export class GamepadManager {
  104770. private _scene?;
  104771. private _babylonGamepads;
  104772. private _oneGamepadConnected;
  104773. /** @hidden */
  104774. _isMonitoring: boolean;
  104775. private _gamepadEventSupported;
  104776. private _gamepadSupport;
  104777. /**
  104778. * observable to be triggered when the gamepad controller has been connected
  104779. */
  104780. onGamepadConnectedObservable: Observable<Gamepad>;
  104781. /**
  104782. * observable to be triggered when the gamepad controller has been disconnected
  104783. */
  104784. onGamepadDisconnectedObservable: Observable<Gamepad>;
  104785. private _onGamepadConnectedEvent;
  104786. private _onGamepadDisconnectedEvent;
  104787. /**
  104788. * Initializes the gamepad manager
  104789. * @param _scene BabylonJS scene
  104790. */
  104791. constructor(_scene?: Scene | undefined);
  104792. /**
  104793. * The gamepads in the game pad manager
  104794. */
  104795. readonly gamepads: Gamepad[];
  104796. /**
  104797. * Get the gamepad controllers based on type
  104798. * @param type The type of gamepad controller
  104799. * @returns Nullable gamepad
  104800. */
  104801. getGamepadByType(type?: number): Nullable<Gamepad>;
  104802. /**
  104803. * Disposes the gamepad manager
  104804. */
  104805. dispose(): void;
  104806. private _addNewGamepad;
  104807. private _startMonitoringGamepads;
  104808. private _stopMonitoringGamepads;
  104809. /** @hidden */
  104810. _checkGamepadsStatus(): void;
  104811. private _updateGamepadObjects;
  104812. }
  104813. }
  104814. declare module BABYLON {
  104815. interface Scene {
  104816. /** @hidden */
  104817. _gamepadManager: Nullable<GamepadManager>;
  104818. /**
  104819. * Gets the gamepad manager associated with the scene
  104820. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  104821. */
  104822. gamepadManager: GamepadManager;
  104823. }
  104824. /**
  104825. * Interface representing a free camera inputs manager
  104826. */
  104827. interface FreeCameraInputsManager {
  104828. /**
  104829. * Adds gamepad input support to the FreeCameraInputsManager.
  104830. * @returns the FreeCameraInputsManager
  104831. */
  104832. addGamepad(): FreeCameraInputsManager;
  104833. }
  104834. /**
  104835. * Interface representing an arc rotate camera inputs manager
  104836. */
  104837. interface ArcRotateCameraInputsManager {
  104838. /**
  104839. * Adds gamepad input support to the ArcRotateCamera InputManager.
  104840. * @returns the camera inputs manager
  104841. */
  104842. addGamepad(): ArcRotateCameraInputsManager;
  104843. }
  104844. /**
  104845. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  104846. */
  104847. export class GamepadSystemSceneComponent implements ISceneComponent {
  104848. /**
  104849. * The component name helpfull to identify the component in the list of scene components.
  104850. */
  104851. readonly name: string;
  104852. /**
  104853. * The scene the component belongs to.
  104854. */
  104855. scene: Scene;
  104856. /**
  104857. * Creates a new instance of the component for the given scene
  104858. * @param scene Defines the scene to register the component in
  104859. */
  104860. constructor(scene: Scene);
  104861. /**
  104862. * Registers the component in a given scene
  104863. */
  104864. register(): void;
  104865. /**
  104866. * Rebuilds the elements related to this component in case of
  104867. * context lost for instance.
  104868. */
  104869. rebuild(): void;
  104870. /**
  104871. * Disposes the component and the associated ressources
  104872. */
  104873. dispose(): void;
  104874. private _beforeCameraUpdate;
  104875. }
  104876. }
  104877. declare module BABYLON {
  104878. /**
  104879. * 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,
  104880. * which still works and will still be found in many Playgrounds.
  104881. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104882. */
  104883. export class UniversalCamera extends TouchCamera {
  104884. /**
  104885. * Defines the gamepad rotation sensiblity.
  104886. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  104887. */
  104888. gamepadAngularSensibility: number;
  104889. /**
  104890. * Defines the gamepad move sensiblity.
  104891. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  104892. */
  104893. gamepadMoveSensibility: number;
  104894. /**
  104895. * 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,
  104896. * which still works and will still be found in many Playgrounds.
  104897. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104898. * @param name Define the name of the camera in the scene
  104899. * @param position Define the start position of the camera in the scene
  104900. * @param scene Define the scene the camera belongs to
  104901. */
  104902. constructor(name: string, position: Vector3, scene: Scene);
  104903. /**
  104904. * Gets the current object class name.
  104905. * @return the class name
  104906. */
  104907. getClassName(): string;
  104908. }
  104909. }
  104910. declare module BABYLON {
  104911. /**
  104912. * This represents a FPS type of camera. This is only here for back compat purpose.
  104913. * Please use the UniversalCamera instead as both are identical.
  104914. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104915. */
  104916. export class GamepadCamera extends UniversalCamera {
  104917. /**
  104918. * Instantiates a new Gamepad Camera
  104919. * This represents a FPS type of camera. This is only here for back compat purpose.
  104920. * Please use the UniversalCamera instead as both are identical.
  104921. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104922. * @param name Define the name of the camera in the scene
  104923. * @param position Define the start position of the camera in the scene
  104924. * @param scene Define the scene the camera belongs to
  104925. */
  104926. constructor(name: string, position: Vector3, scene: Scene);
  104927. /**
  104928. * Gets the current object class name.
  104929. * @return the class name
  104930. */
  104931. getClassName(): string;
  104932. }
  104933. }
  104934. declare module BABYLON {
  104935. /** @hidden */
  104936. export var passPixelShader: {
  104937. name: string;
  104938. shader: string;
  104939. };
  104940. }
  104941. declare module BABYLON {
  104942. /** @hidden */
  104943. export var passCubePixelShader: {
  104944. name: string;
  104945. shader: string;
  104946. };
  104947. }
  104948. declare module BABYLON {
  104949. /**
  104950. * PassPostProcess which produces an output the same as it's input
  104951. */
  104952. export class PassPostProcess extends PostProcess {
  104953. /**
  104954. * Creates the PassPostProcess
  104955. * @param name The name of the effect.
  104956. * @param options The required width/height ratio to downsize to before computing the render pass.
  104957. * @param camera The camera to apply the render pass to.
  104958. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104959. * @param engine The engine which the post process will be applied. (default: current engine)
  104960. * @param reusable If the post process can be reused on the same frame. (default: false)
  104961. * @param textureType The type of texture to be used when performing the post processing.
  104962. * @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)
  104963. */
  104964. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  104965. }
  104966. /**
  104967. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  104968. */
  104969. export class PassCubePostProcess extends PostProcess {
  104970. private _face;
  104971. /**
  104972. * Gets or sets the cube face to display.
  104973. * * 0 is +X
  104974. * * 1 is -X
  104975. * * 2 is +Y
  104976. * * 3 is -Y
  104977. * * 4 is +Z
  104978. * * 5 is -Z
  104979. */
  104980. face: number;
  104981. /**
  104982. * Creates the PassCubePostProcess
  104983. * @param name The name of the effect.
  104984. * @param options The required width/height ratio to downsize to before computing the render pass.
  104985. * @param camera The camera to apply the render pass to.
  104986. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104987. * @param engine The engine which the post process will be applied. (default: current engine)
  104988. * @param reusable If the post process can be reused on the same frame. (default: false)
  104989. * @param textureType The type of texture to be used when performing the post processing.
  104990. * @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)
  104991. */
  104992. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  104993. }
  104994. }
  104995. declare module BABYLON {
  104996. /** @hidden */
  104997. export var anaglyphPixelShader: {
  104998. name: string;
  104999. shader: string;
  105000. };
  105001. }
  105002. declare module BABYLON {
  105003. /**
  105004. * Postprocess used to generate anaglyphic rendering
  105005. */
  105006. export class AnaglyphPostProcess extends PostProcess {
  105007. private _passedProcess;
  105008. /**
  105009. * Creates a new AnaglyphPostProcess
  105010. * @param name defines postprocess name
  105011. * @param options defines creation options or target ratio scale
  105012. * @param rigCameras defines cameras using this postprocess
  105013. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  105014. * @param engine defines hosting engine
  105015. * @param reusable defines if the postprocess will be reused multiple times per frame
  105016. */
  105017. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  105018. }
  105019. }
  105020. declare module BABYLON {
  105021. /**
  105022. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  105023. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  105024. */
  105025. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  105026. /**
  105027. * Creates a new AnaglyphArcRotateCamera
  105028. * @param name defines camera name
  105029. * @param alpha defines alpha angle (in radians)
  105030. * @param beta defines beta angle (in radians)
  105031. * @param radius defines radius
  105032. * @param target defines camera target
  105033. * @param interaxialDistance defines distance between each color axis
  105034. * @param scene defines the hosting scene
  105035. */
  105036. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  105037. /**
  105038. * Gets camera class name
  105039. * @returns AnaglyphArcRotateCamera
  105040. */
  105041. getClassName(): string;
  105042. }
  105043. }
  105044. declare module BABYLON {
  105045. /**
  105046. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  105047. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  105048. */
  105049. export class AnaglyphFreeCamera extends FreeCamera {
  105050. /**
  105051. * Creates a new AnaglyphFreeCamera
  105052. * @param name defines camera name
  105053. * @param position defines initial position
  105054. * @param interaxialDistance defines distance between each color axis
  105055. * @param scene defines the hosting scene
  105056. */
  105057. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  105058. /**
  105059. * Gets camera class name
  105060. * @returns AnaglyphFreeCamera
  105061. */
  105062. getClassName(): string;
  105063. }
  105064. }
  105065. declare module BABYLON {
  105066. /**
  105067. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  105068. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  105069. */
  105070. export class AnaglyphGamepadCamera extends GamepadCamera {
  105071. /**
  105072. * Creates a new AnaglyphGamepadCamera
  105073. * @param name defines camera name
  105074. * @param position defines initial position
  105075. * @param interaxialDistance defines distance between each color axis
  105076. * @param scene defines the hosting scene
  105077. */
  105078. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  105079. /**
  105080. * Gets camera class name
  105081. * @returns AnaglyphGamepadCamera
  105082. */
  105083. getClassName(): string;
  105084. }
  105085. }
  105086. declare module BABYLON {
  105087. /**
  105088. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  105089. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  105090. */
  105091. export class AnaglyphUniversalCamera extends UniversalCamera {
  105092. /**
  105093. * Creates a new AnaglyphUniversalCamera
  105094. * @param name defines camera name
  105095. * @param position defines initial position
  105096. * @param interaxialDistance defines distance between each color axis
  105097. * @param scene defines the hosting scene
  105098. */
  105099. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  105100. /**
  105101. * Gets camera class name
  105102. * @returns AnaglyphUniversalCamera
  105103. */
  105104. getClassName(): string;
  105105. }
  105106. }
  105107. declare module BABYLON {
  105108. /** @hidden */
  105109. export var stereoscopicInterlacePixelShader: {
  105110. name: string;
  105111. shader: string;
  105112. };
  105113. }
  105114. declare module BABYLON {
  105115. /**
  105116. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  105117. */
  105118. export class StereoscopicInterlacePostProcess extends PostProcess {
  105119. private _stepSize;
  105120. private _passedProcess;
  105121. /**
  105122. * Initializes a StereoscopicInterlacePostProcess
  105123. * @param name The name of the effect.
  105124. * @param rigCameras The rig cameras to be appled to the post process
  105125. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  105126. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105127. * @param engine The engine which the post process will be applied. (default: current engine)
  105128. * @param reusable If the post process can be reused on the same frame. (default: false)
  105129. */
  105130. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  105131. }
  105132. }
  105133. declare module BABYLON {
  105134. /**
  105135. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  105136. * @see http://doc.babylonjs.com/features/cameras
  105137. */
  105138. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  105139. /**
  105140. * Creates a new StereoscopicArcRotateCamera
  105141. * @param name defines camera name
  105142. * @param alpha defines alpha angle (in radians)
  105143. * @param beta defines beta angle (in radians)
  105144. * @param radius defines radius
  105145. * @param target defines camera target
  105146. * @param interaxialDistance defines distance between each color axis
  105147. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  105148. * @param scene defines the hosting scene
  105149. */
  105150. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  105151. /**
  105152. * Gets camera class name
  105153. * @returns StereoscopicArcRotateCamera
  105154. */
  105155. getClassName(): string;
  105156. }
  105157. }
  105158. declare module BABYLON {
  105159. /**
  105160. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  105161. * @see http://doc.babylonjs.com/features/cameras
  105162. */
  105163. export class StereoscopicFreeCamera extends FreeCamera {
  105164. /**
  105165. * Creates a new StereoscopicFreeCamera
  105166. * @param name defines camera name
  105167. * @param position defines initial position
  105168. * @param interaxialDistance defines distance between each color axis
  105169. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  105170. * @param scene defines the hosting scene
  105171. */
  105172. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  105173. /**
  105174. * Gets camera class name
  105175. * @returns StereoscopicFreeCamera
  105176. */
  105177. getClassName(): string;
  105178. }
  105179. }
  105180. declare module BABYLON {
  105181. /**
  105182. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  105183. * @see http://doc.babylonjs.com/features/cameras
  105184. */
  105185. export class StereoscopicGamepadCamera extends GamepadCamera {
  105186. /**
  105187. * Creates a new StereoscopicGamepadCamera
  105188. * @param name defines camera name
  105189. * @param position defines initial position
  105190. * @param interaxialDistance defines distance between each color axis
  105191. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  105192. * @param scene defines the hosting scene
  105193. */
  105194. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  105195. /**
  105196. * Gets camera class name
  105197. * @returns StereoscopicGamepadCamera
  105198. */
  105199. getClassName(): string;
  105200. }
  105201. }
  105202. declare module BABYLON {
  105203. /**
  105204. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  105205. * @see http://doc.babylonjs.com/features/cameras
  105206. */
  105207. export class StereoscopicUniversalCamera extends UniversalCamera {
  105208. /**
  105209. * Creates a new StereoscopicUniversalCamera
  105210. * @param name defines camera name
  105211. * @param position defines initial position
  105212. * @param interaxialDistance defines distance between each color axis
  105213. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  105214. * @param scene defines the hosting scene
  105215. */
  105216. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  105217. /**
  105218. * Gets camera class name
  105219. * @returns StereoscopicUniversalCamera
  105220. */
  105221. getClassName(): string;
  105222. }
  105223. }
  105224. declare module BABYLON {
  105225. /**
  105226. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  105227. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  105228. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  105229. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  105230. */
  105231. export class VirtualJoysticksCamera extends FreeCamera {
  105232. /**
  105233. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  105234. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  105235. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  105236. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  105237. * @param name Define the name of the camera in the scene
  105238. * @param position Define the start position of the camera in the scene
  105239. * @param scene Define the scene the camera belongs to
  105240. */
  105241. constructor(name: string, position: Vector3, scene: Scene);
  105242. /**
  105243. * Gets the current object class name.
  105244. * @return the class name
  105245. */
  105246. getClassName(): string;
  105247. }
  105248. }
  105249. declare module BABYLON {
  105250. /**
  105251. * This represents all the required metrics to create a VR camera.
  105252. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  105253. */
  105254. export class VRCameraMetrics {
  105255. /**
  105256. * Define the horizontal resolution off the screen.
  105257. */
  105258. hResolution: number;
  105259. /**
  105260. * Define the vertical resolution off the screen.
  105261. */
  105262. vResolution: number;
  105263. /**
  105264. * Define the horizontal screen size.
  105265. */
  105266. hScreenSize: number;
  105267. /**
  105268. * Define the vertical screen size.
  105269. */
  105270. vScreenSize: number;
  105271. /**
  105272. * Define the vertical screen center position.
  105273. */
  105274. vScreenCenter: number;
  105275. /**
  105276. * Define the distance of the eyes to the screen.
  105277. */
  105278. eyeToScreenDistance: number;
  105279. /**
  105280. * Define the distance between both lenses
  105281. */
  105282. lensSeparationDistance: number;
  105283. /**
  105284. * Define the distance between both viewer's eyes.
  105285. */
  105286. interpupillaryDistance: number;
  105287. /**
  105288. * Define the distortion factor of the VR postprocess.
  105289. * Please, touch with care.
  105290. */
  105291. distortionK: number[];
  105292. /**
  105293. * Define the chromatic aberration correction factors for the VR post process.
  105294. */
  105295. chromaAbCorrection: number[];
  105296. /**
  105297. * Define the scale factor of the post process.
  105298. * The smaller the better but the slower.
  105299. */
  105300. postProcessScaleFactor: number;
  105301. /**
  105302. * Define an offset for the lens center.
  105303. */
  105304. lensCenterOffset: number;
  105305. /**
  105306. * Define if the current vr camera should compensate the distortion of the lense or not.
  105307. */
  105308. compensateDistortion: boolean;
  105309. /**
  105310. * Defines if multiview should be enabled when rendering (Default: false)
  105311. */
  105312. multiviewEnabled: boolean;
  105313. /**
  105314. * Gets the rendering aspect ratio based on the provided resolutions.
  105315. */
  105316. readonly aspectRatio: number;
  105317. /**
  105318. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  105319. */
  105320. readonly aspectRatioFov: number;
  105321. /**
  105322. * @hidden
  105323. */
  105324. readonly leftHMatrix: Matrix;
  105325. /**
  105326. * @hidden
  105327. */
  105328. readonly rightHMatrix: Matrix;
  105329. /**
  105330. * @hidden
  105331. */
  105332. readonly leftPreViewMatrix: Matrix;
  105333. /**
  105334. * @hidden
  105335. */
  105336. readonly rightPreViewMatrix: Matrix;
  105337. /**
  105338. * Get the default VRMetrics based on the most generic setup.
  105339. * @returns the default vr metrics
  105340. */
  105341. static GetDefault(): VRCameraMetrics;
  105342. }
  105343. }
  105344. declare module BABYLON {
  105345. /** @hidden */
  105346. export var vrDistortionCorrectionPixelShader: {
  105347. name: string;
  105348. shader: string;
  105349. };
  105350. }
  105351. declare module BABYLON {
  105352. /**
  105353. * VRDistortionCorrectionPostProcess used for mobile VR
  105354. */
  105355. export class VRDistortionCorrectionPostProcess extends PostProcess {
  105356. private _isRightEye;
  105357. private _distortionFactors;
  105358. private _postProcessScaleFactor;
  105359. private _lensCenterOffset;
  105360. private _scaleIn;
  105361. private _scaleFactor;
  105362. private _lensCenter;
  105363. /**
  105364. * Initializes the VRDistortionCorrectionPostProcess
  105365. * @param name The name of the effect.
  105366. * @param camera The camera to apply the render pass to.
  105367. * @param isRightEye If this is for the right eye distortion
  105368. * @param vrMetrics All the required metrics for the VR camera
  105369. */
  105370. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  105371. }
  105372. }
  105373. declare module BABYLON {
  105374. /**
  105375. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  105376. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  105377. */
  105378. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  105379. /**
  105380. * Creates a new VRDeviceOrientationArcRotateCamera
  105381. * @param name defines camera name
  105382. * @param alpha defines the camera rotation along the logitudinal axis
  105383. * @param beta defines the camera rotation along the latitudinal axis
  105384. * @param radius defines the camera distance from its target
  105385. * @param target defines the camera target
  105386. * @param scene defines the scene the camera belongs to
  105387. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  105388. * @param vrCameraMetrics defines the vr metrics associated to the camera
  105389. */
  105390. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  105391. /**
  105392. * Gets camera class name
  105393. * @returns VRDeviceOrientationArcRotateCamera
  105394. */
  105395. getClassName(): string;
  105396. }
  105397. }
  105398. declare module BABYLON {
  105399. /**
  105400. * Camera used to simulate VR rendering (based on FreeCamera)
  105401. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  105402. */
  105403. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  105404. /**
  105405. * Creates a new VRDeviceOrientationFreeCamera
  105406. * @param name defines camera name
  105407. * @param position defines the start position of the camera
  105408. * @param scene defines the scene the camera belongs to
  105409. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  105410. * @param vrCameraMetrics defines the vr metrics associated to the camera
  105411. */
  105412. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  105413. /**
  105414. * Gets camera class name
  105415. * @returns VRDeviceOrientationFreeCamera
  105416. */
  105417. getClassName(): string;
  105418. }
  105419. }
  105420. declare module BABYLON {
  105421. /**
  105422. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  105423. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  105424. */
  105425. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  105426. /**
  105427. * Creates a new VRDeviceOrientationGamepadCamera
  105428. * @param name defines camera name
  105429. * @param position defines the start position of the camera
  105430. * @param scene defines the scene the camera belongs to
  105431. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  105432. * @param vrCameraMetrics defines the vr metrics associated to the camera
  105433. */
  105434. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  105435. /**
  105436. * Gets camera class name
  105437. * @returns VRDeviceOrientationGamepadCamera
  105438. */
  105439. getClassName(): string;
  105440. }
  105441. }
  105442. declare module BABYLON {
  105443. /**
  105444. * Base class of materials working in push mode in babylon JS
  105445. * @hidden
  105446. */
  105447. export class PushMaterial extends Material {
  105448. protected _activeEffect: Effect;
  105449. protected _normalMatrix: Matrix;
  105450. /**
  105451. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  105452. * This means that the material can keep using a previous shader while a new one is being compiled.
  105453. * This is mostly used when shader parallel compilation is supported (true by default)
  105454. */
  105455. allowShaderHotSwapping: boolean;
  105456. constructor(name: string, scene: Scene);
  105457. getEffect(): Effect;
  105458. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  105459. /**
  105460. * Binds the given world matrix to the active effect
  105461. *
  105462. * @param world the matrix to bind
  105463. */
  105464. bindOnlyWorldMatrix(world: Matrix): void;
  105465. /**
  105466. * Binds the given normal matrix to the active effect
  105467. *
  105468. * @param normalMatrix the matrix to bind
  105469. */
  105470. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  105471. bind(world: Matrix, mesh?: Mesh): void;
  105472. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  105473. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  105474. }
  105475. }
  105476. declare module BABYLON {
  105477. /**
  105478. * This groups all the flags used to control the materials channel.
  105479. */
  105480. export class MaterialFlags {
  105481. private static _DiffuseTextureEnabled;
  105482. /**
  105483. * Are diffuse textures enabled in the application.
  105484. */
  105485. static DiffuseTextureEnabled: boolean;
  105486. private static _AmbientTextureEnabled;
  105487. /**
  105488. * Are ambient textures enabled in the application.
  105489. */
  105490. static AmbientTextureEnabled: boolean;
  105491. private static _OpacityTextureEnabled;
  105492. /**
  105493. * Are opacity textures enabled in the application.
  105494. */
  105495. static OpacityTextureEnabled: boolean;
  105496. private static _ReflectionTextureEnabled;
  105497. /**
  105498. * Are reflection textures enabled in the application.
  105499. */
  105500. static ReflectionTextureEnabled: boolean;
  105501. private static _EmissiveTextureEnabled;
  105502. /**
  105503. * Are emissive textures enabled in the application.
  105504. */
  105505. static EmissiveTextureEnabled: boolean;
  105506. private static _SpecularTextureEnabled;
  105507. /**
  105508. * Are specular textures enabled in the application.
  105509. */
  105510. static SpecularTextureEnabled: boolean;
  105511. private static _BumpTextureEnabled;
  105512. /**
  105513. * Are bump textures enabled in the application.
  105514. */
  105515. static BumpTextureEnabled: boolean;
  105516. private static _LightmapTextureEnabled;
  105517. /**
  105518. * Are lightmap textures enabled in the application.
  105519. */
  105520. static LightmapTextureEnabled: boolean;
  105521. private static _RefractionTextureEnabled;
  105522. /**
  105523. * Are refraction textures enabled in the application.
  105524. */
  105525. static RefractionTextureEnabled: boolean;
  105526. private static _ColorGradingTextureEnabled;
  105527. /**
  105528. * Are color grading textures enabled in the application.
  105529. */
  105530. static ColorGradingTextureEnabled: boolean;
  105531. private static _FresnelEnabled;
  105532. /**
  105533. * Are fresnels enabled in the application.
  105534. */
  105535. static FresnelEnabled: boolean;
  105536. private static _ClearCoatTextureEnabled;
  105537. /**
  105538. * Are clear coat textures enabled in the application.
  105539. */
  105540. static ClearCoatTextureEnabled: boolean;
  105541. private static _ClearCoatBumpTextureEnabled;
  105542. /**
  105543. * Are clear coat bump textures enabled in the application.
  105544. */
  105545. static ClearCoatBumpTextureEnabled: boolean;
  105546. private static _ClearCoatTintTextureEnabled;
  105547. /**
  105548. * Are clear coat tint textures enabled in the application.
  105549. */
  105550. static ClearCoatTintTextureEnabled: boolean;
  105551. private static _SheenTextureEnabled;
  105552. /**
  105553. * Are sheen textures enabled in the application.
  105554. */
  105555. static SheenTextureEnabled: boolean;
  105556. private static _AnisotropicTextureEnabled;
  105557. /**
  105558. * Are anisotropic textures enabled in the application.
  105559. */
  105560. static AnisotropicTextureEnabled: boolean;
  105561. private static _ThicknessTextureEnabled;
  105562. /**
  105563. * Are thickness textures enabled in the application.
  105564. */
  105565. static ThicknessTextureEnabled: boolean;
  105566. }
  105567. }
  105568. declare module BABYLON {
  105569. /** @hidden */
  105570. export var defaultFragmentDeclaration: {
  105571. name: string;
  105572. shader: string;
  105573. };
  105574. }
  105575. declare module BABYLON {
  105576. /** @hidden */
  105577. export var defaultUboDeclaration: {
  105578. name: string;
  105579. shader: string;
  105580. };
  105581. }
  105582. declare module BABYLON {
  105583. /** @hidden */
  105584. export var lightFragmentDeclaration: {
  105585. name: string;
  105586. shader: string;
  105587. };
  105588. }
  105589. declare module BABYLON {
  105590. /** @hidden */
  105591. export var lightUboDeclaration: {
  105592. name: string;
  105593. shader: string;
  105594. };
  105595. }
  105596. declare module BABYLON {
  105597. /** @hidden */
  105598. export var lightsFragmentFunctions: {
  105599. name: string;
  105600. shader: string;
  105601. };
  105602. }
  105603. declare module BABYLON {
  105604. /** @hidden */
  105605. export var shadowsFragmentFunctions: {
  105606. name: string;
  105607. shader: string;
  105608. };
  105609. }
  105610. declare module BABYLON {
  105611. /** @hidden */
  105612. export var fresnelFunction: {
  105613. name: string;
  105614. shader: string;
  105615. };
  105616. }
  105617. declare module BABYLON {
  105618. /** @hidden */
  105619. export var reflectionFunction: {
  105620. name: string;
  105621. shader: string;
  105622. };
  105623. }
  105624. declare module BABYLON {
  105625. /** @hidden */
  105626. export var bumpFragmentFunctions: {
  105627. name: string;
  105628. shader: string;
  105629. };
  105630. }
  105631. declare module BABYLON {
  105632. /** @hidden */
  105633. export var logDepthDeclaration: {
  105634. name: string;
  105635. shader: string;
  105636. };
  105637. }
  105638. declare module BABYLON {
  105639. /** @hidden */
  105640. export var bumpFragment: {
  105641. name: string;
  105642. shader: string;
  105643. };
  105644. }
  105645. declare module BABYLON {
  105646. /** @hidden */
  105647. export var depthPrePass: {
  105648. name: string;
  105649. shader: string;
  105650. };
  105651. }
  105652. declare module BABYLON {
  105653. /** @hidden */
  105654. export var lightFragment: {
  105655. name: string;
  105656. shader: string;
  105657. };
  105658. }
  105659. declare module BABYLON {
  105660. /** @hidden */
  105661. export var logDepthFragment: {
  105662. name: string;
  105663. shader: string;
  105664. };
  105665. }
  105666. declare module BABYLON {
  105667. /** @hidden */
  105668. export var defaultPixelShader: {
  105669. name: string;
  105670. shader: string;
  105671. };
  105672. }
  105673. declare module BABYLON {
  105674. /** @hidden */
  105675. export var defaultVertexDeclaration: {
  105676. name: string;
  105677. shader: string;
  105678. };
  105679. }
  105680. declare module BABYLON {
  105681. /** @hidden */
  105682. export var bumpVertexDeclaration: {
  105683. name: string;
  105684. shader: string;
  105685. };
  105686. }
  105687. declare module BABYLON {
  105688. /** @hidden */
  105689. export var bumpVertex: {
  105690. name: string;
  105691. shader: string;
  105692. };
  105693. }
  105694. declare module BABYLON {
  105695. /** @hidden */
  105696. export var fogVertex: {
  105697. name: string;
  105698. shader: string;
  105699. };
  105700. }
  105701. declare module BABYLON {
  105702. /** @hidden */
  105703. export var shadowsVertex: {
  105704. name: string;
  105705. shader: string;
  105706. };
  105707. }
  105708. declare module BABYLON {
  105709. /** @hidden */
  105710. export var pointCloudVertex: {
  105711. name: string;
  105712. shader: string;
  105713. };
  105714. }
  105715. declare module BABYLON {
  105716. /** @hidden */
  105717. export var logDepthVertex: {
  105718. name: string;
  105719. shader: string;
  105720. };
  105721. }
  105722. declare module BABYLON {
  105723. /** @hidden */
  105724. export var defaultVertexShader: {
  105725. name: string;
  105726. shader: string;
  105727. };
  105728. }
  105729. declare module BABYLON {
  105730. /** @hidden */
  105731. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  105732. MAINUV1: boolean;
  105733. MAINUV2: boolean;
  105734. DIFFUSE: boolean;
  105735. DIFFUSEDIRECTUV: number;
  105736. AMBIENT: boolean;
  105737. AMBIENTDIRECTUV: number;
  105738. OPACITY: boolean;
  105739. OPACITYDIRECTUV: number;
  105740. OPACITYRGB: boolean;
  105741. REFLECTION: boolean;
  105742. EMISSIVE: boolean;
  105743. EMISSIVEDIRECTUV: number;
  105744. SPECULAR: boolean;
  105745. SPECULARDIRECTUV: number;
  105746. BUMP: boolean;
  105747. BUMPDIRECTUV: number;
  105748. PARALLAX: boolean;
  105749. PARALLAXOCCLUSION: boolean;
  105750. SPECULAROVERALPHA: boolean;
  105751. CLIPPLANE: boolean;
  105752. CLIPPLANE2: boolean;
  105753. CLIPPLANE3: boolean;
  105754. CLIPPLANE4: boolean;
  105755. ALPHATEST: boolean;
  105756. DEPTHPREPASS: boolean;
  105757. ALPHAFROMDIFFUSE: boolean;
  105758. POINTSIZE: boolean;
  105759. FOG: boolean;
  105760. SPECULARTERM: boolean;
  105761. DIFFUSEFRESNEL: boolean;
  105762. OPACITYFRESNEL: boolean;
  105763. REFLECTIONFRESNEL: boolean;
  105764. REFRACTIONFRESNEL: boolean;
  105765. EMISSIVEFRESNEL: boolean;
  105766. FRESNEL: boolean;
  105767. NORMAL: boolean;
  105768. UV1: boolean;
  105769. UV2: boolean;
  105770. VERTEXCOLOR: boolean;
  105771. VERTEXALPHA: boolean;
  105772. NUM_BONE_INFLUENCERS: number;
  105773. BonesPerMesh: number;
  105774. BONETEXTURE: boolean;
  105775. INSTANCES: boolean;
  105776. GLOSSINESS: boolean;
  105777. ROUGHNESS: boolean;
  105778. EMISSIVEASILLUMINATION: boolean;
  105779. LINKEMISSIVEWITHDIFFUSE: boolean;
  105780. REFLECTIONFRESNELFROMSPECULAR: boolean;
  105781. LIGHTMAP: boolean;
  105782. LIGHTMAPDIRECTUV: number;
  105783. OBJECTSPACE_NORMALMAP: boolean;
  105784. USELIGHTMAPASSHADOWMAP: boolean;
  105785. REFLECTIONMAP_3D: boolean;
  105786. REFLECTIONMAP_SPHERICAL: boolean;
  105787. REFLECTIONMAP_PLANAR: boolean;
  105788. REFLECTIONMAP_CUBIC: boolean;
  105789. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  105790. REFLECTIONMAP_PROJECTION: boolean;
  105791. REFLECTIONMAP_SKYBOX: boolean;
  105792. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  105793. REFLECTIONMAP_EXPLICIT: boolean;
  105794. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  105795. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  105796. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  105797. INVERTCUBICMAP: boolean;
  105798. LOGARITHMICDEPTH: boolean;
  105799. REFRACTION: boolean;
  105800. REFRACTIONMAP_3D: boolean;
  105801. REFLECTIONOVERALPHA: boolean;
  105802. TWOSIDEDLIGHTING: boolean;
  105803. SHADOWFLOAT: boolean;
  105804. MORPHTARGETS: boolean;
  105805. MORPHTARGETS_NORMAL: boolean;
  105806. MORPHTARGETS_TANGENT: boolean;
  105807. MORPHTARGETS_UV: boolean;
  105808. NUM_MORPH_INFLUENCERS: number;
  105809. NONUNIFORMSCALING: boolean;
  105810. PREMULTIPLYALPHA: boolean;
  105811. IMAGEPROCESSING: boolean;
  105812. VIGNETTE: boolean;
  105813. VIGNETTEBLENDMODEMULTIPLY: boolean;
  105814. VIGNETTEBLENDMODEOPAQUE: boolean;
  105815. TONEMAPPING: boolean;
  105816. TONEMAPPING_ACES: boolean;
  105817. CONTRAST: boolean;
  105818. COLORCURVES: boolean;
  105819. COLORGRADING: boolean;
  105820. COLORGRADING3D: boolean;
  105821. SAMPLER3DGREENDEPTH: boolean;
  105822. SAMPLER3DBGRMAP: boolean;
  105823. IMAGEPROCESSINGPOSTPROCESS: boolean;
  105824. MULTIVIEW: boolean;
  105825. /**
  105826. * If the reflection texture on this material is in linear color space
  105827. * @hidden
  105828. */
  105829. IS_REFLECTION_LINEAR: boolean;
  105830. /**
  105831. * If the refraction texture on this material is in linear color space
  105832. * @hidden
  105833. */
  105834. IS_REFRACTION_LINEAR: boolean;
  105835. EXPOSURE: boolean;
  105836. constructor();
  105837. setReflectionMode(modeToEnable: string): void;
  105838. }
  105839. /**
  105840. * This is the default material used in Babylon. It is the best trade off between quality
  105841. * and performances.
  105842. * @see http://doc.babylonjs.com/babylon101/materials
  105843. */
  105844. export class StandardMaterial extends PushMaterial {
  105845. private _diffuseTexture;
  105846. /**
  105847. * The basic texture of the material as viewed under a light.
  105848. */
  105849. diffuseTexture: Nullable<BaseTexture>;
  105850. private _ambientTexture;
  105851. /**
  105852. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  105853. */
  105854. ambientTexture: Nullable<BaseTexture>;
  105855. private _opacityTexture;
  105856. /**
  105857. * Define the transparency of the material from a texture.
  105858. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  105859. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  105860. */
  105861. opacityTexture: Nullable<BaseTexture>;
  105862. private _reflectionTexture;
  105863. /**
  105864. * Define the texture used to display the reflection.
  105865. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105866. */
  105867. reflectionTexture: Nullable<BaseTexture>;
  105868. private _emissiveTexture;
  105869. /**
  105870. * Define texture of the material as if self lit.
  105871. * This will be mixed in the final result even in the absence of light.
  105872. */
  105873. emissiveTexture: Nullable<BaseTexture>;
  105874. private _specularTexture;
  105875. /**
  105876. * Define how the color and intensity of the highlight given by the light in the material.
  105877. */
  105878. specularTexture: Nullable<BaseTexture>;
  105879. private _bumpTexture;
  105880. /**
  105881. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  105882. * 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.
  105883. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  105884. */
  105885. bumpTexture: Nullable<BaseTexture>;
  105886. private _lightmapTexture;
  105887. /**
  105888. * Complex lighting can be computationally expensive to compute at runtime.
  105889. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  105890. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  105891. */
  105892. lightmapTexture: Nullable<BaseTexture>;
  105893. private _refractionTexture;
  105894. /**
  105895. * Define the texture used to display the refraction.
  105896. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105897. */
  105898. refractionTexture: Nullable<BaseTexture>;
  105899. /**
  105900. * The color of the material lit by the environmental background lighting.
  105901. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  105902. */
  105903. ambientColor: Color3;
  105904. /**
  105905. * The basic color of the material as viewed under a light.
  105906. */
  105907. diffuseColor: Color3;
  105908. /**
  105909. * Define how the color and intensity of the highlight given by the light in the material.
  105910. */
  105911. specularColor: Color3;
  105912. /**
  105913. * Define the color of the material as if self lit.
  105914. * This will be mixed in the final result even in the absence of light.
  105915. */
  105916. emissiveColor: Color3;
  105917. /**
  105918. * Defines how sharp are the highlights in the material.
  105919. * The bigger the value the sharper giving a more glossy feeling to the result.
  105920. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  105921. */
  105922. specularPower: number;
  105923. private _useAlphaFromDiffuseTexture;
  105924. /**
  105925. * Does the transparency come from the diffuse texture alpha channel.
  105926. */
  105927. useAlphaFromDiffuseTexture: boolean;
  105928. private _useEmissiveAsIllumination;
  105929. /**
  105930. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  105931. */
  105932. useEmissiveAsIllumination: boolean;
  105933. private _linkEmissiveWithDiffuse;
  105934. /**
  105935. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  105936. * the emissive level when the final color is close to one.
  105937. */
  105938. linkEmissiveWithDiffuse: boolean;
  105939. private _useSpecularOverAlpha;
  105940. /**
  105941. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  105942. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  105943. */
  105944. useSpecularOverAlpha: boolean;
  105945. private _useReflectionOverAlpha;
  105946. /**
  105947. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  105948. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  105949. */
  105950. useReflectionOverAlpha: boolean;
  105951. private _disableLighting;
  105952. /**
  105953. * Does lights from the scene impacts this material.
  105954. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  105955. */
  105956. disableLighting: boolean;
  105957. private _useObjectSpaceNormalMap;
  105958. /**
  105959. * Allows using an object space normal map (instead of tangent space).
  105960. */
  105961. useObjectSpaceNormalMap: boolean;
  105962. private _useParallax;
  105963. /**
  105964. * Is parallax enabled or not.
  105965. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  105966. */
  105967. useParallax: boolean;
  105968. private _useParallaxOcclusion;
  105969. /**
  105970. * Is parallax occlusion enabled or not.
  105971. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  105972. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  105973. */
  105974. useParallaxOcclusion: boolean;
  105975. /**
  105976. * 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.
  105977. */
  105978. parallaxScaleBias: number;
  105979. private _roughness;
  105980. /**
  105981. * Helps to define how blurry the reflections should appears in the material.
  105982. */
  105983. roughness: number;
  105984. /**
  105985. * In case of refraction, define the value of the index of refraction.
  105986. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105987. */
  105988. indexOfRefraction: number;
  105989. /**
  105990. * Invert the refraction texture alongside the y axis.
  105991. * It can be useful with procedural textures or probe for instance.
  105992. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105993. */
  105994. invertRefractionY: boolean;
  105995. /**
  105996. * Defines the alpha limits in alpha test mode.
  105997. */
  105998. alphaCutOff: number;
  105999. private _useLightmapAsShadowmap;
  106000. /**
  106001. * In case of light mapping, define whether the map contains light or shadow informations.
  106002. */
  106003. useLightmapAsShadowmap: boolean;
  106004. private _diffuseFresnelParameters;
  106005. /**
  106006. * Define the diffuse fresnel parameters of the material.
  106007. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106008. */
  106009. diffuseFresnelParameters: FresnelParameters;
  106010. private _opacityFresnelParameters;
  106011. /**
  106012. * Define the opacity fresnel parameters of the material.
  106013. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106014. */
  106015. opacityFresnelParameters: FresnelParameters;
  106016. private _reflectionFresnelParameters;
  106017. /**
  106018. * Define the reflection fresnel parameters of the material.
  106019. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106020. */
  106021. reflectionFresnelParameters: FresnelParameters;
  106022. private _refractionFresnelParameters;
  106023. /**
  106024. * Define the refraction fresnel parameters of the material.
  106025. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106026. */
  106027. refractionFresnelParameters: FresnelParameters;
  106028. private _emissiveFresnelParameters;
  106029. /**
  106030. * Define the emissive fresnel parameters of the material.
  106031. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106032. */
  106033. emissiveFresnelParameters: FresnelParameters;
  106034. private _useReflectionFresnelFromSpecular;
  106035. /**
  106036. * If true automatically deducts the fresnels values from the material specularity.
  106037. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106038. */
  106039. useReflectionFresnelFromSpecular: boolean;
  106040. private _useGlossinessFromSpecularMapAlpha;
  106041. /**
  106042. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  106043. */
  106044. useGlossinessFromSpecularMapAlpha: boolean;
  106045. private _maxSimultaneousLights;
  106046. /**
  106047. * Defines the maximum number of lights that can be used in the material
  106048. */
  106049. maxSimultaneousLights: number;
  106050. private _invertNormalMapX;
  106051. /**
  106052. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  106053. */
  106054. invertNormalMapX: boolean;
  106055. private _invertNormalMapY;
  106056. /**
  106057. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  106058. */
  106059. invertNormalMapY: boolean;
  106060. private _twoSidedLighting;
  106061. /**
  106062. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  106063. */
  106064. twoSidedLighting: boolean;
  106065. /**
  106066. * Default configuration related to image processing available in the standard Material.
  106067. */
  106068. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  106069. /**
  106070. * Gets the image processing configuration used either in this material.
  106071. */
  106072. /**
  106073. * Sets the Default image processing configuration used either in the this material.
  106074. *
  106075. * If sets to null, the scene one is in use.
  106076. */
  106077. imageProcessingConfiguration: ImageProcessingConfiguration;
  106078. /**
  106079. * Keep track of the image processing observer to allow dispose and replace.
  106080. */
  106081. private _imageProcessingObserver;
  106082. /**
  106083. * Attaches a new image processing configuration to the Standard Material.
  106084. * @param configuration
  106085. */
  106086. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  106087. /**
  106088. * Gets wether the color curves effect is enabled.
  106089. */
  106090. /**
  106091. * Sets wether the color curves effect is enabled.
  106092. */
  106093. cameraColorCurvesEnabled: boolean;
  106094. /**
  106095. * Gets wether the color grading effect is enabled.
  106096. */
  106097. /**
  106098. * Gets wether the color grading effect is enabled.
  106099. */
  106100. cameraColorGradingEnabled: boolean;
  106101. /**
  106102. * Gets wether tonemapping is enabled or not.
  106103. */
  106104. /**
  106105. * Sets wether tonemapping is enabled or not
  106106. */
  106107. cameraToneMappingEnabled: boolean;
  106108. /**
  106109. * The camera exposure used on this material.
  106110. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106111. * This corresponds to a photographic exposure.
  106112. */
  106113. /**
  106114. * The camera exposure used on this material.
  106115. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106116. * This corresponds to a photographic exposure.
  106117. */
  106118. cameraExposure: number;
  106119. /**
  106120. * Gets The camera contrast used on this material.
  106121. */
  106122. /**
  106123. * Sets The camera contrast used on this material.
  106124. */
  106125. cameraContrast: number;
  106126. /**
  106127. * Gets the Color Grading 2D Lookup Texture.
  106128. */
  106129. /**
  106130. * Sets the Color Grading 2D Lookup Texture.
  106131. */
  106132. cameraColorGradingTexture: Nullable<BaseTexture>;
  106133. /**
  106134. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106135. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106136. * 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;
  106137. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106138. */
  106139. /**
  106140. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106141. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106142. * 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;
  106143. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106144. */
  106145. cameraColorCurves: Nullable<ColorCurves>;
  106146. /**
  106147. * Custom callback helping to override the default shader used in the material.
  106148. */
  106149. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  106150. protected _renderTargets: SmartArray<RenderTargetTexture>;
  106151. protected _worldViewProjectionMatrix: Matrix;
  106152. protected _globalAmbientColor: Color3;
  106153. protected _useLogarithmicDepth: boolean;
  106154. protected _rebuildInParallel: boolean;
  106155. /**
  106156. * Instantiates a new standard material.
  106157. * This is the default material used in Babylon. It is the best trade off between quality
  106158. * and performances.
  106159. * @see http://doc.babylonjs.com/babylon101/materials
  106160. * @param name Define the name of the material in the scene
  106161. * @param scene Define the scene the material belong to
  106162. */
  106163. constructor(name: string, scene: Scene);
  106164. /**
  106165. * Gets a boolean indicating that current material needs to register RTT
  106166. */
  106167. readonly hasRenderTargetTextures: boolean;
  106168. /**
  106169. * Gets the current class name of the material e.g. "StandardMaterial"
  106170. * Mainly use in serialization.
  106171. * @returns the class name
  106172. */
  106173. getClassName(): string;
  106174. /**
  106175. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  106176. * You can try switching to logarithmic depth.
  106177. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  106178. */
  106179. useLogarithmicDepth: boolean;
  106180. /**
  106181. * Specifies if the material will require alpha blending
  106182. * @returns a boolean specifying if alpha blending is needed
  106183. */
  106184. needAlphaBlending(): boolean;
  106185. /**
  106186. * Specifies if this material should be rendered in alpha test mode
  106187. * @returns a boolean specifying if an alpha test is needed.
  106188. */
  106189. needAlphaTesting(): boolean;
  106190. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  106191. /**
  106192. * Get the texture used for alpha test purpose.
  106193. * @returns the diffuse texture in case of the standard material.
  106194. */
  106195. getAlphaTestTexture(): Nullable<BaseTexture>;
  106196. /**
  106197. * Get if the submesh is ready to be used and all its information available.
  106198. * Child classes can use it to update shaders
  106199. * @param mesh defines the mesh to check
  106200. * @param subMesh defines which submesh to check
  106201. * @param useInstances specifies that instances should be used
  106202. * @returns a boolean indicating that the submesh is ready or not
  106203. */
  106204. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  106205. /**
  106206. * Builds the material UBO layouts.
  106207. * Used internally during the effect preparation.
  106208. */
  106209. buildUniformLayout(): void;
  106210. /**
  106211. * Unbinds the material from the mesh
  106212. */
  106213. unbind(): void;
  106214. /**
  106215. * Binds the submesh to this material by preparing the effect and shader to draw
  106216. * @param world defines the world transformation matrix
  106217. * @param mesh defines the mesh containing the submesh
  106218. * @param subMesh defines the submesh to bind the material to
  106219. */
  106220. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  106221. /**
  106222. * Get the list of animatables in the material.
  106223. * @returns the list of animatables object used in the material
  106224. */
  106225. getAnimatables(): IAnimatable[];
  106226. /**
  106227. * Gets the active textures from the material
  106228. * @returns an array of textures
  106229. */
  106230. getActiveTextures(): BaseTexture[];
  106231. /**
  106232. * Specifies if the material uses a texture
  106233. * @param texture defines the texture to check against the material
  106234. * @returns a boolean specifying if the material uses the texture
  106235. */
  106236. hasTexture(texture: BaseTexture): boolean;
  106237. /**
  106238. * Disposes the material
  106239. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  106240. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  106241. */
  106242. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  106243. /**
  106244. * Makes a duplicate of the material, and gives it a new name
  106245. * @param name defines the new name for the duplicated material
  106246. * @returns the cloned material
  106247. */
  106248. clone(name: string): StandardMaterial;
  106249. /**
  106250. * Serializes this material in a JSON representation
  106251. * @returns the serialized material object
  106252. */
  106253. serialize(): any;
  106254. /**
  106255. * Creates a standard material from parsed material data
  106256. * @param source defines the JSON representation of the material
  106257. * @param scene defines the hosting scene
  106258. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  106259. * @returns a new standard material
  106260. */
  106261. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  106262. /**
  106263. * Are diffuse textures enabled in the application.
  106264. */
  106265. static DiffuseTextureEnabled: boolean;
  106266. /**
  106267. * Are ambient textures enabled in the application.
  106268. */
  106269. static AmbientTextureEnabled: boolean;
  106270. /**
  106271. * Are opacity textures enabled in the application.
  106272. */
  106273. static OpacityTextureEnabled: boolean;
  106274. /**
  106275. * Are reflection textures enabled in the application.
  106276. */
  106277. static ReflectionTextureEnabled: boolean;
  106278. /**
  106279. * Are emissive textures enabled in the application.
  106280. */
  106281. static EmissiveTextureEnabled: boolean;
  106282. /**
  106283. * Are specular textures enabled in the application.
  106284. */
  106285. static SpecularTextureEnabled: boolean;
  106286. /**
  106287. * Are bump textures enabled in the application.
  106288. */
  106289. static BumpTextureEnabled: boolean;
  106290. /**
  106291. * Are lightmap textures enabled in the application.
  106292. */
  106293. static LightmapTextureEnabled: boolean;
  106294. /**
  106295. * Are refraction textures enabled in the application.
  106296. */
  106297. static RefractionTextureEnabled: boolean;
  106298. /**
  106299. * Are color grading textures enabled in the application.
  106300. */
  106301. static ColorGradingTextureEnabled: boolean;
  106302. /**
  106303. * Are fresnels enabled in the application.
  106304. */
  106305. static FresnelEnabled: boolean;
  106306. }
  106307. }
  106308. declare module BABYLON {
  106309. /** @hidden */
  106310. export var imageProcessingPixelShader: {
  106311. name: string;
  106312. shader: string;
  106313. };
  106314. }
  106315. declare module BABYLON {
  106316. /**
  106317. * ImageProcessingPostProcess
  106318. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  106319. */
  106320. export class ImageProcessingPostProcess extends PostProcess {
  106321. /**
  106322. * Default configuration related to image processing available in the PBR Material.
  106323. */
  106324. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  106325. /**
  106326. * Gets the image processing configuration used either in this material.
  106327. */
  106328. /**
  106329. * Sets the Default image processing configuration used either in the this material.
  106330. *
  106331. * If sets to null, the scene one is in use.
  106332. */
  106333. imageProcessingConfiguration: ImageProcessingConfiguration;
  106334. /**
  106335. * Keep track of the image processing observer to allow dispose and replace.
  106336. */
  106337. private _imageProcessingObserver;
  106338. /**
  106339. * Attaches a new image processing configuration to the PBR Material.
  106340. * @param configuration
  106341. */
  106342. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  106343. /**
  106344. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  106345. */
  106346. /**
  106347. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  106348. */
  106349. colorCurves: Nullable<ColorCurves>;
  106350. /**
  106351. * Gets wether the color curves effect is enabled.
  106352. */
  106353. /**
  106354. * Sets wether the color curves effect is enabled.
  106355. */
  106356. colorCurvesEnabled: boolean;
  106357. /**
  106358. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  106359. */
  106360. /**
  106361. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  106362. */
  106363. colorGradingTexture: Nullable<BaseTexture>;
  106364. /**
  106365. * Gets wether the color grading effect is enabled.
  106366. */
  106367. /**
  106368. * Gets wether the color grading effect is enabled.
  106369. */
  106370. colorGradingEnabled: boolean;
  106371. /**
  106372. * Gets exposure used in the effect.
  106373. */
  106374. /**
  106375. * Sets exposure used in the effect.
  106376. */
  106377. exposure: number;
  106378. /**
  106379. * Gets wether tonemapping is enabled or not.
  106380. */
  106381. /**
  106382. * Sets wether tonemapping is enabled or not
  106383. */
  106384. toneMappingEnabled: boolean;
  106385. /**
  106386. * Gets the type of tone mapping effect.
  106387. */
  106388. /**
  106389. * Sets the type of tone mapping effect.
  106390. */
  106391. toneMappingType: number;
  106392. /**
  106393. * Gets contrast used in the effect.
  106394. */
  106395. /**
  106396. * Sets contrast used in the effect.
  106397. */
  106398. contrast: number;
  106399. /**
  106400. * Gets Vignette stretch size.
  106401. */
  106402. /**
  106403. * Sets Vignette stretch size.
  106404. */
  106405. vignetteStretch: number;
  106406. /**
  106407. * Gets Vignette centre X Offset.
  106408. */
  106409. /**
  106410. * Sets Vignette centre X Offset.
  106411. */
  106412. vignetteCentreX: number;
  106413. /**
  106414. * Gets Vignette centre Y Offset.
  106415. */
  106416. /**
  106417. * Sets Vignette centre Y Offset.
  106418. */
  106419. vignetteCentreY: number;
  106420. /**
  106421. * Gets Vignette weight or intensity of the vignette effect.
  106422. */
  106423. /**
  106424. * Sets Vignette weight or intensity of the vignette effect.
  106425. */
  106426. vignetteWeight: number;
  106427. /**
  106428. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  106429. * if vignetteEnabled is set to true.
  106430. */
  106431. /**
  106432. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  106433. * if vignetteEnabled is set to true.
  106434. */
  106435. vignetteColor: Color4;
  106436. /**
  106437. * Gets Camera field of view used by the Vignette effect.
  106438. */
  106439. /**
  106440. * Sets Camera field of view used by the Vignette effect.
  106441. */
  106442. vignetteCameraFov: number;
  106443. /**
  106444. * Gets the vignette blend mode allowing different kind of effect.
  106445. */
  106446. /**
  106447. * Sets the vignette blend mode allowing different kind of effect.
  106448. */
  106449. vignetteBlendMode: number;
  106450. /**
  106451. * Gets wether the vignette effect is enabled.
  106452. */
  106453. /**
  106454. * Sets wether the vignette effect is enabled.
  106455. */
  106456. vignetteEnabled: boolean;
  106457. private _fromLinearSpace;
  106458. /**
  106459. * Gets wether the input of the processing is in Gamma or Linear Space.
  106460. */
  106461. /**
  106462. * Sets wether the input of the processing is in Gamma or Linear Space.
  106463. */
  106464. fromLinearSpace: boolean;
  106465. /**
  106466. * Defines cache preventing GC.
  106467. */
  106468. private _defines;
  106469. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  106470. /**
  106471. * "ImageProcessingPostProcess"
  106472. * @returns "ImageProcessingPostProcess"
  106473. */
  106474. getClassName(): string;
  106475. protected _updateParameters(): void;
  106476. dispose(camera?: Camera): void;
  106477. }
  106478. }
  106479. declare module BABYLON {
  106480. /**
  106481. * Class containing static functions to help procedurally build meshes
  106482. */
  106483. export class GroundBuilder {
  106484. /**
  106485. * Creates a ground mesh
  106486. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  106487. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  106488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106489. * @param name defines the name of the mesh
  106490. * @param options defines the options used to create the mesh
  106491. * @param scene defines the hosting scene
  106492. * @returns the ground mesh
  106493. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  106494. */
  106495. static CreateGround(name: string, options: {
  106496. width?: number;
  106497. height?: number;
  106498. subdivisions?: number;
  106499. subdivisionsX?: number;
  106500. subdivisionsY?: number;
  106501. updatable?: boolean;
  106502. }, scene: any): Mesh;
  106503. /**
  106504. * Creates a tiled ground mesh
  106505. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  106506. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  106507. * * 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
  106508. * * 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
  106509. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106510. * @param name defines the name of the mesh
  106511. * @param options defines the options used to create the mesh
  106512. * @param scene defines the hosting scene
  106513. * @returns the tiled ground mesh
  106514. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  106515. */
  106516. static CreateTiledGround(name: string, options: {
  106517. xmin: number;
  106518. zmin: number;
  106519. xmax: number;
  106520. zmax: number;
  106521. subdivisions?: {
  106522. w: number;
  106523. h: number;
  106524. };
  106525. precision?: {
  106526. w: number;
  106527. h: number;
  106528. };
  106529. updatable?: boolean;
  106530. }, scene?: Nullable<Scene>): Mesh;
  106531. /**
  106532. * Creates a ground mesh from a height map
  106533. * * The parameter `url` sets the URL of the height map image resource.
  106534. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  106535. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  106536. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  106537. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  106538. * * 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.
  106539. * * 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).
  106540. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  106541. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106542. * @param name defines the name of the mesh
  106543. * @param url defines the url to the height map
  106544. * @param options defines the options used to create the mesh
  106545. * @param scene defines the hosting scene
  106546. * @returns the ground mesh
  106547. * @see https://doc.babylonjs.com/babylon101/height_map
  106548. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  106549. */
  106550. static CreateGroundFromHeightMap(name: string, url: string, options: {
  106551. width?: number;
  106552. height?: number;
  106553. subdivisions?: number;
  106554. minHeight?: number;
  106555. maxHeight?: number;
  106556. colorFilter?: Color3;
  106557. alphaFilter?: number;
  106558. updatable?: boolean;
  106559. onReady?: (mesh: GroundMesh) => void;
  106560. }, scene?: Nullable<Scene>): GroundMesh;
  106561. }
  106562. }
  106563. declare module BABYLON {
  106564. /**
  106565. * Class containing static functions to help procedurally build meshes
  106566. */
  106567. export class TorusBuilder {
  106568. /**
  106569. * Creates a torus mesh
  106570. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  106571. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  106572. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  106573. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106574. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106575. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106576. * @param name defines the name of the mesh
  106577. * @param options defines the options used to create the mesh
  106578. * @param scene defines the hosting scene
  106579. * @returns the torus mesh
  106580. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  106581. */
  106582. static CreateTorus(name: string, options: {
  106583. diameter?: number;
  106584. thickness?: number;
  106585. tessellation?: number;
  106586. updatable?: boolean;
  106587. sideOrientation?: number;
  106588. frontUVs?: Vector4;
  106589. backUVs?: Vector4;
  106590. }, scene: any): Mesh;
  106591. }
  106592. }
  106593. declare module BABYLON {
  106594. /**
  106595. * Class containing static functions to help procedurally build meshes
  106596. */
  106597. export class CylinderBuilder {
  106598. /**
  106599. * Creates a cylinder or a cone mesh
  106600. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  106601. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  106602. * * 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.
  106603. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  106604. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  106605. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  106606. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  106607. * * 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).
  106608. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  106609. * * 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).
  106610. * * 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
  106611. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  106612. * * 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
  106613. * * 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.
  106614. * * If `enclose` is false, a ring surface is one element.
  106615. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  106616. * * 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
  106617. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106618. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106619. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106620. * @param name defines the name of the mesh
  106621. * @param options defines the options used to create the mesh
  106622. * @param scene defines the hosting scene
  106623. * @returns the cylinder mesh
  106624. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  106625. */
  106626. static CreateCylinder(name: string, options: {
  106627. height?: number;
  106628. diameterTop?: number;
  106629. diameterBottom?: number;
  106630. diameter?: number;
  106631. tessellation?: number;
  106632. subdivisions?: number;
  106633. arc?: number;
  106634. faceColors?: Color4[];
  106635. faceUV?: Vector4[];
  106636. updatable?: boolean;
  106637. hasRings?: boolean;
  106638. enclose?: boolean;
  106639. cap?: number;
  106640. sideOrientation?: number;
  106641. frontUVs?: Vector4;
  106642. backUVs?: Vector4;
  106643. }, scene: any): Mesh;
  106644. }
  106645. }
  106646. declare module BABYLON {
  106647. /**
  106648. * Options to modify the vr teleportation behavior.
  106649. */
  106650. export interface VRTeleportationOptions {
  106651. /**
  106652. * The name of the mesh which should be used as the teleportation floor. (default: null)
  106653. */
  106654. floorMeshName?: string;
  106655. /**
  106656. * A list of meshes to be used as the teleportation floor. (default: empty)
  106657. */
  106658. floorMeshes?: Mesh[];
  106659. }
  106660. /**
  106661. * Options to modify the vr experience helper's behavior.
  106662. */
  106663. export interface VRExperienceHelperOptions extends WebVROptions {
  106664. /**
  106665. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  106666. */
  106667. createDeviceOrientationCamera?: boolean;
  106668. /**
  106669. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  106670. */
  106671. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  106672. /**
  106673. * Uses the main button on the controller to toggle the laser casted. (default: true)
  106674. */
  106675. laserToggle?: boolean;
  106676. /**
  106677. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  106678. */
  106679. floorMeshes?: Mesh[];
  106680. /**
  106681. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  106682. */
  106683. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  106684. }
  106685. /**
  106686. * Event containing information after VR has been entered
  106687. */
  106688. export class OnAfterEnteringVRObservableEvent {
  106689. /**
  106690. * If entering vr was successful
  106691. */
  106692. success: boolean;
  106693. }
  106694. /**
  106695. * Helps to quickly add VR support to an existing scene.
  106696. * See http://doc.babylonjs.com/how_to/webvr_helper
  106697. */
  106698. export class VRExperienceHelper {
  106699. /** Options to modify the vr experience helper's behavior. */
  106700. webVROptions: VRExperienceHelperOptions;
  106701. private _scene;
  106702. private _position;
  106703. private _btnVR;
  106704. private _btnVRDisplayed;
  106705. private _webVRsupported;
  106706. private _webVRready;
  106707. private _webVRrequesting;
  106708. private _webVRpresenting;
  106709. private _hasEnteredVR;
  106710. private _fullscreenVRpresenting;
  106711. private _canvas;
  106712. private _webVRCamera;
  106713. private _vrDeviceOrientationCamera;
  106714. private _deviceOrientationCamera;
  106715. private _existingCamera;
  106716. private _onKeyDown;
  106717. private _onVrDisplayPresentChange;
  106718. private _onVRDisplayChanged;
  106719. private _onVRRequestPresentStart;
  106720. private _onVRRequestPresentComplete;
  106721. /**
  106722. * 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)
  106723. */
  106724. enableGazeEvenWhenNoPointerLock: boolean;
  106725. /**
  106726. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  106727. */
  106728. exitVROnDoubleTap: boolean;
  106729. /**
  106730. * Observable raised right before entering VR.
  106731. */
  106732. onEnteringVRObservable: Observable<VRExperienceHelper>;
  106733. /**
  106734. * Observable raised when entering VR has completed.
  106735. */
  106736. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  106737. /**
  106738. * Observable raised when exiting VR.
  106739. */
  106740. onExitingVRObservable: Observable<VRExperienceHelper>;
  106741. /**
  106742. * Observable raised when controller mesh is loaded.
  106743. */
  106744. onControllerMeshLoadedObservable: Observable<WebVRController>;
  106745. /** Return this.onEnteringVRObservable
  106746. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  106747. */
  106748. readonly onEnteringVR: Observable<VRExperienceHelper>;
  106749. /** Return this.onExitingVRObservable
  106750. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  106751. */
  106752. readonly onExitingVR: Observable<VRExperienceHelper>;
  106753. /** Return this.onControllerMeshLoadedObservable
  106754. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  106755. */
  106756. readonly onControllerMeshLoaded: Observable<WebVRController>;
  106757. private _rayLength;
  106758. private _useCustomVRButton;
  106759. private _teleportationRequested;
  106760. private _teleportActive;
  106761. private _floorMeshName;
  106762. private _floorMeshesCollection;
  106763. private _rotationAllowed;
  106764. private _teleportBackwardsVector;
  106765. private _teleportationTarget;
  106766. private _isDefaultTeleportationTarget;
  106767. private _postProcessMove;
  106768. private _teleportationFillColor;
  106769. private _teleportationBorderColor;
  106770. private _rotationAngle;
  106771. private _haloCenter;
  106772. private _cameraGazer;
  106773. private _padSensibilityUp;
  106774. private _padSensibilityDown;
  106775. private _leftController;
  106776. private _rightController;
  106777. /**
  106778. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  106779. */
  106780. onNewMeshSelected: Observable<AbstractMesh>;
  106781. /**
  106782. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  106783. * This observable will provide the mesh and the controller used to select the mesh
  106784. */
  106785. onMeshSelectedWithController: Observable<{
  106786. mesh: AbstractMesh;
  106787. controller: WebVRController;
  106788. }>;
  106789. /**
  106790. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  106791. */
  106792. onNewMeshPicked: Observable<PickingInfo>;
  106793. private _circleEase;
  106794. /**
  106795. * Observable raised before camera teleportation
  106796. */
  106797. onBeforeCameraTeleport: Observable<Vector3>;
  106798. /**
  106799. * Observable raised after camera teleportation
  106800. */
  106801. onAfterCameraTeleport: Observable<Vector3>;
  106802. /**
  106803. * Observable raised when current selected mesh gets unselected
  106804. */
  106805. onSelectedMeshUnselected: Observable<AbstractMesh>;
  106806. private _raySelectionPredicate;
  106807. /**
  106808. * To be optionaly changed by user to define custom ray selection
  106809. */
  106810. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  106811. /**
  106812. * To be optionaly changed by user to define custom selection logic (after ray selection)
  106813. */
  106814. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  106815. /**
  106816. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  106817. */
  106818. teleportationEnabled: boolean;
  106819. private _defaultHeight;
  106820. private _teleportationInitialized;
  106821. private _interactionsEnabled;
  106822. private _interactionsRequested;
  106823. private _displayGaze;
  106824. private _displayLaserPointer;
  106825. /**
  106826. * The mesh used to display where the user is going to teleport.
  106827. */
  106828. /**
  106829. * Sets the mesh to be used to display where the user is going to teleport.
  106830. */
  106831. teleportationTarget: Mesh;
  106832. /**
  106833. * 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
  106834. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  106835. * See http://doc.babylonjs.com/resources/baking_transformations
  106836. */
  106837. gazeTrackerMesh: Mesh;
  106838. /**
  106839. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  106840. */
  106841. updateGazeTrackerScale: boolean;
  106842. /**
  106843. * If the gaze trackers color should be updated when selecting meshes
  106844. */
  106845. updateGazeTrackerColor: boolean;
  106846. /**
  106847. * If the controller laser color should be updated when selecting meshes
  106848. */
  106849. updateControllerLaserColor: boolean;
  106850. /**
  106851. * The gaze tracking mesh corresponding to the left controller
  106852. */
  106853. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  106854. /**
  106855. * The gaze tracking mesh corresponding to the right controller
  106856. */
  106857. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  106858. /**
  106859. * If the ray of the gaze should be displayed.
  106860. */
  106861. /**
  106862. * Sets if the ray of the gaze should be displayed.
  106863. */
  106864. displayGaze: boolean;
  106865. /**
  106866. * If the ray of the LaserPointer should be displayed.
  106867. */
  106868. /**
  106869. * Sets if the ray of the LaserPointer should be displayed.
  106870. */
  106871. displayLaserPointer: boolean;
  106872. /**
  106873. * The deviceOrientationCamera used as the camera when not in VR.
  106874. */
  106875. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  106876. /**
  106877. * Based on the current WebVR support, returns the current VR camera used.
  106878. */
  106879. readonly currentVRCamera: Nullable<Camera>;
  106880. /**
  106881. * The webVRCamera which is used when in VR.
  106882. */
  106883. readonly webVRCamera: WebVRFreeCamera;
  106884. /**
  106885. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  106886. */
  106887. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  106888. /**
  106889. * The html button that is used to trigger entering into VR.
  106890. */
  106891. readonly vrButton: Nullable<HTMLButtonElement>;
  106892. private readonly _teleportationRequestInitiated;
  106893. /**
  106894. * Defines wether or not Pointer lock should be requested when switching to
  106895. * full screen.
  106896. */
  106897. requestPointerLockOnFullScreen: boolean;
  106898. /**
  106899. * Instantiates a VRExperienceHelper.
  106900. * Helps to quickly add VR support to an existing scene.
  106901. * @param scene The scene the VRExperienceHelper belongs to.
  106902. * @param webVROptions Options to modify the vr experience helper's behavior.
  106903. */
  106904. constructor(scene: Scene,
  106905. /** Options to modify the vr experience helper's behavior. */
  106906. webVROptions?: VRExperienceHelperOptions);
  106907. private _onDefaultMeshLoaded;
  106908. private _onResize;
  106909. private _onFullscreenChange;
  106910. /**
  106911. * Gets a value indicating if we are currently in VR mode.
  106912. */
  106913. readonly isInVRMode: boolean;
  106914. private onVrDisplayPresentChange;
  106915. private onVRDisplayChanged;
  106916. private moveButtonToBottomRight;
  106917. private displayVRButton;
  106918. private updateButtonVisibility;
  106919. private _cachedAngularSensibility;
  106920. /**
  106921. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  106922. * Otherwise, will use the fullscreen API.
  106923. */
  106924. enterVR(): void;
  106925. /**
  106926. * Attempt to exit VR, or fullscreen.
  106927. */
  106928. exitVR(): void;
  106929. /**
  106930. * The position of the vr experience helper.
  106931. */
  106932. /**
  106933. * Sets the position of the vr experience helper.
  106934. */
  106935. position: Vector3;
  106936. /**
  106937. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  106938. */
  106939. enableInteractions(): void;
  106940. private readonly _noControllerIsActive;
  106941. private beforeRender;
  106942. private _isTeleportationFloor;
  106943. /**
  106944. * Adds a floor mesh to be used for teleportation.
  106945. * @param floorMesh the mesh to be used for teleportation.
  106946. */
  106947. addFloorMesh(floorMesh: Mesh): void;
  106948. /**
  106949. * Removes a floor mesh from being used for teleportation.
  106950. * @param floorMesh the mesh to be removed.
  106951. */
  106952. removeFloorMesh(floorMesh: Mesh): void;
  106953. /**
  106954. * Enables interactions and teleportation using the VR controllers and gaze.
  106955. * @param vrTeleportationOptions options to modify teleportation behavior.
  106956. */
  106957. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  106958. private _onNewGamepadConnected;
  106959. private _tryEnableInteractionOnController;
  106960. private _onNewGamepadDisconnected;
  106961. private _enableInteractionOnController;
  106962. private _checkTeleportWithRay;
  106963. private _checkRotate;
  106964. private _checkTeleportBackwards;
  106965. private _enableTeleportationOnController;
  106966. private _createTeleportationCircles;
  106967. private _displayTeleportationTarget;
  106968. private _hideTeleportationTarget;
  106969. private _rotateCamera;
  106970. private _moveTeleportationSelectorTo;
  106971. private _workingVector;
  106972. private _workingQuaternion;
  106973. private _workingMatrix;
  106974. /**
  106975. * Teleports the users feet to the desired location
  106976. * @param location The location where the user's feet should be placed
  106977. */
  106978. teleportCamera(location: Vector3): void;
  106979. private _convertNormalToDirectionOfRay;
  106980. private _castRayAndSelectObject;
  106981. private _notifySelectedMeshUnselected;
  106982. /**
  106983. * Sets the color of the laser ray from the vr controllers.
  106984. * @param color new color for the ray.
  106985. */
  106986. changeLaserColor(color: Color3): void;
  106987. /**
  106988. * Sets the color of the ray from the vr headsets gaze.
  106989. * @param color new color for the ray.
  106990. */
  106991. changeGazeColor(color: Color3): void;
  106992. /**
  106993. * Exits VR and disposes of the vr experience helper
  106994. */
  106995. dispose(): void;
  106996. /**
  106997. * Gets the name of the VRExperienceHelper class
  106998. * @returns "VRExperienceHelper"
  106999. */
  107000. getClassName(): string;
  107001. }
  107002. }
  107003. declare module BABYLON {
  107004. /**
  107005. * Manages an XRSession to work with Babylon's engine
  107006. * @see https://doc.babylonjs.com/how_to/webxr
  107007. */
  107008. export class WebXRSessionManager implements IDisposable {
  107009. private scene;
  107010. /**
  107011. * Fires every time a new xrFrame arrives which can be used to update the camera
  107012. */
  107013. onXRFrameObservable: Observable<any>;
  107014. /**
  107015. * Fires when the xr session is ended either by the device or manually done
  107016. */
  107017. onXRSessionEnded: Observable<any>;
  107018. /**
  107019. * Underlying xr session
  107020. */
  107021. session: XRSession;
  107022. /**
  107023. * Type of reference space used when creating the session
  107024. */
  107025. referenceSpace: XRReferenceSpace;
  107026. /** @hidden */
  107027. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  107028. /**
  107029. * Current XR frame
  107030. */
  107031. currentFrame: Nullable<XRFrame>;
  107032. private _xrNavigator;
  107033. private baseLayer;
  107034. /**
  107035. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  107036. * @param scene The scene which the session should be created for
  107037. */
  107038. constructor(scene: Scene);
  107039. /**
  107040. * Initializes the manager
  107041. * After initialization enterXR can be called to start an XR session
  107042. * @returns Promise which resolves after it is initialized
  107043. */
  107044. initializeAsync(): Promise<void>;
  107045. /**
  107046. * Initializes an xr session
  107047. * @param xrSessionMode mode to initialize
  107048. * @returns a promise which will resolve once the session has been initialized
  107049. */
  107050. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  107051. /**
  107052. * Sets the reference space on the xr session
  107053. * @param referenceSpace space to set
  107054. * @returns a promise that will resolve once the reference space has been set
  107055. */
  107056. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  107057. /**
  107058. * Updates the render state of the session
  107059. * @param state state to set
  107060. * @returns a promise that resolves once the render state has been updated
  107061. */
  107062. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  107063. /**
  107064. * Starts rendering to the xr layer
  107065. * @returns a promise that will resolve once rendering has started
  107066. */
  107067. startRenderingToXRAsync(): Promise<void>;
  107068. /**
  107069. * Stops the xrSession and restores the renderloop
  107070. * @returns Promise which resolves after it exits XR
  107071. */
  107072. exitXRAsync(): Promise<unknown>;
  107073. /**
  107074. * Checks if a session would be supported for the creation options specified
  107075. * @param sessionMode session mode to check if supported eg. immersive-vr
  107076. * @returns true if supported
  107077. */
  107078. supportsSessionAsync(sessionMode: XRSessionMode): any;
  107079. /**
  107080. * @hidden
  107081. * Converts the render layer of xrSession to a render target
  107082. * @param session session to create render target for
  107083. * @param scene scene the new render target should be created for
  107084. */
  107085. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  107086. /**
  107087. * Disposes of the session manager
  107088. */
  107089. dispose(): void;
  107090. }
  107091. }
  107092. declare module BABYLON {
  107093. /**
  107094. * WebXR Camera which holds the views for the xrSession
  107095. * @see https://doc.babylonjs.com/how_to/webxr
  107096. */
  107097. export class WebXRCamera extends FreeCamera {
  107098. private static _TmpMatrix;
  107099. /**
  107100. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  107101. * @param name the name of the camera
  107102. * @param scene the scene to add the camera to
  107103. */
  107104. constructor(name: string, scene: Scene);
  107105. private _updateNumberOfRigCameras;
  107106. /** @hidden */
  107107. _updateForDualEyeDebugging(pupilDistance?: number): void;
  107108. /**
  107109. * Updates the cameras position from the current pose information of the XR session
  107110. * @param xrSessionManager the session containing pose information
  107111. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  107112. */
  107113. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  107114. }
  107115. }
  107116. declare module BABYLON {
  107117. /**
  107118. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  107119. */
  107120. export class WebXRManagedOutputCanvas implements IDisposable {
  107121. private helper;
  107122. private _canvas;
  107123. /**
  107124. * xrpresent context of the canvas which can be used to display/mirror xr content
  107125. */
  107126. canvasContext: WebGLRenderingContext;
  107127. /**
  107128. * xr layer for the canvas
  107129. */
  107130. xrLayer: Nullable<XRWebGLLayer>;
  107131. /**
  107132. * Initializes the xr layer for the session
  107133. * @param xrSession xr session
  107134. * @returns a promise that will resolve once the XR Layer has been created
  107135. */
  107136. initializeXRLayerAsync(xrSession: any): any;
  107137. /**
  107138. * Initializes the canvas to be added/removed upon entering/exiting xr
  107139. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  107140. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  107141. */
  107142. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  107143. /**
  107144. * Disposes of the object
  107145. */
  107146. dispose(): void;
  107147. private _setManagedOutputCanvas;
  107148. private _addCanvas;
  107149. private _removeCanvas;
  107150. }
  107151. }
  107152. declare module BABYLON {
  107153. /**
  107154. * States of the webXR experience
  107155. */
  107156. export enum WebXRState {
  107157. /**
  107158. * Transitioning to being in XR mode
  107159. */
  107160. ENTERING_XR = 0,
  107161. /**
  107162. * Transitioning to non XR mode
  107163. */
  107164. EXITING_XR = 1,
  107165. /**
  107166. * In XR mode and presenting
  107167. */
  107168. IN_XR = 2,
  107169. /**
  107170. * Not entered XR mode
  107171. */
  107172. NOT_IN_XR = 3
  107173. }
  107174. /**
  107175. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  107176. * @see https://doc.babylonjs.com/how_to/webxr
  107177. */
  107178. export class WebXRExperienceHelper implements IDisposable {
  107179. private scene;
  107180. /**
  107181. * 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
  107182. */
  107183. container: AbstractMesh;
  107184. /**
  107185. * Camera used to render xr content
  107186. */
  107187. camera: WebXRCamera;
  107188. /**
  107189. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  107190. */
  107191. state: WebXRState;
  107192. private _setState;
  107193. private static _TmpVector;
  107194. /**
  107195. * Fires when the state of the experience helper has changed
  107196. */
  107197. onStateChangedObservable: Observable<WebXRState>;
  107198. /** Session manager used to keep track of xr session */
  107199. sessionManager: WebXRSessionManager;
  107200. private _nonVRCamera;
  107201. private _originalSceneAutoClear;
  107202. private _supported;
  107203. /**
  107204. * Creates the experience helper
  107205. * @param scene the scene to attach the experience helper to
  107206. * @returns a promise for the experience helper
  107207. */
  107208. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  107209. /**
  107210. * Creates a WebXRExperienceHelper
  107211. * @param scene The scene the helper should be created in
  107212. */
  107213. private constructor();
  107214. /**
  107215. * Exits XR mode and returns the scene to its original state
  107216. * @returns promise that resolves after xr mode has exited
  107217. */
  107218. exitXRAsync(): Promise<unknown>;
  107219. /**
  107220. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  107221. * @param sessionCreationOptions options for the XR session
  107222. * @param referenceSpaceType frame of reference of the XR session
  107223. * @param outputCanvas the output canvas that will be used to enter XR mode
  107224. * @returns promise that resolves after xr mode has entered
  107225. */
  107226. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  107227. /**
  107228. * Updates the global position of the camera by moving the camera's container
  107229. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  107230. * @param position The desired global position of the camera
  107231. */
  107232. setPositionOfCameraUsingContainer(position: Vector3): void;
  107233. /**
  107234. * Rotates the xr camera by rotating the camera's container around the camera's position
  107235. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  107236. * @param rotation the desired quaternion rotation to apply to the camera
  107237. */
  107238. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  107239. /**
  107240. * Disposes of the experience helper
  107241. */
  107242. dispose(): void;
  107243. }
  107244. }
  107245. declare module BABYLON {
  107246. /**
  107247. * Button which can be used to enter a different mode of XR
  107248. */
  107249. export class WebXREnterExitUIButton {
  107250. /** button element */
  107251. element: HTMLElement;
  107252. /** XR initialization options for the button */
  107253. sessionMode: XRSessionMode;
  107254. /** Reference space type */
  107255. referenceSpaceType: XRReferenceSpaceType;
  107256. /**
  107257. * Creates a WebXREnterExitUIButton
  107258. * @param element button element
  107259. * @param sessionMode XR initialization session mode
  107260. * @param referenceSpaceType the type of reference space to be used
  107261. */
  107262. constructor(
  107263. /** button element */
  107264. element: HTMLElement,
  107265. /** XR initialization options for the button */
  107266. sessionMode: XRSessionMode,
  107267. /** Reference space type */
  107268. referenceSpaceType: XRReferenceSpaceType);
  107269. /**
  107270. * Overwritable function which can be used to update the button's visuals when the state changes
  107271. * @param activeButton the current active button in the UI
  107272. */
  107273. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  107274. }
  107275. /**
  107276. * Options to create the webXR UI
  107277. */
  107278. export class WebXREnterExitUIOptions {
  107279. /**
  107280. * Context to enter xr with
  107281. */
  107282. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  107283. /**
  107284. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  107285. */
  107286. customButtons?: Array<WebXREnterExitUIButton>;
  107287. }
  107288. /**
  107289. * UI to allow the user to enter/exit XR mode
  107290. */
  107291. export class WebXREnterExitUI implements IDisposable {
  107292. private scene;
  107293. private _overlay;
  107294. private _buttons;
  107295. private _activeButton;
  107296. /**
  107297. * Fired every time the active button is changed.
  107298. *
  107299. * When xr is entered via a button that launches xr that button will be the callback parameter
  107300. *
  107301. * When exiting xr the callback parameter will be null)
  107302. */
  107303. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  107304. /**
  107305. * Creates UI to allow the user to enter/exit XR mode
  107306. * @param scene the scene to add the ui to
  107307. * @param helper the xr experience helper to enter/exit xr with
  107308. * @param options options to configure the UI
  107309. * @returns the created ui
  107310. */
  107311. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  107312. private constructor();
  107313. private _updateButtons;
  107314. /**
  107315. * Disposes of the object
  107316. */
  107317. dispose(): void;
  107318. }
  107319. }
  107320. declare module BABYLON {
  107321. /**
  107322. * Represents an XR input
  107323. */
  107324. export class WebXRController {
  107325. private scene;
  107326. /** The underlying input source for the controller */
  107327. inputSource: XRInputSource;
  107328. private parentContainer;
  107329. /**
  107330. * 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
  107331. */
  107332. grip?: AbstractMesh;
  107333. /**
  107334. * Pointer which can be used to select objects or attach a visible laser to
  107335. */
  107336. pointer: AbstractMesh;
  107337. /**
  107338. * Event that fires when the controller is removed/disposed
  107339. */
  107340. onDisposeObservable: Observable<{}>;
  107341. private _tmpMatrix;
  107342. private _tmpQuaternion;
  107343. private _tmpVector;
  107344. /**
  107345. * Creates the controller
  107346. * @see https://doc.babylonjs.com/how_to/webxr
  107347. * @param scene the scene which the controller should be associated to
  107348. * @param inputSource the underlying input source for the controller
  107349. * @param parentContainer parent that the controller meshes should be children of
  107350. */
  107351. constructor(scene: Scene,
  107352. /** The underlying input source for the controller */
  107353. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  107354. /**
  107355. * Updates the controller pose based on the given XRFrame
  107356. * @param xrFrame xr frame to update the pose with
  107357. * @param referenceSpace reference space to use
  107358. */
  107359. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  107360. /**
  107361. * Gets a world space ray coming from the controller
  107362. * @param result the resulting ray
  107363. */
  107364. getWorldPointerRayToRef(result: Ray): void;
  107365. /**
  107366. * Disposes of the object
  107367. */
  107368. dispose(): void;
  107369. }
  107370. }
  107371. declare module BABYLON {
  107372. /**
  107373. * XR input used to track XR inputs such as controllers/rays
  107374. */
  107375. export class WebXRInput implements IDisposable {
  107376. /**
  107377. * Base experience the input listens to
  107378. */
  107379. baseExperience: WebXRExperienceHelper;
  107380. /**
  107381. * XR controllers being tracked
  107382. */
  107383. controllers: Array<WebXRController>;
  107384. private _frameObserver;
  107385. private _stateObserver;
  107386. /**
  107387. * Event when a controller has been connected/added
  107388. */
  107389. onControllerAddedObservable: Observable<WebXRController>;
  107390. /**
  107391. * Event when a controller has been removed/disconnected
  107392. */
  107393. onControllerRemovedObservable: Observable<WebXRController>;
  107394. /**
  107395. * Initializes the WebXRInput
  107396. * @param baseExperience experience helper which the input should be created for
  107397. */
  107398. constructor(
  107399. /**
  107400. * Base experience the input listens to
  107401. */
  107402. baseExperience: WebXRExperienceHelper);
  107403. private _onInputSourcesChange;
  107404. private _addAndRemoveControllers;
  107405. /**
  107406. * Disposes of the object
  107407. */
  107408. dispose(): void;
  107409. }
  107410. }
  107411. declare module BABYLON {
  107412. /**
  107413. * Enables teleportation
  107414. */
  107415. export class WebXRControllerTeleportation {
  107416. private _teleportationFillColor;
  107417. private _teleportationBorderColor;
  107418. private _tmpRay;
  107419. private _tmpVector;
  107420. /**
  107421. * Creates a WebXRControllerTeleportation
  107422. * @param input input manager to add teleportation to
  107423. * @param floorMeshes floormeshes which can be teleported to
  107424. */
  107425. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  107426. }
  107427. }
  107428. declare module BABYLON {
  107429. /**
  107430. * Handles pointer input automatically for the pointer of XR controllers
  107431. */
  107432. export class WebXRControllerPointerSelection {
  107433. private static _idCounter;
  107434. private _tmpRay;
  107435. /**
  107436. * Creates a WebXRControllerPointerSelection
  107437. * @param input input manager to setup pointer selection
  107438. */
  107439. constructor(input: WebXRInput);
  107440. private _convertNormalToDirectionOfRay;
  107441. private _updatePointerDistance;
  107442. }
  107443. }
  107444. declare module BABYLON {
  107445. /**
  107446. * Class used to represent data loading progression
  107447. */
  107448. export class SceneLoaderProgressEvent {
  107449. /** defines if data length to load can be evaluated */
  107450. readonly lengthComputable: boolean;
  107451. /** defines the loaded data length */
  107452. readonly loaded: number;
  107453. /** defines the data length to load */
  107454. readonly total: number;
  107455. /**
  107456. * Create a new progress event
  107457. * @param lengthComputable defines if data length to load can be evaluated
  107458. * @param loaded defines the loaded data length
  107459. * @param total defines the data length to load
  107460. */
  107461. constructor(
  107462. /** defines if data length to load can be evaluated */
  107463. lengthComputable: boolean,
  107464. /** defines the loaded data length */
  107465. loaded: number,
  107466. /** defines the data length to load */
  107467. total: number);
  107468. /**
  107469. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  107470. * @param event defines the source event
  107471. * @returns a new SceneLoaderProgressEvent
  107472. */
  107473. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  107474. }
  107475. /**
  107476. * Interface used by SceneLoader plugins to define supported file extensions
  107477. */
  107478. export interface ISceneLoaderPluginExtensions {
  107479. /**
  107480. * Defines the list of supported extensions
  107481. */
  107482. [extension: string]: {
  107483. isBinary: boolean;
  107484. };
  107485. }
  107486. /**
  107487. * Interface used by SceneLoader plugin factory
  107488. */
  107489. export interface ISceneLoaderPluginFactory {
  107490. /**
  107491. * Defines the name of the factory
  107492. */
  107493. name: string;
  107494. /**
  107495. * Function called to create a new plugin
  107496. * @return the new plugin
  107497. */
  107498. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  107499. /**
  107500. * Boolean indicating if the plugin can direct load specific data
  107501. */
  107502. canDirectLoad?: (data: string) => boolean;
  107503. }
  107504. /**
  107505. * Interface used to define a SceneLoader plugin
  107506. */
  107507. export interface ISceneLoaderPlugin {
  107508. /**
  107509. * The friendly name of this plugin.
  107510. */
  107511. name: string;
  107512. /**
  107513. * The file extensions supported by this plugin.
  107514. */
  107515. extensions: string | ISceneLoaderPluginExtensions;
  107516. /**
  107517. * Import meshes into a scene.
  107518. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107519. * @param scene The scene to import into
  107520. * @param data The data to import
  107521. * @param rootUrl The root url for scene and resources
  107522. * @param meshes The meshes array to import into
  107523. * @param particleSystems The particle systems array to import into
  107524. * @param skeletons The skeletons array to import into
  107525. * @param onError The callback when import fails
  107526. * @returns True if successful or false otherwise
  107527. */
  107528. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  107529. /**
  107530. * Load into a scene.
  107531. * @param scene The scene to load into
  107532. * @param data The data to import
  107533. * @param rootUrl The root url for scene and resources
  107534. * @param onError The callback when import fails
  107535. * @returns true if successful or false otherwise
  107536. */
  107537. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  107538. /**
  107539. * The callback that returns true if the data can be directly loaded.
  107540. */
  107541. canDirectLoad?: (data: string) => boolean;
  107542. /**
  107543. * The callback that allows custom handling of the root url based on the response url.
  107544. */
  107545. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  107546. /**
  107547. * Load into an asset container.
  107548. * @param scene The scene to load into
  107549. * @param data The data to import
  107550. * @param rootUrl The root url for scene and resources
  107551. * @param onError The callback when import fails
  107552. * @returns The loaded asset container
  107553. */
  107554. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  107555. }
  107556. /**
  107557. * Interface used to define an async SceneLoader plugin
  107558. */
  107559. export interface ISceneLoaderPluginAsync {
  107560. /**
  107561. * The friendly name of this plugin.
  107562. */
  107563. name: string;
  107564. /**
  107565. * The file extensions supported by this plugin.
  107566. */
  107567. extensions: string | ISceneLoaderPluginExtensions;
  107568. /**
  107569. * Import meshes into a scene.
  107570. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107571. * @param scene The scene to import into
  107572. * @param data The data to import
  107573. * @param rootUrl The root url for scene and resources
  107574. * @param onProgress The callback when the load progresses
  107575. * @param fileName Defines the name of the file to load
  107576. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  107577. */
  107578. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  107579. meshes: AbstractMesh[];
  107580. particleSystems: IParticleSystem[];
  107581. skeletons: Skeleton[];
  107582. animationGroups: AnimationGroup[];
  107583. }>;
  107584. /**
  107585. * Load into a scene.
  107586. * @param scene The scene to load into
  107587. * @param data The data to import
  107588. * @param rootUrl The root url for scene and resources
  107589. * @param onProgress The callback when the load progresses
  107590. * @param fileName Defines the name of the file to load
  107591. * @returns Nothing
  107592. */
  107593. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  107594. /**
  107595. * The callback that returns true if the data can be directly loaded.
  107596. */
  107597. canDirectLoad?: (data: string) => boolean;
  107598. /**
  107599. * The callback that allows custom handling of the root url based on the response url.
  107600. */
  107601. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  107602. /**
  107603. * Load into an asset container.
  107604. * @param scene The scene to load into
  107605. * @param data The data to import
  107606. * @param rootUrl The root url for scene and resources
  107607. * @param onProgress The callback when the load progresses
  107608. * @param fileName Defines the name of the file to load
  107609. * @returns The loaded asset container
  107610. */
  107611. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  107612. }
  107613. /**
  107614. * Class used to load scene from various file formats using registered plugins
  107615. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  107616. */
  107617. export class SceneLoader {
  107618. /**
  107619. * No logging while loading
  107620. */
  107621. static readonly NO_LOGGING: number;
  107622. /**
  107623. * Minimal logging while loading
  107624. */
  107625. static readonly MINIMAL_LOGGING: number;
  107626. /**
  107627. * Summary logging while loading
  107628. */
  107629. static readonly SUMMARY_LOGGING: number;
  107630. /**
  107631. * Detailled logging while loading
  107632. */
  107633. static readonly DETAILED_LOGGING: number;
  107634. /**
  107635. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  107636. */
  107637. static ForceFullSceneLoadingForIncremental: boolean;
  107638. /**
  107639. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  107640. */
  107641. static ShowLoadingScreen: boolean;
  107642. /**
  107643. * Defines the current logging level (while loading the scene)
  107644. * @ignorenaming
  107645. */
  107646. static loggingLevel: number;
  107647. /**
  107648. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  107649. */
  107650. static CleanBoneMatrixWeights: boolean;
  107651. /**
  107652. * Event raised when a plugin is used to load a scene
  107653. */
  107654. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  107655. private static _registeredPlugins;
  107656. private static _getDefaultPlugin;
  107657. private static _getPluginForExtension;
  107658. private static _getPluginForDirectLoad;
  107659. private static _getPluginForFilename;
  107660. private static _getDirectLoad;
  107661. private static _loadData;
  107662. private static _getFileInfo;
  107663. /**
  107664. * Gets a plugin that can load the given extension
  107665. * @param extension defines the extension to load
  107666. * @returns a plugin or null if none works
  107667. */
  107668. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  107669. /**
  107670. * Gets a boolean indicating that the given extension can be loaded
  107671. * @param extension defines the extension to load
  107672. * @returns true if the extension is supported
  107673. */
  107674. static IsPluginForExtensionAvailable(extension: string): boolean;
  107675. /**
  107676. * Adds a new plugin to the list of registered plugins
  107677. * @param plugin defines the plugin to add
  107678. */
  107679. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  107680. /**
  107681. * Import meshes into a scene
  107682. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107683. * @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)
  107684. * @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)
  107685. * @param scene the instance of BABYLON.Scene to append to
  107686. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  107687. * @param onProgress a callback with a progress event for each file being loaded
  107688. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107689. * @param pluginExtension the extension used to determine the plugin
  107690. * @returns The loaded plugin
  107691. */
  107692. 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>;
  107693. /**
  107694. * Import meshes into a scene
  107695. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107696. * @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)
  107697. * @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)
  107698. * @param scene the instance of BABYLON.Scene to append to
  107699. * @param onProgress a callback with a progress event for each file being loaded
  107700. * @param pluginExtension the extension used to determine the plugin
  107701. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  107702. */
  107703. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  107704. meshes: AbstractMesh[];
  107705. particleSystems: IParticleSystem[];
  107706. skeletons: Skeleton[];
  107707. animationGroups: AnimationGroup[];
  107708. }>;
  107709. /**
  107710. * Load a scene
  107711. * @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)
  107712. * @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)
  107713. * @param engine is the instance of BABYLON.Engine to use to create the scene
  107714. * @param onSuccess a callback with the scene when import succeeds
  107715. * @param onProgress a callback with a progress event for each file being loaded
  107716. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107717. * @param pluginExtension the extension used to determine the plugin
  107718. * @returns The loaded plugin
  107719. */
  107720. 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>;
  107721. /**
  107722. * Load a scene
  107723. * @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)
  107724. * @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)
  107725. * @param engine is the instance of BABYLON.Engine to use to create the scene
  107726. * @param onProgress a callback with a progress event for each file being loaded
  107727. * @param pluginExtension the extension used to determine the plugin
  107728. * @returns The loaded scene
  107729. */
  107730. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  107731. /**
  107732. * Append a scene
  107733. * @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)
  107734. * @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)
  107735. * @param scene is the instance of BABYLON.Scene to append to
  107736. * @param onSuccess a callback with the scene when import succeeds
  107737. * @param onProgress a callback with a progress event for each file being loaded
  107738. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107739. * @param pluginExtension the extension used to determine the plugin
  107740. * @returns The loaded plugin
  107741. */
  107742. 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>;
  107743. /**
  107744. * Append a scene
  107745. * @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)
  107746. * @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)
  107747. * @param scene is the instance of BABYLON.Scene to append to
  107748. * @param onProgress a callback with a progress event for each file being loaded
  107749. * @param pluginExtension the extension used to determine the plugin
  107750. * @returns The given scene
  107751. */
  107752. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  107753. /**
  107754. * Load a scene into an asset container
  107755. * @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)
  107756. * @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)
  107757. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  107758. * @param onSuccess a callback with the scene when import succeeds
  107759. * @param onProgress a callback with a progress event for each file being loaded
  107760. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107761. * @param pluginExtension the extension used to determine the plugin
  107762. * @returns The loaded plugin
  107763. */
  107764. 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>;
  107765. /**
  107766. * Load a scene into an asset container
  107767. * @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)
  107768. * @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)
  107769. * @param scene is the instance of Scene to append to
  107770. * @param onProgress a callback with a progress event for each file being loaded
  107771. * @param pluginExtension the extension used to determine the plugin
  107772. * @returns The loaded asset container
  107773. */
  107774. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  107775. }
  107776. }
  107777. declare module BABYLON {
  107778. /**
  107779. * Generic Controller
  107780. */
  107781. export class GenericController extends WebVRController {
  107782. /**
  107783. * Base Url for the controller model.
  107784. */
  107785. static readonly MODEL_BASE_URL: string;
  107786. /**
  107787. * File name for the controller model.
  107788. */
  107789. static readonly MODEL_FILENAME: string;
  107790. /**
  107791. * Creates a new GenericController from a gamepad
  107792. * @param vrGamepad the gamepad that the controller should be created from
  107793. */
  107794. constructor(vrGamepad: any);
  107795. /**
  107796. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107797. * @param scene scene in which to add meshes
  107798. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107799. */
  107800. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  107801. /**
  107802. * Called once for each button that changed state since the last frame
  107803. * @param buttonIdx Which button index changed
  107804. * @param state New state of the button
  107805. * @param changes Which properties on the state changed since last frame
  107806. */
  107807. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107808. }
  107809. }
  107810. declare module BABYLON {
  107811. /**
  107812. * Defines the WindowsMotionController object that the state of the windows motion controller
  107813. */
  107814. export class WindowsMotionController extends WebVRController {
  107815. /**
  107816. * The base url used to load the left and right controller models
  107817. */
  107818. static MODEL_BASE_URL: string;
  107819. /**
  107820. * The name of the left controller model file
  107821. */
  107822. static MODEL_LEFT_FILENAME: string;
  107823. /**
  107824. * The name of the right controller model file
  107825. */
  107826. static MODEL_RIGHT_FILENAME: string;
  107827. /**
  107828. * The controller name prefix for this controller type
  107829. */
  107830. static readonly GAMEPAD_ID_PREFIX: string;
  107831. /**
  107832. * The controller id pattern for this controller type
  107833. */
  107834. private static readonly GAMEPAD_ID_PATTERN;
  107835. private _loadedMeshInfo;
  107836. private readonly _mapping;
  107837. /**
  107838. * Fired when the trackpad on this controller is clicked
  107839. */
  107840. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  107841. /**
  107842. * Fired when the trackpad on this controller is modified
  107843. */
  107844. onTrackpadValuesChangedObservable: Observable<StickValues>;
  107845. /**
  107846. * The current x and y values of this controller's trackpad
  107847. */
  107848. trackpad: StickValues;
  107849. /**
  107850. * Creates a new WindowsMotionController from a gamepad
  107851. * @param vrGamepad the gamepad that the controller should be created from
  107852. */
  107853. constructor(vrGamepad: any);
  107854. /**
  107855. * Fired when the trigger on this controller is modified
  107856. */
  107857. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107858. /**
  107859. * Fired when the menu button on this controller is modified
  107860. */
  107861. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107862. /**
  107863. * Fired when the grip button on this controller is modified
  107864. */
  107865. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107866. /**
  107867. * Fired when the thumbstick button on this controller is modified
  107868. */
  107869. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107870. /**
  107871. * Fired when the touchpad button on this controller is modified
  107872. */
  107873. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107874. /**
  107875. * Fired when the touchpad values on this controller are modified
  107876. */
  107877. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  107878. private _updateTrackpad;
  107879. /**
  107880. * Called once per frame by the engine.
  107881. */
  107882. update(): void;
  107883. /**
  107884. * Called once for each button that changed state since the last frame
  107885. * @param buttonIdx Which button index changed
  107886. * @param state New state of the button
  107887. * @param changes Which properties on the state changed since last frame
  107888. */
  107889. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107890. /**
  107891. * Moves the buttons on the controller mesh based on their current state
  107892. * @param buttonName the name of the button to move
  107893. * @param buttonValue the value of the button which determines the buttons new position
  107894. */
  107895. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  107896. /**
  107897. * Moves the axis on the controller mesh based on its current state
  107898. * @param axis the index of the axis
  107899. * @param axisValue the value of the axis which determines the meshes new position
  107900. * @hidden
  107901. */
  107902. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  107903. /**
  107904. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107905. * @param scene scene in which to add meshes
  107906. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107907. */
  107908. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  107909. /**
  107910. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  107911. * can be transformed by button presses and axes values, based on this._mapping.
  107912. *
  107913. * @param scene scene in which the meshes exist
  107914. * @param meshes list of meshes that make up the controller model to process
  107915. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  107916. */
  107917. private processModel;
  107918. private createMeshInfo;
  107919. /**
  107920. * Gets the ray of the controller in the direction the controller is pointing
  107921. * @param length the length the resulting ray should be
  107922. * @returns a ray in the direction the controller is pointing
  107923. */
  107924. getForwardRay(length?: number): Ray;
  107925. /**
  107926. * Disposes of the controller
  107927. */
  107928. dispose(): void;
  107929. }
  107930. }
  107931. declare module BABYLON {
  107932. /**
  107933. * Oculus Touch Controller
  107934. */
  107935. export class OculusTouchController extends WebVRController {
  107936. /**
  107937. * Base Url for the controller model.
  107938. */
  107939. static MODEL_BASE_URL: string;
  107940. /**
  107941. * File name for the left controller model.
  107942. */
  107943. static MODEL_LEFT_FILENAME: string;
  107944. /**
  107945. * File name for the right controller model.
  107946. */
  107947. static MODEL_RIGHT_FILENAME: string;
  107948. /**
  107949. * Base Url for the Quest controller model.
  107950. */
  107951. static QUEST_MODEL_BASE_URL: string;
  107952. /**
  107953. * @hidden
  107954. * If the controllers are running on a device that needs the updated Quest controller models
  107955. */
  107956. static _IsQuest: boolean;
  107957. /**
  107958. * Fired when the secondary trigger on this controller is modified
  107959. */
  107960. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  107961. /**
  107962. * Fired when the thumb rest on this controller is modified
  107963. */
  107964. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  107965. /**
  107966. * Creates a new OculusTouchController from a gamepad
  107967. * @param vrGamepad the gamepad that the controller should be created from
  107968. */
  107969. constructor(vrGamepad: any);
  107970. /**
  107971. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107972. * @param scene scene in which to add meshes
  107973. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107974. */
  107975. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  107976. /**
  107977. * Fired when the A button on this controller is modified
  107978. */
  107979. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107980. /**
  107981. * Fired when the B button on this controller is modified
  107982. */
  107983. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107984. /**
  107985. * Fired when the X button on this controller is modified
  107986. */
  107987. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107988. /**
  107989. * Fired when the Y button on this controller is modified
  107990. */
  107991. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107992. /**
  107993. * Called once for each button that changed state since the last frame
  107994. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  107995. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  107996. * 2) secondary trigger (same)
  107997. * 3) A (right) X (left), touch, pressed = value
  107998. * 4) B / Y
  107999. * 5) thumb rest
  108000. * @param buttonIdx Which button index changed
  108001. * @param state New state of the button
  108002. * @param changes Which properties on the state changed since last frame
  108003. */
  108004. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108005. }
  108006. }
  108007. declare module BABYLON {
  108008. /**
  108009. * Vive Controller
  108010. */
  108011. export class ViveController extends WebVRController {
  108012. /**
  108013. * Base Url for the controller model.
  108014. */
  108015. static MODEL_BASE_URL: string;
  108016. /**
  108017. * File name for the controller model.
  108018. */
  108019. static MODEL_FILENAME: string;
  108020. /**
  108021. * Creates a new ViveController from a gamepad
  108022. * @param vrGamepad the gamepad that the controller should be created from
  108023. */
  108024. constructor(vrGamepad: any);
  108025. /**
  108026. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108027. * @param scene scene in which to add meshes
  108028. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108029. */
  108030. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108031. /**
  108032. * Fired when the left button on this controller is modified
  108033. */
  108034. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108035. /**
  108036. * Fired when the right button on this controller is modified
  108037. */
  108038. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108039. /**
  108040. * Fired when the menu button on this controller is modified
  108041. */
  108042. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108043. /**
  108044. * Called once for each button that changed state since the last frame
  108045. * Vive mapping:
  108046. * 0: touchpad
  108047. * 1: trigger
  108048. * 2: left AND right buttons
  108049. * 3: menu button
  108050. * @param buttonIdx Which button index changed
  108051. * @param state New state of the button
  108052. * @param changes Which properties on the state changed since last frame
  108053. */
  108054. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108055. }
  108056. }
  108057. declare module BABYLON {
  108058. /**
  108059. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  108060. */
  108061. export class WebXRControllerModelLoader {
  108062. /**
  108063. * Creates the WebXRControllerModelLoader
  108064. * @param input xr input that creates the controllers
  108065. */
  108066. constructor(input: WebXRInput);
  108067. }
  108068. }
  108069. declare module BABYLON {
  108070. /**
  108071. * Contains an array of blocks representing the octree
  108072. */
  108073. export interface IOctreeContainer<T> {
  108074. /**
  108075. * Blocks within the octree
  108076. */
  108077. blocks: Array<OctreeBlock<T>>;
  108078. }
  108079. /**
  108080. * Class used to store a cell in an octree
  108081. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108082. */
  108083. export class OctreeBlock<T> {
  108084. /**
  108085. * Gets the content of the current block
  108086. */
  108087. entries: T[];
  108088. /**
  108089. * Gets the list of block children
  108090. */
  108091. blocks: Array<OctreeBlock<T>>;
  108092. private _depth;
  108093. private _maxDepth;
  108094. private _capacity;
  108095. private _minPoint;
  108096. private _maxPoint;
  108097. private _boundingVectors;
  108098. private _creationFunc;
  108099. /**
  108100. * Creates a new block
  108101. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  108102. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  108103. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  108104. * @param depth defines the current depth of this block in the octree
  108105. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  108106. * @param creationFunc defines a callback to call when an element is added to the block
  108107. */
  108108. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  108109. /**
  108110. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  108111. */
  108112. readonly capacity: number;
  108113. /**
  108114. * Gets the minimum vector (in world space) of the block's bounding box
  108115. */
  108116. readonly minPoint: Vector3;
  108117. /**
  108118. * Gets the maximum vector (in world space) of the block's bounding box
  108119. */
  108120. readonly maxPoint: Vector3;
  108121. /**
  108122. * Add a new element to this block
  108123. * @param entry defines the element to add
  108124. */
  108125. addEntry(entry: T): void;
  108126. /**
  108127. * Remove an element from this block
  108128. * @param entry defines the element to remove
  108129. */
  108130. removeEntry(entry: T): void;
  108131. /**
  108132. * Add an array of elements to this block
  108133. * @param entries defines the array of elements to add
  108134. */
  108135. addEntries(entries: T[]): void;
  108136. /**
  108137. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  108138. * @param frustumPlanes defines the frustum planes to test
  108139. * @param selection defines the array to store current content if selection is positive
  108140. * @param allowDuplicate defines if the selection array can contains duplicated entries
  108141. */
  108142. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  108143. /**
  108144. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  108145. * @param sphereCenter defines the bounding sphere center
  108146. * @param sphereRadius defines the bounding sphere radius
  108147. * @param selection defines the array to store current content if selection is positive
  108148. * @param allowDuplicate defines if the selection array can contains duplicated entries
  108149. */
  108150. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  108151. /**
  108152. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  108153. * @param ray defines the ray to test with
  108154. * @param selection defines the array to store current content if selection is positive
  108155. */
  108156. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  108157. /**
  108158. * Subdivide the content into child blocks (this block will then be empty)
  108159. */
  108160. createInnerBlocks(): void;
  108161. /**
  108162. * @hidden
  108163. */
  108164. 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;
  108165. }
  108166. }
  108167. declare module BABYLON {
  108168. /**
  108169. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  108170. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108171. */
  108172. export class Octree<T> {
  108173. /** 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.) */
  108174. maxDepth: number;
  108175. /**
  108176. * Blocks within the octree containing objects
  108177. */
  108178. blocks: Array<OctreeBlock<T>>;
  108179. /**
  108180. * Content stored in the octree
  108181. */
  108182. dynamicContent: T[];
  108183. private _maxBlockCapacity;
  108184. private _selectionContent;
  108185. private _creationFunc;
  108186. /**
  108187. * Creates a octree
  108188. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108189. * @param creationFunc function to be used to instatiate the octree
  108190. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  108191. * @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.)
  108192. */
  108193. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  108194. /** 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.) */
  108195. maxDepth?: number);
  108196. /**
  108197. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  108198. * @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);
  108199. * @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);
  108200. * @param entries meshes to be added to the octree blocks
  108201. */
  108202. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  108203. /**
  108204. * Adds a mesh to the octree
  108205. * @param entry Mesh to add to the octree
  108206. */
  108207. addMesh(entry: T): void;
  108208. /**
  108209. * Remove an element from the octree
  108210. * @param entry defines the element to remove
  108211. */
  108212. removeMesh(entry: T): void;
  108213. /**
  108214. * Selects an array of meshes within the frustum
  108215. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  108216. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  108217. * @returns array of meshes within the frustum
  108218. */
  108219. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  108220. /**
  108221. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  108222. * @param sphereCenter defines the bounding sphere center
  108223. * @param sphereRadius defines the bounding sphere radius
  108224. * @param allowDuplicate defines if the selection array can contains duplicated entries
  108225. * @returns an array of objects that intersect the sphere
  108226. */
  108227. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  108228. /**
  108229. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  108230. * @param ray defines the ray to test with
  108231. * @returns array of intersected objects
  108232. */
  108233. intersectsRay(ray: Ray): SmartArray<T>;
  108234. /**
  108235. * Adds a mesh into the octree block if it intersects the block
  108236. */
  108237. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  108238. /**
  108239. * Adds a submesh into the octree block if it intersects the block
  108240. */
  108241. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  108242. }
  108243. }
  108244. declare module BABYLON {
  108245. interface Scene {
  108246. /**
  108247. * @hidden
  108248. * Backing Filed
  108249. */
  108250. _selectionOctree: Octree<AbstractMesh>;
  108251. /**
  108252. * Gets the octree used to boost mesh selection (picking)
  108253. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108254. */
  108255. selectionOctree: Octree<AbstractMesh>;
  108256. /**
  108257. * Creates or updates the octree used to boost selection (picking)
  108258. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108259. * @param maxCapacity defines the maximum capacity per leaf
  108260. * @param maxDepth defines the maximum depth of the octree
  108261. * @returns an octree of AbstractMesh
  108262. */
  108263. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  108264. }
  108265. interface AbstractMesh {
  108266. /**
  108267. * @hidden
  108268. * Backing Field
  108269. */
  108270. _submeshesOctree: Octree<SubMesh>;
  108271. /**
  108272. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  108273. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  108274. * @param maxCapacity defines the maximum size of each block (64 by default)
  108275. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  108276. * @returns the new octree
  108277. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  108278. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108279. */
  108280. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  108281. }
  108282. /**
  108283. * Defines the octree scene component responsible to manage any octrees
  108284. * in a given scene.
  108285. */
  108286. export class OctreeSceneComponent {
  108287. /**
  108288. * The component name help to identify the component in the list of scene components.
  108289. */
  108290. readonly name: string;
  108291. /**
  108292. * The scene the component belongs to.
  108293. */
  108294. scene: Scene;
  108295. /**
  108296. * Indicates if the meshes have been checked to make sure they are isEnabled()
  108297. */
  108298. readonly checksIsEnabled: boolean;
  108299. /**
  108300. * Creates a new instance of the component for the given scene
  108301. * @param scene Defines the scene to register the component in
  108302. */
  108303. constructor(scene: Scene);
  108304. /**
  108305. * Registers the component in a given scene
  108306. */
  108307. register(): void;
  108308. /**
  108309. * Return the list of active meshes
  108310. * @returns the list of active meshes
  108311. */
  108312. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  108313. /**
  108314. * Return the list of active sub meshes
  108315. * @param mesh The mesh to get the candidates sub meshes from
  108316. * @returns the list of active sub meshes
  108317. */
  108318. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  108319. private _tempRay;
  108320. /**
  108321. * Return the list of sub meshes intersecting with a given local ray
  108322. * @param mesh defines the mesh to find the submesh for
  108323. * @param localRay defines the ray in local space
  108324. * @returns the list of intersecting sub meshes
  108325. */
  108326. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  108327. /**
  108328. * Return the list of sub meshes colliding with a collider
  108329. * @param mesh defines the mesh to find the submesh for
  108330. * @param collider defines the collider to evaluate the collision against
  108331. * @returns the list of colliding sub meshes
  108332. */
  108333. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  108334. /**
  108335. * Rebuilds the elements related to this component in case of
  108336. * context lost for instance.
  108337. */
  108338. rebuild(): void;
  108339. /**
  108340. * Disposes the component and the associated ressources.
  108341. */
  108342. dispose(): void;
  108343. }
  108344. }
  108345. declare module BABYLON {
  108346. /**
  108347. * Renders a layer on top of an existing scene
  108348. */
  108349. export class UtilityLayerRenderer implements IDisposable {
  108350. /** the original scene that will be rendered on top of */
  108351. originalScene: Scene;
  108352. private _pointerCaptures;
  108353. private _lastPointerEvents;
  108354. private static _DefaultUtilityLayer;
  108355. private static _DefaultKeepDepthUtilityLayer;
  108356. private _sharedGizmoLight;
  108357. private _renderCamera;
  108358. /**
  108359. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  108360. * @returns the camera that is used when rendering the utility layer
  108361. */
  108362. getRenderCamera(): Nullable<Camera>;
  108363. /**
  108364. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  108365. * @param cam the camera that should be used when rendering the utility layer
  108366. */
  108367. setRenderCamera(cam: Nullable<Camera>): void;
  108368. /**
  108369. * @hidden
  108370. * Light which used by gizmos to get light shading
  108371. */
  108372. _getSharedGizmoLight(): HemisphericLight;
  108373. /**
  108374. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  108375. */
  108376. pickUtilitySceneFirst: boolean;
  108377. /**
  108378. * 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)
  108379. */
  108380. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  108381. /**
  108382. * 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)
  108383. */
  108384. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  108385. /**
  108386. * The scene that is rendered on top of the original scene
  108387. */
  108388. utilityLayerScene: Scene;
  108389. /**
  108390. * If the utility layer should automatically be rendered on top of existing scene
  108391. */
  108392. shouldRender: boolean;
  108393. /**
  108394. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  108395. */
  108396. onlyCheckPointerDownEvents: boolean;
  108397. /**
  108398. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  108399. */
  108400. processAllEvents: boolean;
  108401. /**
  108402. * Observable raised when the pointer move from the utility layer scene to the main scene
  108403. */
  108404. onPointerOutObservable: Observable<number>;
  108405. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  108406. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  108407. private _afterRenderObserver;
  108408. private _sceneDisposeObserver;
  108409. private _originalPointerObserver;
  108410. /**
  108411. * Instantiates a UtilityLayerRenderer
  108412. * @param originalScene the original scene that will be rendered on top of
  108413. * @param handleEvents boolean indicating if the utility layer should handle events
  108414. */
  108415. constructor(
  108416. /** the original scene that will be rendered on top of */
  108417. originalScene: Scene, handleEvents?: boolean);
  108418. private _notifyObservers;
  108419. /**
  108420. * Renders the utility layers scene on top of the original scene
  108421. */
  108422. render(): void;
  108423. /**
  108424. * Disposes of the renderer
  108425. */
  108426. dispose(): void;
  108427. private _updateCamera;
  108428. }
  108429. }
  108430. declare module BABYLON {
  108431. /**
  108432. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  108433. */
  108434. export class Gizmo implements IDisposable {
  108435. /** The utility layer the gizmo will be added to */
  108436. gizmoLayer: UtilityLayerRenderer;
  108437. /**
  108438. * The root mesh of the gizmo
  108439. */
  108440. _rootMesh: Mesh;
  108441. private _attachedMesh;
  108442. /**
  108443. * Ratio for the scale of the gizmo (Default: 1)
  108444. */
  108445. scaleRatio: number;
  108446. /**
  108447. * If a custom mesh has been set (Default: false)
  108448. */
  108449. protected _customMeshSet: boolean;
  108450. /**
  108451. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  108452. * * When set, interactions will be enabled
  108453. */
  108454. attachedMesh: Nullable<AbstractMesh>;
  108455. /**
  108456. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  108457. * @param mesh The mesh to replace the default mesh of the gizmo
  108458. */
  108459. setCustomMesh(mesh: Mesh): void;
  108460. /**
  108461. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  108462. */
  108463. updateGizmoRotationToMatchAttachedMesh: boolean;
  108464. /**
  108465. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  108466. */
  108467. updateGizmoPositionToMatchAttachedMesh: boolean;
  108468. /**
  108469. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  108470. */
  108471. updateScale: boolean;
  108472. protected _interactionsEnabled: boolean;
  108473. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108474. private _beforeRenderObserver;
  108475. private _tempVector;
  108476. /**
  108477. * Creates a gizmo
  108478. * @param gizmoLayer The utility layer the gizmo will be added to
  108479. */
  108480. constructor(
  108481. /** The utility layer the gizmo will be added to */
  108482. gizmoLayer?: UtilityLayerRenderer);
  108483. /**
  108484. * Updates the gizmo to match the attached mesh's position/rotation
  108485. */
  108486. protected _update(): void;
  108487. /**
  108488. * Disposes of the gizmo
  108489. */
  108490. dispose(): void;
  108491. }
  108492. }
  108493. declare module BABYLON {
  108494. /**
  108495. * Single plane drag gizmo
  108496. */
  108497. export class PlaneDragGizmo extends Gizmo {
  108498. /**
  108499. * Drag behavior responsible for the gizmos dragging interactions
  108500. */
  108501. dragBehavior: PointerDragBehavior;
  108502. private _pointerObserver;
  108503. /**
  108504. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108505. */
  108506. snapDistance: number;
  108507. /**
  108508. * Event that fires each time the gizmo snaps to a new location.
  108509. * * snapDistance is the the change in distance
  108510. */
  108511. onSnapObservable: Observable<{
  108512. snapDistance: number;
  108513. }>;
  108514. private _plane;
  108515. private _coloredMaterial;
  108516. private _hoverMaterial;
  108517. private _isEnabled;
  108518. private _parent;
  108519. /** @hidden */
  108520. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  108521. /** @hidden */
  108522. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  108523. /**
  108524. * Creates a PlaneDragGizmo
  108525. * @param gizmoLayer The utility layer the gizmo will be added to
  108526. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  108527. * @param color The color of the gizmo
  108528. */
  108529. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  108530. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108531. /**
  108532. * If the gizmo is enabled
  108533. */
  108534. isEnabled: boolean;
  108535. /**
  108536. * Disposes of the gizmo
  108537. */
  108538. dispose(): void;
  108539. }
  108540. }
  108541. declare module BABYLON {
  108542. /**
  108543. * Gizmo that enables dragging a mesh along 3 axis
  108544. */
  108545. export class PositionGizmo extends Gizmo {
  108546. /**
  108547. * Internal gizmo used for interactions on the x axis
  108548. */
  108549. xGizmo: AxisDragGizmo;
  108550. /**
  108551. * Internal gizmo used for interactions on the y axis
  108552. */
  108553. yGizmo: AxisDragGizmo;
  108554. /**
  108555. * Internal gizmo used for interactions on the z axis
  108556. */
  108557. zGizmo: AxisDragGizmo;
  108558. /**
  108559. * Internal gizmo used for interactions on the yz plane
  108560. */
  108561. xPlaneGizmo: PlaneDragGizmo;
  108562. /**
  108563. * Internal gizmo used for interactions on the xz plane
  108564. */
  108565. yPlaneGizmo: PlaneDragGizmo;
  108566. /**
  108567. * Internal gizmo used for interactions on the xy plane
  108568. */
  108569. zPlaneGizmo: PlaneDragGizmo;
  108570. /**
  108571. * private variables
  108572. */
  108573. private _meshAttached;
  108574. private _updateGizmoRotationToMatchAttachedMesh;
  108575. private _snapDistance;
  108576. private _scaleRatio;
  108577. /** Fires an event when any of it's sub gizmos are dragged */
  108578. onDragStartObservable: Observable<unknown>;
  108579. /** Fires an event when any of it's sub gizmos are released from dragging */
  108580. onDragEndObservable: Observable<unknown>;
  108581. /**
  108582. * If set to true, planar drag is enabled
  108583. */
  108584. private _planarGizmoEnabled;
  108585. attachedMesh: Nullable<AbstractMesh>;
  108586. /**
  108587. * Creates a PositionGizmo
  108588. * @param gizmoLayer The utility layer the gizmo will be added to
  108589. */
  108590. constructor(gizmoLayer?: UtilityLayerRenderer);
  108591. /**
  108592. * If the planar drag gizmo is enabled
  108593. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  108594. */
  108595. planarGizmoEnabled: boolean;
  108596. updateGizmoRotationToMatchAttachedMesh: boolean;
  108597. /**
  108598. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108599. */
  108600. snapDistance: number;
  108601. /**
  108602. * Ratio for the scale of the gizmo (Default: 1)
  108603. */
  108604. scaleRatio: number;
  108605. /**
  108606. * Disposes of the gizmo
  108607. */
  108608. dispose(): void;
  108609. /**
  108610. * CustomMeshes are not supported by this gizmo
  108611. * @param mesh The mesh to replace the default mesh of the gizmo
  108612. */
  108613. setCustomMesh(mesh: Mesh): void;
  108614. }
  108615. }
  108616. declare module BABYLON {
  108617. /**
  108618. * Single axis drag gizmo
  108619. */
  108620. export class AxisDragGizmo extends Gizmo {
  108621. /**
  108622. * Drag behavior responsible for the gizmos dragging interactions
  108623. */
  108624. dragBehavior: PointerDragBehavior;
  108625. private _pointerObserver;
  108626. /**
  108627. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108628. */
  108629. snapDistance: number;
  108630. /**
  108631. * Event that fires each time the gizmo snaps to a new location.
  108632. * * snapDistance is the the change in distance
  108633. */
  108634. onSnapObservable: Observable<{
  108635. snapDistance: number;
  108636. }>;
  108637. private _isEnabled;
  108638. private _parent;
  108639. private _arrow;
  108640. private _coloredMaterial;
  108641. private _hoverMaterial;
  108642. /** @hidden */
  108643. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  108644. /** @hidden */
  108645. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  108646. /**
  108647. * Creates an AxisDragGizmo
  108648. * @param gizmoLayer The utility layer the gizmo will be added to
  108649. * @param dragAxis The axis which the gizmo will be able to drag on
  108650. * @param color The color of the gizmo
  108651. */
  108652. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  108653. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108654. /**
  108655. * If the gizmo is enabled
  108656. */
  108657. isEnabled: boolean;
  108658. /**
  108659. * Disposes of the gizmo
  108660. */
  108661. dispose(): void;
  108662. }
  108663. }
  108664. declare module BABYLON.Debug {
  108665. /**
  108666. * The Axes viewer will show 3 axes in a specific point in space
  108667. */
  108668. export class AxesViewer {
  108669. private _xAxis;
  108670. private _yAxis;
  108671. private _zAxis;
  108672. private _scaleLinesFactor;
  108673. private _instanced;
  108674. /**
  108675. * Gets the hosting scene
  108676. */
  108677. scene: Scene;
  108678. /**
  108679. * Gets or sets a number used to scale line length
  108680. */
  108681. scaleLines: number;
  108682. /** Gets the node hierarchy used to render x-axis */
  108683. readonly xAxis: TransformNode;
  108684. /** Gets the node hierarchy used to render y-axis */
  108685. readonly yAxis: TransformNode;
  108686. /** Gets the node hierarchy used to render z-axis */
  108687. readonly zAxis: TransformNode;
  108688. /**
  108689. * Creates a new AxesViewer
  108690. * @param scene defines the hosting scene
  108691. * @param scaleLines defines a number used to scale line length (1 by default)
  108692. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  108693. * @param xAxis defines the node hierarchy used to render the x-axis
  108694. * @param yAxis defines the node hierarchy used to render the y-axis
  108695. * @param zAxis defines the node hierarchy used to render the z-axis
  108696. */
  108697. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  108698. /**
  108699. * Force the viewer to update
  108700. * @param position defines the position of the viewer
  108701. * @param xaxis defines the x axis of the viewer
  108702. * @param yaxis defines the y axis of the viewer
  108703. * @param zaxis defines the z axis of the viewer
  108704. */
  108705. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  108706. /**
  108707. * Creates an instance of this axes viewer.
  108708. * @returns a new axes viewer with instanced meshes
  108709. */
  108710. createInstance(): AxesViewer;
  108711. /** Releases resources */
  108712. dispose(): void;
  108713. private static _SetRenderingGroupId;
  108714. }
  108715. }
  108716. declare module BABYLON.Debug {
  108717. /**
  108718. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  108719. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  108720. */
  108721. export class BoneAxesViewer extends AxesViewer {
  108722. /**
  108723. * Gets or sets the target mesh where to display the axes viewer
  108724. */
  108725. mesh: Nullable<Mesh>;
  108726. /**
  108727. * Gets or sets the target bone where to display the axes viewer
  108728. */
  108729. bone: Nullable<Bone>;
  108730. /** Gets current position */
  108731. pos: Vector3;
  108732. /** Gets direction of X axis */
  108733. xaxis: Vector3;
  108734. /** Gets direction of Y axis */
  108735. yaxis: Vector3;
  108736. /** Gets direction of Z axis */
  108737. zaxis: Vector3;
  108738. /**
  108739. * Creates a new BoneAxesViewer
  108740. * @param scene defines the hosting scene
  108741. * @param bone defines the target bone
  108742. * @param mesh defines the target mesh
  108743. * @param scaleLines defines a scaling factor for line length (1 by default)
  108744. */
  108745. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  108746. /**
  108747. * Force the viewer to update
  108748. */
  108749. update(): void;
  108750. /** Releases resources */
  108751. dispose(): void;
  108752. }
  108753. }
  108754. declare module BABYLON {
  108755. /**
  108756. * Interface used to define scene explorer extensibility option
  108757. */
  108758. export interface IExplorerExtensibilityOption {
  108759. /**
  108760. * Define the option label
  108761. */
  108762. label: string;
  108763. /**
  108764. * Defines the action to execute on click
  108765. */
  108766. action: (entity: any) => void;
  108767. }
  108768. /**
  108769. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  108770. */
  108771. export interface IExplorerExtensibilityGroup {
  108772. /**
  108773. * Defines a predicate to test if a given type mut be extended
  108774. */
  108775. predicate: (entity: any) => boolean;
  108776. /**
  108777. * Gets the list of options added to a type
  108778. */
  108779. entries: IExplorerExtensibilityOption[];
  108780. }
  108781. /**
  108782. * Interface used to define the options to use to create the Inspector
  108783. */
  108784. export interface IInspectorOptions {
  108785. /**
  108786. * Display in overlay mode (default: false)
  108787. */
  108788. overlay?: boolean;
  108789. /**
  108790. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  108791. */
  108792. globalRoot?: HTMLElement;
  108793. /**
  108794. * Display the Scene explorer
  108795. */
  108796. showExplorer?: boolean;
  108797. /**
  108798. * Display the property inspector
  108799. */
  108800. showInspector?: boolean;
  108801. /**
  108802. * Display in embed mode (both panes on the right)
  108803. */
  108804. embedMode?: boolean;
  108805. /**
  108806. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  108807. */
  108808. handleResize?: boolean;
  108809. /**
  108810. * Allow the panes to popup (default: true)
  108811. */
  108812. enablePopup?: boolean;
  108813. /**
  108814. * Allow the panes to be closed by users (default: true)
  108815. */
  108816. enableClose?: boolean;
  108817. /**
  108818. * Optional list of extensibility entries
  108819. */
  108820. explorerExtensibility?: IExplorerExtensibilityGroup[];
  108821. /**
  108822. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  108823. */
  108824. inspectorURL?: string;
  108825. }
  108826. interface Scene {
  108827. /**
  108828. * @hidden
  108829. * Backing field
  108830. */
  108831. _debugLayer: DebugLayer;
  108832. /**
  108833. * Gets the debug layer (aka Inspector) associated with the scene
  108834. * @see http://doc.babylonjs.com/features/playground_debuglayer
  108835. */
  108836. debugLayer: DebugLayer;
  108837. }
  108838. /**
  108839. * The debug layer (aka Inspector) is the go to tool in order to better understand
  108840. * what is happening in your scene
  108841. * @see http://doc.babylonjs.com/features/playground_debuglayer
  108842. */
  108843. export class DebugLayer {
  108844. /**
  108845. * Define the url to get the inspector script from.
  108846. * By default it uses the babylonjs CDN.
  108847. * @ignoreNaming
  108848. */
  108849. static InspectorURL: string;
  108850. private _scene;
  108851. private BJSINSPECTOR;
  108852. private _onPropertyChangedObservable?;
  108853. /**
  108854. * Observable triggered when a property is changed through the inspector.
  108855. */
  108856. readonly onPropertyChangedObservable: any;
  108857. /**
  108858. * Instantiates a new debug layer.
  108859. * The debug layer (aka Inspector) is the go to tool in order to better understand
  108860. * what is happening in your scene
  108861. * @see http://doc.babylonjs.com/features/playground_debuglayer
  108862. * @param scene Defines the scene to inspect
  108863. */
  108864. constructor(scene: Scene);
  108865. /** Creates the inspector window. */
  108866. private _createInspector;
  108867. /**
  108868. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  108869. * @param entity defines the entity to select
  108870. * @param lineContainerTitle defines the specific block to highlight
  108871. */
  108872. select(entity: any, lineContainerTitle?: string): void;
  108873. /** Get the inspector from bundle or global */
  108874. private _getGlobalInspector;
  108875. /**
  108876. * Get if the inspector is visible or not.
  108877. * @returns true if visible otherwise, false
  108878. */
  108879. isVisible(): boolean;
  108880. /**
  108881. * Hide the inspector and close its window.
  108882. */
  108883. hide(): void;
  108884. /**
  108885. * Launch the debugLayer.
  108886. * @param config Define the configuration of the inspector
  108887. * @return a promise fulfilled when the debug layer is visible
  108888. */
  108889. show(config?: IInspectorOptions): Promise<DebugLayer>;
  108890. }
  108891. }
  108892. declare module BABYLON {
  108893. /**
  108894. * Class containing static functions to help procedurally build meshes
  108895. */
  108896. export class BoxBuilder {
  108897. /**
  108898. * Creates a box mesh
  108899. * * The parameter `size` sets the size (float) of each box side (default 1)
  108900. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  108901. * * 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)
  108902. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  108903. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108904. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108905. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108906. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  108907. * @param name defines the name of the mesh
  108908. * @param options defines the options used to create the mesh
  108909. * @param scene defines the hosting scene
  108910. * @returns the box mesh
  108911. */
  108912. static CreateBox(name: string, options: {
  108913. size?: number;
  108914. width?: number;
  108915. height?: number;
  108916. depth?: number;
  108917. faceUV?: Vector4[];
  108918. faceColors?: Color4[];
  108919. sideOrientation?: number;
  108920. frontUVs?: Vector4;
  108921. backUVs?: Vector4;
  108922. wrap?: boolean;
  108923. topBaseAt?: number;
  108924. bottomBaseAt?: number;
  108925. updatable?: boolean;
  108926. }, scene?: Nullable<Scene>): Mesh;
  108927. }
  108928. }
  108929. declare module BABYLON {
  108930. /**
  108931. * Class containing static functions to help procedurally build meshes
  108932. */
  108933. export class SphereBuilder {
  108934. /**
  108935. * Creates a sphere mesh
  108936. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  108937. * * 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`)
  108938. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  108939. * * 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
  108940. * * 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)
  108941. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108942. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108943. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108944. * @param name defines the name of the mesh
  108945. * @param options defines the options used to create the mesh
  108946. * @param scene defines the hosting scene
  108947. * @returns the sphere mesh
  108948. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  108949. */
  108950. static CreateSphere(name: string, options: {
  108951. segments?: number;
  108952. diameter?: number;
  108953. diameterX?: number;
  108954. diameterY?: number;
  108955. diameterZ?: number;
  108956. arc?: number;
  108957. slice?: number;
  108958. sideOrientation?: number;
  108959. frontUVs?: Vector4;
  108960. backUVs?: Vector4;
  108961. updatable?: boolean;
  108962. }, scene?: Nullable<Scene>): Mesh;
  108963. }
  108964. }
  108965. declare module BABYLON.Debug {
  108966. /**
  108967. * Used to show the physics impostor around the specific mesh
  108968. */
  108969. export class PhysicsViewer {
  108970. /** @hidden */
  108971. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  108972. /** @hidden */
  108973. protected _meshes: Array<Nullable<AbstractMesh>>;
  108974. /** @hidden */
  108975. protected _scene: Nullable<Scene>;
  108976. /** @hidden */
  108977. protected _numMeshes: number;
  108978. /** @hidden */
  108979. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  108980. private _renderFunction;
  108981. private _utilityLayer;
  108982. private _debugBoxMesh;
  108983. private _debugSphereMesh;
  108984. private _debugCylinderMesh;
  108985. private _debugMaterial;
  108986. private _debugMeshMeshes;
  108987. /**
  108988. * Creates a new PhysicsViewer
  108989. * @param scene defines the hosting scene
  108990. */
  108991. constructor(scene: Scene);
  108992. /** @hidden */
  108993. protected _updateDebugMeshes(): void;
  108994. /**
  108995. * Renders a specified physic impostor
  108996. * @param impostor defines the impostor to render
  108997. * @param targetMesh defines the mesh represented by the impostor
  108998. * @returns the new debug mesh used to render the impostor
  108999. */
  109000. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  109001. /**
  109002. * Hides a specified physic impostor
  109003. * @param impostor defines the impostor to hide
  109004. */
  109005. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  109006. private _getDebugMaterial;
  109007. private _getDebugBoxMesh;
  109008. private _getDebugSphereMesh;
  109009. private _getDebugCylinderMesh;
  109010. private _getDebugMeshMesh;
  109011. private _getDebugMesh;
  109012. /** Releases all resources */
  109013. dispose(): void;
  109014. }
  109015. }
  109016. declare module BABYLON {
  109017. /**
  109018. * Class containing static functions to help procedurally build meshes
  109019. */
  109020. export class LinesBuilder {
  109021. /**
  109022. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  109023. * * 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
  109024. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  109025. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  109026. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  109027. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  109028. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  109029. * * 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
  109030. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  109031. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109032. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  109033. * @param name defines the name of the new line system
  109034. * @param options defines the options used to create the line system
  109035. * @param scene defines the hosting scene
  109036. * @returns a new line system mesh
  109037. */
  109038. static CreateLineSystem(name: string, options: {
  109039. lines: Vector3[][];
  109040. updatable?: boolean;
  109041. instance?: Nullable<LinesMesh>;
  109042. colors?: Nullable<Color4[][]>;
  109043. useVertexAlpha?: boolean;
  109044. }, scene: Nullable<Scene>): LinesMesh;
  109045. /**
  109046. * Creates a line mesh
  109047. * 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
  109048. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  109049. * * The parameter `points` is an array successive Vector3
  109050. * * 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
  109051. * * The optional parameter `colors` is an array of successive Color4, one per line point
  109052. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  109053. * * When updating an instance, remember that only point positions can change, not the number of points
  109054. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109055. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  109056. * @param name defines the name of the new line system
  109057. * @param options defines the options used to create the line system
  109058. * @param scene defines the hosting scene
  109059. * @returns a new line mesh
  109060. */
  109061. static CreateLines(name: string, options: {
  109062. points: Vector3[];
  109063. updatable?: boolean;
  109064. instance?: Nullable<LinesMesh>;
  109065. colors?: Color4[];
  109066. useVertexAlpha?: boolean;
  109067. }, scene?: Nullable<Scene>): LinesMesh;
  109068. /**
  109069. * Creates a dashed line mesh
  109070. * * 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
  109071. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  109072. * * The parameter `points` is an array successive Vector3
  109073. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  109074. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  109075. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  109076. * * 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
  109077. * * When updating an instance, remember that only point positions can change, not the number of points
  109078. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109079. * @param name defines the name of the mesh
  109080. * @param options defines the options used to create the mesh
  109081. * @param scene defines the hosting scene
  109082. * @returns the dashed line mesh
  109083. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  109084. */
  109085. static CreateDashedLines(name: string, options: {
  109086. points: Vector3[];
  109087. dashSize?: number;
  109088. gapSize?: number;
  109089. dashNb?: number;
  109090. updatable?: boolean;
  109091. instance?: LinesMesh;
  109092. }, scene?: Nullable<Scene>): LinesMesh;
  109093. }
  109094. }
  109095. declare module BABYLON {
  109096. /**
  109097. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  109098. * in order to better appreciate the issue one might have.
  109099. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  109100. */
  109101. export class RayHelper {
  109102. /**
  109103. * Defines the ray we are currently tryin to visualize.
  109104. */
  109105. ray: Nullable<Ray>;
  109106. private _renderPoints;
  109107. private _renderLine;
  109108. private _renderFunction;
  109109. private _scene;
  109110. private _updateToMeshFunction;
  109111. private _attachedToMesh;
  109112. private _meshSpaceDirection;
  109113. private _meshSpaceOrigin;
  109114. /**
  109115. * Helper function to create a colored helper in a scene in one line.
  109116. * @param ray Defines the ray we are currently tryin to visualize
  109117. * @param scene Defines the scene the ray is used in
  109118. * @param color Defines the color we want to see the ray in
  109119. * @returns The newly created ray helper.
  109120. */
  109121. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  109122. /**
  109123. * Instantiate a new ray helper.
  109124. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  109125. * in order to better appreciate the issue one might have.
  109126. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  109127. * @param ray Defines the ray we are currently tryin to visualize
  109128. */
  109129. constructor(ray: Ray);
  109130. /**
  109131. * Shows the ray we are willing to debug.
  109132. * @param scene Defines the scene the ray needs to be rendered in
  109133. * @param color Defines the color the ray needs to be rendered in
  109134. */
  109135. show(scene: Scene, color?: Color3): void;
  109136. /**
  109137. * Hides the ray we are debugging.
  109138. */
  109139. hide(): void;
  109140. private _render;
  109141. /**
  109142. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  109143. * @param mesh Defines the mesh we want the helper attached to
  109144. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  109145. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  109146. * @param length Defines the length of the ray
  109147. */
  109148. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  109149. /**
  109150. * Detach the ray helper from the mesh it has previously been attached to.
  109151. */
  109152. detachFromMesh(): void;
  109153. private _updateToMesh;
  109154. /**
  109155. * Dispose the helper and release its associated resources.
  109156. */
  109157. dispose(): void;
  109158. }
  109159. }
  109160. declare module BABYLON.Debug {
  109161. /**
  109162. * Class used to render a debug view of a given skeleton
  109163. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  109164. */
  109165. export class SkeletonViewer {
  109166. /** defines the skeleton to render */
  109167. skeleton: Skeleton;
  109168. /** defines the mesh attached to the skeleton */
  109169. mesh: AbstractMesh;
  109170. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  109171. autoUpdateBonesMatrices: boolean;
  109172. /** defines the rendering group id to use with the viewer */
  109173. renderingGroupId: number;
  109174. /** Gets or sets the color used to render the skeleton */
  109175. color: Color3;
  109176. private _scene;
  109177. private _debugLines;
  109178. private _debugMesh;
  109179. private _isEnabled;
  109180. private _renderFunction;
  109181. private _utilityLayer;
  109182. /**
  109183. * Returns the mesh used to render the bones
  109184. */
  109185. readonly debugMesh: Nullable<LinesMesh>;
  109186. /**
  109187. * Creates a new SkeletonViewer
  109188. * @param skeleton defines the skeleton to render
  109189. * @param mesh defines the mesh attached to the skeleton
  109190. * @param scene defines the hosting scene
  109191. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  109192. * @param renderingGroupId defines the rendering group id to use with the viewer
  109193. */
  109194. constructor(
  109195. /** defines the skeleton to render */
  109196. skeleton: Skeleton,
  109197. /** defines the mesh attached to the skeleton */
  109198. mesh: AbstractMesh, scene: Scene,
  109199. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  109200. autoUpdateBonesMatrices?: boolean,
  109201. /** defines the rendering group id to use with the viewer */
  109202. renderingGroupId?: number);
  109203. /** Gets or sets a boolean indicating if the viewer is enabled */
  109204. isEnabled: boolean;
  109205. private _getBonePosition;
  109206. private _getLinesForBonesWithLength;
  109207. private _getLinesForBonesNoLength;
  109208. /** Update the viewer to sync with current skeleton state */
  109209. update(): void;
  109210. /** Release associated resources */
  109211. dispose(): void;
  109212. }
  109213. }
  109214. declare module BABYLON {
  109215. /**
  109216. * Options to create the null engine
  109217. */
  109218. export class NullEngineOptions {
  109219. /**
  109220. * Render width (Default: 512)
  109221. */
  109222. renderWidth: number;
  109223. /**
  109224. * Render height (Default: 256)
  109225. */
  109226. renderHeight: number;
  109227. /**
  109228. * Texture size (Default: 512)
  109229. */
  109230. textureSize: number;
  109231. /**
  109232. * If delta time between frames should be constant
  109233. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109234. */
  109235. deterministicLockstep: boolean;
  109236. /**
  109237. * Maximum about of steps between frames (Default: 4)
  109238. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109239. */
  109240. lockstepMaxSteps: number;
  109241. }
  109242. /**
  109243. * The null engine class provides support for headless version of babylon.js.
  109244. * This can be used in server side scenario or for testing purposes
  109245. */
  109246. export class NullEngine extends Engine {
  109247. private _options;
  109248. /**
  109249. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109250. */
  109251. isDeterministicLockStep(): boolean;
  109252. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  109253. getLockstepMaxSteps(): number;
  109254. /**
  109255. * Sets hardware scaling, used to save performance if needed
  109256. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109257. */
  109258. getHardwareScalingLevel(): number;
  109259. constructor(options?: NullEngineOptions);
  109260. createVertexBuffer(vertices: FloatArray): DataBuffer;
  109261. createIndexBuffer(indices: IndicesArray): DataBuffer;
  109262. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  109263. getRenderWidth(useScreen?: boolean): number;
  109264. getRenderHeight(useScreen?: boolean): number;
  109265. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  109266. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  109267. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  109268. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  109269. bindSamplers(effect: Effect): void;
  109270. enableEffect(effect: Effect): void;
  109271. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  109272. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  109273. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  109274. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  109275. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  109276. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  109277. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  109278. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  109279. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  109280. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  109281. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  109282. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  109283. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  109284. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  109285. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  109286. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  109287. setFloat(uniform: WebGLUniformLocation, value: number): void;
  109288. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  109289. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  109290. setBool(uniform: WebGLUniformLocation, bool: number): void;
  109291. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  109292. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  109293. bindBuffers(vertexBuffers: {
  109294. [key: string]: VertexBuffer;
  109295. }, indexBuffer: DataBuffer, effect: Effect): void;
  109296. wipeCaches(bruteForce?: boolean): void;
  109297. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  109298. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  109299. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  109300. /** @hidden */
  109301. _createTexture(): WebGLTexture;
  109302. /** @hidden */
  109303. _releaseTexture(texture: InternalTexture): void;
  109304. 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;
  109305. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  109306. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  109307. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  109308. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  109309. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  109310. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  109311. areAllEffectsReady(): boolean;
  109312. /**
  109313. * @hidden
  109314. * Get the current error code of the webGL context
  109315. * @returns the error code
  109316. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  109317. */
  109318. getError(): number;
  109319. /** @hidden */
  109320. _getUnpackAlignement(): number;
  109321. /** @hidden */
  109322. _unpackFlipY(value: boolean): void;
  109323. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  109324. /**
  109325. * Updates a dynamic vertex buffer.
  109326. * @param vertexBuffer the vertex buffer to update
  109327. * @param data the data used to update the vertex buffer
  109328. * @param byteOffset the byte offset of the data (optional)
  109329. * @param byteLength the byte length of the data (optional)
  109330. */
  109331. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  109332. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  109333. /** @hidden */
  109334. _bindTexture(channel: number, texture: InternalTexture): void;
  109335. protected _deleteBuffer(buffer: WebGLBuffer): void;
  109336. releaseEffects(): void;
  109337. displayLoadingUI(): void;
  109338. hideLoadingUI(): void;
  109339. /** @hidden */
  109340. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  109341. /** @hidden */
  109342. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  109343. /** @hidden */
  109344. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  109345. /** @hidden */
  109346. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  109347. }
  109348. }
  109349. declare module BABYLON {
  109350. /** @hidden */
  109351. export class _OcclusionDataStorage {
  109352. /** @hidden */
  109353. occlusionInternalRetryCounter: number;
  109354. /** @hidden */
  109355. isOcclusionQueryInProgress: boolean;
  109356. /** @hidden */
  109357. isOccluded: boolean;
  109358. /** @hidden */
  109359. occlusionRetryCount: number;
  109360. /** @hidden */
  109361. occlusionType: number;
  109362. /** @hidden */
  109363. occlusionQueryAlgorithmType: number;
  109364. }
  109365. interface Engine {
  109366. /**
  109367. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  109368. * @return the new query
  109369. */
  109370. createQuery(): WebGLQuery;
  109371. /**
  109372. * Delete and release a webGL query
  109373. * @param query defines the query to delete
  109374. * @return the current engine
  109375. */
  109376. deleteQuery(query: WebGLQuery): Engine;
  109377. /**
  109378. * Check if a given query has resolved and got its value
  109379. * @param query defines the query to check
  109380. * @returns true if the query got its value
  109381. */
  109382. isQueryResultAvailable(query: WebGLQuery): boolean;
  109383. /**
  109384. * Gets the value of a given query
  109385. * @param query defines the query to check
  109386. * @returns the value of the query
  109387. */
  109388. getQueryResult(query: WebGLQuery): number;
  109389. /**
  109390. * Initiates an occlusion query
  109391. * @param algorithmType defines the algorithm to use
  109392. * @param query defines the query to use
  109393. * @returns the current engine
  109394. * @see http://doc.babylonjs.com/features/occlusionquery
  109395. */
  109396. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  109397. /**
  109398. * Ends an occlusion query
  109399. * @see http://doc.babylonjs.com/features/occlusionquery
  109400. * @param algorithmType defines the algorithm to use
  109401. * @returns the current engine
  109402. */
  109403. endOcclusionQuery(algorithmType: number): Engine;
  109404. /**
  109405. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  109406. * Please note that only one query can be issued at a time
  109407. * @returns a time token used to track the time span
  109408. */
  109409. startTimeQuery(): Nullable<_TimeToken>;
  109410. /**
  109411. * Ends a time query
  109412. * @param token defines the token used to measure the time span
  109413. * @returns the time spent (in ns)
  109414. */
  109415. endTimeQuery(token: _TimeToken): int;
  109416. /** @hidden */
  109417. _currentNonTimestampToken: Nullable<_TimeToken>;
  109418. /** @hidden */
  109419. _createTimeQuery(): WebGLQuery;
  109420. /** @hidden */
  109421. _deleteTimeQuery(query: WebGLQuery): void;
  109422. /** @hidden */
  109423. _getGlAlgorithmType(algorithmType: number): number;
  109424. /** @hidden */
  109425. _getTimeQueryResult(query: WebGLQuery): any;
  109426. /** @hidden */
  109427. _getTimeQueryAvailability(query: WebGLQuery): any;
  109428. }
  109429. interface AbstractMesh {
  109430. /**
  109431. * Backing filed
  109432. * @hidden
  109433. */
  109434. __occlusionDataStorage: _OcclusionDataStorage;
  109435. /**
  109436. * Access property
  109437. * @hidden
  109438. */
  109439. _occlusionDataStorage: _OcclusionDataStorage;
  109440. /**
  109441. * 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.
  109442. * The default value is -1 which means don't break the query and wait till the result
  109443. * @see http://doc.babylonjs.com/features/occlusionquery
  109444. */
  109445. occlusionRetryCount: number;
  109446. /**
  109447. * 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:
  109448. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  109449. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  109450. * * 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.
  109451. * @see http://doc.babylonjs.com/features/occlusionquery
  109452. */
  109453. occlusionType: number;
  109454. /**
  109455. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  109456. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  109457. * * 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.
  109458. * @see http://doc.babylonjs.com/features/occlusionquery
  109459. */
  109460. occlusionQueryAlgorithmType: number;
  109461. /**
  109462. * 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
  109463. * @see http://doc.babylonjs.com/features/occlusionquery
  109464. */
  109465. isOccluded: boolean;
  109466. /**
  109467. * Flag to check the progress status of the query
  109468. * @see http://doc.babylonjs.com/features/occlusionquery
  109469. */
  109470. isOcclusionQueryInProgress: boolean;
  109471. }
  109472. }
  109473. declare module BABYLON {
  109474. /** @hidden */
  109475. export var _forceTransformFeedbackToBundle: boolean;
  109476. interface Engine {
  109477. /**
  109478. * Creates a webGL transform feedback object
  109479. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  109480. * @returns the webGL transform feedback object
  109481. */
  109482. createTransformFeedback(): WebGLTransformFeedback;
  109483. /**
  109484. * Delete a webGL transform feedback object
  109485. * @param value defines the webGL transform feedback object to delete
  109486. */
  109487. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  109488. /**
  109489. * Bind a webGL transform feedback object to the webgl context
  109490. * @param value defines the webGL transform feedback object to bind
  109491. */
  109492. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  109493. /**
  109494. * Begins a transform feedback operation
  109495. * @param usePoints defines if points or triangles must be used
  109496. */
  109497. beginTransformFeedback(usePoints: boolean): void;
  109498. /**
  109499. * Ends a transform feedback operation
  109500. */
  109501. endTransformFeedback(): void;
  109502. /**
  109503. * Specify the varyings to use with transform feedback
  109504. * @param program defines the associated webGL program
  109505. * @param value defines the list of strings representing the varying names
  109506. */
  109507. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  109508. /**
  109509. * Bind a webGL buffer for a transform feedback operation
  109510. * @param value defines the webGL buffer to bind
  109511. */
  109512. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  109513. }
  109514. }
  109515. declare module BABYLON {
  109516. /**
  109517. * Creation options of the multi render target texture.
  109518. */
  109519. export interface IMultiRenderTargetOptions {
  109520. /**
  109521. * Define if the texture needs to create mip maps after render.
  109522. */
  109523. generateMipMaps?: boolean;
  109524. /**
  109525. * Define the types of all the draw buffers we want to create
  109526. */
  109527. types?: number[];
  109528. /**
  109529. * Define the sampling modes of all the draw buffers we want to create
  109530. */
  109531. samplingModes?: number[];
  109532. /**
  109533. * Define if a depth buffer is required
  109534. */
  109535. generateDepthBuffer?: boolean;
  109536. /**
  109537. * Define if a stencil buffer is required
  109538. */
  109539. generateStencilBuffer?: boolean;
  109540. /**
  109541. * Define if a depth texture is required instead of a depth buffer
  109542. */
  109543. generateDepthTexture?: boolean;
  109544. /**
  109545. * Define the number of desired draw buffers
  109546. */
  109547. textureCount?: number;
  109548. /**
  109549. * Define if aspect ratio should be adapted to the texture or stay the scene one
  109550. */
  109551. doNotChangeAspectRatio?: boolean;
  109552. /**
  109553. * Define the default type of the buffers we are creating
  109554. */
  109555. defaultType?: number;
  109556. }
  109557. /**
  109558. * A multi render target, like a render target provides the ability to render to a texture.
  109559. * Unlike the render target, it can render to several draw buffers in one draw.
  109560. * This is specially interesting in deferred rendering or for any effects requiring more than
  109561. * just one color from a single pass.
  109562. */
  109563. export class MultiRenderTarget extends RenderTargetTexture {
  109564. private _internalTextures;
  109565. private _textures;
  109566. private _multiRenderTargetOptions;
  109567. /**
  109568. * Get if draw buffers are currently supported by the used hardware and browser.
  109569. */
  109570. readonly isSupported: boolean;
  109571. /**
  109572. * Get the list of textures generated by the multi render target.
  109573. */
  109574. readonly textures: Texture[];
  109575. /**
  109576. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  109577. */
  109578. readonly depthTexture: Texture;
  109579. /**
  109580. * Set the wrapping mode on U of all the textures we are rendering to.
  109581. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  109582. */
  109583. wrapU: number;
  109584. /**
  109585. * Set the wrapping mode on V of all the textures we are rendering to.
  109586. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  109587. */
  109588. wrapV: number;
  109589. /**
  109590. * Instantiate a new multi render target texture.
  109591. * A multi render target, like a render target provides the ability to render to a texture.
  109592. * Unlike the render target, it can render to several draw buffers in one draw.
  109593. * This is specially interesting in deferred rendering or for any effects requiring more than
  109594. * just one color from a single pass.
  109595. * @param name Define the name of the texture
  109596. * @param size Define the size of the buffers to render to
  109597. * @param count Define the number of target we are rendering into
  109598. * @param scene Define the scene the texture belongs to
  109599. * @param options Define the options used to create the multi render target
  109600. */
  109601. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  109602. /** @hidden */
  109603. _rebuild(): void;
  109604. private _createInternalTextures;
  109605. private _createTextures;
  109606. /**
  109607. * Define the number of samples used if MSAA is enabled.
  109608. */
  109609. samples: number;
  109610. /**
  109611. * Resize all the textures in the multi render target.
  109612. * Be carrefull as it will recreate all the data in the new texture.
  109613. * @param size Define the new size
  109614. */
  109615. resize(size: any): void;
  109616. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  109617. /**
  109618. * Dispose the render targets and their associated resources
  109619. */
  109620. dispose(): void;
  109621. /**
  109622. * Release all the underlying texture used as draw buffers.
  109623. */
  109624. releaseInternalTextures(): void;
  109625. }
  109626. }
  109627. declare module BABYLON {
  109628. interface Engine {
  109629. /**
  109630. * Unbind a list of render target textures from the webGL context
  109631. * This is used only when drawBuffer extension or webGL2 are active
  109632. * @param textures defines the render target textures to unbind
  109633. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  109634. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  109635. */
  109636. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  109637. /**
  109638. * Create a multi render target texture
  109639. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  109640. * @param size defines the size of the texture
  109641. * @param options defines the creation options
  109642. * @returns the cube texture as an InternalTexture
  109643. */
  109644. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  109645. /**
  109646. * Update the sample count for a given multiple render target texture
  109647. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  109648. * @param textures defines the textures to update
  109649. * @param samples defines the sample count to set
  109650. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  109651. */
  109652. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  109653. }
  109654. }
  109655. declare module BABYLON {
  109656. /** @hidden */
  109657. export var rgbdEncodePixelShader: {
  109658. name: string;
  109659. shader: string;
  109660. };
  109661. }
  109662. declare module BABYLON {
  109663. /** @hidden */
  109664. export var rgbdDecodePixelShader: {
  109665. name: string;
  109666. shader: string;
  109667. };
  109668. }
  109669. declare module BABYLON {
  109670. /**
  109671. * Raw texture data and descriptor sufficient for WebGL texture upload
  109672. */
  109673. export interface EnvironmentTextureInfo {
  109674. /**
  109675. * Version of the environment map
  109676. */
  109677. version: number;
  109678. /**
  109679. * Width of image
  109680. */
  109681. width: number;
  109682. /**
  109683. * Irradiance information stored in the file.
  109684. */
  109685. irradiance: any;
  109686. /**
  109687. * Specular information stored in the file.
  109688. */
  109689. specular: any;
  109690. }
  109691. /**
  109692. * Defines One Image in the file. It requires only the position in the file
  109693. * as well as the length.
  109694. */
  109695. interface BufferImageData {
  109696. /**
  109697. * Length of the image data.
  109698. */
  109699. length: number;
  109700. /**
  109701. * Position of the data from the null terminator delimiting the end of the JSON.
  109702. */
  109703. position: number;
  109704. }
  109705. /**
  109706. * Defines the specular data enclosed in the file.
  109707. * This corresponds to the version 1 of the data.
  109708. */
  109709. export interface EnvironmentTextureSpecularInfoV1 {
  109710. /**
  109711. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  109712. */
  109713. specularDataPosition?: number;
  109714. /**
  109715. * This contains all the images data needed to reconstruct the cubemap.
  109716. */
  109717. mipmaps: Array<BufferImageData>;
  109718. /**
  109719. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  109720. */
  109721. lodGenerationScale: number;
  109722. }
  109723. /**
  109724. * Sets of helpers addressing the serialization and deserialization of environment texture
  109725. * stored in a BabylonJS env file.
  109726. * Those files are usually stored as .env files.
  109727. */
  109728. export class EnvironmentTextureTools {
  109729. /**
  109730. * Magic number identifying the env file.
  109731. */
  109732. private static _MagicBytes;
  109733. /**
  109734. * Gets the environment info from an env file.
  109735. * @param data The array buffer containing the .env bytes.
  109736. * @returns the environment file info (the json header) if successfully parsed.
  109737. */
  109738. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  109739. /**
  109740. * Creates an environment texture from a loaded cube texture.
  109741. * @param texture defines the cube texture to convert in env file
  109742. * @return a promise containing the environment data if succesfull.
  109743. */
  109744. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  109745. /**
  109746. * Creates a JSON representation of the spherical data.
  109747. * @param texture defines the texture containing the polynomials
  109748. * @return the JSON representation of the spherical info
  109749. */
  109750. private static _CreateEnvTextureIrradiance;
  109751. /**
  109752. * Creates the ArrayBufferViews used for initializing environment texture image data.
  109753. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  109754. * @param info parameters that determine what views will be created for accessing the underlying buffer
  109755. * @return the views described by info providing access to the underlying buffer
  109756. */
  109757. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  109758. /**
  109759. * Uploads the texture info contained in the env file to the GPU.
  109760. * @param texture defines the internal texture to upload to
  109761. * @param arrayBuffer defines the buffer cotaining the data to load
  109762. * @param info defines the texture info retrieved through the GetEnvInfo method
  109763. * @returns a promise
  109764. */
  109765. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  109766. /**
  109767. * Uploads the levels of image data to the GPU.
  109768. * @param texture defines the internal texture to upload to
  109769. * @param imageData defines the array buffer views of image data [mipmap][face]
  109770. * @returns a promise
  109771. */
  109772. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  109773. /**
  109774. * Uploads spherical polynomials information to the texture.
  109775. * @param texture defines the texture we are trying to upload the information to
  109776. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  109777. */
  109778. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  109779. /** @hidden */
  109780. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  109781. }
  109782. }
  109783. declare module BABYLON {
  109784. /**
  109785. * Contains position and normal vectors for a vertex
  109786. */
  109787. export class PositionNormalVertex {
  109788. /** the position of the vertex (defaut: 0,0,0) */
  109789. position: Vector3;
  109790. /** the normal of the vertex (defaut: 0,1,0) */
  109791. normal: Vector3;
  109792. /**
  109793. * Creates a PositionNormalVertex
  109794. * @param position the position of the vertex (defaut: 0,0,0)
  109795. * @param normal the normal of the vertex (defaut: 0,1,0)
  109796. */
  109797. constructor(
  109798. /** the position of the vertex (defaut: 0,0,0) */
  109799. position?: Vector3,
  109800. /** the normal of the vertex (defaut: 0,1,0) */
  109801. normal?: Vector3);
  109802. /**
  109803. * Clones the PositionNormalVertex
  109804. * @returns the cloned PositionNormalVertex
  109805. */
  109806. clone(): PositionNormalVertex;
  109807. }
  109808. /**
  109809. * Contains position, normal and uv vectors for a vertex
  109810. */
  109811. export class PositionNormalTextureVertex {
  109812. /** the position of the vertex (defaut: 0,0,0) */
  109813. position: Vector3;
  109814. /** the normal of the vertex (defaut: 0,1,0) */
  109815. normal: Vector3;
  109816. /** the uv of the vertex (default: 0,0) */
  109817. uv: Vector2;
  109818. /**
  109819. * Creates a PositionNormalTextureVertex
  109820. * @param position the position of the vertex (defaut: 0,0,0)
  109821. * @param normal the normal of the vertex (defaut: 0,1,0)
  109822. * @param uv the uv of the vertex (default: 0,0)
  109823. */
  109824. constructor(
  109825. /** the position of the vertex (defaut: 0,0,0) */
  109826. position?: Vector3,
  109827. /** the normal of the vertex (defaut: 0,1,0) */
  109828. normal?: Vector3,
  109829. /** the uv of the vertex (default: 0,0) */
  109830. uv?: Vector2);
  109831. /**
  109832. * Clones the PositionNormalTextureVertex
  109833. * @returns the cloned PositionNormalTextureVertex
  109834. */
  109835. clone(): PositionNormalTextureVertex;
  109836. }
  109837. }
  109838. declare module BABYLON {
  109839. /** @hidden */
  109840. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  109841. private _genericAttributeLocation;
  109842. private _varyingLocationCount;
  109843. private _varyingLocationMap;
  109844. private _replacements;
  109845. private _textureCount;
  109846. private _uniforms;
  109847. lineProcessor(line: string): string;
  109848. attributeProcessor(attribute: string): string;
  109849. varyingProcessor(varying: string, isFragment: boolean): string;
  109850. uniformProcessor(uniform: string): string;
  109851. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  109852. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  109853. }
  109854. }
  109855. declare module BABYLON {
  109856. /**
  109857. * Container for accessors for natively-stored mesh data buffers.
  109858. */
  109859. class NativeDataBuffer extends DataBuffer {
  109860. /**
  109861. * Accessor value used to identify/retrieve a natively-stored index buffer.
  109862. */
  109863. nativeIndexBuffer?: any;
  109864. /**
  109865. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  109866. */
  109867. nativeVertexBuffer?: any;
  109868. }
  109869. /** @hidden */
  109870. export class NativeEngine extends Engine {
  109871. private readonly _native;
  109872. getHardwareScalingLevel(): number;
  109873. constructor();
  109874. /**
  109875. * Can be used to override the current requestAnimationFrame requester.
  109876. * @hidden
  109877. */
  109878. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  109879. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  109880. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  109881. createVertexBuffer(data: DataArray): NativeDataBuffer;
  109882. recordVertexArrayObject(vertexBuffers: {
  109883. [key: string]: VertexBuffer;
  109884. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  109885. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  109886. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  109887. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  109888. /**
  109889. * Draw a list of indexed primitives
  109890. * @param fillMode defines the primitive to use
  109891. * @param indexStart defines the starting index
  109892. * @param indexCount defines the number of index to draw
  109893. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  109894. */
  109895. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  109896. /**
  109897. * Draw a list of unindexed primitives
  109898. * @param fillMode defines the primitive to use
  109899. * @param verticesStart defines the index of first vertex to draw
  109900. * @param verticesCount defines the count of vertices to draw
  109901. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  109902. */
  109903. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  109904. createPipelineContext(): IPipelineContext;
  109905. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  109906. /** @hidden */
  109907. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  109908. /** @hidden */
  109909. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  109910. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  109911. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  109912. protected _setProgram(program: WebGLProgram): void;
  109913. _releaseEffect(effect: Effect): void;
  109914. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  109915. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  109916. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  109917. bindSamplers(effect: Effect): void;
  109918. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  109919. getRenderWidth(useScreen?: boolean): number;
  109920. getRenderHeight(useScreen?: boolean): number;
  109921. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  109922. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  109923. /**
  109924. * Set the z offset to apply to current rendering
  109925. * @param value defines the offset to apply
  109926. */
  109927. setZOffset(value: number): void;
  109928. /**
  109929. * Gets the current value of the zOffset
  109930. * @returns the current zOffset state
  109931. */
  109932. getZOffset(): number;
  109933. /**
  109934. * Enable or disable depth buffering
  109935. * @param enable defines the state to set
  109936. */
  109937. setDepthBuffer(enable: boolean): void;
  109938. /**
  109939. * Gets a boolean indicating if depth writing is enabled
  109940. * @returns the current depth writing state
  109941. */
  109942. getDepthWrite(): boolean;
  109943. /**
  109944. * Enable or disable depth writing
  109945. * @param enable defines the state to set
  109946. */
  109947. setDepthWrite(enable: boolean): void;
  109948. /**
  109949. * Enable or disable color writing
  109950. * @param enable defines the state to set
  109951. */
  109952. setColorWrite(enable: boolean): void;
  109953. /**
  109954. * Gets a boolean indicating if color writing is enabled
  109955. * @returns the current color writing state
  109956. */
  109957. getColorWrite(): boolean;
  109958. /**
  109959. * Sets alpha constants used by some alpha blending modes
  109960. * @param r defines the red component
  109961. * @param g defines the green component
  109962. * @param b defines the blue component
  109963. * @param a defines the alpha component
  109964. */
  109965. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  109966. /**
  109967. * Sets the current alpha mode
  109968. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  109969. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  109970. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  109971. */
  109972. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  109973. /**
  109974. * Gets the current alpha mode
  109975. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  109976. * @returns the current alpha mode
  109977. */
  109978. getAlphaMode(): number;
  109979. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  109980. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  109981. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  109982. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  109983. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  109984. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  109985. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  109986. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  109987. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  109988. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  109989. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  109990. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  109991. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  109992. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  109993. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  109994. setFloat(uniform: WebGLUniformLocation, value: number): void;
  109995. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  109996. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  109997. setBool(uniform: WebGLUniformLocation, bool: number): void;
  109998. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  109999. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  110000. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  110001. wipeCaches(bruteForce?: boolean): void;
  110002. _createTexture(): WebGLTexture;
  110003. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  110004. /**
  110005. * Usually called from BABYLON.Texture.ts.
  110006. * Passed information to create a WebGLTexture
  110007. * @param urlArg defines a value which contains one of the following:
  110008. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  110009. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  110010. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  110011. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  110012. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  110013. * @param scene needed for loading to the correct scene
  110014. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  110015. * @param onLoad optional callback to be called upon successful completion
  110016. * @param onError optional callback to be called upon failure
  110017. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  110018. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  110019. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  110020. * @param forcedExtension defines the extension to use to pick the right loader
  110021. * @returns a InternalTexture for assignment back into BABYLON.Texture
  110022. */
  110023. 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;
  110024. /**
  110025. * Creates a cube texture
  110026. * @param rootUrl defines the url where the files to load is located
  110027. * @param scene defines the current scene
  110028. * @param files defines the list of files to load (1 per face)
  110029. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  110030. * @param onLoad defines an optional callback raised when the texture is loaded
  110031. * @param onError defines an optional callback raised if there is an issue to load the texture
  110032. * @param format defines the format of the data
  110033. * @param forcedExtension defines the extension to use to pick the right loader
  110034. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  110035. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  110036. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  110037. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  110038. * @returns the cube texture as an InternalTexture
  110039. */
  110040. 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;
  110041. private _getSamplingFilter;
  110042. private static _GetNativeTextureFormat;
  110043. createRenderTargetTexture(size: number | {
  110044. width: number;
  110045. height: number;
  110046. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  110047. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  110048. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  110049. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  110050. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  110051. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  110052. /**
  110053. * Updates a dynamic vertex buffer.
  110054. * @param vertexBuffer the vertex buffer to update
  110055. * @param data the data used to update the vertex buffer
  110056. * @param byteOffset the byte offset of the data (optional)
  110057. * @param byteLength the byte length of the data (optional)
  110058. */
  110059. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  110060. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  110061. private _updateAnisotropicLevel;
  110062. private _getAddressMode;
  110063. /** @hidden */
  110064. _bindTexture(channel: number, texture: InternalTexture): void;
  110065. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  110066. releaseEffects(): void;
  110067. /** @hidden */
  110068. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110069. /** @hidden */
  110070. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110071. /** @hidden */
  110072. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110073. /** @hidden */
  110074. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  110075. }
  110076. }
  110077. declare module BABYLON {
  110078. /**
  110079. * Gather the list of clipboard event types as constants.
  110080. */
  110081. export class ClipboardEventTypes {
  110082. /**
  110083. * The clipboard event is fired when a copy command is active (pressed).
  110084. */
  110085. static readonly COPY: number;
  110086. /**
  110087. * The clipboard event is fired when a cut command is active (pressed).
  110088. */
  110089. static readonly CUT: number;
  110090. /**
  110091. * The clipboard event is fired when a paste command is active (pressed).
  110092. */
  110093. static readonly PASTE: number;
  110094. }
  110095. /**
  110096. * This class is used to store clipboard related info for the onClipboardObservable event.
  110097. */
  110098. export class ClipboardInfo {
  110099. /**
  110100. * Defines the type of event (BABYLON.ClipboardEventTypes)
  110101. */
  110102. type: number;
  110103. /**
  110104. * Defines the related dom event
  110105. */
  110106. event: ClipboardEvent;
  110107. /**
  110108. *Creates an instance of ClipboardInfo.
  110109. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  110110. * @param event Defines the related dom event
  110111. */
  110112. constructor(
  110113. /**
  110114. * Defines the type of event (BABYLON.ClipboardEventTypes)
  110115. */
  110116. type: number,
  110117. /**
  110118. * Defines the related dom event
  110119. */
  110120. event: ClipboardEvent);
  110121. /**
  110122. * Get the clipboard event's type from the keycode.
  110123. * @param keyCode Defines the keyCode for the current keyboard event.
  110124. * @return {number}
  110125. */
  110126. static GetTypeFromCharacter(keyCode: number): number;
  110127. }
  110128. }
  110129. declare module BABYLON {
  110130. /**
  110131. * Google Daydream controller
  110132. */
  110133. export class DaydreamController extends WebVRController {
  110134. /**
  110135. * Base Url for the controller model.
  110136. */
  110137. static MODEL_BASE_URL: string;
  110138. /**
  110139. * File name for the controller model.
  110140. */
  110141. static MODEL_FILENAME: string;
  110142. /**
  110143. * Gamepad Id prefix used to identify Daydream Controller.
  110144. */
  110145. static readonly GAMEPAD_ID_PREFIX: string;
  110146. /**
  110147. * Creates a new DaydreamController from a gamepad
  110148. * @param vrGamepad the gamepad that the controller should be created from
  110149. */
  110150. constructor(vrGamepad: any);
  110151. /**
  110152. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110153. * @param scene scene in which to add meshes
  110154. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110155. */
  110156. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  110157. /**
  110158. * Called once for each button that changed state since the last frame
  110159. * @param buttonIdx Which button index changed
  110160. * @param state New state of the button
  110161. * @param changes Which properties on the state changed since last frame
  110162. */
  110163. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110164. }
  110165. }
  110166. declare module BABYLON {
  110167. /**
  110168. * Gear VR Controller
  110169. */
  110170. export class GearVRController extends WebVRController {
  110171. /**
  110172. * Base Url for the controller model.
  110173. */
  110174. static MODEL_BASE_URL: string;
  110175. /**
  110176. * File name for the controller model.
  110177. */
  110178. static MODEL_FILENAME: string;
  110179. /**
  110180. * Gamepad Id prefix used to identify this controller.
  110181. */
  110182. static readonly GAMEPAD_ID_PREFIX: string;
  110183. private readonly _buttonIndexToObservableNameMap;
  110184. /**
  110185. * Creates a new GearVRController from a gamepad
  110186. * @param vrGamepad the gamepad that the controller should be created from
  110187. */
  110188. constructor(vrGamepad: any);
  110189. /**
  110190. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110191. * @param scene scene in which to add meshes
  110192. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110193. */
  110194. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  110195. /**
  110196. * Called once for each button that changed state since the last frame
  110197. * @param buttonIdx Which button index changed
  110198. * @param state New state of the button
  110199. * @param changes Which properties on the state changed since last frame
  110200. */
  110201. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110202. }
  110203. }
  110204. declare module BABYLON {
  110205. /**
  110206. * Class containing static functions to help procedurally build meshes
  110207. */
  110208. export class PolyhedronBuilder {
  110209. /**
  110210. * Creates a polyhedron mesh
  110211. * * 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
  110212. * * The parameter `size` (positive float, default 1) sets the polygon size
  110213. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  110214. * * 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`
  110215. * * 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
  110216. * * 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)`)
  110217. * * 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
  110218. * * 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
  110219. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110220. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110221. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110222. * @param name defines the name of the mesh
  110223. * @param options defines the options used to create the mesh
  110224. * @param scene defines the hosting scene
  110225. * @returns the polyhedron mesh
  110226. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  110227. */
  110228. static CreatePolyhedron(name: string, options: {
  110229. type?: number;
  110230. size?: number;
  110231. sizeX?: number;
  110232. sizeY?: number;
  110233. sizeZ?: number;
  110234. custom?: any;
  110235. faceUV?: Vector4[];
  110236. faceColors?: Color4[];
  110237. flat?: boolean;
  110238. updatable?: boolean;
  110239. sideOrientation?: number;
  110240. frontUVs?: Vector4;
  110241. backUVs?: Vector4;
  110242. }, scene?: Nullable<Scene>): Mesh;
  110243. }
  110244. }
  110245. declare module BABYLON {
  110246. /**
  110247. * Gizmo that enables scaling a mesh along 3 axis
  110248. */
  110249. export class ScaleGizmo extends Gizmo {
  110250. /**
  110251. * Internal gizmo used for interactions on the x axis
  110252. */
  110253. xGizmo: AxisScaleGizmo;
  110254. /**
  110255. * Internal gizmo used for interactions on the y axis
  110256. */
  110257. yGizmo: AxisScaleGizmo;
  110258. /**
  110259. * Internal gizmo used for interactions on the z axis
  110260. */
  110261. zGizmo: AxisScaleGizmo;
  110262. /**
  110263. * Internal gizmo used to scale all axis equally
  110264. */
  110265. uniformScaleGizmo: AxisScaleGizmo;
  110266. private _meshAttached;
  110267. private _updateGizmoRotationToMatchAttachedMesh;
  110268. private _snapDistance;
  110269. private _scaleRatio;
  110270. private _uniformScalingMesh;
  110271. private _octahedron;
  110272. /** Fires an event when any of it's sub gizmos are dragged */
  110273. onDragStartObservable: Observable<unknown>;
  110274. /** Fires an event when any of it's sub gizmos are released from dragging */
  110275. onDragEndObservable: Observable<unknown>;
  110276. attachedMesh: Nullable<AbstractMesh>;
  110277. /**
  110278. * Creates a ScaleGizmo
  110279. * @param gizmoLayer The utility layer the gizmo will be added to
  110280. */
  110281. constructor(gizmoLayer?: UtilityLayerRenderer);
  110282. updateGizmoRotationToMatchAttachedMesh: boolean;
  110283. /**
  110284. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110285. */
  110286. snapDistance: number;
  110287. /**
  110288. * Ratio for the scale of the gizmo (Default: 1)
  110289. */
  110290. scaleRatio: number;
  110291. /**
  110292. * Disposes of the gizmo
  110293. */
  110294. dispose(): void;
  110295. }
  110296. }
  110297. declare module BABYLON {
  110298. /**
  110299. * Single axis scale gizmo
  110300. */
  110301. export class AxisScaleGizmo extends Gizmo {
  110302. /**
  110303. * Drag behavior responsible for the gizmos dragging interactions
  110304. */
  110305. dragBehavior: PointerDragBehavior;
  110306. private _pointerObserver;
  110307. /**
  110308. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110309. */
  110310. snapDistance: number;
  110311. /**
  110312. * Event that fires each time the gizmo snaps to a new location.
  110313. * * snapDistance is the the change in distance
  110314. */
  110315. onSnapObservable: Observable<{
  110316. snapDistance: number;
  110317. }>;
  110318. /**
  110319. * If the scaling operation should be done on all axis (default: false)
  110320. */
  110321. uniformScaling: boolean;
  110322. private _isEnabled;
  110323. private _parent;
  110324. private _arrow;
  110325. private _coloredMaterial;
  110326. private _hoverMaterial;
  110327. /**
  110328. * Creates an AxisScaleGizmo
  110329. * @param gizmoLayer The utility layer the gizmo will be added to
  110330. * @param dragAxis The axis which the gizmo will be able to scale on
  110331. * @param color The color of the gizmo
  110332. */
  110333. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  110334. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110335. /**
  110336. * If the gizmo is enabled
  110337. */
  110338. isEnabled: boolean;
  110339. /**
  110340. * Disposes of the gizmo
  110341. */
  110342. dispose(): void;
  110343. /**
  110344. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  110345. * @param mesh The mesh to replace the default mesh of the gizmo
  110346. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  110347. */
  110348. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  110349. }
  110350. }
  110351. declare module BABYLON {
  110352. /**
  110353. * Bounding box gizmo
  110354. */
  110355. export class BoundingBoxGizmo extends Gizmo {
  110356. private _lineBoundingBox;
  110357. private _rotateSpheresParent;
  110358. private _scaleBoxesParent;
  110359. private _boundingDimensions;
  110360. private _renderObserver;
  110361. private _pointerObserver;
  110362. private _scaleDragSpeed;
  110363. private _tmpQuaternion;
  110364. private _tmpVector;
  110365. private _tmpRotationMatrix;
  110366. /**
  110367. * 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)
  110368. */
  110369. ignoreChildren: boolean;
  110370. /**
  110371. * 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)
  110372. */
  110373. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  110374. /**
  110375. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  110376. */
  110377. rotationSphereSize: number;
  110378. /**
  110379. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  110380. */
  110381. scaleBoxSize: number;
  110382. /**
  110383. * 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)
  110384. */
  110385. fixedDragMeshScreenSize: boolean;
  110386. /**
  110387. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  110388. */
  110389. fixedDragMeshScreenSizeDistanceFactor: number;
  110390. /**
  110391. * Fired when a rotation sphere or scale box is dragged
  110392. */
  110393. onDragStartObservable: Observable<{}>;
  110394. /**
  110395. * Fired when a scale box is dragged
  110396. */
  110397. onScaleBoxDragObservable: Observable<{}>;
  110398. /**
  110399. * Fired when a scale box drag is ended
  110400. */
  110401. onScaleBoxDragEndObservable: Observable<{}>;
  110402. /**
  110403. * Fired when a rotation sphere is dragged
  110404. */
  110405. onRotationSphereDragObservable: Observable<{}>;
  110406. /**
  110407. * Fired when a rotation sphere drag is ended
  110408. */
  110409. onRotationSphereDragEndObservable: Observable<{}>;
  110410. /**
  110411. * 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)
  110412. */
  110413. scalePivot: Nullable<Vector3>;
  110414. /**
  110415. * Mesh used as a pivot to rotate the attached mesh
  110416. */
  110417. private _anchorMesh;
  110418. private _existingMeshScale;
  110419. private _dragMesh;
  110420. private pointerDragBehavior;
  110421. private coloredMaterial;
  110422. private hoverColoredMaterial;
  110423. /**
  110424. * Sets the color of the bounding box gizmo
  110425. * @param color the color to set
  110426. */
  110427. setColor(color: Color3): void;
  110428. /**
  110429. * Creates an BoundingBoxGizmo
  110430. * @param gizmoLayer The utility layer the gizmo will be added to
  110431. * @param color The color of the gizmo
  110432. */
  110433. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  110434. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110435. private _selectNode;
  110436. /**
  110437. * Updates the bounding box information for the Gizmo
  110438. */
  110439. updateBoundingBox(): void;
  110440. private _updateRotationSpheres;
  110441. private _updateScaleBoxes;
  110442. /**
  110443. * Enables rotation on the specified axis and disables rotation on the others
  110444. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  110445. */
  110446. setEnabledRotationAxis(axis: string): void;
  110447. /**
  110448. * Enables/disables scaling
  110449. * @param enable if scaling should be enabled
  110450. */
  110451. setEnabledScaling(enable: boolean): void;
  110452. private _updateDummy;
  110453. /**
  110454. * Enables a pointer drag behavior on the bounding box of the gizmo
  110455. */
  110456. enableDragBehavior(): void;
  110457. /**
  110458. * Disposes of the gizmo
  110459. */
  110460. dispose(): void;
  110461. /**
  110462. * 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)
  110463. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  110464. * @returns the bounding box mesh with the passed in mesh as a child
  110465. */
  110466. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  110467. /**
  110468. * CustomMeshes are not supported by this gizmo
  110469. * @param mesh The mesh to replace the default mesh of the gizmo
  110470. */
  110471. setCustomMesh(mesh: Mesh): void;
  110472. }
  110473. }
  110474. declare module BABYLON {
  110475. /**
  110476. * Single plane rotation gizmo
  110477. */
  110478. export class PlaneRotationGizmo extends Gizmo {
  110479. /**
  110480. * Drag behavior responsible for the gizmos dragging interactions
  110481. */
  110482. dragBehavior: PointerDragBehavior;
  110483. private _pointerObserver;
  110484. /**
  110485. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  110486. */
  110487. snapDistance: number;
  110488. /**
  110489. * Event that fires each time the gizmo snaps to a new location.
  110490. * * snapDistance is the the change in distance
  110491. */
  110492. onSnapObservable: Observable<{
  110493. snapDistance: number;
  110494. }>;
  110495. private _isEnabled;
  110496. private _parent;
  110497. /**
  110498. * Creates a PlaneRotationGizmo
  110499. * @param gizmoLayer The utility layer the gizmo will be added to
  110500. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  110501. * @param color The color of the gizmo
  110502. * @param tessellation Amount of tessellation to be used when creating rotation circles
  110503. * @param useEulerRotation Use and update Euler angle instead of quaternion
  110504. */
  110505. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  110506. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110507. /**
  110508. * If the gizmo is enabled
  110509. */
  110510. isEnabled: boolean;
  110511. /**
  110512. * Disposes of the gizmo
  110513. */
  110514. dispose(): void;
  110515. }
  110516. }
  110517. declare module BABYLON {
  110518. /**
  110519. * Gizmo that enables rotating a mesh along 3 axis
  110520. */
  110521. export class RotationGizmo extends Gizmo {
  110522. /**
  110523. * Internal gizmo used for interactions on the x axis
  110524. */
  110525. xGizmo: PlaneRotationGizmo;
  110526. /**
  110527. * Internal gizmo used for interactions on the y axis
  110528. */
  110529. yGizmo: PlaneRotationGizmo;
  110530. /**
  110531. * Internal gizmo used for interactions on the z axis
  110532. */
  110533. zGizmo: PlaneRotationGizmo;
  110534. /** Fires an event when any of it's sub gizmos are dragged */
  110535. onDragStartObservable: Observable<unknown>;
  110536. /** Fires an event when any of it's sub gizmos are released from dragging */
  110537. onDragEndObservable: Observable<unknown>;
  110538. private _meshAttached;
  110539. attachedMesh: Nullable<AbstractMesh>;
  110540. /**
  110541. * Creates a RotationGizmo
  110542. * @param gizmoLayer The utility layer the gizmo will be added to
  110543. * @param tessellation Amount of tessellation to be used when creating rotation circles
  110544. * @param useEulerRotation Use and update Euler angle instead of quaternion
  110545. */
  110546. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  110547. updateGizmoRotationToMatchAttachedMesh: boolean;
  110548. /**
  110549. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110550. */
  110551. snapDistance: number;
  110552. /**
  110553. * Ratio for the scale of the gizmo (Default: 1)
  110554. */
  110555. scaleRatio: number;
  110556. /**
  110557. * Disposes of the gizmo
  110558. */
  110559. dispose(): void;
  110560. /**
  110561. * CustomMeshes are not supported by this gizmo
  110562. * @param mesh The mesh to replace the default mesh of the gizmo
  110563. */
  110564. setCustomMesh(mesh: Mesh): void;
  110565. }
  110566. }
  110567. declare module BABYLON {
  110568. /**
  110569. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  110570. */
  110571. export class GizmoManager implements IDisposable {
  110572. private scene;
  110573. /**
  110574. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  110575. */
  110576. gizmos: {
  110577. positionGizmo: Nullable<PositionGizmo>;
  110578. rotationGizmo: Nullable<RotationGizmo>;
  110579. scaleGizmo: Nullable<ScaleGizmo>;
  110580. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  110581. };
  110582. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  110583. clearGizmoOnEmptyPointerEvent: boolean;
  110584. /** Fires an event when the manager is attached to a mesh */
  110585. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  110586. private _gizmosEnabled;
  110587. private _pointerObserver;
  110588. private _attachedMesh;
  110589. private _boundingBoxColor;
  110590. private _defaultUtilityLayer;
  110591. private _defaultKeepDepthUtilityLayer;
  110592. /**
  110593. * When bounding box gizmo is enabled, this can be used to track drag/end events
  110594. */
  110595. boundingBoxDragBehavior: SixDofDragBehavior;
  110596. /**
  110597. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  110598. */
  110599. attachableMeshes: Nullable<Array<AbstractMesh>>;
  110600. /**
  110601. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  110602. */
  110603. usePointerToAttachGizmos: boolean;
  110604. /**
  110605. * Utility layer that the bounding box gizmo belongs to
  110606. */
  110607. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  110608. /**
  110609. * Utility layer that all gizmos besides bounding box belong to
  110610. */
  110611. readonly utilityLayer: UtilityLayerRenderer;
  110612. /**
  110613. * Instatiates a gizmo manager
  110614. * @param scene the scene to overlay the gizmos on top of
  110615. */
  110616. constructor(scene: Scene);
  110617. /**
  110618. * Attaches a set of gizmos to the specified mesh
  110619. * @param mesh The mesh the gizmo's should be attached to
  110620. */
  110621. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  110622. /**
  110623. * If the position gizmo is enabled
  110624. */
  110625. positionGizmoEnabled: boolean;
  110626. /**
  110627. * If the rotation gizmo is enabled
  110628. */
  110629. rotationGizmoEnabled: boolean;
  110630. /**
  110631. * If the scale gizmo is enabled
  110632. */
  110633. scaleGizmoEnabled: boolean;
  110634. /**
  110635. * If the boundingBox gizmo is enabled
  110636. */
  110637. boundingBoxGizmoEnabled: boolean;
  110638. /**
  110639. * Disposes of the gizmo manager
  110640. */
  110641. dispose(): void;
  110642. }
  110643. }
  110644. declare module BABYLON {
  110645. /**
  110646. * A directional light is defined by a direction (what a surprise!).
  110647. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  110648. * 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.
  110649. * Documentation: https://doc.babylonjs.com/babylon101/lights
  110650. */
  110651. export class DirectionalLight extends ShadowLight {
  110652. private _shadowFrustumSize;
  110653. /**
  110654. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  110655. */
  110656. /**
  110657. * Specifies a fix frustum size for the shadow generation.
  110658. */
  110659. shadowFrustumSize: number;
  110660. private _shadowOrthoScale;
  110661. /**
  110662. * Gets the shadow projection scale against the optimal computed one.
  110663. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  110664. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  110665. */
  110666. /**
  110667. * Sets the shadow projection scale against the optimal computed one.
  110668. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  110669. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  110670. */
  110671. shadowOrthoScale: number;
  110672. /**
  110673. * Automatically compute the projection matrix to best fit (including all the casters)
  110674. * on each frame.
  110675. */
  110676. autoUpdateExtends: boolean;
  110677. private _orthoLeft;
  110678. private _orthoRight;
  110679. private _orthoTop;
  110680. private _orthoBottom;
  110681. /**
  110682. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  110683. * The directional light is emitted from everywhere in the given direction.
  110684. * It can cast shadows.
  110685. * Documentation : https://doc.babylonjs.com/babylon101/lights
  110686. * @param name The friendly name of the light
  110687. * @param direction The direction of the light
  110688. * @param scene The scene the light belongs to
  110689. */
  110690. constructor(name: string, direction: Vector3, scene: Scene);
  110691. /**
  110692. * Returns the string "DirectionalLight".
  110693. * @return The class name
  110694. */
  110695. getClassName(): string;
  110696. /**
  110697. * Returns the integer 1.
  110698. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  110699. */
  110700. getTypeID(): number;
  110701. /**
  110702. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  110703. * Returns the DirectionalLight Shadow projection matrix.
  110704. */
  110705. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  110706. /**
  110707. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  110708. * Returns the DirectionalLight Shadow projection matrix.
  110709. */
  110710. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  110711. /**
  110712. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  110713. * Returns the DirectionalLight Shadow projection matrix.
  110714. */
  110715. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  110716. protected _buildUniformLayout(): void;
  110717. /**
  110718. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  110719. * @param effect The effect to update
  110720. * @param lightIndex The index of the light in the effect to update
  110721. * @returns The directional light
  110722. */
  110723. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  110724. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  110725. /**
  110726. * Gets the minZ used for shadow according to both the scene and the light.
  110727. *
  110728. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  110729. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  110730. * @param activeCamera The camera we are returning the min for
  110731. * @returns the depth min z
  110732. */
  110733. getDepthMinZ(activeCamera: Camera): number;
  110734. /**
  110735. * Gets the maxZ used for shadow according to both the scene and the light.
  110736. *
  110737. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  110738. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  110739. * @param activeCamera The camera we are returning the max for
  110740. * @returns the depth max z
  110741. */
  110742. getDepthMaxZ(activeCamera: Camera): number;
  110743. /**
  110744. * Prepares the list of defines specific to the light type.
  110745. * @param defines the list of defines
  110746. * @param lightIndex defines the index of the light for the effect
  110747. */
  110748. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  110749. }
  110750. }
  110751. declare module BABYLON {
  110752. /**
  110753. * Class containing static functions to help procedurally build meshes
  110754. */
  110755. export class HemisphereBuilder {
  110756. /**
  110757. * Creates a hemisphere mesh
  110758. * @param name defines the name of the mesh
  110759. * @param options defines the options used to create the mesh
  110760. * @param scene defines the hosting scene
  110761. * @returns the hemisphere mesh
  110762. */
  110763. static CreateHemisphere(name: string, options: {
  110764. segments?: number;
  110765. diameter?: number;
  110766. sideOrientation?: number;
  110767. }, scene: any): Mesh;
  110768. }
  110769. }
  110770. declare module BABYLON {
  110771. /**
  110772. * A spot light is defined by a position, a direction, an angle, and an exponent.
  110773. * These values define a cone of light starting from the position, emitting toward the direction.
  110774. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  110775. * and the exponent defines the speed of the decay of the light with distance (reach).
  110776. * Documentation: https://doc.babylonjs.com/babylon101/lights
  110777. */
  110778. export class SpotLight extends ShadowLight {
  110779. private _angle;
  110780. private _innerAngle;
  110781. private _cosHalfAngle;
  110782. private _lightAngleScale;
  110783. private _lightAngleOffset;
  110784. /**
  110785. * Gets the cone angle of the spot light in Radians.
  110786. */
  110787. /**
  110788. * Sets the cone angle of the spot light in Radians.
  110789. */
  110790. angle: number;
  110791. /**
  110792. * Only used in gltf falloff mode, this defines the angle where
  110793. * the directional falloff will start before cutting at angle which could be seen
  110794. * as outer angle.
  110795. */
  110796. /**
  110797. * Only used in gltf falloff mode, this defines the angle where
  110798. * the directional falloff will start before cutting at angle which could be seen
  110799. * as outer angle.
  110800. */
  110801. innerAngle: number;
  110802. private _shadowAngleScale;
  110803. /**
  110804. * Allows scaling the angle of the light for shadow generation only.
  110805. */
  110806. /**
  110807. * Allows scaling the angle of the light for shadow generation only.
  110808. */
  110809. shadowAngleScale: number;
  110810. /**
  110811. * The light decay speed with the distance from the emission spot.
  110812. */
  110813. exponent: number;
  110814. private _projectionTextureMatrix;
  110815. /**
  110816. * Allows reading the projecton texture
  110817. */
  110818. readonly projectionTextureMatrix: Matrix;
  110819. protected _projectionTextureLightNear: number;
  110820. /**
  110821. * Gets the near clip of the Spotlight for texture projection.
  110822. */
  110823. /**
  110824. * Sets the near clip of the Spotlight for texture projection.
  110825. */
  110826. projectionTextureLightNear: number;
  110827. protected _projectionTextureLightFar: number;
  110828. /**
  110829. * Gets the far clip of the Spotlight for texture projection.
  110830. */
  110831. /**
  110832. * Sets the far clip of the Spotlight for texture projection.
  110833. */
  110834. projectionTextureLightFar: number;
  110835. protected _projectionTextureUpDirection: Vector3;
  110836. /**
  110837. * Gets the Up vector of the Spotlight for texture projection.
  110838. */
  110839. /**
  110840. * Sets the Up vector of the Spotlight for texture projection.
  110841. */
  110842. projectionTextureUpDirection: Vector3;
  110843. private _projectionTexture;
  110844. /**
  110845. * Gets the projection texture of the light.
  110846. */
  110847. /**
  110848. * Sets the projection texture of the light.
  110849. */
  110850. projectionTexture: Nullable<BaseTexture>;
  110851. private _projectionTextureViewLightDirty;
  110852. private _projectionTextureProjectionLightDirty;
  110853. private _projectionTextureDirty;
  110854. private _projectionTextureViewTargetVector;
  110855. private _projectionTextureViewLightMatrix;
  110856. private _projectionTextureProjectionLightMatrix;
  110857. private _projectionTextureScalingMatrix;
  110858. /**
  110859. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  110860. * It can cast shadows.
  110861. * Documentation : https://doc.babylonjs.com/babylon101/lights
  110862. * @param name The light friendly name
  110863. * @param position The position of the spot light in the scene
  110864. * @param direction The direction of the light in the scene
  110865. * @param angle The cone angle of the light in Radians
  110866. * @param exponent The light decay speed with the distance from the emission spot
  110867. * @param scene The scene the lights belongs to
  110868. */
  110869. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  110870. /**
  110871. * Returns the string "SpotLight".
  110872. * @returns the class name
  110873. */
  110874. getClassName(): string;
  110875. /**
  110876. * Returns the integer 2.
  110877. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  110878. */
  110879. getTypeID(): number;
  110880. /**
  110881. * Overrides the direction setter to recompute the projection texture view light Matrix.
  110882. */
  110883. protected _setDirection(value: Vector3): void;
  110884. /**
  110885. * Overrides the position setter to recompute the projection texture view light Matrix.
  110886. */
  110887. protected _setPosition(value: Vector3): void;
  110888. /**
  110889. * 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.
  110890. * Returns the SpotLight.
  110891. */
  110892. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  110893. protected _computeProjectionTextureViewLightMatrix(): void;
  110894. protected _computeProjectionTextureProjectionLightMatrix(): void;
  110895. /**
  110896. * Main function for light texture projection matrix computing.
  110897. */
  110898. protected _computeProjectionTextureMatrix(): void;
  110899. protected _buildUniformLayout(): void;
  110900. private _computeAngleValues;
  110901. /**
  110902. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  110903. * @param effect The effect to update
  110904. * @param lightIndex The index of the light in the effect to update
  110905. * @returns The spot light
  110906. */
  110907. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  110908. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  110909. /**
  110910. * Disposes the light and the associated resources.
  110911. */
  110912. dispose(): void;
  110913. /**
  110914. * Prepares the list of defines specific to the light type.
  110915. * @param defines the list of defines
  110916. * @param lightIndex defines the index of the light for the effect
  110917. */
  110918. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  110919. }
  110920. }
  110921. declare module BABYLON {
  110922. /**
  110923. * Gizmo that enables viewing a light
  110924. */
  110925. export class LightGizmo extends Gizmo {
  110926. private _lightMesh;
  110927. private _material;
  110928. private cachedPosition;
  110929. private cachedForward;
  110930. /**
  110931. * Creates a LightGizmo
  110932. * @param gizmoLayer The utility layer the gizmo will be added to
  110933. */
  110934. constructor(gizmoLayer?: UtilityLayerRenderer);
  110935. private _light;
  110936. /**
  110937. * The light that the gizmo is attached to
  110938. */
  110939. light: Nullable<Light>;
  110940. /**
  110941. * Gets the material used to render the light gizmo
  110942. */
  110943. readonly material: StandardMaterial;
  110944. /**
  110945. * @hidden
  110946. * Updates the gizmo to match the attached mesh's position/rotation
  110947. */
  110948. protected _update(): void;
  110949. private static _Scale;
  110950. /**
  110951. * Creates the lines for a light mesh
  110952. */
  110953. private static _createLightLines;
  110954. /**
  110955. * Disposes of the light gizmo
  110956. */
  110957. dispose(): void;
  110958. private static _CreateHemisphericLightMesh;
  110959. private static _CreatePointLightMesh;
  110960. private static _CreateSpotLightMesh;
  110961. private static _CreateDirectionalLightMesh;
  110962. }
  110963. }
  110964. declare module BABYLON {
  110965. /** @hidden */
  110966. export var backgroundFragmentDeclaration: {
  110967. name: string;
  110968. shader: string;
  110969. };
  110970. }
  110971. declare module BABYLON {
  110972. /** @hidden */
  110973. export var backgroundUboDeclaration: {
  110974. name: string;
  110975. shader: string;
  110976. };
  110977. }
  110978. declare module BABYLON {
  110979. /** @hidden */
  110980. export var backgroundPixelShader: {
  110981. name: string;
  110982. shader: string;
  110983. };
  110984. }
  110985. declare module BABYLON {
  110986. /** @hidden */
  110987. export var backgroundVertexDeclaration: {
  110988. name: string;
  110989. shader: string;
  110990. };
  110991. }
  110992. declare module BABYLON {
  110993. /** @hidden */
  110994. export var backgroundVertexShader: {
  110995. name: string;
  110996. shader: string;
  110997. };
  110998. }
  110999. declare module BABYLON {
  111000. /**
  111001. * Background material used to create an efficient environement around your scene.
  111002. */
  111003. export class BackgroundMaterial extends PushMaterial {
  111004. /**
  111005. * Standard reflectance value at parallel view angle.
  111006. */
  111007. static StandardReflectance0: number;
  111008. /**
  111009. * Standard reflectance value at grazing angle.
  111010. */
  111011. static StandardReflectance90: number;
  111012. protected _primaryColor: Color3;
  111013. /**
  111014. * Key light Color (multiply against the environement texture)
  111015. */
  111016. primaryColor: Color3;
  111017. protected __perceptualColor: Nullable<Color3>;
  111018. /**
  111019. * Experimental Internal Use Only.
  111020. *
  111021. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  111022. * This acts as a helper to set the primary color to a more "human friendly" value.
  111023. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  111024. * output color as close as possible from the chosen value.
  111025. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  111026. * part of lighting setup.)
  111027. */
  111028. _perceptualColor: Nullable<Color3>;
  111029. protected _primaryColorShadowLevel: float;
  111030. /**
  111031. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  111032. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  111033. */
  111034. primaryColorShadowLevel: float;
  111035. protected _primaryColorHighlightLevel: float;
  111036. /**
  111037. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  111038. * The primary color is used at the level chosen to define what the white area would look.
  111039. */
  111040. primaryColorHighlightLevel: float;
  111041. protected _reflectionTexture: Nullable<BaseTexture>;
  111042. /**
  111043. * Reflection Texture used in the material.
  111044. * Should be author in a specific way for the best result (refer to the documentation).
  111045. */
  111046. reflectionTexture: Nullable<BaseTexture>;
  111047. protected _reflectionBlur: float;
  111048. /**
  111049. * Reflection Texture level of blur.
  111050. *
  111051. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  111052. * texture twice.
  111053. */
  111054. reflectionBlur: float;
  111055. protected _diffuseTexture: Nullable<BaseTexture>;
  111056. /**
  111057. * Diffuse Texture used in the material.
  111058. * Should be author in a specific way for the best result (refer to the documentation).
  111059. */
  111060. diffuseTexture: Nullable<BaseTexture>;
  111061. protected _shadowLights: Nullable<IShadowLight[]>;
  111062. /**
  111063. * Specify the list of lights casting shadow on the material.
  111064. * All scene shadow lights will be included if null.
  111065. */
  111066. shadowLights: Nullable<IShadowLight[]>;
  111067. protected _shadowLevel: float;
  111068. /**
  111069. * Helps adjusting the shadow to a softer level if required.
  111070. * 0 means black shadows and 1 means no shadows.
  111071. */
  111072. shadowLevel: float;
  111073. protected _sceneCenter: Vector3;
  111074. /**
  111075. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  111076. * It is usually zero but might be interesting to modify according to your setup.
  111077. */
  111078. sceneCenter: Vector3;
  111079. protected _opacityFresnel: boolean;
  111080. /**
  111081. * This helps specifying that the material is falling off to the sky box at grazing angle.
  111082. * This helps ensuring a nice transition when the camera goes under the ground.
  111083. */
  111084. opacityFresnel: boolean;
  111085. protected _reflectionFresnel: boolean;
  111086. /**
  111087. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  111088. * This helps adding a mirror texture on the ground.
  111089. */
  111090. reflectionFresnel: boolean;
  111091. protected _reflectionFalloffDistance: number;
  111092. /**
  111093. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  111094. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  111095. */
  111096. reflectionFalloffDistance: number;
  111097. protected _reflectionAmount: number;
  111098. /**
  111099. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  111100. */
  111101. reflectionAmount: number;
  111102. protected _reflectionReflectance0: number;
  111103. /**
  111104. * This specifies the weight of the reflection at grazing angle.
  111105. */
  111106. reflectionReflectance0: number;
  111107. protected _reflectionReflectance90: number;
  111108. /**
  111109. * This specifies the weight of the reflection at a perpendicular point of view.
  111110. */
  111111. reflectionReflectance90: number;
  111112. /**
  111113. * Sets the reflection reflectance fresnel values according to the default standard
  111114. * empirically know to work well :-)
  111115. */
  111116. reflectionStandardFresnelWeight: number;
  111117. protected _useRGBColor: boolean;
  111118. /**
  111119. * Helps to directly use the maps channels instead of their level.
  111120. */
  111121. useRGBColor: boolean;
  111122. protected _enableNoise: boolean;
  111123. /**
  111124. * This helps reducing the banding effect that could occur on the background.
  111125. */
  111126. enableNoise: boolean;
  111127. /**
  111128. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  111129. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  111130. * Recommended to be keep at 1.0 except for special cases.
  111131. */
  111132. fovMultiplier: number;
  111133. private _fovMultiplier;
  111134. /**
  111135. * Enable the FOV adjustment feature controlled by fovMultiplier.
  111136. */
  111137. useEquirectangularFOV: boolean;
  111138. private _maxSimultaneousLights;
  111139. /**
  111140. * Number of Simultaneous lights allowed on the material.
  111141. */
  111142. maxSimultaneousLights: int;
  111143. /**
  111144. * Default configuration related to image processing available in the Background Material.
  111145. */
  111146. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  111147. /**
  111148. * Keep track of the image processing observer to allow dispose and replace.
  111149. */
  111150. private _imageProcessingObserver;
  111151. /**
  111152. * Attaches a new image processing configuration to the PBR Material.
  111153. * @param configuration (if null the scene configuration will be use)
  111154. */
  111155. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  111156. /**
  111157. * Gets the image processing configuration used either in this material.
  111158. */
  111159. /**
  111160. * Sets the Default image processing configuration used either in the this material.
  111161. *
  111162. * If sets to null, the scene one is in use.
  111163. */
  111164. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  111165. /**
  111166. * Gets wether the color curves effect is enabled.
  111167. */
  111168. /**
  111169. * Sets wether the color curves effect is enabled.
  111170. */
  111171. cameraColorCurvesEnabled: boolean;
  111172. /**
  111173. * Gets wether the color grading effect is enabled.
  111174. */
  111175. /**
  111176. * Gets wether the color grading effect is enabled.
  111177. */
  111178. cameraColorGradingEnabled: boolean;
  111179. /**
  111180. * Gets wether tonemapping is enabled or not.
  111181. */
  111182. /**
  111183. * Sets wether tonemapping is enabled or not
  111184. */
  111185. cameraToneMappingEnabled: boolean;
  111186. /**
  111187. * The camera exposure used on this material.
  111188. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111189. * This corresponds to a photographic exposure.
  111190. */
  111191. /**
  111192. * The camera exposure used on this material.
  111193. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111194. * This corresponds to a photographic exposure.
  111195. */
  111196. cameraExposure: float;
  111197. /**
  111198. * Gets The camera contrast used on this material.
  111199. */
  111200. /**
  111201. * Sets The camera contrast used on this material.
  111202. */
  111203. cameraContrast: float;
  111204. /**
  111205. * Gets the Color Grading 2D Lookup Texture.
  111206. */
  111207. /**
  111208. * Sets the Color Grading 2D Lookup Texture.
  111209. */
  111210. cameraColorGradingTexture: Nullable<BaseTexture>;
  111211. /**
  111212. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111213. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111214. * 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;
  111215. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111216. */
  111217. /**
  111218. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111219. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111220. * 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;
  111221. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111222. */
  111223. cameraColorCurves: Nullable<ColorCurves>;
  111224. /**
  111225. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  111226. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  111227. */
  111228. switchToBGR: boolean;
  111229. private _renderTargets;
  111230. private _reflectionControls;
  111231. private _white;
  111232. private _primaryShadowColor;
  111233. private _primaryHighlightColor;
  111234. /**
  111235. * Instantiates a Background Material in the given scene
  111236. * @param name The friendly name of the material
  111237. * @param scene The scene to add the material to
  111238. */
  111239. constructor(name: string, scene: Scene);
  111240. /**
  111241. * Gets a boolean indicating that current material needs to register RTT
  111242. */
  111243. readonly hasRenderTargetTextures: boolean;
  111244. /**
  111245. * The entire material has been created in order to prevent overdraw.
  111246. * @returns false
  111247. */
  111248. needAlphaTesting(): boolean;
  111249. /**
  111250. * The entire material has been created in order to prevent overdraw.
  111251. * @returns true if blending is enable
  111252. */
  111253. needAlphaBlending(): boolean;
  111254. /**
  111255. * Checks wether the material is ready to be rendered for a given mesh.
  111256. * @param mesh The mesh to render
  111257. * @param subMesh The submesh to check against
  111258. * @param useInstances Specify wether or not the material is used with instances
  111259. * @returns true if all the dependencies are ready (Textures, Effects...)
  111260. */
  111261. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  111262. /**
  111263. * Compute the primary color according to the chosen perceptual color.
  111264. */
  111265. private _computePrimaryColorFromPerceptualColor;
  111266. /**
  111267. * Compute the highlights and shadow colors according to their chosen levels.
  111268. */
  111269. private _computePrimaryColors;
  111270. /**
  111271. * Build the uniform buffer used in the material.
  111272. */
  111273. buildUniformLayout(): void;
  111274. /**
  111275. * Unbind the material.
  111276. */
  111277. unbind(): void;
  111278. /**
  111279. * Bind only the world matrix to the material.
  111280. * @param world The world matrix to bind.
  111281. */
  111282. bindOnlyWorldMatrix(world: Matrix): void;
  111283. /**
  111284. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  111285. * @param world The world matrix to bind.
  111286. * @param subMesh The submesh to bind for.
  111287. */
  111288. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  111289. /**
  111290. * Checks to see if a texture is used in the material.
  111291. * @param texture - Base texture to use.
  111292. * @returns - Boolean specifying if a texture is used in the material.
  111293. */
  111294. hasTexture(texture: BaseTexture): boolean;
  111295. /**
  111296. * Dispose the material.
  111297. * @param forceDisposeEffect Force disposal of the associated effect.
  111298. * @param forceDisposeTextures Force disposal of the associated textures.
  111299. */
  111300. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  111301. /**
  111302. * Clones the material.
  111303. * @param name The cloned name.
  111304. * @returns The cloned material.
  111305. */
  111306. clone(name: string): BackgroundMaterial;
  111307. /**
  111308. * Serializes the current material to its JSON representation.
  111309. * @returns The JSON representation.
  111310. */
  111311. serialize(): any;
  111312. /**
  111313. * Gets the class name of the material
  111314. * @returns "BackgroundMaterial"
  111315. */
  111316. getClassName(): string;
  111317. /**
  111318. * Parse a JSON input to create back a background material.
  111319. * @param source The JSON data to parse
  111320. * @param scene The scene to create the parsed material in
  111321. * @param rootUrl The root url of the assets the material depends upon
  111322. * @returns the instantiated BackgroundMaterial.
  111323. */
  111324. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  111325. }
  111326. }
  111327. declare module BABYLON {
  111328. /**
  111329. * Represents the different options available during the creation of
  111330. * a Environment helper.
  111331. *
  111332. * This can control the default ground, skybox and image processing setup of your scene.
  111333. */
  111334. export interface IEnvironmentHelperOptions {
  111335. /**
  111336. * Specifies wether or not to create a ground.
  111337. * True by default.
  111338. */
  111339. createGround: boolean;
  111340. /**
  111341. * Specifies the ground size.
  111342. * 15 by default.
  111343. */
  111344. groundSize: number;
  111345. /**
  111346. * The texture used on the ground for the main color.
  111347. * Comes from the BabylonJS CDN by default.
  111348. *
  111349. * Remarks: Can be either a texture or a url.
  111350. */
  111351. groundTexture: string | BaseTexture;
  111352. /**
  111353. * The color mixed in the ground texture by default.
  111354. * BabylonJS clearColor by default.
  111355. */
  111356. groundColor: Color3;
  111357. /**
  111358. * Specifies the ground opacity.
  111359. * 1 by default.
  111360. */
  111361. groundOpacity: number;
  111362. /**
  111363. * Enables the ground to receive shadows.
  111364. * True by default.
  111365. */
  111366. enableGroundShadow: boolean;
  111367. /**
  111368. * Helps preventing the shadow to be fully black on the ground.
  111369. * 0.5 by default.
  111370. */
  111371. groundShadowLevel: number;
  111372. /**
  111373. * Creates a mirror texture attach to the ground.
  111374. * false by default.
  111375. */
  111376. enableGroundMirror: boolean;
  111377. /**
  111378. * Specifies the ground mirror size ratio.
  111379. * 0.3 by default as the default kernel is 64.
  111380. */
  111381. groundMirrorSizeRatio: number;
  111382. /**
  111383. * Specifies the ground mirror blur kernel size.
  111384. * 64 by default.
  111385. */
  111386. groundMirrorBlurKernel: number;
  111387. /**
  111388. * Specifies the ground mirror visibility amount.
  111389. * 1 by default
  111390. */
  111391. groundMirrorAmount: number;
  111392. /**
  111393. * Specifies the ground mirror reflectance weight.
  111394. * This uses the standard weight of the background material to setup the fresnel effect
  111395. * of the mirror.
  111396. * 1 by default.
  111397. */
  111398. groundMirrorFresnelWeight: number;
  111399. /**
  111400. * Specifies the ground mirror Falloff distance.
  111401. * This can helps reducing the size of the reflection.
  111402. * 0 by Default.
  111403. */
  111404. groundMirrorFallOffDistance: number;
  111405. /**
  111406. * Specifies the ground mirror texture type.
  111407. * Unsigned Int by Default.
  111408. */
  111409. groundMirrorTextureType: number;
  111410. /**
  111411. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  111412. * the shown objects.
  111413. */
  111414. groundYBias: number;
  111415. /**
  111416. * Specifies wether or not to create a skybox.
  111417. * True by default.
  111418. */
  111419. createSkybox: boolean;
  111420. /**
  111421. * Specifies the skybox size.
  111422. * 20 by default.
  111423. */
  111424. skyboxSize: number;
  111425. /**
  111426. * The texture used on the skybox for the main color.
  111427. * Comes from the BabylonJS CDN by default.
  111428. *
  111429. * Remarks: Can be either a texture or a url.
  111430. */
  111431. skyboxTexture: string | BaseTexture;
  111432. /**
  111433. * The color mixed in the skybox texture by default.
  111434. * BabylonJS clearColor by default.
  111435. */
  111436. skyboxColor: Color3;
  111437. /**
  111438. * The background rotation around the Y axis of the scene.
  111439. * This helps aligning the key lights of your scene with the background.
  111440. * 0 by default.
  111441. */
  111442. backgroundYRotation: number;
  111443. /**
  111444. * Compute automatically the size of the elements to best fit with the scene.
  111445. */
  111446. sizeAuto: boolean;
  111447. /**
  111448. * Default position of the rootMesh if autoSize is not true.
  111449. */
  111450. rootPosition: Vector3;
  111451. /**
  111452. * Sets up the image processing in the scene.
  111453. * true by default.
  111454. */
  111455. setupImageProcessing: boolean;
  111456. /**
  111457. * The texture used as your environment texture in the scene.
  111458. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  111459. *
  111460. * Remarks: Can be either a texture or a url.
  111461. */
  111462. environmentTexture: string | BaseTexture;
  111463. /**
  111464. * The value of the exposure to apply to the scene.
  111465. * 0.6 by default if setupImageProcessing is true.
  111466. */
  111467. cameraExposure: number;
  111468. /**
  111469. * The value of the contrast to apply to the scene.
  111470. * 1.6 by default if setupImageProcessing is true.
  111471. */
  111472. cameraContrast: number;
  111473. /**
  111474. * Specifies wether or not tonemapping should be enabled in the scene.
  111475. * true by default if setupImageProcessing is true.
  111476. */
  111477. toneMappingEnabled: boolean;
  111478. }
  111479. /**
  111480. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  111481. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  111482. * It also helps with the default setup of your imageProcessing configuration.
  111483. */
  111484. export class EnvironmentHelper {
  111485. /**
  111486. * Default ground texture URL.
  111487. */
  111488. private static _groundTextureCDNUrl;
  111489. /**
  111490. * Default skybox texture URL.
  111491. */
  111492. private static _skyboxTextureCDNUrl;
  111493. /**
  111494. * Default environment texture URL.
  111495. */
  111496. private static _environmentTextureCDNUrl;
  111497. /**
  111498. * Creates the default options for the helper.
  111499. */
  111500. private static _getDefaultOptions;
  111501. private _rootMesh;
  111502. /**
  111503. * Gets the root mesh created by the helper.
  111504. */
  111505. readonly rootMesh: Mesh;
  111506. private _skybox;
  111507. /**
  111508. * Gets the skybox created by the helper.
  111509. */
  111510. readonly skybox: Nullable<Mesh>;
  111511. private _skyboxTexture;
  111512. /**
  111513. * Gets the skybox texture created by the helper.
  111514. */
  111515. readonly skyboxTexture: Nullable<BaseTexture>;
  111516. private _skyboxMaterial;
  111517. /**
  111518. * Gets the skybox material created by the helper.
  111519. */
  111520. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  111521. private _ground;
  111522. /**
  111523. * Gets the ground mesh created by the helper.
  111524. */
  111525. readonly ground: Nullable<Mesh>;
  111526. private _groundTexture;
  111527. /**
  111528. * Gets the ground texture created by the helper.
  111529. */
  111530. readonly groundTexture: Nullable<BaseTexture>;
  111531. private _groundMirror;
  111532. /**
  111533. * Gets the ground mirror created by the helper.
  111534. */
  111535. readonly groundMirror: Nullable<MirrorTexture>;
  111536. /**
  111537. * Gets the ground mirror render list to helps pushing the meshes
  111538. * you wish in the ground reflection.
  111539. */
  111540. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  111541. private _groundMaterial;
  111542. /**
  111543. * Gets the ground material created by the helper.
  111544. */
  111545. readonly groundMaterial: Nullable<BackgroundMaterial>;
  111546. /**
  111547. * Stores the creation options.
  111548. */
  111549. private readonly _scene;
  111550. private _options;
  111551. /**
  111552. * This observable will be notified with any error during the creation of the environment,
  111553. * mainly texture creation errors.
  111554. */
  111555. onErrorObservable: Observable<{
  111556. message?: string;
  111557. exception?: any;
  111558. }>;
  111559. /**
  111560. * constructor
  111561. * @param options Defines the options we want to customize the helper
  111562. * @param scene The scene to add the material to
  111563. */
  111564. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  111565. /**
  111566. * Updates the background according to the new options
  111567. * @param options
  111568. */
  111569. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  111570. /**
  111571. * Sets the primary color of all the available elements.
  111572. * @param color the main color to affect to the ground and the background
  111573. */
  111574. setMainColor(color: Color3): void;
  111575. /**
  111576. * Setup the image processing according to the specified options.
  111577. */
  111578. private _setupImageProcessing;
  111579. /**
  111580. * Setup the environment texture according to the specified options.
  111581. */
  111582. private _setupEnvironmentTexture;
  111583. /**
  111584. * Setup the background according to the specified options.
  111585. */
  111586. private _setupBackground;
  111587. /**
  111588. * Get the scene sizes according to the setup.
  111589. */
  111590. private _getSceneSize;
  111591. /**
  111592. * Setup the ground according to the specified options.
  111593. */
  111594. private _setupGround;
  111595. /**
  111596. * Setup the ground material according to the specified options.
  111597. */
  111598. private _setupGroundMaterial;
  111599. /**
  111600. * Setup the ground diffuse texture according to the specified options.
  111601. */
  111602. private _setupGroundDiffuseTexture;
  111603. /**
  111604. * Setup the ground mirror texture according to the specified options.
  111605. */
  111606. private _setupGroundMirrorTexture;
  111607. /**
  111608. * Setup the ground to receive the mirror texture.
  111609. */
  111610. private _setupMirrorInGroundMaterial;
  111611. /**
  111612. * Setup the skybox according to the specified options.
  111613. */
  111614. private _setupSkybox;
  111615. /**
  111616. * Setup the skybox material according to the specified options.
  111617. */
  111618. private _setupSkyboxMaterial;
  111619. /**
  111620. * Setup the skybox reflection texture according to the specified options.
  111621. */
  111622. private _setupSkyboxReflectionTexture;
  111623. private _errorHandler;
  111624. /**
  111625. * Dispose all the elements created by the Helper.
  111626. */
  111627. dispose(): void;
  111628. }
  111629. }
  111630. declare module BABYLON {
  111631. /**
  111632. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  111633. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  111634. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  111635. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  111636. */
  111637. export class PhotoDome extends TransformNode {
  111638. /**
  111639. * Define the image as a Monoscopic panoramic 360 image.
  111640. */
  111641. static readonly MODE_MONOSCOPIC: number;
  111642. /**
  111643. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  111644. */
  111645. static readonly MODE_TOPBOTTOM: number;
  111646. /**
  111647. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  111648. */
  111649. static readonly MODE_SIDEBYSIDE: number;
  111650. private _useDirectMapping;
  111651. /**
  111652. * The texture being displayed on the sphere
  111653. */
  111654. protected _photoTexture: Texture;
  111655. /**
  111656. * Gets or sets the texture being displayed on the sphere
  111657. */
  111658. photoTexture: Texture;
  111659. /**
  111660. * Observable raised when an error occured while loading the 360 image
  111661. */
  111662. onLoadErrorObservable: Observable<string>;
  111663. /**
  111664. * The skybox material
  111665. */
  111666. protected _material: BackgroundMaterial;
  111667. /**
  111668. * The surface used for the skybox
  111669. */
  111670. protected _mesh: Mesh;
  111671. /**
  111672. * Gets the mesh used for the skybox.
  111673. */
  111674. readonly mesh: Mesh;
  111675. /**
  111676. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  111677. * Also see the options.resolution property.
  111678. */
  111679. fovMultiplier: number;
  111680. private _imageMode;
  111681. /**
  111682. * Gets or set the current video mode for the video. It can be:
  111683. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  111684. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  111685. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  111686. */
  111687. imageMode: number;
  111688. /**
  111689. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  111690. * @param name Element's name, child elements will append suffixes for their own names.
  111691. * @param urlsOfPhoto defines the url of the photo to display
  111692. * @param options defines an object containing optional or exposed sub element properties
  111693. * @param onError defines a callback called when an error occured while loading the texture
  111694. */
  111695. constructor(name: string, urlOfPhoto: string, options: {
  111696. resolution?: number;
  111697. size?: number;
  111698. useDirectMapping?: boolean;
  111699. faceForward?: boolean;
  111700. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  111701. private _onBeforeCameraRenderObserver;
  111702. private _changeImageMode;
  111703. /**
  111704. * Releases resources associated with this node.
  111705. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  111706. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  111707. */
  111708. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  111709. }
  111710. }
  111711. declare module BABYLON {
  111712. /**
  111713. * Class used to host RGBD texture specific utilities
  111714. */
  111715. export class RGBDTextureTools {
  111716. /**
  111717. * Expand the RGBD Texture from RGBD to Half Float if possible.
  111718. * @param texture the texture to expand.
  111719. */
  111720. static ExpandRGBDTexture(texture: Texture): void;
  111721. }
  111722. }
  111723. declare module BABYLON {
  111724. /**
  111725. * Class used to host texture specific utilities
  111726. */
  111727. export class BRDFTextureTools {
  111728. /**
  111729. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  111730. * @param scene defines the hosting scene
  111731. * @returns the environment BRDF texture
  111732. */
  111733. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  111734. private static _environmentBRDFBase64Texture;
  111735. }
  111736. }
  111737. declare module BABYLON {
  111738. /**
  111739. * @hidden
  111740. */
  111741. export interface IMaterialClearCoatDefines {
  111742. CLEARCOAT: boolean;
  111743. CLEARCOAT_DEFAULTIOR: boolean;
  111744. CLEARCOAT_TEXTURE: boolean;
  111745. CLEARCOAT_TEXTUREDIRECTUV: number;
  111746. CLEARCOAT_BUMP: boolean;
  111747. CLEARCOAT_BUMPDIRECTUV: number;
  111748. CLEARCOAT_TINT: boolean;
  111749. CLEARCOAT_TINT_TEXTURE: boolean;
  111750. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  111751. /** @hidden */
  111752. _areTexturesDirty: boolean;
  111753. }
  111754. /**
  111755. * Define the code related to the clear coat parameters of the pbr material.
  111756. */
  111757. export class PBRClearCoatConfiguration {
  111758. /**
  111759. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  111760. * The default fits with a polyurethane material.
  111761. */
  111762. private static readonly _DefaultIndexOfRefraction;
  111763. private _isEnabled;
  111764. /**
  111765. * Defines if the clear coat is enabled in the material.
  111766. */
  111767. isEnabled: boolean;
  111768. /**
  111769. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  111770. */
  111771. intensity: number;
  111772. /**
  111773. * Defines the clear coat layer roughness.
  111774. */
  111775. roughness: number;
  111776. private _indexOfRefraction;
  111777. /**
  111778. * Defines the index of refraction of the clear coat.
  111779. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  111780. * The default fits with a polyurethane material.
  111781. * Changing the default value is more performance intensive.
  111782. */
  111783. indexOfRefraction: number;
  111784. private _texture;
  111785. /**
  111786. * Stores the clear coat values in a texture.
  111787. */
  111788. texture: Nullable<BaseTexture>;
  111789. private _bumpTexture;
  111790. /**
  111791. * Define the clear coat specific bump texture.
  111792. */
  111793. bumpTexture: Nullable<BaseTexture>;
  111794. private _isTintEnabled;
  111795. /**
  111796. * Defines if the clear coat tint is enabled in the material.
  111797. */
  111798. isTintEnabled: boolean;
  111799. /**
  111800. * Defines the clear coat tint of the material.
  111801. * This is only use if tint is enabled
  111802. */
  111803. tintColor: Color3;
  111804. /**
  111805. * Defines the distance at which the tint color should be found in the
  111806. * clear coat media.
  111807. * This is only use if tint is enabled
  111808. */
  111809. tintColorAtDistance: number;
  111810. /**
  111811. * Defines the clear coat layer thickness.
  111812. * This is only use if tint is enabled
  111813. */
  111814. tintThickness: number;
  111815. private _tintTexture;
  111816. /**
  111817. * Stores the clear tint values in a texture.
  111818. * rgb is tint
  111819. * a is a thickness factor
  111820. */
  111821. tintTexture: Nullable<BaseTexture>;
  111822. /** @hidden */
  111823. private _internalMarkAllSubMeshesAsTexturesDirty;
  111824. /** @hidden */
  111825. _markAllSubMeshesAsTexturesDirty(): void;
  111826. /**
  111827. * Instantiate a new istance of clear coat configuration.
  111828. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  111829. */
  111830. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  111831. /**
  111832. * Gets wehter the submesh is ready to be used or not.
  111833. * @param defines the list of "defines" to update.
  111834. * @param scene defines the scene the material belongs to.
  111835. * @param engine defines the engine the material belongs to.
  111836. * @param disableBumpMap defines wether the material disables bump or not.
  111837. * @returns - boolean indicating that the submesh is ready or not.
  111838. */
  111839. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  111840. /**
  111841. * Checks to see if a texture is used in the material.
  111842. * @param defines the list of "defines" to update.
  111843. * @param scene defines the scene to the material belongs to.
  111844. */
  111845. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  111846. /**
  111847. * Binds the material data.
  111848. * @param uniformBuffer defines the Uniform buffer to fill in.
  111849. * @param scene defines the scene the material belongs to.
  111850. * @param engine defines the engine the material belongs to.
  111851. * @param disableBumpMap defines wether the material disables bump or not.
  111852. * @param isFrozen defines wether the material is frozen or not.
  111853. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  111854. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  111855. */
  111856. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  111857. /**
  111858. * Checks to see if a texture is used in the material.
  111859. * @param texture - Base texture to use.
  111860. * @returns - Boolean specifying if a texture is used in the material.
  111861. */
  111862. hasTexture(texture: BaseTexture): boolean;
  111863. /**
  111864. * Returns an array of the actively used textures.
  111865. * @param activeTextures Array of BaseTextures
  111866. */
  111867. getActiveTextures(activeTextures: BaseTexture[]): void;
  111868. /**
  111869. * Returns the animatable textures.
  111870. * @param animatables Array of animatable textures.
  111871. */
  111872. getAnimatables(animatables: IAnimatable[]): void;
  111873. /**
  111874. * Disposes the resources of the material.
  111875. * @param forceDisposeTextures - Forces the disposal of all textures.
  111876. */
  111877. dispose(forceDisposeTextures?: boolean): void;
  111878. /**
  111879. * Get the current class name of the texture useful for serialization or dynamic coding.
  111880. * @returns "PBRClearCoatConfiguration"
  111881. */
  111882. getClassName(): string;
  111883. /**
  111884. * Add fallbacks to the effect fallbacks list.
  111885. * @param defines defines the Base texture to use.
  111886. * @param fallbacks defines the current fallback list.
  111887. * @param currentRank defines the current fallback rank.
  111888. * @returns the new fallback rank.
  111889. */
  111890. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  111891. /**
  111892. * Add the required uniforms to the current list.
  111893. * @param uniforms defines the current uniform list.
  111894. */
  111895. static AddUniforms(uniforms: string[]): void;
  111896. /**
  111897. * Add the required samplers to the current list.
  111898. * @param samplers defines the current sampler list.
  111899. */
  111900. static AddSamplers(samplers: string[]): void;
  111901. /**
  111902. * Add the required uniforms to the current buffer.
  111903. * @param uniformBuffer defines the current uniform buffer.
  111904. */
  111905. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  111906. /**
  111907. * Makes a duplicate of the current configuration into another one.
  111908. * @param clearCoatConfiguration define the config where to copy the info
  111909. */
  111910. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  111911. /**
  111912. * Serializes this clear coat configuration.
  111913. * @returns - An object with the serialized config.
  111914. */
  111915. serialize(): any;
  111916. /**
  111917. * Parses a anisotropy Configuration from a serialized object.
  111918. * @param source - Serialized object.
  111919. * @param scene Defines the scene we are parsing for
  111920. * @param rootUrl Defines the rootUrl to load from
  111921. */
  111922. parse(source: any, scene: Scene, rootUrl: string): void;
  111923. }
  111924. }
  111925. declare module BABYLON {
  111926. /**
  111927. * @hidden
  111928. */
  111929. export interface IMaterialAnisotropicDefines {
  111930. ANISOTROPIC: boolean;
  111931. ANISOTROPIC_TEXTURE: boolean;
  111932. ANISOTROPIC_TEXTUREDIRECTUV: number;
  111933. MAINUV1: boolean;
  111934. _areTexturesDirty: boolean;
  111935. _needUVs: boolean;
  111936. }
  111937. /**
  111938. * Define the code related to the anisotropic parameters of the pbr material.
  111939. */
  111940. export class PBRAnisotropicConfiguration {
  111941. private _isEnabled;
  111942. /**
  111943. * Defines if the anisotropy is enabled in the material.
  111944. */
  111945. isEnabled: boolean;
  111946. /**
  111947. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  111948. */
  111949. intensity: number;
  111950. /**
  111951. * Defines if the effect is along the tangents, bitangents or in between.
  111952. * By default, the effect is "strectching" the highlights along the tangents.
  111953. */
  111954. direction: Vector2;
  111955. private _texture;
  111956. /**
  111957. * Stores the anisotropy values in a texture.
  111958. * rg is direction (like normal from -1 to 1)
  111959. * b is a intensity
  111960. */
  111961. texture: Nullable<BaseTexture>;
  111962. /** @hidden */
  111963. private _internalMarkAllSubMeshesAsTexturesDirty;
  111964. /** @hidden */
  111965. _markAllSubMeshesAsTexturesDirty(): void;
  111966. /**
  111967. * Instantiate a new istance of anisotropy configuration.
  111968. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  111969. */
  111970. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  111971. /**
  111972. * Specifies that the submesh is ready to be used.
  111973. * @param defines the list of "defines" to update.
  111974. * @param scene defines the scene the material belongs to.
  111975. * @returns - boolean indicating that the submesh is ready or not.
  111976. */
  111977. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  111978. /**
  111979. * Checks to see if a texture is used in the material.
  111980. * @param defines the list of "defines" to update.
  111981. * @param mesh the mesh we are preparing the defines for.
  111982. * @param scene defines the scene the material belongs to.
  111983. */
  111984. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  111985. /**
  111986. * Binds the material data.
  111987. * @param uniformBuffer defines the Uniform buffer to fill in.
  111988. * @param scene defines the scene the material belongs to.
  111989. * @param isFrozen defines wether the material is frozen or not.
  111990. */
  111991. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  111992. /**
  111993. * Checks to see if a texture is used in the material.
  111994. * @param texture - Base texture to use.
  111995. * @returns - Boolean specifying if a texture is used in the material.
  111996. */
  111997. hasTexture(texture: BaseTexture): boolean;
  111998. /**
  111999. * Returns an array of the actively used textures.
  112000. * @param activeTextures Array of BaseTextures
  112001. */
  112002. getActiveTextures(activeTextures: BaseTexture[]): void;
  112003. /**
  112004. * Returns the animatable textures.
  112005. * @param animatables Array of animatable textures.
  112006. */
  112007. getAnimatables(animatables: IAnimatable[]): void;
  112008. /**
  112009. * Disposes the resources of the material.
  112010. * @param forceDisposeTextures - Forces the disposal of all textures.
  112011. */
  112012. dispose(forceDisposeTextures?: boolean): void;
  112013. /**
  112014. * Get the current class name of the texture useful for serialization or dynamic coding.
  112015. * @returns "PBRAnisotropicConfiguration"
  112016. */
  112017. getClassName(): string;
  112018. /**
  112019. * Add fallbacks to the effect fallbacks list.
  112020. * @param defines defines the Base texture to use.
  112021. * @param fallbacks defines the current fallback list.
  112022. * @param currentRank defines the current fallback rank.
  112023. * @returns the new fallback rank.
  112024. */
  112025. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  112026. /**
  112027. * Add the required uniforms to the current list.
  112028. * @param uniforms defines the current uniform list.
  112029. */
  112030. static AddUniforms(uniforms: string[]): void;
  112031. /**
  112032. * Add the required uniforms to the current buffer.
  112033. * @param uniformBuffer defines the current uniform buffer.
  112034. */
  112035. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  112036. /**
  112037. * Add the required samplers to the current list.
  112038. * @param samplers defines the current sampler list.
  112039. */
  112040. static AddSamplers(samplers: string[]): void;
  112041. /**
  112042. * Makes a duplicate of the current configuration into another one.
  112043. * @param anisotropicConfiguration define the config where to copy the info
  112044. */
  112045. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  112046. /**
  112047. * Serializes this anisotropy configuration.
  112048. * @returns - An object with the serialized config.
  112049. */
  112050. serialize(): any;
  112051. /**
  112052. * Parses a anisotropy Configuration from a serialized object.
  112053. * @param source - Serialized object.
  112054. * @param scene Defines the scene we are parsing for
  112055. * @param rootUrl Defines the rootUrl to load from
  112056. */
  112057. parse(source: any, scene: Scene, rootUrl: string): void;
  112058. }
  112059. }
  112060. declare module BABYLON {
  112061. /**
  112062. * @hidden
  112063. */
  112064. export interface IMaterialBRDFDefines {
  112065. BRDF_V_HEIGHT_CORRELATED: boolean;
  112066. MS_BRDF_ENERGY_CONSERVATION: boolean;
  112067. SPHERICAL_HARMONICS: boolean;
  112068. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  112069. /** @hidden */
  112070. _areMiscDirty: boolean;
  112071. }
  112072. /**
  112073. * Define the code related to the BRDF parameters of the pbr material.
  112074. */
  112075. export class PBRBRDFConfiguration {
  112076. /**
  112077. * Default value used for the energy conservation.
  112078. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  112079. */
  112080. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  112081. /**
  112082. * Default value used for the Smith Visibility Height Correlated mode.
  112083. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  112084. */
  112085. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  112086. /**
  112087. * Default value used for the IBL diffuse part.
  112088. * This can help switching back to the polynomials mode globally which is a tiny bit
  112089. * less GPU intensive at the drawback of a lower quality.
  112090. */
  112091. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  112092. /**
  112093. * Default value used for activating energy conservation for the specular workflow.
  112094. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  112095. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  112096. */
  112097. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  112098. private _useEnergyConservation;
  112099. /**
  112100. * Defines if the material uses energy conservation.
  112101. */
  112102. useEnergyConservation: boolean;
  112103. private _useSmithVisibilityHeightCorrelated;
  112104. /**
  112105. * LEGACY Mode set to false
  112106. * Defines if the material uses height smith correlated visibility term.
  112107. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  112108. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  112109. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  112110. * Not relying on height correlated will also disable energy conservation.
  112111. */
  112112. useSmithVisibilityHeightCorrelated: boolean;
  112113. private _useSphericalHarmonics;
  112114. /**
  112115. * LEGACY Mode set to false
  112116. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  112117. * diffuse part of the IBL.
  112118. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  112119. * to the ground truth.
  112120. */
  112121. useSphericalHarmonics: boolean;
  112122. private _useSpecularGlossinessInputEnergyConservation;
  112123. /**
  112124. * Defines if the material uses energy conservation, when the specular workflow is active.
  112125. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  112126. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  112127. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  112128. */
  112129. useSpecularGlossinessInputEnergyConservation: boolean;
  112130. /** @hidden */
  112131. private _internalMarkAllSubMeshesAsMiscDirty;
  112132. /** @hidden */
  112133. _markAllSubMeshesAsMiscDirty(): void;
  112134. /**
  112135. * Instantiate a new istance of clear coat configuration.
  112136. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  112137. */
  112138. constructor(markAllSubMeshesAsMiscDirty: () => void);
  112139. /**
  112140. * Checks to see if a texture is used in the material.
  112141. * @param defines the list of "defines" to update.
  112142. */
  112143. prepareDefines(defines: IMaterialBRDFDefines): void;
  112144. /**
  112145. * Get the current class name of the texture useful for serialization or dynamic coding.
  112146. * @returns "PBRClearCoatConfiguration"
  112147. */
  112148. getClassName(): string;
  112149. /**
  112150. * Makes a duplicate of the current configuration into another one.
  112151. * @param brdfConfiguration define the config where to copy the info
  112152. */
  112153. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  112154. /**
  112155. * Serializes this BRDF configuration.
  112156. * @returns - An object with the serialized config.
  112157. */
  112158. serialize(): any;
  112159. /**
  112160. * Parses a anisotropy Configuration from a serialized object.
  112161. * @param source - Serialized object.
  112162. * @param scene Defines the scene we are parsing for
  112163. * @param rootUrl Defines the rootUrl to load from
  112164. */
  112165. parse(source: any, scene: Scene, rootUrl: string): void;
  112166. }
  112167. }
  112168. declare module BABYLON {
  112169. /**
  112170. * @hidden
  112171. */
  112172. export interface IMaterialSheenDefines {
  112173. SHEEN: boolean;
  112174. SHEEN_TEXTURE: boolean;
  112175. SHEEN_TEXTUREDIRECTUV: number;
  112176. SHEEN_LINKWITHALBEDO: boolean;
  112177. /** @hidden */
  112178. _areTexturesDirty: boolean;
  112179. }
  112180. /**
  112181. * Define the code related to the Sheen parameters of the pbr material.
  112182. */
  112183. export class PBRSheenConfiguration {
  112184. private _isEnabled;
  112185. /**
  112186. * Defines if the material uses sheen.
  112187. */
  112188. isEnabled: boolean;
  112189. private _linkSheenWithAlbedo;
  112190. /**
  112191. * Defines if the sheen is linked to the sheen color.
  112192. */
  112193. linkSheenWithAlbedo: boolean;
  112194. /**
  112195. * Defines the sheen intensity.
  112196. */
  112197. intensity: number;
  112198. /**
  112199. * Defines the sheen color.
  112200. */
  112201. color: Color3;
  112202. private _texture;
  112203. /**
  112204. * Stores the sheen tint values in a texture.
  112205. * rgb is tint
  112206. * a is a intensity
  112207. */
  112208. texture: Nullable<BaseTexture>;
  112209. /** @hidden */
  112210. private _internalMarkAllSubMeshesAsTexturesDirty;
  112211. /** @hidden */
  112212. _markAllSubMeshesAsTexturesDirty(): void;
  112213. /**
  112214. * Instantiate a new istance of clear coat configuration.
  112215. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  112216. */
  112217. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  112218. /**
  112219. * Specifies that the submesh is ready to be used.
  112220. * @param defines the list of "defines" to update.
  112221. * @param scene defines the scene the material belongs to.
  112222. * @returns - boolean indicating that the submesh is ready or not.
  112223. */
  112224. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  112225. /**
  112226. * Checks to see if a texture is used in the material.
  112227. * @param defines the list of "defines" to update.
  112228. * @param scene defines the scene the material belongs to.
  112229. */
  112230. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  112231. /**
  112232. * Binds the material data.
  112233. * @param uniformBuffer defines the Uniform buffer to fill in.
  112234. * @param scene defines the scene the material belongs to.
  112235. * @param isFrozen defines wether the material is frozen or not.
  112236. */
  112237. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  112238. /**
  112239. * Checks to see if a texture is used in the material.
  112240. * @param texture - Base texture to use.
  112241. * @returns - Boolean specifying if a texture is used in the material.
  112242. */
  112243. hasTexture(texture: BaseTexture): boolean;
  112244. /**
  112245. * Returns an array of the actively used textures.
  112246. * @param activeTextures Array of BaseTextures
  112247. */
  112248. getActiveTextures(activeTextures: BaseTexture[]): void;
  112249. /**
  112250. * Returns the animatable textures.
  112251. * @param animatables Array of animatable textures.
  112252. */
  112253. getAnimatables(animatables: IAnimatable[]): void;
  112254. /**
  112255. * Disposes the resources of the material.
  112256. * @param forceDisposeTextures - Forces the disposal of all textures.
  112257. */
  112258. dispose(forceDisposeTextures?: boolean): void;
  112259. /**
  112260. * Get the current class name of the texture useful for serialization or dynamic coding.
  112261. * @returns "PBRSheenConfiguration"
  112262. */
  112263. getClassName(): string;
  112264. /**
  112265. * Add fallbacks to the effect fallbacks list.
  112266. * @param defines defines the Base texture to use.
  112267. * @param fallbacks defines the current fallback list.
  112268. * @param currentRank defines the current fallback rank.
  112269. * @returns the new fallback rank.
  112270. */
  112271. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  112272. /**
  112273. * Add the required uniforms to the current list.
  112274. * @param uniforms defines the current uniform list.
  112275. */
  112276. static AddUniforms(uniforms: string[]): void;
  112277. /**
  112278. * Add the required uniforms to the current buffer.
  112279. * @param uniformBuffer defines the current uniform buffer.
  112280. */
  112281. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  112282. /**
  112283. * Add the required samplers to the current list.
  112284. * @param samplers defines the current sampler list.
  112285. */
  112286. static AddSamplers(samplers: string[]): void;
  112287. /**
  112288. * Makes a duplicate of the current configuration into another one.
  112289. * @param sheenConfiguration define the config where to copy the info
  112290. */
  112291. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  112292. /**
  112293. * Serializes this BRDF configuration.
  112294. * @returns - An object with the serialized config.
  112295. */
  112296. serialize(): any;
  112297. /**
  112298. * Parses a anisotropy Configuration from a serialized object.
  112299. * @param source - Serialized object.
  112300. * @param scene Defines the scene we are parsing for
  112301. * @param rootUrl Defines the rootUrl to load from
  112302. */
  112303. parse(source: any, scene: Scene, rootUrl: string): void;
  112304. }
  112305. }
  112306. declare module BABYLON {
  112307. /**
  112308. * @hidden
  112309. */
  112310. export interface IMaterialSubSurfaceDefines {
  112311. SUBSURFACE: boolean;
  112312. SS_REFRACTION: boolean;
  112313. SS_TRANSLUCENCY: boolean;
  112314. SS_SCATERRING: boolean;
  112315. SS_THICKNESSANDMASK_TEXTURE: boolean;
  112316. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  112317. SS_REFRACTIONMAP_3D: boolean;
  112318. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  112319. SS_LODINREFRACTIONALPHA: boolean;
  112320. SS_GAMMAREFRACTION: boolean;
  112321. SS_RGBDREFRACTION: boolean;
  112322. SS_LINEARSPECULARREFRACTION: boolean;
  112323. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  112324. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  112325. /** @hidden */
  112326. _areTexturesDirty: boolean;
  112327. }
  112328. /**
  112329. * Define the code related to the sub surface parameters of the pbr material.
  112330. */
  112331. export class PBRSubSurfaceConfiguration {
  112332. private _isRefractionEnabled;
  112333. /**
  112334. * Defines if the refraction is enabled in the material.
  112335. */
  112336. isRefractionEnabled: boolean;
  112337. private _isTranslucencyEnabled;
  112338. /**
  112339. * Defines if the translucency is enabled in the material.
  112340. */
  112341. isTranslucencyEnabled: boolean;
  112342. private _isScatteringEnabled;
  112343. /**
  112344. * Defines the refraction intensity of the material.
  112345. * The refraction when enabled replaces the Diffuse part of the material.
  112346. * The intensity helps transitionning between diffuse and refraction.
  112347. */
  112348. refractionIntensity: number;
  112349. /**
  112350. * Defines the translucency intensity of the material.
  112351. * When translucency has been enabled, this defines how much of the "translucency"
  112352. * is addded to the diffuse part of the material.
  112353. */
  112354. translucencyIntensity: number;
  112355. /**
  112356. * Defines the scattering intensity of the material.
  112357. * When scattering has been enabled, this defines how much of the "scattered light"
  112358. * is addded to the diffuse part of the material.
  112359. */
  112360. scatteringIntensity: number;
  112361. private _thicknessTexture;
  112362. /**
  112363. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  112364. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  112365. * 0 would mean minimumThickness
  112366. * 1 would mean maximumThickness
  112367. * The other channels might be use as a mask to vary the different effects intensity.
  112368. */
  112369. thicknessTexture: Nullable<BaseTexture>;
  112370. private _refractionTexture;
  112371. /**
  112372. * Defines the texture to use for refraction.
  112373. */
  112374. refractionTexture: Nullable<BaseTexture>;
  112375. private _indexOfRefraction;
  112376. /**
  112377. * Defines the index of refraction used in the material.
  112378. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  112379. */
  112380. indexOfRefraction: number;
  112381. private _invertRefractionY;
  112382. /**
  112383. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  112384. */
  112385. invertRefractionY: boolean;
  112386. private _linkRefractionWithTransparency;
  112387. /**
  112388. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  112389. * Materials half opaque for instance using refraction could benefit from this control.
  112390. */
  112391. linkRefractionWithTransparency: boolean;
  112392. /**
  112393. * Defines the minimum thickness stored in the thickness map.
  112394. * If no thickness map is defined, this value will be used to simulate thickness.
  112395. */
  112396. minimumThickness: number;
  112397. /**
  112398. * Defines the maximum thickness stored in the thickness map.
  112399. */
  112400. maximumThickness: number;
  112401. /**
  112402. * Defines the volume tint of the material.
  112403. * This is used for both translucency and scattering.
  112404. */
  112405. tintColor: Color3;
  112406. /**
  112407. * Defines the distance at which the tint color should be found in the media.
  112408. * This is used for refraction only.
  112409. */
  112410. tintColorAtDistance: number;
  112411. /**
  112412. * Defines how far each channel transmit through the media.
  112413. * It is defined as a color to simplify it selection.
  112414. */
  112415. diffusionDistance: Color3;
  112416. private _useMaskFromThicknessTexture;
  112417. /**
  112418. * Stores the intensity of the different subsurface effects in the thickness texture.
  112419. * * the green channel is the translucency intensity.
  112420. * * the blue channel is the scattering intensity.
  112421. * * the alpha channel is the refraction intensity.
  112422. */
  112423. useMaskFromThicknessTexture: boolean;
  112424. /** @hidden */
  112425. private _internalMarkAllSubMeshesAsTexturesDirty;
  112426. /** @hidden */
  112427. _markAllSubMeshesAsTexturesDirty(): void;
  112428. /**
  112429. * Instantiate a new istance of sub surface configuration.
  112430. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  112431. */
  112432. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  112433. /**
  112434. * Gets wehter the submesh is ready to be used or not.
  112435. * @param defines the list of "defines" to update.
  112436. * @param scene defines the scene the material belongs to.
  112437. * @returns - boolean indicating that the submesh is ready or not.
  112438. */
  112439. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  112440. /**
  112441. * Checks to see if a texture is used in the material.
  112442. * @param defines the list of "defines" to update.
  112443. * @param scene defines the scene to the material belongs to.
  112444. */
  112445. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  112446. /**
  112447. * Binds the material data.
  112448. * @param uniformBuffer defines the Uniform buffer to fill in.
  112449. * @param scene defines the scene the material belongs to.
  112450. * @param engine defines the engine the material belongs to.
  112451. * @param isFrozen defines wether the material is frozen or not.
  112452. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  112453. */
  112454. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  112455. /**
  112456. * Unbinds the material from the mesh.
  112457. * @param activeEffect defines the effect that should be unbound from.
  112458. * @returns true if unbound, otherwise false
  112459. */
  112460. unbind(activeEffect: Effect): boolean;
  112461. /**
  112462. * Returns the texture used for refraction or null if none is used.
  112463. * @param scene defines the scene the material belongs to.
  112464. * @returns - Refraction texture if present. If no refraction texture and refraction
  112465. * is linked with transparency, returns environment texture. Otherwise, returns null.
  112466. */
  112467. private _getRefractionTexture;
  112468. /**
  112469. * Returns true if alpha blending should be disabled.
  112470. */
  112471. readonly disableAlphaBlending: boolean;
  112472. /**
  112473. * Fills the list of render target textures.
  112474. * @param renderTargets the list of render targets to update
  112475. */
  112476. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  112477. /**
  112478. * Checks to see if a texture is used in the material.
  112479. * @param texture - Base texture to use.
  112480. * @returns - Boolean specifying if a texture is used in the material.
  112481. */
  112482. hasTexture(texture: BaseTexture): boolean;
  112483. /**
  112484. * Gets a boolean indicating that current material needs to register RTT
  112485. * @returns true if this uses a render target otherwise false.
  112486. */
  112487. hasRenderTargetTextures(): boolean;
  112488. /**
  112489. * Returns an array of the actively used textures.
  112490. * @param activeTextures Array of BaseTextures
  112491. */
  112492. getActiveTextures(activeTextures: BaseTexture[]): void;
  112493. /**
  112494. * Returns the animatable textures.
  112495. * @param animatables Array of animatable textures.
  112496. */
  112497. getAnimatables(animatables: IAnimatable[]): void;
  112498. /**
  112499. * Disposes the resources of the material.
  112500. * @param forceDisposeTextures - Forces the disposal of all textures.
  112501. */
  112502. dispose(forceDisposeTextures?: boolean): void;
  112503. /**
  112504. * Get the current class name of the texture useful for serialization or dynamic coding.
  112505. * @returns "PBRSubSurfaceConfiguration"
  112506. */
  112507. getClassName(): string;
  112508. /**
  112509. * Add fallbacks to the effect fallbacks list.
  112510. * @param defines defines the Base texture to use.
  112511. * @param fallbacks defines the current fallback list.
  112512. * @param currentRank defines the current fallback rank.
  112513. * @returns the new fallback rank.
  112514. */
  112515. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  112516. /**
  112517. * Add the required uniforms to the current list.
  112518. * @param uniforms defines the current uniform list.
  112519. */
  112520. static AddUniforms(uniforms: string[]): void;
  112521. /**
  112522. * Add the required samplers to the current list.
  112523. * @param samplers defines the current sampler list.
  112524. */
  112525. static AddSamplers(samplers: string[]): void;
  112526. /**
  112527. * Add the required uniforms to the current buffer.
  112528. * @param uniformBuffer defines the current uniform buffer.
  112529. */
  112530. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  112531. /**
  112532. * Makes a duplicate of the current configuration into another one.
  112533. * @param configuration define the config where to copy the info
  112534. */
  112535. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  112536. /**
  112537. * Serializes this Sub Surface configuration.
  112538. * @returns - An object with the serialized config.
  112539. */
  112540. serialize(): any;
  112541. /**
  112542. * Parses a anisotropy Configuration from a serialized object.
  112543. * @param source - Serialized object.
  112544. * @param scene Defines the scene we are parsing for
  112545. * @param rootUrl Defines the rootUrl to load from
  112546. */
  112547. parse(source: any, scene: Scene, rootUrl: string): void;
  112548. }
  112549. }
  112550. declare module BABYLON {
  112551. /** @hidden */
  112552. export var pbrFragmentDeclaration: {
  112553. name: string;
  112554. shader: string;
  112555. };
  112556. }
  112557. declare module BABYLON {
  112558. /** @hidden */
  112559. export var pbrUboDeclaration: {
  112560. name: string;
  112561. shader: string;
  112562. };
  112563. }
  112564. declare module BABYLON {
  112565. /** @hidden */
  112566. export var pbrFragmentExtraDeclaration: {
  112567. name: string;
  112568. shader: string;
  112569. };
  112570. }
  112571. declare module BABYLON {
  112572. /** @hidden */
  112573. export var pbrFragmentSamplersDeclaration: {
  112574. name: string;
  112575. shader: string;
  112576. };
  112577. }
  112578. declare module BABYLON {
  112579. /** @hidden */
  112580. export var pbrHelperFunctions: {
  112581. name: string;
  112582. shader: string;
  112583. };
  112584. }
  112585. declare module BABYLON {
  112586. /** @hidden */
  112587. export var harmonicsFunctions: {
  112588. name: string;
  112589. shader: string;
  112590. };
  112591. }
  112592. declare module BABYLON {
  112593. /** @hidden */
  112594. export var pbrDirectLightingSetupFunctions: {
  112595. name: string;
  112596. shader: string;
  112597. };
  112598. }
  112599. declare module BABYLON {
  112600. /** @hidden */
  112601. export var pbrDirectLightingFalloffFunctions: {
  112602. name: string;
  112603. shader: string;
  112604. };
  112605. }
  112606. declare module BABYLON {
  112607. /** @hidden */
  112608. export var pbrBRDFFunctions: {
  112609. name: string;
  112610. shader: string;
  112611. };
  112612. }
  112613. declare module BABYLON {
  112614. /** @hidden */
  112615. export var pbrDirectLightingFunctions: {
  112616. name: string;
  112617. shader: string;
  112618. };
  112619. }
  112620. declare module BABYLON {
  112621. /** @hidden */
  112622. export var pbrIBLFunctions: {
  112623. name: string;
  112624. shader: string;
  112625. };
  112626. }
  112627. declare module BABYLON {
  112628. /** @hidden */
  112629. export var pbrDebug: {
  112630. name: string;
  112631. shader: string;
  112632. };
  112633. }
  112634. declare module BABYLON {
  112635. /** @hidden */
  112636. export var pbrPixelShader: {
  112637. name: string;
  112638. shader: string;
  112639. };
  112640. }
  112641. declare module BABYLON {
  112642. /** @hidden */
  112643. export var pbrVertexDeclaration: {
  112644. name: string;
  112645. shader: string;
  112646. };
  112647. }
  112648. declare module BABYLON {
  112649. /** @hidden */
  112650. export var pbrVertexShader: {
  112651. name: string;
  112652. shader: string;
  112653. };
  112654. }
  112655. declare module BABYLON {
  112656. /**
  112657. * Manages the defines for the PBR Material.
  112658. * @hidden
  112659. */
  112660. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  112661. PBR: boolean;
  112662. MAINUV1: boolean;
  112663. MAINUV2: boolean;
  112664. UV1: boolean;
  112665. UV2: boolean;
  112666. ALBEDO: boolean;
  112667. ALBEDODIRECTUV: number;
  112668. VERTEXCOLOR: boolean;
  112669. AMBIENT: boolean;
  112670. AMBIENTDIRECTUV: number;
  112671. AMBIENTINGRAYSCALE: boolean;
  112672. OPACITY: boolean;
  112673. VERTEXALPHA: boolean;
  112674. OPACITYDIRECTUV: number;
  112675. OPACITYRGB: boolean;
  112676. ALPHATEST: boolean;
  112677. DEPTHPREPASS: boolean;
  112678. ALPHABLEND: boolean;
  112679. ALPHAFROMALBEDO: boolean;
  112680. ALPHATESTVALUE: string;
  112681. SPECULAROVERALPHA: boolean;
  112682. RADIANCEOVERALPHA: boolean;
  112683. ALPHAFRESNEL: boolean;
  112684. LINEARALPHAFRESNEL: boolean;
  112685. PREMULTIPLYALPHA: boolean;
  112686. EMISSIVE: boolean;
  112687. EMISSIVEDIRECTUV: number;
  112688. REFLECTIVITY: boolean;
  112689. REFLECTIVITYDIRECTUV: number;
  112690. SPECULARTERM: boolean;
  112691. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  112692. MICROSURFACEAUTOMATIC: boolean;
  112693. LODBASEDMICROSFURACE: boolean;
  112694. MICROSURFACEMAP: boolean;
  112695. MICROSURFACEMAPDIRECTUV: number;
  112696. METALLICWORKFLOW: boolean;
  112697. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  112698. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  112699. METALLNESSSTOREINMETALMAPBLUE: boolean;
  112700. AOSTOREINMETALMAPRED: boolean;
  112701. ENVIRONMENTBRDF: boolean;
  112702. ENVIRONMENTBRDF_RGBD: boolean;
  112703. NORMAL: boolean;
  112704. TANGENT: boolean;
  112705. BUMP: boolean;
  112706. BUMPDIRECTUV: number;
  112707. OBJECTSPACE_NORMALMAP: boolean;
  112708. PARALLAX: boolean;
  112709. PARALLAXOCCLUSION: boolean;
  112710. NORMALXYSCALE: boolean;
  112711. LIGHTMAP: boolean;
  112712. LIGHTMAPDIRECTUV: number;
  112713. USELIGHTMAPASSHADOWMAP: boolean;
  112714. GAMMALIGHTMAP: boolean;
  112715. RGBDLIGHTMAP: boolean;
  112716. REFLECTION: boolean;
  112717. REFLECTIONMAP_3D: boolean;
  112718. REFLECTIONMAP_SPHERICAL: boolean;
  112719. REFLECTIONMAP_PLANAR: boolean;
  112720. REFLECTIONMAP_CUBIC: boolean;
  112721. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  112722. REFLECTIONMAP_PROJECTION: boolean;
  112723. REFLECTIONMAP_SKYBOX: boolean;
  112724. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  112725. REFLECTIONMAP_EXPLICIT: boolean;
  112726. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  112727. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  112728. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  112729. INVERTCUBICMAP: boolean;
  112730. USESPHERICALFROMREFLECTIONMAP: boolean;
  112731. USEIRRADIANCEMAP: boolean;
  112732. SPHERICAL_HARMONICS: boolean;
  112733. USESPHERICALINVERTEX: boolean;
  112734. REFLECTIONMAP_OPPOSITEZ: boolean;
  112735. LODINREFLECTIONALPHA: boolean;
  112736. GAMMAREFLECTION: boolean;
  112737. RGBDREFLECTION: boolean;
  112738. LINEARSPECULARREFLECTION: boolean;
  112739. RADIANCEOCCLUSION: boolean;
  112740. HORIZONOCCLUSION: boolean;
  112741. INSTANCES: boolean;
  112742. NUM_BONE_INFLUENCERS: number;
  112743. BonesPerMesh: number;
  112744. BONETEXTURE: boolean;
  112745. NONUNIFORMSCALING: boolean;
  112746. MORPHTARGETS: boolean;
  112747. MORPHTARGETS_NORMAL: boolean;
  112748. MORPHTARGETS_TANGENT: boolean;
  112749. MORPHTARGETS_UV: boolean;
  112750. NUM_MORPH_INFLUENCERS: number;
  112751. IMAGEPROCESSING: boolean;
  112752. VIGNETTE: boolean;
  112753. VIGNETTEBLENDMODEMULTIPLY: boolean;
  112754. VIGNETTEBLENDMODEOPAQUE: boolean;
  112755. TONEMAPPING: boolean;
  112756. TONEMAPPING_ACES: boolean;
  112757. CONTRAST: boolean;
  112758. COLORCURVES: boolean;
  112759. COLORGRADING: boolean;
  112760. COLORGRADING3D: boolean;
  112761. SAMPLER3DGREENDEPTH: boolean;
  112762. SAMPLER3DBGRMAP: boolean;
  112763. IMAGEPROCESSINGPOSTPROCESS: boolean;
  112764. EXPOSURE: boolean;
  112765. MULTIVIEW: boolean;
  112766. USEPHYSICALLIGHTFALLOFF: boolean;
  112767. USEGLTFLIGHTFALLOFF: boolean;
  112768. TWOSIDEDLIGHTING: boolean;
  112769. SHADOWFLOAT: boolean;
  112770. CLIPPLANE: boolean;
  112771. CLIPPLANE2: boolean;
  112772. CLIPPLANE3: boolean;
  112773. CLIPPLANE4: boolean;
  112774. POINTSIZE: boolean;
  112775. FOG: boolean;
  112776. LOGARITHMICDEPTH: boolean;
  112777. FORCENORMALFORWARD: boolean;
  112778. SPECULARAA: boolean;
  112779. CLEARCOAT: boolean;
  112780. CLEARCOAT_DEFAULTIOR: boolean;
  112781. CLEARCOAT_TEXTURE: boolean;
  112782. CLEARCOAT_TEXTUREDIRECTUV: number;
  112783. CLEARCOAT_BUMP: boolean;
  112784. CLEARCOAT_BUMPDIRECTUV: number;
  112785. CLEARCOAT_TINT: boolean;
  112786. CLEARCOAT_TINT_TEXTURE: boolean;
  112787. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  112788. ANISOTROPIC: boolean;
  112789. ANISOTROPIC_TEXTURE: boolean;
  112790. ANISOTROPIC_TEXTUREDIRECTUV: number;
  112791. BRDF_V_HEIGHT_CORRELATED: boolean;
  112792. MS_BRDF_ENERGY_CONSERVATION: boolean;
  112793. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  112794. SHEEN: boolean;
  112795. SHEEN_TEXTURE: boolean;
  112796. SHEEN_TEXTUREDIRECTUV: number;
  112797. SHEEN_LINKWITHALBEDO: boolean;
  112798. SUBSURFACE: boolean;
  112799. SS_REFRACTION: boolean;
  112800. SS_TRANSLUCENCY: boolean;
  112801. SS_SCATERRING: boolean;
  112802. SS_THICKNESSANDMASK_TEXTURE: boolean;
  112803. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  112804. SS_REFRACTIONMAP_3D: boolean;
  112805. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  112806. SS_LODINREFRACTIONALPHA: boolean;
  112807. SS_GAMMAREFRACTION: boolean;
  112808. SS_RGBDREFRACTION: boolean;
  112809. SS_LINEARSPECULARREFRACTION: boolean;
  112810. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  112811. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  112812. UNLIT: boolean;
  112813. DEBUGMODE: number;
  112814. /**
  112815. * Initializes the PBR Material defines.
  112816. */
  112817. constructor();
  112818. /**
  112819. * Resets the PBR Material defines.
  112820. */
  112821. reset(): void;
  112822. }
  112823. /**
  112824. * The Physically based material base class of BJS.
  112825. *
  112826. * This offers the main features of a standard PBR material.
  112827. * For more information, please refer to the documentation :
  112828. * https://doc.babylonjs.com/how_to/physically_based_rendering
  112829. */
  112830. export abstract class PBRBaseMaterial extends PushMaterial {
  112831. /**
  112832. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  112833. */
  112834. static readonly PBRMATERIAL_OPAQUE: number;
  112835. /**
  112836. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  112837. */
  112838. static readonly PBRMATERIAL_ALPHATEST: number;
  112839. /**
  112840. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  112841. */
  112842. static readonly PBRMATERIAL_ALPHABLEND: number;
  112843. /**
  112844. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  112845. * They are also discarded below the alpha cutoff threshold to improve performances.
  112846. */
  112847. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  112848. /**
  112849. * Defines the default value of how much AO map is occluding the analytical lights
  112850. * (point spot...).
  112851. */
  112852. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  112853. /**
  112854. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  112855. */
  112856. static readonly LIGHTFALLOFF_PHYSICAL: number;
  112857. /**
  112858. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  112859. * to enhance interoperability with other engines.
  112860. */
  112861. static readonly LIGHTFALLOFF_GLTF: number;
  112862. /**
  112863. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  112864. * to enhance interoperability with other materials.
  112865. */
  112866. static readonly LIGHTFALLOFF_STANDARD: number;
  112867. /**
  112868. * Intensity of the direct lights e.g. the four lights available in your scene.
  112869. * This impacts both the direct diffuse and specular highlights.
  112870. */
  112871. protected _directIntensity: number;
  112872. /**
  112873. * Intensity of the emissive part of the material.
  112874. * This helps controlling the emissive effect without modifying the emissive color.
  112875. */
  112876. protected _emissiveIntensity: number;
  112877. /**
  112878. * Intensity of the environment e.g. how much the environment will light the object
  112879. * either through harmonics for rough material or through the refelction for shiny ones.
  112880. */
  112881. protected _environmentIntensity: number;
  112882. /**
  112883. * This is a special control allowing the reduction of the specular highlights coming from the
  112884. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  112885. */
  112886. protected _specularIntensity: number;
  112887. /**
  112888. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  112889. */
  112890. private _lightingInfos;
  112891. /**
  112892. * Debug Control allowing disabling the bump map on this material.
  112893. */
  112894. protected _disableBumpMap: boolean;
  112895. /**
  112896. * AKA Diffuse Texture in standard nomenclature.
  112897. */
  112898. protected _albedoTexture: Nullable<BaseTexture>;
  112899. /**
  112900. * AKA Occlusion Texture in other nomenclature.
  112901. */
  112902. protected _ambientTexture: Nullable<BaseTexture>;
  112903. /**
  112904. * AKA Occlusion Texture Intensity in other nomenclature.
  112905. */
  112906. protected _ambientTextureStrength: number;
  112907. /**
  112908. * Defines how much the AO map is occluding the analytical lights (point spot...).
  112909. * 1 means it completely occludes it
  112910. * 0 mean it has no impact
  112911. */
  112912. protected _ambientTextureImpactOnAnalyticalLights: number;
  112913. /**
  112914. * Stores the alpha values in a texture.
  112915. */
  112916. protected _opacityTexture: Nullable<BaseTexture>;
  112917. /**
  112918. * Stores the reflection values in a texture.
  112919. */
  112920. protected _reflectionTexture: Nullable<BaseTexture>;
  112921. /**
  112922. * Stores the emissive values in a texture.
  112923. */
  112924. protected _emissiveTexture: Nullable<BaseTexture>;
  112925. /**
  112926. * AKA Specular texture in other nomenclature.
  112927. */
  112928. protected _reflectivityTexture: Nullable<BaseTexture>;
  112929. /**
  112930. * Used to switch from specular/glossiness to metallic/roughness workflow.
  112931. */
  112932. protected _metallicTexture: Nullable<BaseTexture>;
  112933. /**
  112934. * Specifies the metallic scalar of the metallic/roughness workflow.
  112935. * Can also be used to scale the metalness values of the metallic texture.
  112936. */
  112937. protected _metallic: Nullable<number>;
  112938. /**
  112939. * Specifies the roughness scalar of the metallic/roughness workflow.
  112940. * Can also be used to scale the roughness values of the metallic texture.
  112941. */
  112942. protected _roughness: Nullable<number>;
  112943. /**
  112944. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  112945. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  112946. */
  112947. protected _microSurfaceTexture: Nullable<BaseTexture>;
  112948. /**
  112949. * Stores surface normal data used to displace a mesh in a texture.
  112950. */
  112951. protected _bumpTexture: Nullable<BaseTexture>;
  112952. /**
  112953. * Stores the pre-calculated light information of a mesh in a texture.
  112954. */
  112955. protected _lightmapTexture: Nullable<BaseTexture>;
  112956. /**
  112957. * The color of a material in ambient lighting.
  112958. */
  112959. protected _ambientColor: Color3;
  112960. /**
  112961. * AKA Diffuse Color in other nomenclature.
  112962. */
  112963. protected _albedoColor: Color3;
  112964. /**
  112965. * AKA Specular Color in other nomenclature.
  112966. */
  112967. protected _reflectivityColor: Color3;
  112968. /**
  112969. * The color applied when light is reflected from a material.
  112970. */
  112971. protected _reflectionColor: Color3;
  112972. /**
  112973. * The color applied when light is emitted from a material.
  112974. */
  112975. protected _emissiveColor: Color3;
  112976. /**
  112977. * AKA Glossiness in other nomenclature.
  112978. */
  112979. protected _microSurface: number;
  112980. /**
  112981. * Specifies that the material will use the light map as a show map.
  112982. */
  112983. protected _useLightmapAsShadowmap: boolean;
  112984. /**
  112985. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  112986. * makes the reflect vector face the model (under horizon).
  112987. */
  112988. protected _useHorizonOcclusion: boolean;
  112989. /**
  112990. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  112991. * too much the area relying on ambient texture to define their ambient occlusion.
  112992. */
  112993. protected _useRadianceOcclusion: boolean;
  112994. /**
  112995. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  112996. */
  112997. protected _useAlphaFromAlbedoTexture: boolean;
  112998. /**
  112999. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  113000. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  113001. */
  113002. protected _useSpecularOverAlpha: boolean;
  113003. /**
  113004. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  113005. */
  113006. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  113007. /**
  113008. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  113009. */
  113010. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  113011. /**
  113012. * Specifies if the metallic texture contains the roughness information in its green channel.
  113013. */
  113014. protected _useRoughnessFromMetallicTextureGreen: boolean;
  113015. /**
  113016. * Specifies if the metallic texture contains the metallness information in its blue channel.
  113017. */
  113018. protected _useMetallnessFromMetallicTextureBlue: boolean;
  113019. /**
  113020. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  113021. */
  113022. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  113023. /**
  113024. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  113025. */
  113026. protected _useAmbientInGrayScale: boolean;
  113027. /**
  113028. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  113029. * The material will try to infer what glossiness each pixel should be.
  113030. */
  113031. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  113032. /**
  113033. * Defines the falloff type used in this material.
  113034. * It by default is Physical.
  113035. */
  113036. protected _lightFalloff: number;
  113037. /**
  113038. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  113039. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  113040. */
  113041. protected _useRadianceOverAlpha: boolean;
  113042. /**
  113043. * Allows using an object space normal map (instead of tangent space).
  113044. */
  113045. protected _useObjectSpaceNormalMap: boolean;
  113046. /**
  113047. * Allows using the bump map in parallax mode.
  113048. */
  113049. protected _useParallax: boolean;
  113050. /**
  113051. * Allows using the bump map in parallax occlusion mode.
  113052. */
  113053. protected _useParallaxOcclusion: boolean;
  113054. /**
  113055. * Controls the scale bias of the parallax mode.
  113056. */
  113057. protected _parallaxScaleBias: number;
  113058. /**
  113059. * If sets to true, disables all the lights affecting the material.
  113060. */
  113061. protected _disableLighting: boolean;
  113062. /**
  113063. * Number of Simultaneous lights allowed on the material.
  113064. */
  113065. protected _maxSimultaneousLights: number;
  113066. /**
  113067. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  113068. */
  113069. protected _invertNormalMapX: boolean;
  113070. /**
  113071. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  113072. */
  113073. protected _invertNormalMapY: boolean;
  113074. /**
  113075. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  113076. */
  113077. protected _twoSidedLighting: boolean;
  113078. /**
  113079. * Defines the alpha limits in alpha test mode.
  113080. */
  113081. protected _alphaCutOff: number;
  113082. /**
  113083. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  113084. */
  113085. protected _forceAlphaTest: boolean;
  113086. /**
  113087. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  113088. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  113089. */
  113090. protected _useAlphaFresnel: boolean;
  113091. /**
  113092. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  113093. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  113094. */
  113095. protected _useLinearAlphaFresnel: boolean;
  113096. /**
  113097. * The transparency mode of the material.
  113098. */
  113099. protected _transparencyMode: Nullable<number>;
  113100. /**
  113101. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  113102. * from cos thetav and roughness:
  113103. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  113104. */
  113105. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  113106. /**
  113107. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  113108. */
  113109. protected _forceIrradianceInFragment: boolean;
  113110. /**
  113111. * Force normal to face away from face.
  113112. */
  113113. protected _forceNormalForward: boolean;
  113114. /**
  113115. * Enables specular anti aliasing in the PBR shader.
  113116. * It will both interacts on the Geometry for analytical and IBL lighting.
  113117. * It also prefilter the roughness map based on the bump values.
  113118. */
  113119. protected _enableSpecularAntiAliasing: boolean;
  113120. /**
  113121. * Default configuration related to image processing available in the PBR Material.
  113122. */
  113123. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  113124. /**
  113125. * Keep track of the image processing observer to allow dispose and replace.
  113126. */
  113127. private _imageProcessingObserver;
  113128. /**
  113129. * Attaches a new image processing configuration to the PBR Material.
  113130. * @param configuration
  113131. */
  113132. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  113133. /**
  113134. * Stores the available render targets.
  113135. */
  113136. private _renderTargets;
  113137. /**
  113138. * Sets the global ambient color for the material used in lighting calculations.
  113139. */
  113140. private _globalAmbientColor;
  113141. /**
  113142. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  113143. */
  113144. private _useLogarithmicDepth;
  113145. /**
  113146. * If set to true, no lighting calculations will be applied.
  113147. */
  113148. private _unlit;
  113149. private _debugMode;
  113150. /**
  113151. * @hidden
  113152. * This is reserved for the inspector.
  113153. * Defines the material debug mode.
  113154. * It helps seeing only some components of the material while troubleshooting.
  113155. */
  113156. debugMode: number;
  113157. /**
  113158. * @hidden
  113159. * This is reserved for the inspector.
  113160. * Specify from where on screen the debug mode should start.
  113161. * The value goes from -1 (full screen) to 1 (not visible)
  113162. * It helps with side by side comparison against the final render
  113163. * This defaults to -1
  113164. */
  113165. private debugLimit;
  113166. /**
  113167. * @hidden
  113168. * This is reserved for the inspector.
  113169. * As the default viewing range might not be enough (if the ambient is really small for instance)
  113170. * You can use the factor to better multiply the final value.
  113171. */
  113172. private debugFactor;
  113173. /**
  113174. * Defines the clear coat layer parameters for the material.
  113175. */
  113176. readonly clearCoat: PBRClearCoatConfiguration;
  113177. /**
  113178. * Defines the anisotropic parameters for the material.
  113179. */
  113180. readonly anisotropy: PBRAnisotropicConfiguration;
  113181. /**
  113182. * Defines the BRDF parameters for the material.
  113183. */
  113184. readonly brdf: PBRBRDFConfiguration;
  113185. /**
  113186. * Defines the Sheen parameters for the material.
  113187. */
  113188. readonly sheen: PBRSheenConfiguration;
  113189. /**
  113190. * Defines the SubSurface parameters for the material.
  113191. */
  113192. readonly subSurface: PBRSubSurfaceConfiguration;
  113193. /**
  113194. * Custom callback helping to override the default shader used in the material.
  113195. */
  113196. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  113197. protected _rebuildInParallel: boolean;
  113198. /**
  113199. * Instantiates a new PBRMaterial instance.
  113200. *
  113201. * @param name The material name
  113202. * @param scene The scene the material will be use in.
  113203. */
  113204. constructor(name: string, scene: Scene);
  113205. /**
  113206. * Gets a boolean indicating that current material needs to register RTT
  113207. */
  113208. readonly hasRenderTargetTextures: boolean;
  113209. /**
  113210. * Gets the name of the material class.
  113211. */
  113212. getClassName(): string;
  113213. /**
  113214. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  113215. */
  113216. /**
  113217. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  113218. */
  113219. useLogarithmicDepth: boolean;
  113220. /**
  113221. * Gets the current transparency mode.
  113222. */
  113223. /**
  113224. * Sets the transparency mode of the material.
  113225. *
  113226. * | Value | Type | Description |
  113227. * | ----- | ----------------------------------- | ----------- |
  113228. * | 0 | OPAQUE | |
  113229. * | 1 | ALPHATEST | |
  113230. * | 2 | ALPHABLEND | |
  113231. * | 3 | ALPHATESTANDBLEND | |
  113232. *
  113233. */
  113234. transparencyMode: Nullable<number>;
  113235. /**
  113236. * Returns true if alpha blending should be disabled.
  113237. */
  113238. private readonly _disableAlphaBlending;
  113239. /**
  113240. * Specifies whether or not this material should be rendered in alpha blend mode.
  113241. */
  113242. needAlphaBlending(): boolean;
  113243. /**
  113244. * Specifies if the mesh will require alpha blending.
  113245. * @param mesh - BJS mesh.
  113246. */
  113247. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  113248. /**
  113249. * Specifies whether or not this material should be rendered in alpha test mode.
  113250. */
  113251. needAlphaTesting(): boolean;
  113252. /**
  113253. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  113254. */
  113255. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  113256. /**
  113257. * Gets the texture used for the alpha test.
  113258. */
  113259. getAlphaTestTexture(): Nullable<BaseTexture>;
  113260. /**
  113261. * Specifies that the submesh is ready to be used.
  113262. * @param mesh - BJS mesh.
  113263. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  113264. * @param useInstances - Specifies that instances should be used.
  113265. * @returns - boolean indicating that the submesh is ready or not.
  113266. */
  113267. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  113268. /**
  113269. * Specifies if the material uses metallic roughness workflow.
  113270. * @returns boolean specifiying if the material uses metallic roughness workflow.
  113271. */
  113272. isMetallicWorkflow(): boolean;
  113273. private _prepareEffect;
  113274. private _prepareDefines;
  113275. /**
  113276. * Force shader compilation
  113277. */
  113278. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  113279. clipPlane: boolean;
  113280. }>): void;
  113281. /**
  113282. * Initializes the uniform buffer layout for the shader.
  113283. */
  113284. buildUniformLayout(): void;
  113285. /**
  113286. * Unbinds the material from the mesh
  113287. */
  113288. unbind(): void;
  113289. /**
  113290. * Binds the submesh data.
  113291. * @param world - The world matrix.
  113292. * @param mesh - The BJS mesh.
  113293. * @param subMesh - A submesh of the BJS mesh.
  113294. */
  113295. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  113296. /**
  113297. * Returns the animatable textures.
  113298. * @returns - Array of animatable textures.
  113299. */
  113300. getAnimatables(): IAnimatable[];
  113301. /**
  113302. * Returns the texture used for reflections.
  113303. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  113304. */
  113305. private _getReflectionTexture;
  113306. /**
  113307. * Returns an array of the actively used textures.
  113308. * @returns - Array of BaseTextures
  113309. */
  113310. getActiveTextures(): BaseTexture[];
  113311. /**
  113312. * Checks to see if a texture is used in the material.
  113313. * @param texture - Base texture to use.
  113314. * @returns - Boolean specifying if a texture is used in the material.
  113315. */
  113316. hasTexture(texture: BaseTexture): boolean;
  113317. /**
  113318. * Disposes the resources of the material.
  113319. * @param forceDisposeEffect - Forces the disposal of effects.
  113320. * @param forceDisposeTextures - Forces the disposal of all textures.
  113321. */
  113322. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  113323. }
  113324. }
  113325. declare module BABYLON {
  113326. /**
  113327. * The Physically based material of BJS.
  113328. *
  113329. * This offers the main features of a standard PBR material.
  113330. * For more information, please refer to the documentation :
  113331. * https://doc.babylonjs.com/how_to/physically_based_rendering
  113332. */
  113333. export class PBRMaterial extends PBRBaseMaterial {
  113334. /**
  113335. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  113336. */
  113337. static readonly PBRMATERIAL_OPAQUE: number;
  113338. /**
  113339. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  113340. */
  113341. static readonly PBRMATERIAL_ALPHATEST: number;
  113342. /**
  113343. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  113344. */
  113345. static readonly PBRMATERIAL_ALPHABLEND: number;
  113346. /**
  113347. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  113348. * They are also discarded below the alpha cutoff threshold to improve performances.
  113349. */
  113350. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  113351. /**
  113352. * Defines the default value of how much AO map is occluding the analytical lights
  113353. * (point spot...).
  113354. */
  113355. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  113356. /**
  113357. * Intensity of the direct lights e.g. the four lights available in your scene.
  113358. * This impacts both the direct diffuse and specular highlights.
  113359. */
  113360. directIntensity: number;
  113361. /**
  113362. * Intensity of the emissive part of the material.
  113363. * This helps controlling the emissive effect without modifying the emissive color.
  113364. */
  113365. emissiveIntensity: number;
  113366. /**
  113367. * Intensity of the environment e.g. how much the environment will light the object
  113368. * either through harmonics for rough material or through the refelction for shiny ones.
  113369. */
  113370. environmentIntensity: number;
  113371. /**
  113372. * This is a special control allowing the reduction of the specular highlights coming from the
  113373. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  113374. */
  113375. specularIntensity: number;
  113376. /**
  113377. * Debug Control allowing disabling the bump map on this material.
  113378. */
  113379. disableBumpMap: boolean;
  113380. /**
  113381. * AKA Diffuse Texture in standard nomenclature.
  113382. */
  113383. albedoTexture: BaseTexture;
  113384. /**
  113385. * AKA Occlusion Texture in other nomenclature.
  113386. */
  113387. ambientTexture: BaseTexture;
  113388. /**
  113389. * AKA Occlusion Texture Intensity in other nomenclature.
  113390. */
  113391. ambientTextureStrength: number;
  113392. /**
  113393. * Defines how much the AO map is occluding the analytical lights (point spot...).
  113394. * 1 means it completely occludes it
  113395. * 0 mean it has no impact
  113396. */
  113397. ambientTextureImpactOnAnalyticalLights: number;
  113398. /**
  113399. * Stores the alpha values in a texture.
  113400. */
  113401. opacityTexture: BaseTexture;
  113402. /**
  113403. * Stores the reflection values in a texture.
  113404. */
  113405. reflectionTexture: Nullable<BaseTexture>;
  113406. /**
  113407. * Stores the emissive values in a texture.
  113408. */
  113409. emissiveTexture: BaseTexture;
  113410. /**
  113411. * AKA Specular texture in other nomenclature.
  113412. */
  113413. reflectivityTexture: BaseTexture;
  113414. /**
  113415. * Used to switch from specular/glossiness to metallic/roughness workflow.
  113416. */
  113417. metallicTexture: BaseTexture;
  113418. /**
  113419. * Specifies the metallic scalar of the metallic/roughness workflow.
  113420. * Can also be used to scale the metalness values of the metallic texture.
  113421. */
  113422. metallic: Nullable<number>;
  113423. /**
  113424. * Specifies the roughness scalar of the metallic/roughness workflow.
  113425. * Can also be used to scale the roughness values of the metallic texture.
  113426. */
  113427. roughness: Nullable<number>;
  113428. /**
  113429. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  113430. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  113431. */
  113432. microSurfaceTexture: BaseTexture;
  113433. /**
  113434. * Stores surface normal data used to displace a mesh in a texture.
  113435. */
  113436. bumpTexture: BaseTexture;
  113437. /**
  113438. * Stores the pre-calculated light information of a mesh in a texture.
  113439. */
  113440. lightmapTexture: BaseTexture;
  113441. /**
  113442. * Stores the refracted light information in a texture.
  113443. */
  113444. refractionTexture: Nullable<BaseTexture>;
  113445. /**
  113446. * The color of a material in ambient lighting.
  113447. */
  113448. ambientColor: Color3;
  113449. /**
  113450. * AKA Diffuse Color in other nomenclature.
  113451. */
  113452. albedoColor: Color3;
  113453. /**
  113454. * AKA Specular Color in other nomenclature.
  113455. */
  113456. reflectivityColor: Color3;
  113457. /**
  113458. * The color reflected from the material.
  113459. */
  113460. reflectionColor: Color3;
  113461. /**
  113462. * The color emitted from the material.
  113463. */
  113464. emissiveColor: Color3;
  113465. /**
  113466. * AKA Glossiness in other nomenclature.
  113467. */
  113468. microSurface: number;
  113469. /**
  113470. * source material index of refraction (IOR)' / 'destination material IOR.
  113471. */
  113472. indexOfRefraction: number;
  113473. /**
  113474. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  113475. */
  113476. invertRefractionY: boolean;
  113477. /**
  113478. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  113479. * Materials half opaque for instance using refraction could benefit from this control.
  113480. */
  113481. linkRefractionWithTransparency: boolean;
  113482. /**
  113483. * If true, the light map contains occlusion information instead of lighting info.
  113484. */
  113485. useLightmapAsShadowmap: boolean;
  113486. /**
  113487. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  113488. */
  113489. useAlphaFromAlbedoTexture: boolean;
  113490. /**
  113491. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  113492. */
  113493. forceAlphaTest: boolean;
  113494. /**
  113495. * Defines the alpha limits in alpha test mode.
  113496. */
  113497. alphaCutOff: number;
  113498. /**
  113499. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  113500. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  113501. */
  113502. useSpecularOverAlpha: boolean;
  113503. /**
  113504. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  113505. */
  113506. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  113507. /**
  113508. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  113509. */
  113510. useRoughnessFromMetallicTextureAlpha: boolean;
  113511. /**
  113512. * Specifies if the metallic texture contains the roughness information in its green channel.
  113513. */
  113514. useRoughnessFromMetallicTextureGreen: boolean;
  113515. /**
  113516. * Specifies if the metallic texture contains the metallness information in its blue channel.
  113517. */
  113518. useMetallnessFromMetallicTextureBlue: boolean;
  113519. /**
  113520. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  113521. */
  113522. useAmbientOcclusionFromMetallicTextureRed: boolean;
  113523. /**
  113524. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  113525. */
  113526. useAmbientInGrayScale: boolean;
  113527. /**
  113528. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  113529. * The material will try to infer what glossiness each pixel should be.
  113530. */
  113531. useAutoMicroSurfaceFromReflectivityMap: boolean;
  113532. /**
  113533. * BJS is using an harcoded light falloff based on a manually sets up range.
  113534. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  113535. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  113536. */
  113537. /**
  113538. * BJS is using an harcoded light falloff based on a manually sets up range.
  113539. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  113540. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  113541. */
  113542. usePhysicalLightFalloff: boolean;
  113543. /**
  113544. * In order to support the falloff compatibility with gltf, a special mode has been added
  113545. * to reproduce the gltf light falloff.
  113546. */
  113547. /**
  113548. * In order to support the falloff compatibility with gltf, a special mode has been added
  113549. * to reproduce the gltf light falloff.
  113550. */
  113551. useGLTFLightFalloff: boolean;
  113552. /**
  113553. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  113554. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  113555. */
  113556. useRadianceOverAlpha: boolean;
  113557. /**
  113558. * Allows using an object space normal map (instead of tangent space).
  113559. */
  113560. useObjectSpaceNormalMap: boolean;
  113561. /**
  113562. * Allows using the bump map in parallax mode.
  113563. */
  113564. useParallax: boolean;
  113565. /**
  113566. * Allows using the bump map in parallax occlusion mode.
  113567. */
  113568. useParallaxOcclusion: boolean;
  113569. /**
  113570. * Controls the scale bias of the parallax mode.
  113571. */
  113572. parallaxScaleBias: number;
  113573. /**
  113574. * If sets to true, disables all the lights affecting the material.
  113575. */
  113576. disableLighting: boolean;
  113577. /**
  113578. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  113579. */
  113580. forceIrradianceInFragment: boolean;
  113581. /**
  113582. * Number of Simultaneous lights allowed on the material.
  113583. */
  113584. maxSimultaneousLights: number;
  113585. /**
  113586. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  113587. */
  113588. invertNormalMapX: boolean;
  113589. /**
  113590. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  113591. */
  113592. invertNormalMapY: boolean;
  113593. /**
  113594. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  113595. */
  113596. twoSidedLighting: boolean;
  113597. /**
  113598. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  113599. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  113600. */
  113601. useAlphaFresnel: boolean;
  113602. /**
  113603. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  113604. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  113605. */
  113606. useLinearAlphaFresnel: boolean;
  113607. /**
  113608. * Let user defines the brdf lookup texture used for IBL.
  113609. * A default 8bit version is embedded but you could point at :
  113610. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  113611. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  113612. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  113613. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  113614. */
  113615. environmentBRDFTexture: Nullable<BaseTexture>;
  113616. /**
  113617. * Force normal to face away from face.
  113618. */
  113619. forceNormalForward: boolean;
  113620. /**
  113621. * Enables specular anti aliasing in the PBR shader.
  113622. * It will both interacts on the Geometry for analytical and IBL lighting.
  113623. * It also prefilter the roughness map based on the bump values.
  113624. */
  113625. enableSpecularAntiAliasing: boolean;
  113626. /**
  113627. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  113628. * makes the reflect vector face the model (under horizon).
  113629. */
  113630. useHorizonOcclusion: boolean;
  113631. /**
  113632. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  113633. * too much the area relying on ambient texture to define their ambient occlusion.
  113634. */
  113635. useRadianceOcclusion: boolean;
  113636. /**
  113637. * If set to true, no lighting calculations will be applied.
  113638. */
  113639. unlit: boolean;
  113640. /**
  113641. * Gets the image processing configuration used either in this material.
  113642. */
  113643. /**
  113644. * Sets the Default image processing configuration used either in the this material.
  113645. *
  113646. * If sets to null, the scene one is in use.
  113647. */
  113648. imageProcessingConfiguration: ImageProcessingConfiguration;
  113649. /**
  113650. * Gets wether the color curves effect is enabled.
  113651. */
  113652. /**
  113653. * Sets wether the color curves effect is enabled.
  113654. */
  113655. cameraColorCurvesEnabled: boolean;
  113656. /**
  113657. * Gets wether the color grading effect is enabled.
  113658. */
  113659. /**
  113660. * Gets wether the color grading effect is enabled.
  113661. */
  113662. cameraColorGradingEnabled: boolean;
  113663. /**
  113664. * Gets wether tonemapping is enabled or not.
  113665. */
  113666. /**
  113667. * Sets wether tonemapping is enabled or not
  113668. */
  113669. cameraToneMappingEnabled: boolean;
  113670. /**
  113671. * The camera exposure used on this material.
  113672. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  113673. * This corresponds to a photographic exposure.
  113674. */
  113675. /**
  113676. * The camera exposure used on this material.
  113677. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  113678. * This corresponds to a photographic exposure.
  113679. */
  113680. cameraExposure: number;
  113681. /**
  113682. * Gets The camera contrast used on this material.
  113683. */
  113684. /**
  113685. * Sets The camera contrast used on this material.
  113686. */
  113687. cameraContrast: number;
  113688. /**
  113689. * Gets the Color Grading 2D Lookup Texture.
  113690. */
  113691. /**
  113692. * Sets the Color Grading 2D Lookup Texture.
  113693. */
  113694. cameraColorGradingTexture: Nullable<BaseTexture>;
  113695. /**
  113696. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  113697. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  113698. * 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;
  113699. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  113700. */
  113701. /**
  113702. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  113703. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  113704. * 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;
  113705. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  113706. */
  113707. cameraColorCurves: Nullable<ColorCurves>;
  113708. /**
  113709. * Instantiates a new PBRMaterial instance.
  113710. *
  113711. * @param name The material name
  113712. * @param scene The scene the material will be use in.
  113713. */
  113714. constructor(name: string, scene: Scene);
  113715. /**
  113716. * Returns the name of this material class.
  113717. */
  113718. getClassName(): string;
  113719. /**
  113720. * Makes a duplicate of the current material.
  113721. * @param name - name to use for the new material.
  113722. */
  113723. clone(name: string): PBRMaterial;
  113724. /**
  113725. * Serializes this PBR Material.
  113726. * @returns - An object with the serialized material.
  113727. */
  113728. serialize(): any;
  113729. /**
  113730. * Parses a PBR Material from a serialized object.
  113731. * @param source - Serialized object.
  113732. * @param scene - BJS scene instance.
  113733. * @param rootUrl - url for the scene object
  113734. * @returns - PBRMaterial
  113735. */
  113736. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  113737. }
  113738. }
  113739. declare module BABYLON {
  113740. /**
  113741. * Direct draw surface info
  113742. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  113743. */
  113744. export interface DDSInfo {
  113745. /**
  113746. * Width of the texture
  113747. */
  113748. width: number;
  113749. /**
  113750. * Width of the texture
  113751. */
  113752. height: number;
  113753. /**
  113754. * Number of Mipmaps for the texture
  113755. * @see https://en.wikipedia.org/wiki/Mipmap
  113756. */
  113757. mipmapCount: number;
  113758. /**
  113759. * If the textures format is a known fourCC format
  113760. * @see https://www.fourcc.org/
  113761. */
  113762. isFourCC: boolean;
  113763. /**
  113764. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  113765. */
  113766. isRGB: boolean;
  113767. /**
  113768. * If the texture is a lumincance format
  113769. */
  113770. isLuminance: boolean;
  113771. /**
  113772. * If this is a cube texture
  113773. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  113774. */
  113775. isCube: boolean;
  113776. /**
  113777. * If the texture is a compressed format eg. FOURCC_DXT1
  113778. */
  113779. isCompressed: boolean;
  113780. /**
  113781. * The dxgiFormat of the texture
  113782. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  113783. */
  113784. dxgiFormat: number;
  113785. /**
  113786. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  113787. */
  113788. textureType: number;
  113789. /**
  113790. * Sphericle polynomial created for the dds texture
  113791. */
  113792. sphericalPolynomial?: SphericalPolynomial;
  113793. }
  113794. /**
  113795. * Class used to provide DDS decompression tools
  113796. */
  113797. export class DDSTools {
  113798. /**
  113799. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  113800. */
  113801. static StoreLODInAlphaChannel: boolean;
  113802. /**
  113803. * Gets DDS information from an array buffer
  113804. * @param arrayBuffer defines the array buffer to read data from
  113805. * @returns the DDS information
  113806. */
  113807. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  113808. private static _FloatView;
  113809. private static _Int32View;
  113810. private static _ToHalfFloat;
  113811. private static _FromHalfFloat;
  113812. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  113813. private static _GetHalfFloatRGBAArrayBuffer;
  113814. private static _GetFloatRGBAArrayBuffer;
  113815. private static _GetFloatAsUIntRGBAArrayBuffer;
  113816. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  113817. private static _GetRGBAArrayBuffer;
  113818. private static _ExtractLongWordOrder;
  113819. private static _GetRGBArrayBuffer;
  113820. private static _GetLuminanceArrayBuffer;
  113821. /**
  113822. * Uploads DDS Levels to a Babylon Texture
  113823. * @hidden
  113824. */
  113825. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  113826. }
  113827. interface Engine {
  113828. /**
  113829. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  113830. * @param rootUrl defines the url where the file to load is located
  113831. * @param scene defines the current scene
  113832. * @param lodScale defines scale to apply to the mip map selection
  113833. * @param lodOffset defines offset to apply to the mip map selection
  113834. * @param onLoad defines an optional callback raised when the texture is loaded
  113835. * @param onError defines an optional callback raised if there is an issue to load the texture
  113836. * @param format defines the format of the data
  113837. * @param forcedExtension defines the extension to use to pick the right loader
  113838. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  113839. * @returns the cube texture as an InternalTexture
  113840. */
  113841. 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;
  113842. }
  113843. }
  113844. declare module BABYLON {
  113845. /**
  113846. * Implementation of the DDS Texture Loader.
  113847. * @hidden
  113848. */
  113849. export class _DDSTextureLoader implements IInternalTextureLoader {
  113850. /**
  113851. * Defines wether the loader supports cascade loading the different faces.
  113852. */
  113853. readonly supportCascades: boolean;
  113854. /**
  113855. * This returns if the loader support the current file information.
  113856. * @param extension defines the file extension of the file being loaded
  113857. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113858. * @param fallback defines the fallback internal texture if any
  113859. * @param isBase64 defines whether the texture is encoded as a base64
  113860. * @param isBuffer defines whether the texture data are stored as a buffer
  113861. * @returns true if the loader can load the specified file
  113862. */
  113863. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  113864. /**
  113865. * Transform the url before loading if required.
  113866. * @param rootUrl the url of the texture
  113867. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113868. * @returns the transformed texture
  113869. */
  113870. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  113871. /**
  113872. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  113873. * @param rootUrl the url of the texture
  113874. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113875. * @returns the fallback texture
  113876. */
  113877. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  113878. /**
  113879. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  113880. * @param data contains the texture data
  113881. * @param texture defines the BabylonJS internal texture
  113882. * @param createPolynomials will be true if polynomials have been requested
  113883. * @param onLoad defines the callback to trigger once the texture is ready
  113884. * @param onError defines the callback to trigger in case of error
  113885. */
  113886. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  113887. /**
  113888. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  113889. * @param data contains the texture data
  113890. * @param texture defines the BabylonJS internal texture
  113891. * @param callback defines the method to call once ready to upload
  113892. */
  113893. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  113894. }
  113895. }
  113896. declare module BABYLON {
  113897. /**
  113898. * Implementation of the ENV Texture Loader.
  113899. * @hidden
  113900. */
  113901. export class _ENVTextureLoader implements IInternalTextureLoader {
  113902. /**
  113903. * Defines wether the loader supports cascade loading the different faces.
  113904. */
  113905. readonly supportCascades: boolean;
  113906. /**
  113907. * This returns if the loader support the current file information.
  113908. * @param extension defines the file extension of the file being loaded
  113909. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113910. * @param fallback defines the fallback internal texture if any
  113911. * @param isBase64 defines whether the texture is encoded as a base64
  113912. * @param isBuffer defines whether the texture data are stored as a buffer
  113913. * @returns true if the loader can load the specified file
  113914. */
  113915. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  113916. /**
  113917. * Transform the url before loading if required.
  113918. * @param rootUrl the url of the texture
  113919. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113920. * @returns the transformed texture
  113921. */
  113922. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  113923. /**
  113924. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  113925. * @param rootUrl the url of the texture
  113926. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113927. * @returns the fallback texture
  113928. */
  113929. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  113930. /**
  113931. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  113932. * @param data contains the texture data
  113933. * @param texture defines the BabylonJS internal texture
  113934. * @param createPolynomials will be true if polynomials have been requested
  113935. * @param onLoad defines the callback to trigger once the texture is ready
  113936. * @param onError defines the callback to trigger in case of error
  113937. */
  113938. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  113939. /**
  113940. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  113941. * @param data contains the texture data
  113942. * @param texture defines the BabylonJS internal texture
  113943. * @param callback defines the method to call once ready to upload
  113944. */
  113945. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  113946. }
  113947. }
  113948. declare module BABYLON {
  113949. /**
  113950. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  113951. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  113952. */
  113953. export class KhronosTextureContainer {
  113954. /** contents of the KTX container file */
  113955. arrayBuffer: any;
  113956. private static HEADER_LEN;
  113957. private static COMPRESSED_2D;
  113958. private static COMPRESSED_3D;
  113959. private static TEX_2D;
  113960. private static TEX_3D;
  113961. /**
  113962. * Gets the openGL type
  113963. */
  113964. glType: number;
  113965. /**
  113966. * Gets the openGL type size
  113967. */
  113968. glTypeSize: number;
  113969. /**
  113970. * Gets the openGL format
  113971. */
  113972. glFormat: number;
  113973. /**
  113974. * Gets the openGL internal format
  113975. */
  113976. glInternalFormat: number;
  113977. /**
  113978. * Gets the base internal format
  113979. */
  113980. glBaseInternalFormat: number;
  113981. /**
  113982. * Gets image width in pixel
  113983. */
  113984. pixelWidth: number;
  113985. /**
  113986. * Gets image height in pixel
  113987. */
  113988. pixelHeight: number;
  113989. /**
  113990. * Gets image depth in pixels
  113991. */
  113992. pixelDepth: number;
  113993. /**
  113994. * Gets the number of array elements
  113995. */
  113996. numberOfArrayElements: number;
  113997. /**
  113998. * Gets the number of faces
  113999. */
  114000. numberOfFaces: number;
  114001. /**
  114002. * Gets the number of mipmap levels
  114003. */
  114004. numberOfMipmapLevels: number;
  114005. /**
  114006. * Gets the bytes of key value data
  114007. */
  114008. bytesOfKeyValueData: number;
  114009. /**
  114010. * Gets the load type
  114011. */
  114012. loadType: number;
  114013. /**
  114014. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  114015. */
  114016. isInvalid: boolean;
  114017. /**
  114018. * Creates a new KhronosTextureContainer
  114019. * @param arrayBuffer contents of the KTX container file
  114020. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  114021. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  114022. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  114023. */
  114024. constructor(
  114025. /** contents of the KTX container file */
  114026. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  114027. /**
  114028. * Uploads KTX content to a Babylon Texture.
  114029. * It is assumed that the texture has already been created & is currently bound
  114030. * @hidden
  114031. */
  114032. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  114033. private _upload2DCompressedLevels;
  114034. }
  114035. }
  114036. declare module BABYLON {
  114037. /**
  114038. * Implementation of the KTX Texture Loader.
  114039. * @hidden
  114040. */
  114041. export class _KTXTextureLoader implements IInternalTextureLoader {
  114042. /**
  114043. * Defines wether the loader supports cascade loading the different faces.
  114044. */
  114045. readonly supportCascades: boolean;
  114046. /**
  114047. * This returns if the loader support the current file information.
  114048. * @param extension defines the file extension of the file being loaded
  114049. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114050. * @param fallback defines the fallback internal texture if any
  114051. * @param isBase64 defines whether the texture is encoded as a base64
  114052. * @param isBuffer defines whether the texture data are stored as a buffer
  114053. * @returns true if the loader can load the specified file
  114054. */
  114055. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  114056. /**
  114057. * Transform the url before loading if required.
  114058. * @param rootUrl the url of the texture
  114059. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114060. * @returns the transformed texture
  114061. */
  114062. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  114063. /**
  114064. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  114065. * @param rootUrl the url of the texture
  114066. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114067. * @returns the fallback texture
  114068. */
  114069. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  114070. /**
  114071. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  114072. * @param data contains the texture data
  114073. * @param texture defines the BabylonJS internal texture
  114074. * @param createPolynomials will be true if polynomials have been requested
  114075. * @param onLoad defines the callback to trigger once the texture is ready
  114076. * @param onError defines the callback to trigger in case of error
  114077. */
  114078. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  114079. /**
  114080. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  114081. * @param data contains the texture data
  114082. * @param texture defines the BabylonJS internal texture
  114083. * @param callback defines the method to call once ready to upload
  114084. */
  114085. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  114086. }
  114087. }
  114088. declare module BABYLON {
  114089. /**
  114090. * Options for the default xr helper
  114091. */
  114092. export class WebXRDefaultExperienceOptions {
  114093. /**
  114094. * Floor meshes that should be used for teleporting
  114095. */
  114096. floorMeshes: Array<AbstractMesh>;
  114097. }
  114098. /**
  114099. * Default experience which provides a similar setup to the previous webVRExperience
  114100. */
  114101. export class WebXRDefaultExperience {
  114102. /**
  114103. * Base experience
  114104. */
  114105. baseExperience: WebXRExperienceHelper;
  114106. /**
  114107. * Input experience extension
  114108. */
  114109. input: WebXRInput;
  114110. /**
  114111. * Loads the controller models
  114112. */
  114113. controllerModelLoader: WebXRControllerModelLoader;
  114114. /**
  114115. * Enables laser pointer and selection
  114116. */
  114117. pointerSelection: WebXRControllerPointerSelection;
  114118. /**
  114119. * Enables teleportation
  114120. */
  114121. teleportation: WebXRControllerTeleportation;
  114122. /**
  114123. * Enables ui for enetering/exiting xr
  114124. */
  114125. enterExitUI: WebXREnterExitUI;
  114126. /**
  114127. * Default output canvas xr should render to
  114128. */
  114129. outputCanvas: WebXRManagedOutputCanvas;
  114130. /**
  114131. * Creates the default xr experience
  114132. * @param scene scene
  114133. * @param options options for basic configuration
  114134. * @returns resulting WebXRDefaultExperience
  114135. */
  114136. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  114137. private constructor();
  114138. /**
  114139. * DIsposes of the experience helper
  114140. */
  114141. dispose(): void;
  114142. }
  114143. }
  114144. declare module BABYLON {
  114145. /** @hidden */
  114146. export var _forceSceneHelpersToBundle: boolean;
  114147. interface Scene {
  114148. /**
  114149. * Creates a default light for the scene.
  114150. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  114151. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  114152. */
  114153. createDefaultLight(replace?: boolean): void;
  114154. /**
  114155. * Creates a default camera for the scene.
  114156. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  114157. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  114158. * @param replace has default false, when true replaces the active camera in the scene
  114159. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  114160. */
  114161. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  114162. /**
  114163. * Creates a default camera and a default light.
  114164. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  114165. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  114166. * @param replace has the default false, when true replaces the active camera/light in the scene
  114167. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  114168. */
  114169. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  114170. /**
  114171. * Creates a new sky box
  114172. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  114173. * @param environmentTexture defines the texture to use as environment texture
  114174. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  114175. * @param scale defines the overall scale of the skybox
  114176. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  114177. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  114178. * @returns a new mesh holding the sky box
  114179. */
  114180. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  114181. /**
  114182. * Creates a new environment
  114183. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  114184. * @param options defines the options you can use to configure the environment
  114185. * @returns the new EnvironmentHelper
  114186. */
  114187. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  114188. /**
  114189. * Creates a new VREXperienceHelper
  114190. * @see http://doc.babylonjs.com/how_to/webvr_helper
  114191. * @param webVROptions defines the options used to create the new VREXperienceHelper
  114192. * @returns a new VREXperienceHelper
  114193. */
  114194. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  114195. /**
  114196. * Creates a new WebXRDefaultExperience
  114197. * @see http://doc.babylonjs.com/how_to/webxr
  114198. * @param options experience options
  114199. * @returns a promise for a new WebXRDefaultExperience
  114200. */
  114201. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  114202. }
  114203. }
  114204. declare module BABYLON {
  114205. /**
  114206. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  114207. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  114208. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  114209. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  114210. */
  114211. export class VideoDome extends TransformNode {
  114212. /**
  114213. * Define the video source as a Monoscopic panoramic 360 video.
  114214. */
  114215. static readonly MODE_MONOSCOPIC: number;
  114216. /**
  114217. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  114218. */
  114219. static readonly MODE_TOPBOTTOM: number;
  114220. /**
  114221. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  114222. */
  114223. static readonly MODE_SIDEBYSIDE: number;
  114224. private _halfDome;
  114225. private _useDirectMapping;
  114226. /**
  114227. * The video texture being displayed on the sphere
  114228. */
  114229. protected _videoTexture: VideoTexture;
  114230. /**
  114231. * Gets the video texture being displayed on the sphere
  114232. */
  114233. readonly videoTexture: VideoTexture;
  114234. /**
  114235. * The skybox material
  114236. */
  114237. protected _material: BackgroundMaterial;
  114238. /**
  114239. * The surface used for the skybox
  114240. */
  114241. protected _mesh: Mesh;
  114242. /**
  114243. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  114244. */
  114245. private _halfDomeMask;
  114246. /**
  114247. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  114248. * Also see the options.resolution property.
  114249. */
  114250. fovMultiplier: number;
  114251. private _videoMode;
  114252. /**
  114253. * Gets or set the current video mode for the video. It can be:
  114254. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  114255. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  114256. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  114257. */
  114258. videoMode: number;
  114259. /**
  114260. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  114261. *
  114262. */
  114263. /**
  114264. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  114265. */
  114266. halfDome: boolean;
  114267. /**
  114268. * Oberserver used in Stereoscopic VR Mode.
  114269. */
  114270. private _onBeforeCameraRenderObserver;
  114271. /**
  114272. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  114273. * @param name Element's name, child elements will append suffixes for their own names.
  114274. * @param urlsOrVideo defines the url(s) or the video element to use
  114275. * @param options An object containing optional or exposed sub element properties
  114276. */
  114277. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  114278. resolution?: number;
  114279. clickToPlay?: boolean;
  114280. autoPlay?: boolean;
  114281. loop?: boolean;
  114282. size?: number;
  114283. poster?: string;
  114284. faceForward?: boolean;
  114285. useDirectMapping?: boolean;
  114286. halfDomeMode?: boolean;
  114287. }, scene: Scene);
  114288. private _changeVideoMode;
  114289. /**
  114290. * Releases resources associated with this node.
  114291. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  114292. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  114293. */
  114294. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  114295. }
  114296. }
  114297. declare module BABYLON {
  114298. /**
  114299. * This class can be used to get instrumentation data from a Babylon engine
  114300. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  114301. */
  114302. export class EngineInstrumentation implements IDisposable {
  114303. /**
  114304. * Define the instrumented engine.
  114305. */
  114306. engine: Engine;
  114307. private _captureGPUFrameTime;
  114308. private _gpuFrameTimeToken;
  114309. private _gpuFrameTime;
  114310. private _captureShaderCompilationTime;
  114311. private _shaderCompilationTime;
  114312. private _onBeginFrameObserver;
  114313. private _onEndFrameObserver;
  114314. private _onBeforeShaderCompilationObserver;
  114315. private _onAfterShaderCompilationObserver;
  114316. /**
  114317. * Gets the perf counter used for GPU frame time
  114318. */
  114319. readonly gpuFrameTimeCounter: PerfCounter;
  114320. /**
  114321. * Gets the GPU frame time capture status
  114322. */
  114323. /**
  114324. * Enable or disable the GPU frame time capture
  114325. */
  114326. captureGPUFrameTime: boolean;
  114327. /**
  114328. * Gets the perf counter used for shader compilation time
  114329. */
  114330. readonly shaderCompilationTimeCounter: PerfCounter;
  114331. /**
  114332. * Gets the shader compilation time capture status
  114333. */
  114334. /**
  114335. * Enable or disable the shader compilation time capture
  114336. */
  114337. captureShaderCompilationTime: boolean;
  114338. /**
  114339. * Instantiates a new engine instrumentation.
  114340. * This class can be used to get instrumentation data from a Babylon engine
  114341. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  114342. * @param engine Defines the engine to instrument
  114343. */
  114344. constructor(
  114345. /**
  114346. * Define the instrumented engine.
  114347. */
  114348. engine: Engine);
  114349. /**
  114350. * Dispose and release associated resources.
  114351. */
  114352. dispose(): void;
  114353. }
  114354. }
  114355. declare module BABYLON {
  114356. /**
  114357. * This class can be used to get instrumentation data from a Babylon engine
  114358. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  114359. */
  114360. export class SceneInstrumentation implements IDisposable {
  114361. /**
  114362. * Defines the scene to instrument
  114363. */
  114364. scene: Scene;
  114365. private _captureActiveMeshesEvaluationTime;
  114366. private _activeMeshesEvaluationTime;
  114367. private _captureRenderTargetsRenderTime;
  114368. private _renderTargetsRenderTime;
  114369. private _captureFrameTime;
  114370. private _frameTime;
  114371. private _captureRenderTime;
  114372. private _renderTime;
  114373. private _captureInterFrameTime;
  114374. private _interFrameTime;
  114375. private _captureParticlesRenderTime;
  114376. private _particlesRenderTime;
  114377. private _captureSpritesRenderTime;
  114378. private _spritesRenderTime;
  114379. private _capturePhysicsTime;
  114380. private _physicsTime;
  114381. private _captureAnimationsTime;
  114382. private _animationsTime;
  114383. private _captureCameraRenderTime;
  114384. private _cameraRenderTime;
  114385. private _onBeforeActiveMeshesEvaluationObserver;
  114386. private _onAfterActiveMeshesEvaluationObserver;
  114387. private _onBeforeRenderTargetsRenderObserver;
  114388. private _onAfterRenderTargetsRenderObserver;
  114389. private _onAfterRenderObserver;
  114390. private _onBeforeDrawPhaseObserver;
  114391. private _onAfterDrawPhaseObserver;
  114392. private _onBeforeAnimationsObserver;
  114393. private _onBeforeParticlesRenderingObserver;
  114394. private _onAfterParticlesRenderingObserver;
  114395. private _onBeforeSpritesRenderingObserver;
  114396. private _onAfterSpritesRenderingObserver;
  114397. private _onBeforePhysicsObserver;
  114398. private _onAfterPhysicsObserver;
  114399. private _onAfterAnimationsObserver;
  114400. private _onBeforeCameraRenderObserver;
  114401. private _onAfterCameraRenderObserver;
  114402. /**
  114403. * Gets the perf counter used for active meshes evaluation time
  114404. */
  114405. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  114406. /**
  114407. * Gets the active meshes evaluation time capture status
  114408. */
  114409. /**
  114410. * Enable or disable the active meshes evaluation time capture
  114411. */
  114412. captureActiveMeshesEvaluationTime: boolean;
  114413. /**
  114414. * Gets the perf counter used for render targets render time
  114415. */
  114416. readonly renderTargetsRenderTimeCounter: PerfCounter;
  114417. /**
  114418. * Gets the render targets render time capture status
  114419. */
  114420. /**
  114421. * Enable or disable the render targets render time capture
  114422. */
  114423. captureRenderTargetsRenderTime: boolean;
  114424. /**
  114425. * Gets the perf counter used for particles render time
  114426. */
  114427. readonly particlesRenderTimeCounter: PerfCounter;
  114428. /**
  114429. * Gets the particles render time capture status
  114430. */
  114431. /**
  114432. * Enable or disable the particles render time capture
  114433. */
  114434. captureParticlesRenderTime: boolean;
  114435. /**
  114436. * Gets the perf counter used for sprites render time
  114437. */
  114438. readonly spritesRenderTimeCounter: PerfCounter;
  114439. /**
  114440. * Gets the sprites render time capture status
  114441. */
  114442. /**
  114443. * Enable or disable the sprites render time capture
  114444. */
  114445. captureSpritesRenderTime: boolean;
  114446. /**
  114447. * Gets the perf counter used for physics time
  114448. */
  114449. readonly physicsTimeCounter: PerfCounter;
  114450. /**
  114451. * Gets the physics time capture status
  114452. */
  114453. /**
  114454. * Enable or disable the physics time capture
  114455. */
  114456. capturePhysicsTime: boolean;
  114457. /**
  114458. * Gets the perf counter used for animations time
  114459. */
  114460. readonly animationsTimeCounter: PerfCounter;
  114461. /**
  114462. * Gets the animations time capture status
  114463. */
  114464. /**
  114465. * Enable or disable the animations time capture
  114466. */
  114467. captureAnimationsTime: boolean;
  114468. /**
  114469. * Gets the perf counter used for frame time capture
  114470. */
  114471. readonly frameTimeCounter: PerfCounter;
  114472. /**
  114473. * Gets the frame time capture status
  114474. */
  114475. /**
  114476. * Enable or disable the frame time capture
  114477. */
  114478. captureFrameTime: boolean;
  114479. /**
  114480. * Gets the perf counter used for inter-frames time capture
  114481. */
  114482. readonly interFrameTimeCounter: PerfCounter;
  114483. /**
  114484. * Gets the inter-frames time capture status
  114485. */
  114486. /**
  114487. * Enable or disable the inter-frames time capture
  114488. */
  114489. captureInterFrameTime: boolean;
  114490. /**
  114491. * Gets the perf counter used for render time capture
  114492. */
  114493. readonly renderTimeCounter: PerfCounter;
  114494. /**
  114495. * Gets the render time capture status
  114496. */
  114497. /**
  114498. * Enable or disable the render time capture
  114499. */
  114500. captureRenderTime: boolean;
  114501. /**
  114502. * Gets the perf counter used for camera render time capture
  114503. */
  114504. readonly cameraRenderTimeCounter: PerfCounter;
  114505. /**
  114506. * Gets the camera render time capture status
  114507. */
  114508. /**
  114509. * Enable or disable the camera render time capture
  114510. */
  114511. captureCameraRenderTime: boolean;
  114512. /**
  114513. * Gets the perf counter used for draw calls
  114514. */
  114515. readonly drawCallsCounter: PerfCounter;
  114516. /**
  114517. * Instantiates a new scene instrumentation.
  114518. * This class can be used to get instrumentation data from a Babylon engine
  114519. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  114520. * @param scene Defines the scene to instrument
  114521. */
  114522. constructor(
  114523. /**
  114524. * Defines the scene to instrument
  114525. */
  114526. scene: Scene);
  114527. /**
  114528. * Dispose and release associated resources.
  114529. */
  114530. dispose(): void;
  114531. }
  114532. }
  114533. declare module BABYLON {
  114534. /** @hidden */
  114535. export var glowMapGenerationPixelShader: {
  114536. name: string;
  114537. shader: string;
  114538. };
  114539. }
  114540. declare module BABYLON {
  114541. /** @hidden */
  114542. export var glowMapGenerationVertexShader: {
  114543. name: string;
  114544. shader: string;
  114545. };
  114546. }
  114547. declare module BABYLON {
  114548. /**
  114549. * Effect layer options. This helps customizing the behaviour
  114550. * of the effect layer.
  114551. */
  114552. export interface IEffectLayerOptions {
  114553. /**
  114554. * Multiplication factor apply to the canvas size to compute the render target size
  114555. * used to generated the objects (the smaller the faster).
  114556. */
  114557. mainTextureRatio: number;
  114558. /**
  114559. * Enforces a fixed size texture to ensure effect stability across devices.
  114560. */
  114561. mainTextureFixedSize?: number;
  114562. /**
  114563. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  114564. */
  114565. alphaBlendingMode: number;
  114566. /**
  114567. * The camera attached to the layer.
  114568. */
  114569. camera: Nullable<Camera>;
  114570. /**
  114571. * The rendering group to draw the layer in.
  114572. */
  114573. renderingGroupId: number;
  114574. }
  114575. /**
  114576. * The effect layer Helps adding post process effect blended with the main pass.
  114577. *
  114578. * This can be for instance use to generate glow or higlight effects on the scene.
  114579. *
  114580. * The effect layer class can not be used directly and is intented to inherited from to be
  114581. * customized per effects.
  114582. */
  114583. export abstract class EffectLayer {
  114584. private _vertexBuffers;
  114585. private _indexBuffer;
  114586. private _cachedDefines;
  114587. private _effectLayerMapGenerationEffect;
  114588. private _effectLayerOptions;
  114589. private _mergeEffect;
  114590. protected _scene: Scene;
  114591. protected _engine: Engine;
  114592. protected _maxSize: number;
  114593. protected _mainTextureDesiredSize: ISize;
  114594. protected _mainTexture: RenderTargetTexture;
  114595. protected _shouldRender: boolean;
  114596. protected _postProcesses: PostProcess[];
  114597. protected _textures: BaseTexture[];
  114598. protected _emissiveTextureAndColor: {
  114599. texture: Nullable<BaseTexture>;
  114600. color: Color4;
  114601. };
  114602. /**
  114603. * The name of the layer
  114604. */
  114605. name: string;
  114606. /**
  114607. * The clear color of the texture used to generate the glow map.
  114608. */
  114609. neutralColor: Color4;
  114610. /**
  114611. * Specifies wether the highlight layer is enabled or not.
  114612. */
  114613. isEnabled: boolean;
  114614. /**
  114615. * Gets the camera attached to the layer.
  114616. */
  114617. readonly camera: Nullable<Camera>;
  114618. /**
  114619. * Gets the rendering group id the layer should render in.
  114620. */
  114621. renderingGroupId: number;
  114622. /**
  114623. * An event triggered when the effect layer has been disposed.
  114624. */
  114625. onDisposeObservable: Observable<EffectLayer>;
  114626. /**
  114627. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  114628. */
  114629. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  114630. /**
  114631. * An event triggered when the generated texture is being merged in the scene.
  114632. */
  114633. onBeforeComposeObservable: Observable<EffectLayer>;
  114634. /**
  114635. * An event triggered when the generated texture has been merged in the scene.
  114636. */
  114637. onAfterComposeObservable: Observable<EffectLayer>;
  114638. /**
  114639. * An event triggered when the efffect layer changes its size.
  114640. */
  114641. onSizeChangedObservable: Observable<EffectLayer>;
  114642. /** @hidden */
  114643. static _SceneComponentInitialization: (scene: Scene) => void;
  114644. /**
  114645. * Instantiates a new effect Layer and references it in the scene.
  114646. * @param name The name of the layer
  114647. * @param scene The scene to use the layer in
  114648. */
  114649. constructor(
  114650. /** The Friendly of the effect in the scene */
  114651. name: string, scene: Scene);
  114652. /**
  114653. * Get the effect name of the layer.
  114654. * @return The effect name
  114655. */
  114656. abstract getEffectName(): string;
  114657. /**
  114658. * Checks for the readiness of the element composing the layer.
  114659. * @param subMesh the mesh to check for
  114660. * @param useInstances specify wether or not to use instances to render the mesh
  114661. * @return true if ready otherwise, false
  114662. */
  114663. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  114664. /**
  114665. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  114666. * @returns true if the effect requires stencil during the main canvas render pass.
  114667. */
  114668. abstract needStencil(): boolean;
  114669. /**
  114670. * Create the merge effect. This is the shader use to blit the information back
  114671. * to the main canvas at the end of the scene rendering.
  114672. * @returns The effect containing the shader used to merge the effect on the main canvas
  114673. */
  114674. protected abstract _createMergeEffect(): Effect;
  114675. /**
  114676. * Creates the render target textures and post processes used in the effect layer.
  114677. */
  114678. protected abstract _createTextureAndPostProcesses(): void;
  114679. /**
  114680. * Implementation specific of rendering the generating effect on the main canvas.
  114681. * @param effect The effect used to render through
  114682. */
  114683. protected abstract _internalRender(effect: Effect): void;
  114684. /**
  114685. * Sets the required values for both the emissive texture and and the main color.
  114686. */
  114687. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  114688. /**
  114689. * Free any resources and references associated to a mesh.
  114690. * Internal use
  114691. * @param mesh The mesh to free.
  114692. */
  114693. abstract _disposeMesh(mesh: Mesh): void;
  114694. /**
  114695. * Serializes this layer (Glow or Highlight for example)
  114696. * @returns a serialized layer object
  114697. */
  114698. abstract serialize?(): any;
  114699. /**
  114700. * Initializes the effect layer with the required options.
  114701. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  114702. */
  114703. protected _init(options: Partial<IEffectLayerOptions>): void;
  114704. /**
  114705. * Generates the index buffer of the full screen quad blending to the main canvas.
  114706. */
  114707. private _generateIndexBuffer;
  114708. /**
  114709. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  114710. */
  114711. private _generateVertexBuffer;
  114712. /**
  114713. * Sets the main texture desired size which is the closest power of two
  114714. * of the engine canvas size.
  114715. */
  114716. private _setMainTextureSize;
  114717. /**
  114718. * Creates the main texture for the effect layer.
  114719. */
  114720. protected _createMainTexture(): void;
  114721. /**
  114722. * Adds specific effects defines.
  114723. * @param defines The defines to add specifics to.
  114724. */
  114725. protected _addCustomEffectDefines(defines: string[]): void;
  114726. /**
  114727. * Checks for the readiness of the element composing the layer.
  114728. * @param subMesh the mesh to check for
  114729. * @param useInstances specify wether or not to use instances to render the mesh
  114730. * @param emissiveTexture the associated emissive texture used to generate the glow
  114731. * @return true if ready otherwise, false
  114732. */
  114733. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  114734. /**
  114735. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  114736. */
  114737. render(): void;
  114738. /**
  114739. * Determine if a given mesh will be used in the current effect.
  114740. * @param mesh mesh to test
  114741. * @returns true if the mesh will be used
  114742. */
  114743. hasMesh(mesh: AbstractMesh): boolean;
  114744. /**
  114745. * Returns true if the layer contains information to display, otherwise false.
  114746. * @returns true if the glow layer should be rendered
  114747. */
  114748. shouldRender(): boolean;
  114749. /**
  114750. * Returns true if the mesh should render, otherwise false.
  114751. * @param mesh The mesh to render
  114752. * @returns true if it should render otherwise false
  114753. */
  114754. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  114755. /**
  114756. * Returns true if the mesh can be rendered, otherwise false.
  114757. * @param mesh The mesh to render
  114758. * @param material The material used on the mesh
  114759. * @returns true if it can be rendered otherwise false
  114760. */
  114761. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  114762. /**
  114763. * Returns true if the mesh should render, otherwise false.
  114764. * @param mesh The mesh to render
  114765. * @returns true if it should render otherwise false
  114766. */
  114767. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  114768. /**
  114769. * Renders the submesh passed in parameter to the generation map.
  114770. */
  114771. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  114772. /**
  114773. * Rebuild the required buffers.
  114774. * @hidden Internal use only.
  114775. */
  114776. _rebuild(): void;
  114777. /**
  114778. * Dispose only the render target textures and post process.
  114779. */
  114780. private _disposeTextureAndPostProcesses;
  114781. /**
  114782. * Dispose the highlight layer and free resources.
  114783. */
  114784. dispose(): void;
  114785. /**
  114786. * Gets the class name of the effect layer
  114787. * @returns the string with the class name of the effect layer
  114788. */
  114789. getClassName(): string;
  114790. /**
  114791. * Creates an effect layer from parsed effect layer data
  114792. * @param parsedEffectLayer defines effect layer data
  114793. * @param scene defines the current scene
  114794. * @param rootUrl defines the root URL containing the effect layer information
  114795. * @returns a parsed effect Layer
  114796. */
  114797. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  114798. }
  114799. }
  114800. declare module BABYLON {
  114801. interface AbstractScene {
  114802. /**
  114803. * The list of effect layers (highlights/glow) added to the scene
  114804. * @see http://doc.babylonjs.com/how_to/highlight_layer
  114805. * @see http://doc.babylonjs.com/how_to/glow_layer
  114806. */
  114807. effectLayers: Array<EffectLayer>;
  114808. /**
  114809. * Removes the given effect layer from this scene.
  114810. * @param toRemove defines the effect layer to remove
  114811. * @returns the index of the removed effect layer
  114812. */
  114813. removeEffectLayer(toRemove: EffectLayer): number;
  114814. /**
  114815. * Adds the given effect layer to this scene
  114816. * @param newEffectLayer defines the effect layer to add
  114817. */
  114818. addEffectLayer(newEffectLayer: EffectLayer): void;
  114819. }
  114820. /**
  114821. * Defines the layer scene component responsible to manage any effect layers
  114822. * in a given scene.
  114823. */
  114824. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  114825. /**
  114826. * The component name helpfull to identify the component in the list of scene components.
  114827. */
  114828. readonly name: string;
  114829. /**
  114830. * The scene the component belongs to.
  114831. */
  114832. scene: Scene;
  114833. private _engine;
  114834. private _renderEffects;
  114835. private _needStencil;
  114836. private _previousStencilState;
  114837. /**
  114838. * Creates a new instance of the component for the given scene
  114839. * @param scene Defines the scene to register the component in
  114840. */
  114841. constructor(scene: Scene);
  114842. /**
  114843. * Registers the component in a given scene
  114844. */
  114845. register(): void;
  114846. /**
  114847. * Rebuilds the elements related to this component in case of
  114848. * context lost for instance.
  114849. */
  114850. rebuild(): void;
  114851. /**
  114852. * Serializes the component data to the specified json object
  114853. * @param serializationObject The object to serialize to
  114854. */
  114855. serialize(serializationObject: any): void;
  114856. /**
  114857. * Adds all the elements from the container to the scene
  114858. * @param container the container holding the elements
  114859. */
  114860. addFromContainer(container: AbstractScene): void;
  114861. /**
  114862. * Removes all the elements in the container from the scene
  114863. * @param container contains the elements to remove
  114864. * @param dispose if the removed element should be disposed (default: false)
  114865. */
  114866. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  114867. /**
  114868. * Disposes the component and the associated ressources.
  114869. */
  114870. dispose(): void;
  114871. private _isReadyForMesh;
  114872. private _renderMainTexture;
  114873. private _setStencil;
  114874. private _setStencilBack;
  114875. private _draw;
  114876. private _drawCamera;
  114877. private _drawRenderingGroup;
  114878. }
  114879. }
  114880. declare module BABYLON {
  114881. /** @hidden */
  114882. export var glowMapMergePixelShader: {
  114883. name: string;
  114884. shader: string;
  114885. };
  114886. }
  114887. declare module BABYLON {
  114888. /** @hidden */
  114889. export var glowMapMergeVertexShader: {
  114890. name: string;
  114891. shader: string;
  114892. };
  114893. }
  114894. declare module BABYLON {
  114895. interface AbstractScene {
  114896. /**
  114897. * Return a the first highlight layer of the scene with a given name.
  114898. * @param name The name of the highlight layer to look for.
  114899. * @return The highlight layer if found otherwise null.
  114900. */
  114901. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  114902. }
  114903. /**
  114904. * Glow layer options. This helps customizing the behaviour
  114905. * of the glow layer.
  114906. */
  114907. export interface IGlowLayerOptions {
  114908. /**
  114909. * Multiplication factor apply to the canvas size to compute the render target size
  114910. * used to generated the glowing objects (the smaller the faster).
  114911. */
  114912. mainTextureRatio: number;
  114913. /**
  114914. * Enforces a fixed size texture to ensure resize independant blur.
  114915. */
  114916. mainTextureFixedSize?: number;
  114917. /**
  114918. * How big is the kernel of the blur texture.
  114919. */
  114920. blurKernelSize: number;
  114921. /**
  114922. * The camera attached to the layer.
  114923. */
  114924. camera: Nullable<Camera>;
  114925. /**
  114926. * Enable MSAA by chosing the number of samples.
  114927. */
  114928. mainTextureSamples?: number;
  114929. /**
  114930. * The rendering group to draw the layer in.
  114931. */
  114932. renderingGroupId: number;
  114933. }
  114934. /**
  114935. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  114936. *
  114937. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  114938. * glowy meshes to your scene.
  114939. *
  114940. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  114941. */
  114942. export class GlowLayer extends EffectLayer {
  114943. /**
  114944. * Effect Name of the layer.
  114945. */
  114946. static readonly EffectName: string;
  114947. /**
  114948. * The default blur kernel size used for the glow.
  114949. */
  114950. static DefaultBlurKernelSize: number;
  114951. /**
  114952. * The default texture size ratio used for the glow.
  114953. */
  114954. static DefaultTextureRatio: number;
  114955. /**
  114956. * Sets the kernel size of the blur.
  114957. */
  114958. /**
  114959. * Gets the kernel size of the blur.
  114960. */
  114961. blurKernelSize: number;
  114962. /**
  114963. * Sets the glow intensity.
  114964. */
  114965. /**
  114966. * Gets the glow intensity.
  114967. */
  114968. intensity: number;
  114969. private _options;
  114970. private _intensity;
  114971. private _horizontalBlurPostprocess1;
  114972. private _verticalBlurPostprocess1;
  114973. private _horizontalBlurPostprocess2;
  114974. private _verticalBlurPostprocess2;
  114975. private _blurTexture1;
  114976. private _blurTexture2;
  114977. private _postProcesses1;
  114978. private _postProcesses2;
  114979. private _includedOnlyMeshes;
  114980. private _excludedMeshes;
  114981. /**
  114982. * Callback used to let the user override the color selection on a per mesh basis
  114983. */
  114984. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  114985. /**
  114986. * Callback used to let the user override the texture selection on a per mesh basis
  114987. */
  114988. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  114989. /**
  114990. * Instantiates a new glow Layer and references it to the scene.
  114991. * @param name The name of the layer
  114992. * @param scene The scene to use the layer in
  114993. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  114994. */
  114995. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  114996. /**
  114997. * Get the effect name of the layer.
  114998. * @return The effect name
  114999. */
  115000. getEffectName(): string;
  115001. /**
  115002. * Create the merge effect. This is the shader use to blit the information back
  115003. * to the main canvas at the end of the scene rendering.
  115004. */
  115005. protected _createMergeEffect(): Effect;
  115006. /**
  115007. * Creates the render target textures and post processes used in the glow layer.
  115008. */
  115009. protected _createTextureAndPostProcesses(): void;
  115010. /**
  115011. * Checks for the readiness of the element composing the layer.
  115012. * @param subMesh the mesh to check for
  115013. * @param useInstances specify wether or not to use instances to render the mesh
  115014. * @param emissiveTexture the associated emissive texture used to generate the glow
  115015. * @return true if ready otherwise, false
  115016. */
  115017. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  115018. /**
  115019. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  115020. */
  115021. needStencil(): boolean;
  115022. /**
  115023. * Returns true if the mesh can be rendered, otherwise false.
  115024. * @param mesh The mesh to render
  115025. * @param material The material used on the mesh
  115026. * @returns true if it can be rendered otherwise false
  115027. */
  115028. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  115029. /**
  115030. * Implementation specific of rendering the generating effect on the main canvas.
  115031. * @param effect The effect used to render through
  115032. */
  115033. protected _internalRender(effect: Effect): void;
  115034. /**
  115035. * Sets the required values for both the emissive texture and and the main color.
  115036. */
  115037. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  115038. /**
  115039. * Returns true if the mesh should render, otherwise false.
  115040. * @param mesh The mesh to render
  115041. * @returns true if it should render otherwise false
  115042. */
  115043. protected _shouldRenderMesh(mesh: Mesh): boolean;
  115044. /**
  115045. * Adds specific effects defines.
  115046. * @param defines The defines to add specifics to.
  115047. */
  115048. protected _addCustomEffectDefines(defines: string[]): void;
  115049. /**
  115050. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  115051. * @param mesh The mesh to exclude from the glow layer
  115052. */
  115053. addExcludedMesh(mesh: Mesh): void;
  115054. /**
  115055. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  115056. * @param mesh The mesh to remove
  115057. */
  115058. removeExcludedMesh(mesh: Mesh): void;
  115059. /**
  115060. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  115061. * @param mesh The mesh to include in the glow layer
  115062. */
  115063. addIncludedOnlyMesh(mesh: Mesh): void;
  115064. /**
  115065. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  115066. * @param mesh The mesh to remove
  115067. */
  115068. removeIncludedOnlyMesh(mesh: Mesh): void;
  115069. /**
  115070. * Determine if a given mesh will be used in the glow layer
  115071. * @param mesh The mesh to test
  115072. * @returns true if the mesh will be highlighted by the current glow layer
  115073. */
  115074. hasMesh(mesh: AbstractMesh): boolean;
  115075. /**
  115076. * Free any resources and references associated to a mesh.
  115077. * Internal use
  115078. * @param mesh The mesh to free.
  115079. * @hidden
  115080. */
  115081. _disposeMesh(mesh: Mesh): void;
  115082. /**
  115083. * Gets the class name of the effect layer
  115084. * @returns the string with the class name of the effect layer
  115085. */
  115086. getClassName(): string;
  115087. /**
  115088. * Serializes this glow layer
  115089. * @returns a serialized glow layer object
  115090. */
  115091. serialize(): any;
  115092. /**
  115093. * Creates a Glow Layer from parsed glow layer data
  115094. * @param parsedGlowLayer defines glow layer data
  115095. * @param scene defines the current scene
  115096. * @param rootUrl defines the root URL containing the glow layer information
  115097. * @returns a parsed Glow Layer
  115098. */
  115099. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  115100. }
  115101. }
  115102. declare module BABYLON {
  115103. /** @hidden */
  115104. export var glowBlurPostProcessPixelShader: {
  115105. name: string;
  115106. shader: string;
  115107. };
  115108. }
  115109. declare module BABYLON {
  115110. interface AbstractScene {
  115111. /**
  115112. * Return a the first highlight layer of the scene with a given name.
  115113. * @param name The name of the highlight layer to look for.
  115114. * @return The highlight layer if found otherwise null.
  115115. */
  115116. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  115117. }
  115118. /**
  115119. * Highlight layer options. This helps customizing the behaviour
  115120. * of the highlight layer.
  115121. */
  115122. export interface IHighlightLayerOptions {
  115123. /**
  115124. * Multiplication factor apply to the canvas size to compute the render target size
  115125. * used to generated the glowing objects (the smaller the faster).
  115126. */
  115127. mainTextureRatio: number;
  115128. /**
  115129. * Enforces a fixed size texture to ensure resize independant blur.
  115130. */
  115131. mainTextureFixedSize?: number;
  115132. /**
  115133. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  115134. * of the picture to blur (the smaller the faster).
  115135. */
  115136. blurTextureSizeRatio: number;
  115137. /**
  115138. * How big in texel of the blur texture is the vertical blur.
  115139. */
  115140. blurVerticalSize: number;
  115141. /**
  115142. * How big in texel of the blur texture is the horizontal blur.
  115143. */
  115144. blurHorizontalSize: number;
  115145. /**
  115146. * Alpha blending mode used to apply the blur. Default is combine.
  115147. */
  115148. alphaBlendingMode: number;
  115149. /**
  115150. * The camera attached to the layer.
  115151. */
  115152. camera: Nullable<Camera>;
  115153. /**
  115154. * Should we display highlight as a solid stroke?
  115155. */
  115156. isStroke?: boolean;
  115157. /**
  115158. * The rendering group to draw the layer in.
  115159. */
  115160. renderingGroupId: number;
  115161. }
  115162. /**
  115163. * The highlight layer Helps adding a glow effect around a mesh.
  115164. *
  115165. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  115166. * glowy meshes to your scene.
  115167. *
  115168. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  115169. */
  115170. export class HighlightLayer extends EffectLayer {
  115171. name: string;
  115172. /**
  115173. * Effect Name of the highlight layer.
  115174. */
  115175. static readonly EffectName: string;
  115176. /**
  115177. * The neutral color used during the preparation of the glow effect.
  115178. * This is black by default as the blend operation is a blend operation.
  115179. */
  115180. static NeutralColor: Color4;
  115181. /**
  115182. * Stencil value used for glowing meshes.
  115183. */
  115184. static GlowingMeshStencilReference: number;
  115185. /**
  115186. * Stencil value used for the other meshes in the scene.
  115187. */
  115188. static NormalMeshStencilReference: number;
  115189. /**
  115190. * Specifies whether or not the inner glow is ACTIVE in the layer.
  115191. */
  115192. innerGlow: boolean;
  115193. /**
  115194. * Specifies whether or not the outer glow is ACTIVE in the layer.
  115195. */
  115196. outerGlow: boolean;
  115197. /**
  115198. * Specifies the horizontal size of the blur.
  115199. */
  115200. /**
  115201. * Gets the horizontal size of the blur.
  115202. */
  115203. blurHorizontalSize: number;
  115204. /**
  115205. * Specifies the vertical size of the blur.
  115206. */
  115207. /**
  115208. * Gets the vertical size of the blur.
  115209. */
  115210. blurVerticalSize: number;
  115211. /**
  115212. * An event triggered when the highlight layer is being blurred.
  115213. */
  115214. onBeforeBlurObservable: Observable<HighlightLayer>;
  115215. /**
  115216. * An event triggered when the highlight layer has been blurred.
  115217. */
  115218. onAfterBlurObservable: Observable<HighlightLayer>;
  115219. private _instanceGlowingMeshStencilReference;
  115220. private _options;
  115221. private _downSamplePostprocess;
  115222. private _horizontalBlurPostprocess;
  115223. private _verticalBlurPostprocess;
  115224. private _blurTexture;
  115225. private _meshes;
  115226. private _excludedMeshes;
  115227. /**
  115228. * Instantiates a new highlight Layer and references it to the scene..
  115229. * @param name The name of the layer
  115230. * @param scene The scene to use the layer in
  115231. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  115232. */
  115233. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  115234. /**
  115235. * Get the effect name of the layer.
  115236. * @return The effect name
  115237. */
  115238. getEffectName(): string;
  115239. /**
  115240. * Create the merge effect. This is the shader use to blit the information back
  115241. * to the main canvas at the end of the scene rendering.
  115242. */
  115243. protected _createMergeEffect(): Effect;
  115244. /**
  115245. * Creates the render target textures and post processes used in the highlight layer.
  115246. */
  115247. protected _createTextureAndPostProcesses(): void;
  115248. /**
  115249. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  115250. */
  115251. needStencil(): boolean;
  115252. /**
  115253. * Checks for the readiness of the element composing the layer.
  115254. * @param subMesh the mesh to check for
  115255. * @param useInstances specify wether or not to use instances to render the mesh
  115256. * @param emissiveTexture the associated emissive texture used to generate the glow
  115257. * @return true if ready otherwise, false
  115258. */
  115259. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  115260. /**
  115261. * Implementation specific of rendering the generating effect on the main canvas.
  115262. * @param effect The effect used to render through
  115263. */
  115264. protected _internalRender(effect: Effect): void;
  115265. /**
  115266. * Returns true if the layer contains information to display, otherwise false.
  115267. */
  115268. shouldRender(): boolean;
  115269. /**
  115270. * Returns true if the mesh should render, otherwise false.
  115271. * @param mesh The mesh to render
  115272. * @returns true if it should render otherwise false
  115273. */
  115274. protected _shouldRenderMesh(mesh: Mesh): boolean;
  115275. /**
  115276. * Sets the required values for both the emissive texture and and the main color.
  115277. */
  115278. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  115279. /**
  115280. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  115281. * @param mesh The mesh to exclude from the highlight layer
  115282. */
  115283. addExcludedMesh(mesh: Mesh): void;
  115284. /**
  115285. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  115286. * @param mesh The mesh to highlight
  115287. */
  115288. removeExcludedMesh(mesh: Mesh): void;
  115289. /**
  115290. * Determine if a given mesh will be highlighted by the current HighlightLayer
  115291. * @param mesh mesh to test
  115292. * @returns true if the mesh will be highlighted by the current HighlightLayer
  115293. */
  115294. hasMesh(mesh: AbstractMesh): boolean;
  115295. /**
  115296. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  115297. * @param mesh The mesh to highlight
  115298. * @param color The color of the highlight
  115299. * @param glowEmissiveOnly Extract the glow from the emissive texture
  115300. */
  115301. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  115302. /**
  115303. * Remove a mesh from the highlight layer in order to make it stop glowing.
  115304. * @param mesh The mesh to highlight
  115305. */
  115306. removeMesh(mesh: Mesh): void;
  115307. /**
  115308. * Force the stencil to the normal expected value for none glowing parts
  115309. */
  115310. private _defaultStencilReference;
  115311. /**
  115312. * Free any resources and references associated to a mesh.
  115313. * Internal use
  115314. * @param mesh The mesh to free.
  115315. * @hidden
  115316. */
  115317. _disposeMesh(mesh: Mesh): void;
  115318. /**
  115319. * Dispose the highlight layer and free resources.
  115320. */
  115321. dispose(): void;
  115322. /**
  115323. * Gets the class name of the effect layer
  115324. * @returns the string with the class name of the effect layer
  115325. */
  115326. getClassName(): string;
  115327. /**
  115328. * Serializes this Highlight layer
  115329. * @returns a serialized Highlight layer object
  115330. */
  115331. serialize(): any;
  115332. /**
  115333. * Creates a Highlight layer from parsed Highlight layer data
  115334. * @param parsedHightlightLayer defines the Highlight layer data
  115335. * @param scene defines the current scene
  115336. * @param rootUrl defines the root URL containing the Highlight layer information
  115337. * @returns a parsed Highlight layer
  115338. */
  115339. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  115340. }
  115341. }
  115342. declare module BABYLON {
  115343. interface AbstractScene {
  115344. /**
  115345. * The list of layers (background and foreground) of the scene
  115346. */
  115347. layers: Array<Layer>;
  115348. }
  115349. /**
  115350. * Defines the layer scene component responsible to manage any layers
  115351. * in a given scene.
  115352. */
  115353. export class LayerSceneComponent implements ISceneComponent {
  115354. /**
  115355. * The component name helpfull to identify the component in the list of scene components.
  115356. */
  115357. readonly name: string;
  115358. /**
  115359. * The scene the component belongs to.
  115360. */
  115361. scene: Scene;
  115362. private _engine;
  115363. /**
  115364. * Creates a new instance of the component for the given scene
  115365. * @param scene Defines the scene to register the component in
  115366. */
  115367. constructor(scene: Scene);
  115368. /**
  115369. * Registers the component in a given scene
  115370. */
  115371. register(): void;
  115372. /**
  115373. * Rebuilds the elements related to this component in case of
  115374. * context lost for instance.
  115375. */
  115376. rebuild(): void;
  115377. /**
  115378. * Disposes the component and the associated ressources.
  115379. */
  115380. dispose(): void;
  115381. private _draw;
  115382. private _drawCameraPredicate;
  115383. private _drawCameraBackground;
  115384. private _drawCameraForeground;
  115385. private _drawRenderTargetPredicate;
  115386. private _drawRenderTargetBackground;
  115387. private _drawRenderTargetForeground;
  115388. /**
  115389. * Adds all the elements from the container to the scene
  115390. * @param container the container holding the elements
  115391. */
  115392. addFromContainer(container: AbstractScene): void;
  115393. /**
  115394. * Removes all the elements in the container from the scene
  115395. * @param container contains the elements to remove
  115396. * @param dispose if the removed element should be disposed (default: false)
  115397. */
  115398. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  115399. }
  115400. }
  115401. declare module BABYLON {
  115402. /** @hidden */
  115403. export var layerPixelShader: {
  115404. name: string;
  115405. shader: string;
  115406. };
  115407. }
  115408. declare module BABYLON {
  115409. /** @hidden */
  115410. export var layerVertexShader: {
  115411. name: string;
  115412. shader: string;
  115413. };
  115414. }
  115415. declare module BABYLON {
  115416. /**
  115417. * This represents a full screen 2d layer.
  115418. * This can be useful to display a picture in the background of your scene for instance.
  115419. * @see https://www.babylonjs-playground.com/#08A2BS#1
  115420. */
  115421. export class Layer {
  115422. /**
  115423. * Define the name of the layer.
  115424. */
  115425. name: string;
  115426. /**
  115427. * Define the texture the layer should display.
  115428. */
  115429. texture: Nullable<Texture>;
  115430. /**
  115431. * Is the layer in background or foreground.
  115432. */
  115433. isBackground: boolean;
  115434. /**
  115435. * Define the color of the layer (instead of texture).
  115436. */
  115437. color: Color4;
  115438. /**
  115439. * Define the scale of the layer in order to zoom in out of the texture.
  115440. */
  115441. scale: Vector2;
  115442. /**
  115443. * Define an offset for the layer in order to shift the texture.
  115444. */
  115445. offset: Vector2;
  115446. /**
  115447. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  115448. */
  115449. alphaBlendingMode: number;
  115450. /**
  115451. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  115452. * Alpha test will not mix with the background color in case of transparency.
  115453. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  115454. */
  115455. alphaTest: boolean;
  115456. /**
  115457. * Define a mask to restrict the layer to only some of the scene cameras.
  115458. */
  115459. layerMask: number;
  115460. /**
  115461. * Define the list of render target the layer is visible into.
  115462. */
  115463. renderTargetTextures: RenderTargetTexture[];
  115464. /**
  115465. * Define if the layer is only used in renderTarget or if it also
  115466. * renders in the main frame buffer of the canvas.
  115467. */
  115468. renderOnlyInRenderTargetTextures: boolean;
  115469. private _scene;
  115470. private _vertexBuffers;
  115471. private _indexBuffer;
  115472. private _effect;
  115473. private _alphaTestEffect;
  115474. /**
  115475. * An event triggered when the layer is disposed.
  115476. */
  115477. onDisposeObservable: Observable<Layer>;
  115478. private _onDisposeObserver;
  115479. /**
  115480. * Back compatibility with callback before the onDisposeObservable existed.
  115481. * The set callback will be triggered when the layer has been disposed.
  115482. */
  115483. onDispose: () => void;
  115484. /**
  115485. * An event triggered before rendering the scene
  115486. */
  115487. onBeforeRenderObservable: Observable<Layer>;
  115488. private _onBeforeRenderObserver;
  115489. /**
  115490. * Back compatibility with callback before the onBeforeRenderObservable existed.
  115491. * The set callback will be triggered just before rendering the layer.
  115492. */
  115493. onBeforeRender: () => void;
  115494. /**
  115495. * An event triggered after rendering the scene
  115496. */
  115497. onAfterRenderObservable: Observable<Layer>;
  115498. private _onAfterRenderObserver;
  115499. /**
  115500. * Back compatibility with callback before the onAfterRenderObservable existed.
  115501. * The set callback will be triggered just after rendering the layer.
  115502. */
  115503. onAfterRender: () => void;
  115504. /**
  115505. * Instantiates a new layer.
  115506. * This represents a full screen 2d layer.
  115507. * This can be useful to display a picture in the background of your scene for instance.
  115508. * @see https://www.babylonjs-playground.com/#08A2BS#1
  115509. * @param name Define the name of the layer in the scene
  115510. * @param imgUrl Define the url of the texture to display in the layer
  115511. * @param scene Define the scene the layer belongs to
  115512. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  115513. * @param color Defines a color for the layer
  115514. */
  115515. constructor(
  115516. /**
  115517. * Define the name of the layer.
  115518. */
  115519. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  115520. private _createIndexBuffer;
  115521. /** @hidden */
  115522. _rebuild(): void;
  115523. /**
  115524. * Renders the layer in the scene.
  115525. */
  115526. render(): void;
  115527. /**
  115528. * Disposes and releases the associated ressources.
  115529. */
  115530. dispose(): void;
  115531. }
  115532. }
  115533. declare module BABYLON {
  115534. /** @hidden */
  115535. export var lensFlarePixelShader: {
  115536. name: string;
  115537. shader: string;
  115538. };
  115539. }
  115540. declare module BABYLON {
  115541. /** @hidden */
  115542. export var lensFlareVertexShader: {
  115543. name: string;
  115544. shader: string;
  115545. };
  115546. }
  115547. declare module BABYLON {
  115548. /**
  115549. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  115550. * It is usually composed of several `lensFlare`.
  115551. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115552. */
  115553. export class LensFlareSystem {
  115554. /**
  115555. * Define the name of the lens flare system
  115556. */
  115557. name: string;
  115558. /**
  115559. * List of lens flares used in this system.
  115560. */
  115561. lensFlares: LensFlare[];
  115562. /**
  115563. * Define a limit from the border the lens flare can be visible.
  115564. */
  115565. borderLimit: number;
  115566. /**
  115567. * Define a viewport border we do not want to see the lens flare in.
  115568. */
  115569. viewportBorder: number;
  115570. /**
  115571. * Define a predicate which could limit the list of meshes able to occlude the effect.
  115572. */
  115573. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  115574. /**
  115575. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  115576. */
  115577. layerMask: number;
  115578. /**
  115579. * Define the id of the lens flare system in the scene.
  115580. * (equal to name by default)
  115581. */
  115582. id: string;
  115583. private _scene;
  115584. private _emitter;
  115585. private _vertexBuffers;
  115586. private _indexBuffer;
  115587. private _effect;
  115588. private _positionX;
  115589. private _positionY;
  115590. private _isEnabled;
  115591. /** @hidden */
  115592. static _SceneComponentInitialization: (scene: Scene) => void;
  115593. /**
  115594. * Instantiates a lens flare system.
  115595. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  115596. * It is usually composed of several `lensFlare`.
  115597. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115598. * @param name Define the name of the lens flare system in the scene
  115599. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  115600. * @param scene Define the scene the lens flare system belongs to
  115601. */
  115602. constructor(
  115603. /**
  115604. * Define the name of the lens flare system
  115605. */
  115606. name: string, emitter: any, scene: Scene);
  115607. /**
  115608. * Define if the lens flare system is enabled.
  115609. */
  115610. isEnabled: boolean;
  115611. /**
  115612. * Get the scene the effects belongs to.
  115613. * @returns the scene holding the lens flare system
  115614. */
  115615. getScene(): Scene;
  115616. /**
  115617. * Get the emitter of the lens flare system.
  115618. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  115619. * @returns the emitter of the lens flare system
  115620. */
  115621. getEmitter(): any;
  115622. /**
  115623. * Set the emitter of the lens flare system.
  115624. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  115625. * @param newEmitter Define the new emitter of the system
  115626. */
  115627. setEmitter(newEmitter: any): void;
  115628. /**
  115629. * Get the lens flare system emitter position.
  115630. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  115631. * @returns the position
  115632. */
  115633. getEmitterPosition(): Vector3;
  115634. /**
  115635. * @hidden
  115636. */
  115637. computeEffectivePosition(globalViewport: Viewport): boolean;
  115638. /** @hidden */
  115639. _isVisible(): boolean;
  115640. /**
  115641. * @hidden
  115642. */
  115643. render(): boolean;
  115644. /**
  115645. * Dispose and release the lens flare with its associated resources.
  115646. */
  115647. dispose(): void;
  115648. /**
  115649. * Parse a lens flare system from a JSON repressentation
  115650. * @param parsedLensFlareSystem Define the JSON to parse
  115651. * @param scene Define the scene the parsed system should be instantiated in
  115652. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  115653. * @returns the parsed system
  115654. */
  115655. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  115656. /**
  115657. * Serialize the current Lens Flare System into a JSON representation.
  115658. * @returns the serialized JSON
  115659. */
  115660. serialize(): any;
  115661. }
  115662. }
  115663. declare module BABYLON {
  115664. /**
  115665. * This represents one of the lens effect in a `lensFlareSystem`.
  115666. * It controls one of the indiviual texture used in the effect.
  115667. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115668. */
  115669. export class LensFlare {
  115670. /**
  115671. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  115672. */
  115673. size: number;
  115674. /**
  115675. * 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.
  115676. */
  115677. position: number;
  115678. /**
  115679. * Define the lens color.
  115680. */
  115681. color: Color3;
  115682. /**
  115683. * Define the lens texture.
  115684. */
  115685. texture: Nullable<Texture>;
  115686. /**
  115687. * Define the alpha mode to render this particular lens.
  115688. */
  115689. alphaMode: number;
  115690. private _system;
  115691. /**
  115692. * Creates a new Lens Flare.
  115693. * This represents one of the lens effect in a `lensFlareSystem`.
  115694. * It controls one of the indiviual texture used in the effect.
  115695. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115696. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  115697. * @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.
  115698. * @param color Define the lens color
  115699. * @param imgUrl Define the lens texture url
  115700. * @param system Define the `lensFlareSystem` this flare is part of
  115701. * @returns The newly created Lens Flare
  115702. */
  115703. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  115704. /**
  115705. * Instantiates a new Lens Flare.
  115706. * This represents one of the lens effect in a `lensFlareSystem`.
  115707. * It controls one of the indiviual texture used in the effect.
  115708. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115709. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  115710. * @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.
  115711. * @param color Define the lens color
  115712. * @param imgUrl Define the lens texture url
  115713. * @param system Define the `lensFlareSystem` this flare is part of
  115714. */
  115715. constructor(
  115716. /**
  115717. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  115718. */
  115719. size: number,
  115720. /**
  115721. * 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.
  115722. */
  115723. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  115724. /**
  115725. * Dispose and release the lens flare with its associated resources.
  115726. */
  115727. dispose(): void;
  115728. }
  115729. }
  115730. declare module BABYLON {
  115731. interface AbstractScene {
  115732. /**
  115733. * The list of lens flare system added to the scene
  115734. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115735. */
  115736. lensFlareSystems: Array<LensFlareSystem>;
  115737. /**
  115738. * Removes the given lens flare system from this scene.
  115739. * @param toRemove The lens flare system to remove
  115740. * @returns The index of the removed lens flare system
  115741. */
  115742. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  115743. /**
  115744. * Adds the given lens flare system to this scene
  115745. * @param newLensFlareSystem The lens flare system to add
  115746. */
  115747. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  115748. /**
  115749. * Gets a lens flare system using its name
  115750. * @param name defines the name to look for
  115751. * @returns the lens flare system or null if not found
  115752. */
  115753. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  115754. /**
  115755. * Gets a lens flare system using its id
  115756. * @param id defines the id to look for
  115757. * @returns the lens flare system or null if not found
  115758. */
  115759. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  115760. }
  115761. /**
  115762. * Defines the lens flare scene component responsible to manage any lens flares
  115763. * in a given scene.
  115764. */
  115765. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  115766. /**
  115767. * The component name helpfull to identify the component in the list of scene components.
  115768. */
  115769. readonly name: string;
  115770. /**
  115771. * The scene the component belongs to.
  115772. */
  115773. scene: Scene;
  115774. /**
  115775. * Creates a new instance of the component for the given scene
  115776. * @param scene Defines the scene to register the component in
  115777. */
  115778. constructor(scene: Scene);
  115779. /**
  115780. * Registers the component in a given scene
  115781. */
  115782. register(): void;
  115783. /**
  115784. * Rebuilds the elements related to this component in case of
  115785. * context lost for instance.
  115786. */
  115787. rebuild(): void;
  115788. /**
  115789. * Adds all the elements from the container to the scene
  115790. * @param container the container holding the elements
  115791. */
  115792. addFromContainer(container: AbstractScene): void;
  115793. /**
  115794. * Removes all the elements in the container from the scene
  115795. * @param container contains the elements to remove
  115796. * @param dispose if the removed element should be disposed (default: false)
  115797. */
  115798. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  115799. /**
  115800. * Serializes the component data to the specified json object
  115801. * @param serializationObject The object to serialize to
  115802. */
  115803. serialize(serializationObject: any): void;
  115804. /**
  115805. * Disposes the component and the associated ressources.
  115806. */
  115807. dispose(): void;
  115808. private _draw;
  115809. }
  115810. }
  115811. declare module BABYLON {
  115812. /**
  115813. * Defines the shadow generator component responsible to manage any shadow generators
  115814. * in a given scene.
  115815. */
  115816. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  115817. /**
  115818. * The component name helpfull to identify the component in the list of scene components.
  115819. */
  115820. readonly name: string;
  115821. /**
  115822. * The scene the component belongs to.
  115823. */
  115824. scene: Scene;
  115825. /**
  115826. * Creates a new instance of the component for the given scene
  115827. * @param scene Defines the scene to register the component in
  115828. */
  115829. constructor(scene: Scene);
  115830. /**
  115831. * Registers the component in a given scene
  115832. */
  115833. register(): void;
  115834. /**
  115835. * Rebuilds the elements related to this component in case of
  115836. * context lost for instance.
  115837. */
  115838. rebuild(): void;
  115839. /**
  115840. * Serializes the component data to the specified json object
  115841. * @param serializationObject The object to serialize to
  115842. */
  115843. serialize(serializationObject: any): void;
  115844. /**
  115845. * Adds all the elements from the container to the scene
  115846. * @param container the container holding the elements
  115847. */
  115848. addFromContainer(container: AbstractScene): void;
  115849. /**
  115850. * Removes all the elements in the container from the scene
  115851. * @param container contains the elements to remove
  115852. * @param dispose if the removed element should be disposed (default: false)
  115853. */
  115854. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  115855. /**
  115856. * Rebuilds the elements related to this component in case of
  115857. * context lost for instance.
  115858. */
  115859. dispose(): void;
  115860. private _gatherRenderTargets;
  115861. }
  115862. }
  115863. declare module BABYLON {
  115864. /**
  115865. * A point light is a light defined by an unique point in world space.
  115866. * The light is emitted in every direction from this point.
  115867. * A good example of a point light is a standard light bulb.
  115868. * Documentation: https://doc.babylonjs.com/babylon101/lights
  115869. */
  115870. export class PointLight extends ShadowLight {
  115871. private _shadowAngle;
  115872. /**
  115873. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  115874. * This specifies what angle the shadow will use to be created.
  115875. *
  115876. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  115877. */
  115878. /**
  115879. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  115880. * This specifies what angle the shadow will use to be created.
  115881. *
  115882. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  115883. */
  115884. shadowAngle: number;
  115885. /**
  115886. * Gets the direction if it has been set.
  115887. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  115888. */
  115889. /**
  115890. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  115891. */
  115892. direction: Vector3;
  115893. /**
  115894. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  115895. * A PointLight emits the light in every direction.
  115896. * It can cast shadows.
  115897. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  115898. * ```javascript
  115899. * var pointLight = new PointLight("pl", camera.position, scene);
  115900. * ```
  115901. * Documentation : https://doc.babylonjs.com/babylon101/lights
  115902. * @param name The light friendly name
  115903. * @param position The position of the point light in the scene
  115904. * @param scene The scene the lights belongs to
  115905. */
  115906. constructor(name: string, position: Vector3, scene: Scene);
  115907. /**
  115908. * Returns the string "PointLight"
  115909. * @returns the class name
  115910. */
  115911. getClassName(): string;
  115912. /**
  115913. * Returns the integer 0.
  115914. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  115915. */
  115916. getTypeID(): number;
  115917. /**
  115918. * Specifies wether or not the shadowmap should be a cube texture.
  115919. * @returns true if the shadowmap needs to be a cube texture.
  115920. */
  115921. needCube(): boolean;
  115922. /**
  115923. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  115924. * @param faceIndex The index of the face we are computed the direction to generate shadow
  115925. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  115926. */
  115927. getShadowDirection(faceIndex?: number): Vector3;
  115928. /**
  115929. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  115930. * - fov = PI / 2
  115931. * - aspect ratio : 1.0
  115932. * - z-near and far equal to the active camera minZ and maxZ.
  115933. * Returns the PointLight.
  115934. */
  115935. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  115936. protected _buildUniformLayout(): void;
  115937. /**
  115938. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  115939. * @param effect The effect to update
  115940. * @param lightIndex The index of the light in the effect to update
  115941. * @returns The point light
  115942. */
  115943. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  115944. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  115945. /**
  115946. * Prepares the list of defines specific to the light type.
  115947. * @param defines the list of defines
  115948. * @param lightIndex defines the index of the light for the effect
  115949. */
  115950. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  115951. }
  115952. }
  115953. declare module BABYLON {
  115954. /**
  115955. * Header information of HDR texture files.
  115956. */
  115957. export interface HDRInfo {
  115958. /**
  115959. * The height of the texture in pixels.
  115960. */
  115961. height: number;
  115962. /**
  115963. * The width of the texture in pixels.
  115964. */
  115965. width: number;
  115966. /**
  115967. * The index of the beginning of the data in the binary file.
  115968. */
  115969. dataPosition: number;
  115970. }
  115971. /**
  115972. * This groups tools to convert HDR texture to native colors array.
  115973. */
  115974. export class HDRTools {
  115975. private static Ldexp;
  115976. private static Rgbe2float;
  115977. private static readStringLine;
  115978. /**
  115979. * Reads header information from an RGBE texture stored in a native array.
  115980. * More information on this format are available here:
  115981. * https://en.wikipedia.org/wiki/RGBE_image_format
  115982. *
  115983. * @param uint8array The binary file stored in native array.
  115984. * @return The header information.
  115985. */
  115986. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  115987. /**
  115988. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  115989. * This RGBE texture needs to store the information as a panorama.
  115990. *
  115991. * More information on this format are available here:
  115992. * https://en.wikipedia.org/wiki/RGBE_image_format
  115993. *
  115994. * @param buffer The binary file stored in an array buffer.
  115995. * @param size The expected size of the extracted cubemap.
  115996. * @return The Cube Map information.
  115997. */
  115998. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  115999. /**
  116000. * Returns the pixels data extracted from an RGBE texture.
  116001. * This pixels will be stored left to right up to down in the R G B order in one array.
  116002. *
  116003. * More information on this format are available here:
  116004. * https://en.wikipedia.org/wiki/RGBE_image_format
  116005. *
  116006. * @param uint8array The binary file stored in an array buffer.
  116007. * @param hdrInfo The header information of the file.
  116008. * @return The pixels data in RGB right to left up to down order.
  116009. */
  116010. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  116011. private static RGBE_ReadPixels_RLE;
  116012. }
  116013. }
  116014. declare module BABYLON {
  116015. /**
  116016. * This represents a texture coming from an HDR input.
  116017. *
  116018. * The only supported format is currently panorama picture stored in RGBE format.
  116019. * Example of such files can be found on HDRLib: http://hdrlib.com/
  116020. */
  116021. export class HDRCubeTexture extends BaseTexture {
  116022. private static _facesMapping;
  116023. private _generateHarmonics;
  116024. private _noMipmap;
  116025. private _textureMatrix;
  116026. private _size;
  116027. private _onLoad;
  116028. private _onError;
  116029. /**
  116030. * The texture URL.
  116031. */
  116032. url: string;
  116033. /**
  116034. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  116035. */
  116036. coordinatesMode: number;
  116037. protected _isBlocking: boolean;
  116038. /**
  116039. * Sets wether or not the texture is blocking during loading.
  116040. */
  116041. /**
  116042. * Gets wether or not the texture is blocking during loading.
  116043. */
  116044. isBlocking: boolean;
  116045. protected _rotationY: number;
  116046. /**
  116047. * Sets texture matrix rotation angle around Y axis in radians.
  116048. */
  116049. /**
  116050. * Gets texture matrix rotation angle around Y axis radians.
  116051. */
  116052. rotationY: number;
  116053. /**
  116054. * Gets or sets the center of the bounding box associated with the cube texture
  116055. * It must define where the camera used to render the texture was set
  116056. */
  116057. boundingBoxPosition: Vector3;
  116058. private _boundingBoxSize;
  116059. /**
  116060. * Gets or sets the size of the bounding box associated with the cube texture
  116061. * When defined, the cubemap will switch to local mode
  116062. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  116063. * @example https://www.babylonjs-playground.com/#RNASML
  116064. */
  116065. boundingBoxSize: Vector3;
  116066. /**
  116067. * Instantiates an HDRTexture from the following parameters.
  116068. *
  116069. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  116070. * @param scene The scene the texture will be used in
  116071. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  116072. * @param noMipmap Forces to not generate the mipmap if true
  116073. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  116074. * @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)
  116075. * @param reserved Reserved flag for internal use.
  116076. */
  116077. 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>);
  116078. /**
  116079. * Get the current class name of the texture useful for serialization or dynamic coding.
  116080. * @returns "HDRCubeTexture"
  116081. */
  116082. getClassName(): string;
  116083. /**
  116084. * Occurs when the file is raw .hdr file.
  116085. */
  116086. private loadTexture;
  116087. clone(): HDRCubeTexture;
  116088. delayLoad(): void;
  116089. /**
  116090. * Get the texture reflection matrix used to rotate/transform the reflection.
  116091. * @returns the reflection matrix
  116092. */
  116093. getReflectionTextureMatrix(): Matrix;
  116094. /**
  116095. * Set the texture reflection matrix used to rotate/transform the reflection.
  116096. * @param value Define the reflection matrix to set
  116097. */
  116098. setReflectionTextureMatrix(value: Matrix): void;
  116099. /**
  116100. * Parses a JSON representation of an HDR Texture in order to create the texture
  116101. * @param parsedTexture Define the JSON representation
  116102. * @param scene Define the scene the texture should be created in
  116103. * @param rootUrl Define the root url in case we need to load relative dependencies
  116104. * @returns the newly created texture after parsing
  116105. */
  116106. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  116107. serialize(): any;
  116108. }
  116109. }
  116110. declare module BABYLON {
  116111. /**
  116112. * Class used to control physics engine
  116113. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  116114. */
  116115. export class PhysicsEngine implements IPhysicsEngine {
  116116. private _physicsPlugin;
  116117. /**
  116118. * Global value used to control the smallest number supported by the simulation
  116119. */
  116120. static Epsilon: number;
  116121. private _impostors;
  116122. private _joints;
  116123. /**
  116124. * Gets the gravity vector used by the simulation
  116125. */
  116126. gravity: Vector3;
  116127. /**
  116128. * Factory used to create the default physics plugin.
  116129. * @returns The default physics plugin
  116130. */
  116131. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  116132. /**
  116133. * Creates a new Physics Engine
  116134. * @param gravity defines the gravity vector used by the simulation
  116135. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  116136. */
  116137. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  116138. /**
  116139. * Sets the gravity vector used by the simulation
  116140. * @param gravity defines the gravity vector to use
  116141. */
  116142. setGravity(gravity: Vector3): void;
  116143. /**
  116144. * Set the time step of the physics engine.
  116145. * Default is 1/60.
  116146. * To slow it down, enter 1/600 for example.
  116147. * To speed it up, 1/30
  116148. * @param newTimeStep defines the new timestep to apply to this world.
  116149. */
  116150. setTimeStep(newTimeStep?: number): void;
  116151. /**
  116152. * Get the time step of the physics engine.
  116153. * @returns the current time step
  116154. */
  116155. getTimeStep(): number;
  116156. /**
  116157. * Release all resources
  116158. */
  116159. dispose(): void;
  116160. /**
  116161. * Gets the name of the current physics plugin
  116162. * @returns the name of the plugin
  116163. */
  116164. getPhysicsPluginName(): string;
  116165. /**
  116166. * Adding a new impostor for the impostor tracking.
  116167. * This will be done by the impostor itself.
  116168. * @param impostor the impostor to add
  116169. */
  116170. addImpostor(impostor: PhysicsImpostor): void;
  116171. /**
  116172. * Remove an impostor from the engine.
  116173. * This impostor and its mesh will not longer be updated by the physics engine.
  116174. * @param impostor the impostor to remove
  116175. */
  116176. removeImpostor(impostor: PhysicsImpostor): void;
  116177. /**
  116178. * Add a joint to the physics engine
  116179. * @param mainImpostor defines the main impostor to which the joint is added.
  116180. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  116181. * @param joint defines the joint that will connect both impostors.
  116182. */
  116183. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  116184. /**
  116185. * Removes a joint from the simulation
  116186. * @param mainImpostor defines the impostor used with the joint
  116187. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  116188. * @param joint defines the joint to remove
  116189. */
  116190. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  116191. /**
  116192. * Called by the scene. No need to call it.
  116193. * @param delta defines the timespam between frames
  116194. */
  116195. _step(delta: number): void;
  116196. /**
  116197. * Gets the current plugin used to run the simulation
  116198. * @returns current plugin
  116199. */
  116200. getPhysicsPlugin(): IPhysicsEnginePlugin;
  116201. /**
  116202. * Gets the list of physic impostors
  116203. * @returns an array of PhysicsImpostor
  116204. */
  116205. getImpostors(): Array<PhysicsImpostor>;
  116206. /**
  116207. * Gets the impostor for a physics enabled object
  116208. * @param object defines the object impersonated by the impostor
  116209. * @returns the PhysicsImpostor or null if not found
  116210. */
  116211. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  116212. /**
  116213. * Gets the impostor for a physics body object
  116214. * @param body defines physics body used by the impostor
  116215. * @returns the PhysicsImpostor or null if not found
  116216. */
  116217. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  116218. /**
  116219. * Does a raycast in the physics world
  116220. * @param from when should the ray start?
  116221. * @param to when should the ray end?
  116222. * @returns PhysicsRaycastResult
  116223. */
  116224. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  116225. }
  116226. }
  116227. declare module BABYLON {
  116228. /** @hidden */
  116229. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  116230. private _useDeltaForWorldStep;
  116231. world: any;
  116232. name: string;
  116233. private _physicsMaterials;
  116234. private _fixedTimeStep;
  116235. private _cannonRaycastResult;
  116236. private _raycastResult;
  116237. private _physicsBodysToRemoveAfterStep;
  116238. BJSCANNON: any;
  116239. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  116240. setGravity(gravity: Vector3): void;
  116241. setTimeStep(timeStep: number): void;
  116242. getTimeStep(): number;
  116243. executeStep(delta: number): void;
  116244. private _removeMarkedPhysicsBodiesFromWorld;
  116245. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116246. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116247. generatePhysicsBody(impostor: PhysicsImpostor): void;
  116248. private _processChildMeshes;
  116249. removePhysicsBody(impostor: PhysicsImpostor): void;
  116250. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  116251. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  116252. private _addMaterial;
  116253. private _checkWithEpsilon;
  116254. private _createShape;
  116255. private _createHeightmap;
  116256. private _minus90X;
  116257. private _plus90X;
  116258. private _tmpPosition;
  116259. private _tmpDeltaPosition;
  116260. private _tmpUnityRotation;
  116261. private _updatePhysicsBodyTransformation;
  116262. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  116263. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  116264. isSupported(): boolean;
  116265. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116266. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116267. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116268. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116269. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  116270. getBodyMass(impostor: PhysicsImpostor): number;
  116271. getBodyFriction(impostor: PhysicsImpostor): number;
  116272. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  116273. getBodyRestitution(impostor: PhysicsImpostor): number;
  116274. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  116275. sleepBody(impostor: PhysicsImpostor): void;
  116276. wakeUpBody(impostor: PhysicsImpostor): void;
  116277. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  116278. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  116279. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  116280. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  116281. getRadius(impostor: PhysicsImpostor): number;
  116282. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  116283. dispose(): void;
  116284. private _extendNamespace;
  116285. /**
  116286. * Does a raycast in the physics world
  116287. * @param from when should the ray start?
  116288. * @param to when should the ray end?
  116289. * @returns PhysicsRaycastResult
  116290. */
  116291. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  116292. }
  116293. }
  116294. declare module BABYLON {
  116295. /** @hidden */
  116296. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  116297. world: any;
  116298. name: string;
  116299. BJSOIMO: any;
  116300. private _raycastResult;
  116301. constructor(iterations?: number, oimoInjection?: any);
  116302. setGravity(gravity: Vector3): void;
  116303. setTimeStep(timeStep: number): void;
  116304. getTimeStep(): number;
  116305. private _tmpImpostorsArray;
  116306. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  116307. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116308. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116309. generatePhysicsBody(impostor: PhysicsImpostor): void;
  116310. private _tmpPositionVector;
  116311. removePhysicsBody(impostor: PhysicsImpostor): void;
  116312. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  116313. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  116314. isSupported(): boolean;
  116315. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  116316. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  116317. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116318. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116319. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116320. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116321. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  116322. getBodyMass(impostor: PhysicsImpostor): number;
  116323. getBodyFriction(impostor: PhysicsImpostor): number;
  116324. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  116325. getBodyRestitution(impostor: PhysicsImpostor): number;
  116326. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  116327. sleepBody(impostor: PhysicsImpostor): void;
  116328. wakeUpBody(impostor: PhysicsImpostor): void;
  116329. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  116330. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  116331. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  116332. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  116333. getRadius(impostor: PhysicsImpostor): number;
  116334. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  116335. dispose(): void;
  116336. /**
  116337. * Does a raycast in the physics world
  116338. * @param from when should the ray start?
  116339. * @param to when should the ray end?
  116340. * @returns PhysicsRaycastResult
  116341. */
  116342. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  116343. }
  116344. }
  116345. declare module BABYLON {
  116346. /**
  116347. * Class containing static functions to help procedurally build meshes
  116348. */
  116349. export class RibbonBuilder {
  116350. /**
  116351. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  116352. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  116353. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  116354. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  116355. * * 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
  116356. * * 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
  116357. * * 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
  116358. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116359. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116360. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116361. * * 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
  116362. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  116363. * * 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
  116364. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  116365. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116366. * @param name defines the name of the mesh
  116367. * @param options defines the options used to create the mesh
  116368. * @param scene defines the hosting scene
  116369. * @returns the ribbon mesh
  116370. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  116371. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116372. */
  116373. static CreateRibbon(name: string, options: {
  116374. pathArray: Vector3[][];
  116375. closeArray?: boolean;
  116376. closePath?: boolean;
  116377. offset?: number;
  116378. updatable?: boolean;
  116379. sideOrientation?: number;
  116380. frontUVs?: Vector4;
  116381. backUVs?: Vector4;
  116382. instance?: Mesh;
  116383. invertUV?: boolean;
  116384. uvs?: Vector2[];
  116385. colors?: Color4[];
  116386. }, scene?: Nullable<Scene>): Mesh;
  116387. }
  116388. }
  116389. declare module BABYLON {
  116390. /**
  116391. * Class containing static functions to help procedurally build meshes
  116392. */
  116393. export class ShapeBuilder {
  116394. /**
  116395. * 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.
  116396. * * 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.
  116397. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  116398. * * 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.
  116399. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  116400. * * 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
  116401. * * 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
  116402. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  116403. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116404. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116405. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  116406. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116407. * @param name defines the name of the mesh
  116408. * @param options defines the options used to create the mesh
  116409. * @param scene defines the hosting scene
  116410. * @returns the extruded shape mesh
  116411. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116412. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  116413. */
  116414. static ExtrudeShape(name: string, options: {
  116415. shape: Vector3[];
  116416. path: Vector3[];
  116417. scale?: number;
  116418. rotation?: number;
  116419. cap?: number;
  116420. updatable?: boolean;
  116421. sideOrientation?: number;
  116422. frontUVs?: Vector4;
  116423. backUVs?: Vector4;
  116424. instance?: Mesh;
  116425. invertUV?: boolean;
  116426. }, scene?: Nullable<Scene>): Mesh;
  116427. /**
  116428. * Creates an custom extruded shape mesh.
  116429. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  116430. * * 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.
  116431. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  116432. * * 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
  116433. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  116434. * * 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
  116435. * * It must returns a float value that will be the scale value applied to the shape on each path point
  116436. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  116437. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  116438. * * 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
  116439. * * 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
  116440. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  116441. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116442. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116443. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116444. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116445. * @param name defines the name of the mesh
  116446. * @param options defines the options used to create the mesh
  116447. * @param scene defines the hosting scene
  116448. * @returns the custom extruded shape mesh
  116449. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  116450. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116451. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  116452. */
  116453. static ExtrudeShapeCustom(name: string, options: {
  116454. shape: Vector3[];
  116455. path: Vector3[];
  116456. scaleFunction?: any;
  116457. rotationFunction?: any;
  116458. ribbonCloseArray?: boolean;
  116459. ribbonClosePath?: boolean;
  116460. cap?: number;
  116461. updatable?: boolean;
  116462. sideOrientation?: number;
  116463. frontUVs?: Vector4;
  116464. backUVs?: Vector4;
  116465. instance?: Mesh;
  116466. invertUV?: boolean;
  116467. }, scene?: Nullable<Scene>): Mesh;
  116468. private static _ExtrudeShapeGeneric;
  116469. }
  116470. }
  116471. declare module BABYLON {
  116472. /**
  116473. * AmmoJS Physics plugin
  116474. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116475. * @see https://github.com/kripken/ammo.js/
  116476. */
  116477. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  116478. private _useDeltaForWorldStep;
  116479. /**
  116480. * Reference to the Ammo library
  116481. */
  116482. bjsAMMO: any;
  116483. /**
  116484. * Created ammoJS world which physics bodies are added to
  116485. */
  116486. world: any;
  116487. /**
  116488. * Name of the plugin
  116489. */
  116490. name: string;
  116491. private _timeStep;
  116492. private _fixedTimeStep;
  116493. private _maxSteps;
  116494. private _tmpQuaternion;
  116495. private _tmpAmmoTransform;
  116496. private _tmpAmmoQuaternion;
  116497. private _tmpAmmoConcreteContactResultCallback;
  116498. private _collisionConfiguration;
  116499. private _dispatcher;
  116500. private _overlappingPairCache;
  116501. private _solver;
  116502. private _softBodySolver;
  116503. private _tmpAmmoVectorA;
  116504. private _tmpAmmoVectorB;
  116505. private _tmpAmmoVectorC;
  116506. private _tmpAmmoVectorD;
  116507. private _tmpContactCallbackResult;
  116508. private _tmpAmmoVectorRCA;
  116509. private _tmpAmmoVectorRCB;
  116510. private _raycastResult;
  116511. private static readonly DISABLE_COLLISION_FLAG;
  116512. private static readonly KINEMATIC_FLAG;
  116513. private static readonly DISABLE_DEACTIVATION_FLAG;
  116514. /**
  116515. * Initializes the ammoJS plugin
  116516. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  116517. * @param ammoInjection can be used to inject your own ammo reference
  116518. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  116519. */
  116520. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  116521. /**
  116522. * Sets the gravity of the physics world (m/(s^2))
  116523. * @param gravity Gravity to set
  116524. */
  116525. setGravity(gravity: Vector3): void;
  116526. /**
  116527. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  116528. * @param timeStep timestep to use in seconds
  116529. */
  116530. setTimeStep(timeStep: number): void;
  116531. /**
  116532. * 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)
  116533. * @param fixedTimeStep fixedTimeStep to use in seconds
  116534. */
  116535. setFixedTimeStep(fixedTimeStep: number): void;
  116536. /**
  116537. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  116538. * @param maxSteps the maximum number of steps by the physics engine per frame
  116539. */
  116540. setMaxSteps(maxSteps: number): void;
  116541. /**
  116542. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  116543. * @returns the current timestep in seconds
  116544. */
  116545. getTimeStep(): number;
  116546. private _isImpostorInContact;
  116547. private _isImpostorPairInContact;
  116548. private _stepSimulation;
  116549. /**
  116550. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  116551. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  116552. * After the step the babylon meshes are set to the position of the physics imposters
  116553. * @param delta amount of time to step forward
  116554. * @param impostors array of imposters to update before/after the step
  116555. */
  116556. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  116557. /**
  116558. * Update babylon mesh to match physics world object
  116559. * @param impostor imposter to match
  116560. */
  116561. private _afterSoftStep;
  116562. /**
  116563. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  116564. * @param impostor imposter to match
  116565. */
  116566. private _ropeStep;
  116567. /**
  116568. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  116569. * @param impostor imposter to match
  116570. */
  116571. private _softbodyOrClothStep;
  116572. private _tmpVector;
  116573. private _tmpMatrix;
  116574. /**
  116575. * Applies an impulse on the imposter
  116576. * @param impostor imposter to apply impulse to
  116577. * @param force amount of force to be applied to the imposter
  116578. * @param contactPoint the location to apply the impulse on the imposter
  116579. */
  116580. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116581. /**
  116582. * Applies a force on the imposter
  116583. * @param impostor imposter to apply force
  116584. * @param force amount of force to be applied to the imposter
  116585. * @param contactPoint the location to apply the force on the imposter
  116586. */
  116587. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116588. /**
  116589. * Creates a physics body using the plugin
  116590. * @param impostor the imposter to create the physics body on
  116591. */
  116592. generatePhysicsBody(impostor: PhysicsImpostor): void;
  116593. /**
  116594. * Removes the physics body from the imposter and disposes of the body's memory
  116595. * @param impostor imposter to remove the physics body from
  116596. */
  116597. removePhysicsBody(impostor: PhysicsImpostor): void;
  116598. /**
  116599. * Generates a joint
  116600. * @param impostorJoint the imposter joint to create the joint with
  116601. */
  116602. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  116603. /**
  116604. * Removes a joint
  116605. * @param impostorJoint the imposter joint to remove the joint from
  116606. */
  116607. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  116608. private _addMeshVerts;
  116609. /**
  116610. * Initialise the soft body vertices to match its object's (mesh) vertices
  116611. * Softbody vertices (nodes) are in world space and to match this
  116612. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  116613. * @param impostor to create the softbody for
  116614. */
  116615. private _softVertexData;
  116616. /**
  116617. * Create an impostor's soft body
  116618. * @param impostor to create the softbody for
  116619. */
  116620. private _createSoftbody;
  116621. /**
  116622. * Create cloth for an impostor
  116623. * @param impostor to create the softbody for
  116624. */
  116625. private _createCloth;
  116626. /**
  116627. * Create rope for an impostor
  116628. * @param impostor to create the softbody for
  116629. */
  116630. private _createRope;
  116631. private _addHullVerts;
  116632. private _createShape;
  116633. /**
  116634. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  116635. * @param impostor imposter containing the physics body and babylon object
  116636. */
  116637. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  116638. /**
  116639. * Sets the babylon object's position/rotation from the physics body's position/rotation
  116640. * @param impostor imposter containing the physics body and babylon object
  116641. * @param newPosition new position
  116642. * @param newRotation new rotation
  116643. */
  116644. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  116645. /**
  116646. * If this plugin is supported
  116647. * @returns true if its supported
  116648. */
  116649. isSupported(): boolean;
  116650. /**
  116651. * Sets the linear velocity of the physics body
  116652. * @param impostor imposter to set the velocity on
  116653. * @param velocity velocity to set
  116654. */
  116655. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116656. /**
  116657. * Sets the angular velocity of the physics body
  116658. * @param impostor imposter to set the velocity on
  116659. * @param velocity velocity to set
  116660. */
  116661. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116662. /**
  116663. * gets the linear velocity
  116664. * @param impostor imposter to get linear velocity from
  116665. * @returns linear velocity
  116666. */
  116667. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116668. /**
  116669. * gets the angular velocity
  116670. * @param impostor imposter to get angular velocity from
  116671. * @returns angular velocity
  116672. */
  116673. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116674. /**
  116675. * Sets the mass of physics body
  116676. * @param impostor imposter to set the mass on
  116677. * @param mass mass to set
  116678. */
  116679. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  116680. /**
  116681. * Gets the mass of the physics body
  116682. * @param impostor imposter to get the mass from
  116683. * @returns mass
  116684. */
  116685. getBodyMass(impostor: PhysicsImpostor): number;
  116686. /**
  116687. * Gets friction of the impostor
  116688. * @param impostor impostor to get friction from
  116689. * @returns friction value
  116690. */
  116691. getBodyFriction(impostor: PhysicsImpostor): number;
  116692. /**
  116693. * Sets friction of the impostor
  116694. * @param impostor impostor to set friction on
  116695. * @param friction friction value
  116696. */
  116697. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  116698. /**
  116699. * Gets restitution of the impostor
  116700. * @param impostor impostor to get restitution from
  116701. * @returns restitution value
  116702. */
  116703. getBodyRestitution(impostor: PhysicsImpostor): number;
  116704. /**
  116705. * Sets resitution of the impostor
  116706. * @param impostor impostor to set resitution on
  116707. * @param restitution resitution value
  116708. */
  116709. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  116710. /**
  116711. * Gets pressure inside the impostor
  116712. * @param impostor impostor to get pressure from
  116713. * @returns pressure value
  116714. */
  116715. getBodyPressure(impostor: PhysicsImpostor): number;
  116716. /**
  116717. * Sets pressure inside a soft body impostor
  116718. * Cloth and rope must remain 0 pressure
  116719. * @param impostor impostor to set pressure on
  116720. * @param pressure pressure value
  116721. */
  116722. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  116723. /**
  116724. * Gets stiffness of the impostor
  116725. * @param impostor impostor to get stiffness from
  116726. * @returns pressure value
  116727. */
  116728. getBodyStiffness(impostor: PhysicsImpostor): number;
  116729. /**
  116730. * Sets stiffness of the impostor
  116731. * @param impostor impostor to set stiffness on
  116732. * @param stiffness stiffness value from 0 to 1
  116733. */
  116734. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  116735. /**
  116736. * Gets velocityIterations of the impostor
  116737. * @param impostor impostor to get velocity iterations from
  116738. * @returns velocityIterations value
  116739. */
  116740. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  116741. /**
  116742. * Sets velocityIterations of the impostor
  116743. * @param impostor impostor to set velocity iterations on
  116744. * @param velocityIterations velocityIterations value
  116745. */
  116746. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  116747. /**
  116748. * Gets positionIterations of the impostor
  116749. * @param impostor impostor to get position iterations from
  116750. * @returns positionIterations value
  116751. */
  116752. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  116753. /**
  116754. * Sets positionIterations of the impostor
  116755. * @param impostor impostor to set position on
  116756. * @param positionIterations positionIterations value
  116757. */
  116758. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  116759. /**
  116760. * Append an anchor to a cloth object
  116761. * @param impostor is the cloth impostor to add anchor to
  116762. * @param otherImpostor is the rigid impostor to anchor to
  116763. * @param width ratio across width from 0 to 1
  116764. * @param height ratio up height from 0 to 1
  116765. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  116766. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  116767. */
  116768. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  116769. /**
  116770. * Append an hook to a rope object
  116771. * @param impostor is the rope impostor to add hook to
  116772. * @param otherImpostor is the rigid impostor to hook to
  116773. * @param length ratio along the rope from 0 to 1
  116774. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  116775. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  116776. */
  116777. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  116778. /**
  116779. * Sleeps the physics body and stops it from being active
  116780. * @param impostor impostor to sleep
  116781. */
  116782. sleepBody(impostor: PhysicsImpostor): void;
  116783. /**
  116784. * Activates the physics body
  116785. * @param impostor impostor to activate
  116786. */
  116787. wakeUpBody(impostor: PhysicsImpostor): void;
  116788. /**
  116789. * Updates the distance parameters of the joint
  116790. * @param joint joint to update
  116791. * @param maxDistance maximum distance of the joint
  116792. * @param minDistance minimum distance of the joint
  116793. */
  116794. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  116795. /**
  116796. * Sets a motor on the joint
  116797. * @param joint joint to set motor on
  116798. * @param speed speed of the motor
  116799. * @param maxForce maximum force of the motor
  116800. * @param motorIndex index of the motor
  116801. */
  116802. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  116803. /**
  116804. * Sets the motors limit
  116805. * @param joint joint to set limit on
  116806. * @param upperLimit upper limit
  116807. * @param lowerLimit lower limit
  116808. */
  116809. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  116810. /**
  116811. * Syncs the position and rotation of a mesh with the impostor
  116812. * @param mesh mesh to sync
  116813. * @param impostor impostor to update the mesh with
  116814. */
  116815. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  116816. /**
  116817. * Gets the radius of the impostor
  116818. * @param impostor impostor to get radius from
  116819. * @returns the radius
  116820. */
  116821. getRadius(impostor: PhysicsImpostor): number;
  116822. /**
  116823. * Gets the box size of the impostor
  116824. * @param impostor impostor to get box size from
  116825. * @param result the resulting box size
  116826. */
  116827. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  116828. /**
  116829. * Disposes of the impostor
  116830. */
  116831. dispose(): void;
  116832. /**
  116833. * Does a raycast in the physics world
  116834. * @param from when should the ray start?
  116835. * @param to when should the ray end?
  116836. * @returns PhysicsRaycastResult
  116837. */
  116838. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  116839. }
  116840. }
  116841. declare module BABYLON {
  116842. interface AbstractScene {
  116843. /**
  116844. * The list of reflection probes added to the scene
  116845. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  116846. */
  116847. reflectionProbes: Array<ReflectionProbe>;
  116848. /**
  116849. * Removes the given reflection probe from this scene.
  116850. * @param toRemove The reflection probe to remove
  116851. * @returns The index of the removed reflection probe
  116852. */
  116853. removeReflectionProbe(toRemove: ReflectionProbe): number;
  116854. /**
  116855. * Adds the given reflection probe to this scene.
  116856. * @param newReflectionProbe The reflection probe to add
  116857. */
  116858. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  116859. }
  116860. /**
  116861. * Class used to generate realtime reflection / refraction cube textures
  116862. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  116863. */
  116864. export class ReflectionProbe {
  116865. /** defines the name of the probe */
  116866. name: string;
  116867. private _scene;
  116868. private _renderTargetTexture;
  116869. private _projectionMatrix;
  116870. private _viewMatrix;
  116871. private _target;
  116872. private _add;
  116873. private _attachedMesh;
  116874. private _invertYAxis;
  116875. /** Gets or sets probe position (center of the cube map) */
  116876. position: Vector3;
  116877. /**
  116878. * Creates a new reflection probe
  116879. * @param name defines the name of the probe
  116880. * @param size defines the texture resolution (for each face)
  116881. * @param scene defines the hosting scene
  116882. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  116883. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  116884. */
  116885. constructor(
  116886. /** defines the name of the probe */
  116887. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  116888. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  116889. samples: number;
  116890. /** Gets or sets the refresh rate to use (on every frame by default) */
  116891. refreshRate: number;
  116892. /**
  116893. * Gets the hosting scene
  116894. * @returns a Scene
  116895. */
  116896. getScene(): Scene;
  116897. /** Gets the internal CubeTexture used to render to */
  116898. readonly cubeTexture: RenderTargetTexture;
  116899. /** Gets the list of meshes to render */
  116900. readonly renderList: Nullable<AbstractMesh[]>;
  116901. /**
  116902. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  116903. * @param mesh defines the mesh to attach to
  116904. */
  116905. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  116906. /**
  116907. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  116908. * @param renderingGroupId The rendering group id corresponding to its index
  116909. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  116910. */
  116911. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  116912. /**
  116913. * Clean all associated resources
  116914. */
  116915. dispose(): void;
  116916. /**
  116917. * Converts the reflection probe information to a readable string for debug purpose.
  116918. * @param fullDetails Supports for multiple levels of logging within scene loading
  116919. * @returns the human readable reflection probe info
  116920. */
  116921. toString(fullDetails?: boolean): string;
  116922. /**
  116923. * Get the class name of the relfection probe.
  116924. * @returns "ReflectionProbe"
  116925. */
  116926. getClassName(): string;
  116927. /**
  116928. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  116929. * @returns The JSON representation of the texture
  116930. */
  116931. serialize(): any;
  116932. /**
  116933. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  116934. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  116935. * @param scene Define the scene the parsed reflection probe should be instantiated in
  116936. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  116937. * @returns The parsed reflection probe if successful
  116938. */
  116939. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  116940. }
  116941. }
  116942. declare module BABYLON {
  116943. /** @hidden */
  116944. export var _BabylonLoaderRegistered: boolean;
  116945. }
  116946. declare module BABYLON {
  116947. /**
  116948. * The Physically based simple base material of BJS.
  116949. *
  116950. * This enables better naming and convention enforcements on top of the pbrMaterial.
  116951. * It is used as the base class for both the specGloss and metalRough conventions.
  116952. */
  116953. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  116954. /**
  116955. * Number of Simultaneous lights allowed on the material.
  116956. */
  116957. maxSimultaneousLights: number;
  116958. /**
  116959. * If sets to true, disables all the lights affecting the material.
  116960. */
  116961. disableLighting: boolean;
  116962. /**
  116963. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  116964. */
  116965. environmentTexture: BaseTexture;
  116966. /**
  116967. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  116968. */
  116969. invertNormalMapX: boolean;
  116970. /**
  116971. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  116972. */
  116973. invertNormalMapY: boolean;
  116974. /**
  116975. * Normal map used in the model.
  116976. */
  116977. normalTexture: BaseTexture;
  116978. /**
  116979. * Emissivie color used to self-illuminate the model.
  116980. */
  116981. emissiveColor: Color3;
  116982. /**
  116983. * Emissivie texture used to self-illuminate the model.
  116984. */
  116985. emissiveTexture: BaseTexture;
  116986. /**
  116987. * Occlusion Channel Strenght.
  116988. */
  116989. occlusionStrength: number;
  116990. /**
  116991. * Occlusion Texture of the material (adding extra occlusion effects).
  116992. */
  116993. occlusionTexture: BaseTexture;
  116994. /**
  116995. * Defines the alpha limits in alpha test mode.
  116996. */
  116997. alphaCutOff: number;
  116998. /**
  116999. * Gets the current double sided mode.
  117000. */
  117001. /**
  117002. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  117003. */
  117004. doubleSided: boolean;
  117005. /**
  117006. * Stores the pre-calculated light information of a mesh in a texture.
  117007. */
  117008. lightmapTexture: BaseTexture;
  117009. /**
  117010. * If true, the light map contains occlusion information instead of lighting info.
  117011. */
  117012. useLightmapAsShadowmap: boolean;
  117013. /**
  117014. * Instantiates a new PBRMaterial instance.
  117015. *
  117016. * @param name The material name
  117017. * @param scene The scene the material will be use in.
  117018. */
  117019. constructor(name: string, scene: Scene);
  117020. getClassName(): string;
  117021. }
  117022. }
  117023. declare module BABYLON {
  117024. /**
  117025. * The PBR material of BJS following the metal roughness convention.
  117026. *
  117027. * This fits to the PBR convention in the GLTF definition:
  117028. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  117029. */
  117030. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  117031. /**
  117032. * The base color has two different interpretations depending on the value of metalness.
  117033. * When the material is a metal, the base color is the specific measured reflectance value
  117034. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  117035. * of the material.
  117036. */
  117037. baseColor: Color3;
  117038. /**
  117039. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  117040. * well as opacity information in the alpha channel.
  117041. */
  117042. baseTexture: BaseTexture;
  117043. /**
  117044. * Specifies the metallic scalar value of the material.
  117045. * Can also be used to scale the metalness values of the metallic texture.
  117046. */
  117047. metallic: number;
  117048. /**
  117049. * Specifies the roughness scalar value of the material.
  117050. * Can also be used to scale the roughness values of the metallic texture.
  117051. */
  117052. roughness: number;
  117053. /**
  117054. * Texture containing both the metallic value in the B channel and the
  117055. * roughness value in the G channel to keep better precision.
  117056. */
  117057. metallicRoughnessTexture: BaseTexture;
  117058. /**
  117059. * Instantiates a new PBRMetalRoughnessMaterial instance.
  117060. *
  117061. * @param name The material name
  117062. * @param scene The scene the material will be use in.
  117063. */
  117064. constructor(name: string, scene: Scene);
  117065. /**
  117066. * Return the currrent class name of the material.
  117067. */
  117068. getClassName(): string;
  117069. /**
  117070. * Makes a duplicate of the current material.
  117071. * @param name - name to use for the new material.
  117072. */
  117073. clone(name: string): PBRMetallicRoughnessMaterial;
  117074. /**
  117075. * Serialize the material to a parsable JSON object.
  117076. */
  117077. serialize(): any;
  117078. /**
  117079. * Parses a JSON object correponding to the serialize function.
  117080. */
  117081. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  117082. }
  117083. }
  117084. declare module BABYLON {
  117085. /**
  117086. * The PBR material of BJS following the specular glossiness convention.
  117087. *
  117088. * This fits to the PBR convention in the GLTF definition:
  117089. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  117090. */
  117091. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  117092. /**
  117093. * Specifies the diffuse color of the material.
  117094. */
  117095. diffuseColor: Color3;
  117096. /**
  117097. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  117098. * channel.
  117099. */
  117100. diffuseTexture: BaseTexture;
  117101. /**
  117102. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  117103. */
  117104. specularColor: Color3;
  117105. /**
  117106. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  117107. */
  117108. glossiness: number;
  117109. /**
  117110. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  117111. */
  117112. specularGlossinessTexture: BaseTexture;
  117113. /**
  117114. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  117115. *
  117116. * @param name The material name
  117117. * @param scene The scene the material will be use in.
  117118. */
  117119. constructor(name: string, scene: Scene);
  117120. /**
  117121. * Return the currrent class name of the material.
  117122. */
  117123. getClassName(): string;
  117124. /**
  117125. * Makes a duplicate of the current material.
  117126. * @param name - name to use for the new material.
  117127. */
  117128. clone(name: string): PBRSpecularGlossinessMaterial;
  117129. /**
  117130. * Serialize the material to a parsable JSON object.
  117131. */
  117132. serialize(): any;
  117133. /**
  117134. * Parses a JSON object correponding to the serialize function.
  117135. */
  117136. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  117137. }
  117138. }
  117139. declare module BABYLON {
  117140. /**
  117141. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  117142. * It can help converting any input color in a desired output one. This can then be used to create effects
  117143. * from sepia, black and white to sixties or futuristic rendering...
  117144. *
  117145. * The only supported format is currently 3dl.
  117146. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  117147. */
  117148. export class ColorGradingTexture extends BaseTexture {
  117149. /**
  117150. * The current texture matrix. (will always be identity in color grading texture)
  117151. */
  117152. private _textureMatrix;
  117153. /**
  117154. * The texture URL.
  117155. */
  117156. url: string;
  117157. /**
  117158. * Empty line regex stored for GC.
  117159. */
  117160. private static _noneEmptyLineRegex;
  117161. private _engine;
  117162. /**
  117163. * Instantiates a ColorGradingTexture from the following parameters.
  117164. *
  117165. * @param url The location of the color gradind data (currently only supporting 3dl)
  117166. * @param scene The scene the texture will be used in
  117167. */
  117168. constructor(url: string, scene: Scene);
  117169. /**
  117170. * Returns the texture matrix used in most of the material.
  117171. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  117172. */
  117173. getTextureMatrix(): Matrix;
  117174. /**
  117175. * Occurs when the file being loaded is a .3dl LUT file.
  117176. */
  117177. private load3dlTexture;
  117178. /**
  117179. * Starts the loading process of the texture.
  117180. */
  117181. private loadTexture;
  117182. /**
  117183. * Clones the color gradind texture.
  117184. */
  117185. clone(): ColorGradingTexture;
  117186. /**
  117187. * Called during delayed load for textures.
  117188. */
  117189. delayLoad(): void;
  117190. /**
  117191. * Parses a color grading texture serialized by Babylon.
  117192. * @param parsedTexture The texture information being parsedTexture
  117193. * @param scene The scene to load the texture in
  117194. * @param rootUrl The root url of the data assets to load
  117195. * @return A color gradind texture
  117196. */
  117197. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  117198. /**
  117199. * Serializes the LUT texture to json format.
  117200. */
  117201. serialize(): any;
  117202. }
  117203. }
  117204. declare module BABYLON {
  117205. /**
  117206. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  117207. */
  117208. export class EquiRectangularCubeTexture extends BaseTexture {
  117209. /** The six faces of the cube. */
  117210. private static _FacesMapping;
  117211. private _noMipmap;
  117212. private _onLoad;
  117213. private _onError;
  117214. /** The size of the cubemap. */
  117215. private _size;
  117216. /** The buffer of the image. */
  117217. private _buffer;
  117218. /** The width of the input image. */
  117219. private _width;
  117220. /** The height of the input image. */
  117221. private _height;
  117222. /** The URL to the image. */
  117223. url: string;
  117224. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  117225. coordinatesMode: number;
  117226. /**
  117227. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  117228. * @param url The location of the image
  117229. * @param scene The scene the texture will be used in
  117230. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  117231. * @param noMipmap Forces to not generate the mipmap if true
  117232. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  117233. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  117234. * @param onLoad — defines a callback called when texture is loaded
  117235. * @param onError — defines a callback called if there is an error
  117236. */
  117237. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  117238. /**
  117239. * Load the image data, by putting the image on a canvas and extracting its buffer.
  117240. */
  117241. private loadImage;
  117242. /**
  117243. * Convert the image buffer into a cubemap and create a CubeTexture.
  117244. */
  117245. private loadTexture;
  117246. /**
  117247. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  117248. * @param buffer The ArrayBuffer that should be converted.
  117249. * @returns The buffer as Float32Array.
  117250. */
  117251. private getFloat32ArrayFromArrayBuffer;
  117252. /**
  117253. * Get the current class name of the texture useful for serialization or dynamic coding.
  117254. * @returns "EquiRectangularCubeTexture"
  117255. */
  117256. getClassName(): string;
  117257. /**
  117258. * Create a clone of the current EquiRectangularCubeTexture and return it.
  117259. * @returns A clone of the current EquiRectangularCubeTexture.
  117260. */
  117261. clone(): EquiRectangularCubeTexture;
  117262. }
  117263. }
  117264. declare module BABYLON {
  117265. /**
  117266. * Based on jsTGALoader - Javascript loader for TGA file
  117267. * By Vincent Thibault
  117268. * @see http://blog.robrowser.com/javascript-tga-loader.html
  117269. */
  117270. export class TGATools {
  117271. private static _TYPE_INDEXED;
  117272. private static _TYPE_RGB;
  117273. private static _TYPE_GREY;
  117274. private static _TYPE_RLE_INDEXED;
  117275. private static _TYPE_RLE_RGB;
  117276. private static _TYPE_RLE_GREY;
  117277. private static _ORIGIN_MASK;
  117278. private static _ORIGIN_SHIFT;
  117279. private static _ORIGIN_BL;
  117280. private static _ORIGIN_BR;
  117281. private static _ORIGIN_UL;
  117282. private static _ORIGIN_UR;
  117283. /**
  117284. * Gets the header of a TGA file
  117285. * @param data defines the TGA data
  117286. * @returns the header
  117287. */
  117288. static GetTGAHeader(data: Uint8Array): any;
  117289. /**
  117290. * Uploads TGA content to a Babylon Texture
  117291. * @hidden
  117292. */
  117293. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  117294. /** @hidden */
  117295. 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;
  117296. /** @hidden */
  117297. 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;
  117298. /** @hidden */
  117299. 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;
  117300. /** @hidden */
  117301. 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;
  117302. /** @hidden */
  117303. 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;
  117304. /** @hidden */
  117305. 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;
  117306. }
  117307. }
  117308. declare module BABYLON {
  117309. /**
  117310. * Implementation of the TGA Texture Loader.
  117311. * @hidden
  117312. */
  117313. export class _TGATextureLoader implements IInternalTextureLoader {
  117314. /**
  117315. * Defines wether the loader supports cascade loading the different faces.
  117316. */
  117317. readonly supportCascades: boolean;
  117318. /**
  117319. * This returns if the loader support the current file information.
  117320. * @param extension defines the file extension of the file being loaded
  117321. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117322. * @param fallback defines the fallback internal texture if any
  117323. * @param isBase64 defines whether the texture is encoded as a base64
  117324. * @param isBuffer defines whether the texture data are stored as a buffer
  117325. * @returns true if the loader can load the specified file
  117326. */
  117327. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117328. /**
  117329. * Transform the url before loading if required.
  117330. * @param rootUrl the url of the texture
  117331. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117332. * @returns the transformed texture
  117333. */
  117334. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117335. /**
  117336. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117337. * @param rootUrl the url of the texture
  117338. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117339. * @returns the fallback texture
  117340. */
  117341. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117342. /**
  117343. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  117344. * @param data contains the texture data
  117345. * @param texture defines the BabylonJS internal texture
  117346. * @param createPolynomials will be true if polynomials have been requested
  117347. * @param onLoad defines the callback to trigger once the texture is ready
  117348. * @param onError defines the callback to trigger in case of error
  117349. */
  117350. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117351. /**
  117352. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117353. * @param data contains the texture data
  117354. * @param texture defines the BabylonJS internal texture
  117355. * @param callback defines the method to call once ready to upload
  117356. */
  117357. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  117358. }
  117359. }
  117360. declare module BABYLON {
  117361. /**
  117362. * Info about the .basis files
  117363. */
  117364. class BasisFileInfo {
  117365. /**
  117366. * If the file has alpha
  117367. */
  117368. hasAlpha: boolean;
  117369. /**
  117370. * Info about each image of the basis file
  117371. */
  117372. images: Array<{
  117373. levels: Array<{
  117374. width: number;
  117375. height: number;
  117376. transcodedPixels: ArrayBufferView;
  117377. }>;
  117378. }>;
  117379. }
  117380. /**
  117381. * Result of transcoding a basis file
  117382. */
  117383. class TranscodeResult {
  117384. /**
  117385. * Info about the .basis file
  117386. */
  117387. fileInfo: BasisFileInfo;
  117388. /**
  117389. * Format to use when loading the file
  117390. */
  117391. format: number;
  117392. }
  117393. /**
  117394. * Configuration options for the Basis transcoder
  117395. */
  117396. export class BasisTranscodeConfiguration {
  117397. /**
  117398. * Supported compression formats used to determine the supported output format of the transcoder
  117399. */
  117400. supportedCompressionFormats?: {
  117401. /**
  117402. * etc1 compression format
  117403. */
  117404. etc1?: boolean;
  117405. /**
  117406. * s3tc compression format
  117407. */
  117408. s3tc?: boolean;
  117409. /**
  117410. * pvrtc compression format
  117411. */
  117412. pvrtc?: boolean;
  117413. /**
  117414. * etc2 compression format
  117415. */
  117416. etc2?: boolean;
  117417. };
  117418. /**
  117419. * If mipmap levels should be loaded for transcoded images (Default: true)
  117420. */
  117421. loadMipmapLevels?: boolean;
  117422. /**
  117423. * Index of a single image to load (Default: all images)
  117424. */
  117425. loadSingleImage?: number;
  117426. }
  117427. /**
  117428. * Used to load .Basis files
  117429. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  117430. */
  117431. export class BasisTools {
  117432. private static _IgnoreSupportedFormats;
  117433. /**
  117434. * URL to use when loading the basis transcoder
  117435. */
  117436. static JSModuleURL: string;
  117437. /**
  117438. * URL to use when loading the wasm module for the transcoder
  117439. */
  117440. static WasmModuleURL: string;
  117441. /**
  117442. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  117443. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  117444. * @returns internal format corresponding to the Basis format
  117445. */
  117446. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  117447. private static _WorkerPromise;
  117448. private static _Worker;
  117449. private static _actionId;
  117450. private static _CreateWorkerAsync;
  117451. /**
  117452. * Transcodes a loaded image file to compressed pixel data
  117453. * @param imageData image data to transcode
  117454. * @param config configuration options for the transcoding
  117455. * @returns a promise resulting in the transcoded image
  117456. */
  117457. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  117458. /**
  117459. * Loads a texture from the transcode result
  117460. * @param texture texture load to
  117461. * @param transcodeResult the result of transcoding the basis file to load from
  117462. */
  117463. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  117464. }
  117465. }
  117466. declare module BABYLON {
  117467. /**
  117468. * Loader for .basis file format
  117469. */
  117470. export class _BasisTextureLoader implements IInternalTextureLoader {
  117471. /**
  117472. * Defines whether the loader supports cascade loading the different faces.
  117473. */
  117474. readonly supportCascades: boolean;
  117475. /**
  117476. * This returns if the loader support the current file information.
  117477. * @param extension defines the file extension of the file being loaded
  117478. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117479. * @param fallback defines the fallback internal texture if any
  117480. * @param isBase64 defines whether the texture is encoded as a base64
  117481. * @param isBuffer defines whether the texture data are stored as a buffer
  117482. * @returns true if the loader can load the specified file
  117483. */
  117484. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117485. /**
  117486. * Transform the url before loading if required.
  117487. * @param rootUrl the url of the texture
  117488. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117489. * @returns the transformed texture
  117490. */
  117491. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117492. /**
  117493. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117494. * @param rootUrl the url of the texture
  117495. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117496. * @returns the fallback texture
  117497. */
  117498. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117499. /**
  117500. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  117501. * @param data contains the texture data
  117502. * @param texture defines the BabylonJS internal texture
  117503. * @param createPolynomials will be true if polynomials have been requested
  117504. * @param onLoad defines the callback to trigger once the texture is ready
  117505. * @param onError defines the callback to trigger in case of error
  117506. */
  117507. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117508. /**
  117509. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117510. * @param data contains the texture data
  117511. * @param texture defines the BabylonJS internal texture
  117512. * @param callback defines the method to call once ready to upload
  117513. */
  117514. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  117515. }
  117516. }
  117517. declare module BABYLON {
  117518. /**
  117519. * 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.
  117520. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  117521. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  117522. */
  117523. export class CustomProceduralTexture extends ProceduralTexture {
  117524. private _animate;
  117525. private _time;
  117526. private _config;
  117527. private _texturePath;
  117528. /**
  117529. * Instantiates a new Custom Procedural Texture.
  117530. * 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.
  117531. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  117532. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  117533. * @param name Define the name of the texture
  117534. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  117535. * @param size Define the size of the texture to create
  117536. * @param scene Define the scene the texture belongs to
  117537. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  117538. * @param generateMipMaps Define if the texture should creates mip maps or not
  117539. */
  117540. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  117541. private _loadJson;
  117542. /**
  117543. * Is the texture ready to be used ? (rendered at least once)
  117544. * @returns true if ready, otherwise, false.
  117545. */
  117546. isReady(): boolean;
  117547. /**
  117548. * Render the texture to its associated render target.
  117549. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  117550. */
  117551. render(useCameraPostProcess?: boolean): void;
  117552. /**
  117553. * Update the list of dependant textures samplers in the shader.
  117554. */
  117555. updateTextures(): void;
  117556. /**
  117557. * Update the uniform values of the procedural texture in the shader.
  117558. */
  117559. updateShaderUniforms(): void;
  117560. /**
  117561. * Define if the texture animates or not.
  117562. */
  117563. animate: boolean;
  117564. }
  117565. }
  117566. declare module BABYLON {
  117567. /** @hidden */
  117568. export var noisePixelShader: {
  117569. name: string;
  117570. shader: string;
  117571. };
  117572. }
  117573. declare module BABYLON {
  117574. /**
  117575. * Class used to generate noise procedural textures
  117576. */
  117577. export class NoiseProceduralTexture extends ProceduralTexture {
  117578. private _time;
  117579. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  117580. brightness: number;
  117581. /** Defines the number of octaves to process */
  117582. octaves: number;
  117583. /** Defines the level of persistence (0.8 by default) */
  117584. persistence: number;
  117585. /** Gets or sets animation speed factor (default is 1) */
  117586. animationSpeedFactor: number;
  117587. /**
  117588. * Creates a new NoiseProceduralTexture
  117589. * @param name defines the name fo the texture
  117590. * @param size defines the size of the texture (default is 256)
  117591. * @param scene defines the hosting scene
  117592. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  117593. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  117594. */
  117595. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  117596. private _updateShaderUniforms;
  117597. protected _getDefines(): string;
  117598. /** Generate the current state of the procedural texture */
  117599. render(useCameraPostProcess?: boolean): void;
  117600. /**
  117601. * Serializes this noise procedural texture
  117602. * @returns a serialized noise procedural texture object
  117603. */
  117604. serialize(): any;
  117605. /**
  117606. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  117607. * @param parsedTexture defines parsed texture data
  117608. * @param scene defines the current scene
  117609. * @param rootUrl defines the root URL containing noise procedural texture information
  117610. * @returns a parsed NoiseProceduralTexture
  117611. */
  117612. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  117613. }
  117614. }
  117615. declare module BABYLON {
  117616. /**
  117617. * Raw cube texture where the raw buffers are passed in
  117618. */
  117619. export class RawCubeTexture extends CubeTexture {
  117620. /**
  117621. * Creates a cube texture where the raw buffers are passed in.
  117622. * @param scene defines the scene the texture is attached to
  117623. * @param data defines the array of data to use to create each face
  117624. * @param size defines the size of the textures
  117625. * @param format defines the format of the data
  117626. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  117627. * @param generateMipMaps defines if the engine should generate the mip levels
  117628. * @param invertY defines if data must be stored with Y axis inverted
  117629. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  117630. * @param compression defines the compression used (null by default)
  117631. */
  117632. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  117633. /**
  117634. * Updates the raw cube texture.
  117635. * @param data defines the data to store
  117636. * @param format defines the data format
  117637. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  117638. * @param invertY defines if data must be stored with Y axis inverted
  117639. * @param compression defines the compression used (null by default)
  117640. * @param level defines which level of the texture to update
  117641. */
  117642. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  117643. /**
  117644. * Updates a raw cube texture with RGBD encoded data.
  117645. * @param data defines the array of data [mipmap][face] to use to create each face
  117646. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  117647. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  117648. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  117649. * @returns a promsie that resolves when the operation is complete
  117650. */
  117651. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  117652. /**
  117653. * Clones the raw cube texture.
  117654. * @return a new cube texture
  117655. */
  117656. clone(): CubeTexture;
  117657. /** @hidden */
  117658. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  117659. }
  117660. }
  117661. declare module BABYLON {
  117662. /**
  117663. * Class used to store 3D textures containing user data
  117664. */
  117665. export class RawTexture3D extends Texture {
  117666. /** Gets or sets the texture format to use */
  117667. format: number;
  117668. private _engine;
  117669. /**
  117670. * Create a new RawTexture3D
  117671. * @param data defines the data of the texture
  117672. * @param width defines the width of the texture
  117673. * @param height defines the height of the texture
  117674. * @param depth defines the depth of the texture
  117675. * @param format defines the texture format to use
  117676. * @param scene defines the hosting scene
  117677. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  117678. * @param invertY defines if texture must be stored with Y axis inverted
  117679. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  117680. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  117681. */
  117682. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  117683. /** Gets or sets the texture format to use */
  117684. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  117685. /**
  117686. * Update the texture with new data
  117687. * @param data defines the data to store in the texture
  117688. */
  117689. update(data: ArrayBufferView): void;
  117690. }
  117691. }
  117692. declare module BABYLON {
  117693. /**
  117694. * Creates a refraction texture used by refraction channel of the standard material.
  117695. * It is like a mirror but to see through a material.
  117696. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  117697. */
  117698. export class RefractionTexture extends RenderTargetTexture {
  117699. /**
  117700. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  117701. * 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.
  117702. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  117703. */
  117704. refractionPlane: Plane;
  117705. /**
  117706. * Define how deep under the surface we should see.
  117707. */
  117708. depth: number;
  117709. /**
  117710. * Creates a refraction texture used by refraction channel of the standard material.
  117711. * It is like a mirror but to see through a material.
  117712. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  117713. * @param name Define the texture name
  117714. * @param size Define the size of the underlying texture
  117715. * @param scene Define the scene the refraction belongs to
  117716. * @param generateMipMaps Define if we need to generate mips level for the refraction
  117717. */
  117718. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  117719. /**
  117720. * Clone the refraction texture.
  117721. * @returns the cloned texture
  117722. */
  117723. clone(): RefractionTexture;
  117724. /**
  117725. * Serialize the texture to a JSON representation you could use in Parse later on
  117726. * @returns the serialized JSON representation
  117727. */
  117728. serialize(): any;
  117729. }
  117730. }
  117731. declare module BABYLON {
  117732. /**
  117733. * Defines the options related to the creation of an HtmlElementTexture
  117734. */
  117735. export interface IHtmlElementTextureOptions {
  117736. /**
  117737. * Defines wether mip maps should be created or not.
  117738. */
  117739. generateMipMaps?: boolean;
  117740. /**
  117741. * Defines the sampling mode of the texture.
  117742. */
  117743. samplingMode?: number;
  117744. /**
  117745. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  117746. */
  117747. engine: Nullable<Engine>;
  117748. /**
  117749. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  117750. */
  117751. scene: Nullable<Scene>;
  117752. }
  117753. /**
  117754. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  117755. * To be as efficient as possible depending on your constraints nothing aside the first upload
  117756. * is automatically managed.
  117757. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  117758. * in your application.
  117759. *
  117760. * As the update is not automatic, you need to call them manually.
  117761. */
  117762. export class HtmlElementTexture extends BaseTexture {
  117763. /**
  117764. * The texture URL.
  117765. */
  117766. element: HTMLVideoElement | HTMLCanvasElement;
  117767. private static readonly DefaultOptions;
  117768. private _textureMatrix;
  117769. private _engine;
  117770. private _isVideo;
  117771. private _generateMipMaps;
  117772. private _samplingMode;
  117773. /**
  117774. * Instantiates a HtmlElementTexture from the following parameters.
  117775. *
  117776. * @param name Defines the name of the texture
  117777. * @param element Defines the video or canvas the texture is filled with
  117778. * @param options Defines the other none mandatory texture creation options
  117779. */
  117780. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  117781. private _createInternalTexture;
  117782. /**
  117783. * Returns the texture matrix used in most of the material.
  117784. */
  117785. getTextureMatrix(): Matrix;
  117786. /**
  117787. * Updates the content of the texture.
  117788. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  117789. */
  117790. update(invertY?: Nullable<boolean>): void;
  117791. }
  117792. }
  117793. declare module BABYLON {
  117794. /**
  117795. * Enum used to define the target of a block
  117796. */
  117797. export enum NodeMaterialBlockTargets {
  117798. /** Vertex shader */
  117799. Vertex = 1,
  117800. /** Fragment shader */
  117801. Fragment = 2,
  117802. /** Neutral */
  117803. Neutral = 4,
  117804. /** Vertex and Fragment */
  117805. VertexAndFragment = 3
  117806. }
  117807. }
  117808. declare module BABYLON {
  117809. /**
  117810. * Defines the kind of connection point for node based material
  117811. */
  117812. export enum NodeMaterialBlockConnectionPointTypes {
  117813. /** Float */
  117814. Float = 1,
  117815. /** Int */
  117816. Int = 2,
  117817. /** Vector2 */
  117818. Vector2 = 4,
  117819. /** Vector3 */
  117820. Vector3 = 8,
  117821. /** Vector4 */
  117822. Vector4 = 16,
  117823. /** Color3 */
  117824. Color3 = 32,
  117825. /** Color4 */
  117826. Color4 = 64,
  117827. /** Matrix */
  117828. Matrix = 128,
  117829. /** Detect type based on connection */
  117830. AutoDetect = 1024,
  117831. /** Output type that will be defined by input type */
  117832. BasedOnInput = 2048
  117833. }
  117834. }
  117835. declare module BABYLON {
  117836. /**
  117837. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  117838. */
  117839. export enum NodeMaterialBlockConnectionPointMode {
  117840. /** Value is an uniform */
  117841. Uniform = 0,
  117842. /** Value is a mesh attribute */
  117843. Attribute = 1,
  117844. /** Value is a varying between vertex and fragment shaders */
  117845. Varying = 2,
  117846. /** Mode is undefined */
  117847. Undefined = 3
  117848. }
  117849. }
  117850. declare module BABYLON {
  117851. /**
  117852. * Enum used to define system values e.g. values automatically provided by the system
  117853. */
  117854. export enum NodeMaterialSystemValues {
  117855. /** World */
  117856. World = 1,
  117857. /** View */
  117858. View = 2,
  117859. /** Projection */
  117860. Projection = 3,
  117861. /** ViewProjection */
  117862. ViewProjection = 4,
  117863. /** WorldView */
  117864. WorldView = 5,
  117865. /** WorldViewProjection */
  117866. WorldViewProjection = 6,
  117867. /** CameraPosition */
  117868. CameraPosition = 7,
  117869. /** Fog Color */
  117870. FogColor = 8
  117871. }
  117872. }
  117873. declare module BABYLON {
  117874. /**
  117875. * Root class for all node material optimizers
  117876. */
  117877. export class NodeMaterialOptimizer {
  117878. /**
  117879. * Function used to optimize a NodeMaterial graph
  117880. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  117881. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  117882. */
  117883. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  117884. }
  117885. }
  117886. declare module BABYLON {
  117887. /**
  117888. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  117889. */
  117890. export class TransformBlock extends NodeMaterialBlock {
  117891. /**
  117892. * Defines the value to use to complement W value to transform it to a Vector4
  117893. */
  117894. complementW: number;
  117895. /**
  117896. * Defines the value to use to complement z value to transform it to a Vector4
  117897. */
  117898. complementZ: number;
  117899. /**
  117900. * Creates a new TransformBlock
  117901. * @param name defines the block name
  117902. */
  117903. constructor(name: string);
  117904. /**
  117905. * Gets the current class name
  117906. * @returns the class name
  117907. */
  117908. getClassName(): string;
  117909. /**
  117910. * Gets the vector input
  117911. */
  117912. readonly vector: NodeMaterialConnectionPoint;
  117913. /**
  117914. * Gets the output component
  117915. */
  117916. readonly output: NodeMaterialConnectionPoint;
  117917. /**
  117918. * Gets the matrix transform input
  117919. */
  117920. readonly transform: NodeMaterialConnectionPoint;
  117921. protected _buildBlock(state: NodeMaterialBuildState): this;
  117922. serialize(): any;
  117923. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  117924. protected _dumpPropertiesCode(): string;
  117925. }
  117926. }
  117927. declare module BABYLON {
  117928. /**
  117929. * Block used to output the vertex position
  117930. */
  117931. export class VertexOutputBlock extends NodeMaterialBlock {
  117932. /**
  117933. * Creates a new VertexOutputBlock
  117934. * @param name defines the block name
  117935. */
  117936. constructor(name: string);
  117937. /**
  117938. * Gets the current class name
  117939. * @returns the class name
  117940. */
  117941. getClassName(): string;
  117942. /**
  117943. * Gets the vector input component
  117944. */
  117945. readonly vector: NodeMaterialConnectionPoint;
  117946. protected _buildBlock(state: NodeMaterialBuildState): this;
  117947. }
  117948. }
  117949. declare module BABYLON {
  117950. /**
  117951. * Block used to output the final color
  117952. */
  117953. export class FragmentOutputBlock extends NodeMaterialBlock {
  117954. /**
  117955. * Create a new FragmentOutputBlock
  117956. * @param name defines the block name
  117957. */
  117958. constructor(name: string);
  117959. /**
  117960. * Gets the current class name
  117961. * @returns the class name
  117962. */
  117963. getClassName(): string;
  117964. /**
  117965. * Gets the rgba input component
  117966. */
  117967. readonly rgba: NodeMaterialConnectionPoint;
  117968. /**
  117969. * Gets the rgb input component
  117970. */
  117971. readonly rgb: NodeMaterialConnectionPoint;
  117972. /**
  117973. * Gets the a input component
  117974. */
  117975. readonly a: NodeMaterialConnectionPoint;
  117976. protected _buildBlock(state: NodeMaterialBuildState): this;
  117977. }
  117978. }
  117979. declare module BABYLON {
  117980. /**
  117981. * Block used to read a reflection texture from a sampler
  117982. */
  117983. export class ReflectionTextureBlock extends NodeMaterialBlock {
  117984. private _define3DName;
  117985. private _defineCubicName;
  117986. private _defineExplicitName;
  117987. private _defineProjectionName;
  117988. private _defineLocalCubicName;
  117989. private _defineSphericalName;
  117990. private _definePlanarName;
  117991. private _defineEquirectangularName;
  117992. private _defineMirroredEquirectangularFixedName;
  117993. private _defineEquirectangularFixedName;
  117994. private _defineSkyboxName;
  117995. private _cubeSamplerName;
  117996. private _2DSamplerName;
  117997. private _positionUVWName;
  117998. private _directionWName;
  117999. private _reflectionCoordsName;
  118000. private _reflection2DCoordsName;
  118001. private _reflectionColorName;
  118002. private _reflectionMatrixName;
  118003. /**
  118004. * Gets or sets the texture associated with the node
  118005. */
  118006. texture: Nullable<BaseTexture>;
  118007. /**
  118008. * Create a new TextureBlock
  118009. * @param name defines the block name
  118010. */
  118011. constructor(name: string);
  118012. /**
  118013. * Gets the current class name
  118014. * @returns the class name
  118015. */
  118016. getClassName(): string;
  118017. /**
  118018. * Gets the world position input component
  118019. */
  118020. readonly position: NodeMaterialConnectionPoint;
  118021. /**
  118022. * Gets the world position input component
  118023. */
  118024. readonly worldPosition: NodeMaterialConnectionPoint;
  118025. /**
  118026. * Gets the world normal input component
  118027. */
  118028. readonly worldNormal: NodeMaterialConnectionPoint;
  118029. /**
  118030. * Gets the world input component
  118031. */
  118032. readonly world: NodeMaterialConnectionPoint;
  118033. /**
  118034. * Gets the camera (or eye) position component
  118035. */
  118036. readonly cameraPosition: NodeMaterialConnectionPoint;
  118037. /**
  118038. * Gets the view input component
  118039. */
  118040. readonly view: NodeMaterialConnectionPoint;
  118041. /**
  118042. * Gets the rgb output component
  118043. */
  118044. readonly rgb: NodeMaterialConnectionPoint;
  118045. /**
  118046. * Gets the r output component
  118047. */
  118048. readonly r: NodeMaterialConnectionPoint;
  118049. /**
  118050. * Gets the g output component
  118051. */
  118052. readonly g: NodeMaterialConnectionPoint;
  118053. /**
  118054. * Gets the b output component
  118055. */
  118056. readonly b: NodeMaterialConnectionPoint;
  118057. autoConfigure(material: NodeMaterial): void;
  118058. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118059. isReady(): boolean;
  118060. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118061. private _injectVertexCode;
  118062. private _writeOutput;
  118063. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  118064. serialize(): any;
  118065. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118066. }
  118067. }
  118068. declare module BABYLON {
  118069. /**
  118070. * Interface used to configure the node material editor
  118071. */
  118072. export interface INodeMaterialEditorOptions {
  118073. /** Define the URl to load node editor script */
  118074. editorURL?: string;
  118075. }
  118076. /** @hidden */
  118077. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  118078. /** BONES */
  118079. NUM_BONE_INFLUENCERS: number;
  118080. BonesPerMesh: number;
  118081. BONETEXTURE: boolean;
  118082. /** MORPH TARGETS */
  118083. MORPHTARGETS: boolean;
  118084. MORPHTARGETS_NORMAL: boolean;
  118085. MORPHTARGETS_TANGENT: boolean;
  118086. MORPHTARGETS_UV: boolean;
  118087. NUM_MORPH_INFLUENCERS: number;
  118088. /** IMAGE PROCESSING */
  118089. IMAGEPROCESSING: boolean;
  118090. VIGNETTE: boolean;
  118091. VIGNETTEBLENDMODEMULTIPLY: boolean;
  118092. VIGNETTEBLENDMODEOPAQUE: boolean;
  118093. TONEMAPPING: boolean;
  118094. TONEMAPPING_ACES: boolean;
  118095. CONTRAST: boolean;
  118096. EXPOSURE: boolean;
  118097. COLORCURVES: boolean;
  118098. COLORGRADING: boolean;
  118099. COLORGRADING3D: boolean;
  118100. SAMPLER3DGREENDEPTH: boolean;
  118101. SAMPLER3DBGRMAP: boolean;
  118102. IMAGEPROCESSINGPOSTPROCESS: boolean;
  118103. /** MISC. */
  118104. BUMPDIRECTUV: number;
  118105. constructor();
  118106. setValue(name: string, value: boolean): void;
  118107. }
  118108. /**
  118109. * Class used to configure NodeMaterial
  118110. */
  118111. export interface INodeMaterialOptions {
  118112. /**
  118113. * Defines if blocks should emit comments
  118114. */
  118115. emitComments: boolean;
  118116. }
  118117. /**
  118118. * Class used to create a node based material built by assembling shader blocks
  118119. */
  118120. export class NodeMaterial extends PushMaterial {
  118121. private static _BuildIdGenerator;
  118122. private _options;
  118123. private _vertexCompilationState;
  118124. private _fragmentCompilationState;
  118125. private _sharedData;
  118126. private _buildId;
  118127. private _buildWasSuccessful;
  118128. private _cachedWorldViewMatrix;
  118129. private _cachedWorldViewProjectionMatrix;
  118130. private _optimizers;
  118131. private _animationFrame;
  118132. /** Define the URl to load node editor script */
  118133. static EditorURL: string;
  118134. private BJSNODEMATERIALEDITOR;
  118135. /** Get the inspector from bundle or global */
  118136. private _getGlobalNodeMaterialEditor;
  118137. /**
  118138. * 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)
  118139. */
  118140. ignoreAlpha: boolean;
  118141. /**
  118142. * Defines the maximum number of lights that can be used in the material
  118143. */
  118144. maxSimultaneousLights: number;
  118145. /**
  118146. * Observable raised when the material is built
  118147. */
  118148. onBuildObservable: Observable<NodeMaterial>;
  118149. /**
  118150. * Gets or sets the root nodes of the material vertex shader
  118151. */
  118152. _vertexOutputNodes: NodeMaterialBlock[];
  118153. /**
  118154. * Gets or sets the root nodes of the material fragment (pixel) shader
  118155. */
  118156. _fragmentOutputNodes: NodeMaterialBlock[];
  118157. /** Gets or sets options to control the node material overall behavior */
  118158. options: INodeMaterialOptions;
  118159. /**
  118160. * Default configuration related to image processing available in the standard Material.
  118161. */
  118162. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  118163. /**
  118164. * Gets the image processing configuration used either in this material.
  118165. */
  118166. /**
  118167. * Sets the Default image processing configuration used either in the this material.
  118168. *
  118169. * If sets to null, the scene one is in use.
  118170. */
  118171. imageProcessingConfiguration: ImageProcessingConfiguration;
  118172. /**
  118173. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  118174. */
  118175. attachedBlocks: NodeMaterialBlock[];
  118176. /**
  118177. * Create a new node based material
  118178. * @param name defines the material name
  118179. * @param scene defines the hosting scene
  118180. * @param options defines creation option
  118181. */
  118182. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  118183. /**
  118184. * Gets the current class name of the material e.g. "NodeMaterial"
  118185. * @returns the class name
  118186. */
  118187. getClassName(): string;
  118188. /**
  118189. * Keep track of the image processing observer to allow dispose and replace.
  118190. */
  118191. private _imageProcessingObserver;
  118192. /**
  118193. * Attaches a new image processing configuration to the Standard Material.
  118194. * @param configuration
  118195. */
  118196. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  118197. /**
  118198. * Get a block by its name
  118199. * @param name defines the name of the block to retrieve
  118200. * @returns the required block or null if not found
  118201. */
  118202. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  118203. /**
  118204. * Get a block by its name
  118205. * @param predicate defines the predicate used to find the good candidate
  118206. * @returns the required block or null if not found
  118207. */
  118208. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  118209. /**
  118210. * Get an input block by its name
  118211. * @param predicate defines the predicate used to find the good candidate
  118212. * @returns the required input block or null if not found
  118213. */
  118214. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  118215. /**
  118216. * Gets the list of input blocks attached to this material
  118217. * @returns an array of InputBlocks
  118218. */
  118219. getInputBlocks(): InputBlock[];
  118220. /**
  118221. * Adds a new optimizer to the list of optimizers
  118222. * @param optimizer defines the optimizers to add
  118223. * @returns the current material
  118224. */
  118225. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  118226. /**
  118227. * Remove an optimizer from the list of optimizers
  118228. * @param optimizer defines the optimizers to remove
  118229. * @returns the current material
  118230. */
  118231. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  118232. /**
  118233. * Add a new block to the list of output nodes
  118234. * @param node defines the node to add
  118235. * @returns the current material
  118236. */
  118237. addOutputNode(node: NodeMaterialBlock): this;
  118238. /**
  118239. * Remove a block from the list of root nodes
  118240. * @param node defines the node to remove
  118241. * @returns the current material
  118242. */
  118243. removeOutputNode(node: NodeMaterialBlock): this;
  118244. private _addVertexOutputNode;
  118245. private _removeVertexOutputNode;
  118246. private _addFragmentOutputNode;
  118247. private _removeFragmentOutputNode;
  118248. /**
  118249. * Specifies if the material will require alpha blending
  118250. * @returns a boolean specifying if alpha blending is needed
  118251. */
  118252. needAlphaBlending(): boolean;
  118253. /**
  118254. * Specifies if this material should be rendered in alpha test mode
  118255. * @returns a boolean specifying if an alpha test is needed.
  118256. */
  118257. needAlphaTesting(): boolean;
  118258. private _initializeBlock;
  118259. private _resetDualBlocks;
  118260. /**
  118261. * Build the material and generates the inner effect
  118262. * @param verbose defines if the build should log activity
  118263. */
  118264. build(verbose?: boolean): void;
  118265. /**
  118266. * Runs an otpimization phase to try to improve the shader code
  118267. */
  118268. optimize(): void;
  118269. private _prepareDefinesForAttributes;
  118270. /**
  118271. * Get if the submesh is ready to be used and all its information available.
  118272. * Child classes can use it to update shaders
  118273. * @param mesh defines the mesh to check
  118274. * @param subMesh defines which submesh to check
  118275. * @param useInstances specifies that instances should be used
  118276. * @returns a boolean indicating that the submesh is ready or not
  118277. */
  118278. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  118279. /**
  118280. * Get a string representing the shaders built by the current node graph
  118281. */
  118282. readonly compiledShaders: string;
  118283. /**
  118284. * Binds the world matrix to the material
  118285. * @param world defines the world transformation matrix
  118286. */
  118287. bindOnlyWorldMatrix(world: Matrix): void;
  118288. /**
  118289. * Binds the submesh to this material by preparing the effect and shader to draw
  118290. * @param world defines the world transformation matrix
  118291. * @param mesh defines the mesh containing the submesh
  118292. * @param subMesh defines the submesh to bind the material to
  118293. */
  118294. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  118295. /**
  118296. * Gets the active textures from the material
  118297. * @returns an array of textures
  118298. */
  118299. getActiveTextures(): BaseTexture[];
  118300. /**
  118301. * Gets the list of texture blocks
  118302. * @returns an array of texture blocks
  118303. */
  118304. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  118305. /**
  118306. * Specifies if the material uses a texture
  118307. * @param texture defines the texture to check against the material
  118308. * @returns a boolean specifying if the material uses the texture
  118309. */
  118310. hasTexture(texture: BaseTexture): boolean;
  118311. /**
  118312. * Disposes the material
  118313. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  118314. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  118315. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  118316. */
  118317. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  118318. /** Creates the node editor window. */
  118319. private _createNodeEditor;
  118320. /**
  118321. * Launch the node material editor
  118322. * @param config Define the configuration of the editor
  118323. * @return a promise fulfilled when the node editor is visible
  118324. */
  118325. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  118326. /**
  118327. * Clear the current material
  118328. */
  118329. clear(): void;
  118330. /**
  118331. * Clear the current material and set it to a default state
  118332. */
  118333. setToDefault(): void;
  118334. /**
  118335. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  118336. * @param url defines the url to load from
  118337. * @returns a promise that will fullfil when the material is fully loaded
  118338. */
  118339. loadAsync(url: string): Promise<unknown>;
  118340. private _gatherBlocks;
  118341. /**
  118342. * Generate a string containing the code declaration required to create an equivalent of this material
  118343. * @returns a string
  118344. */
  118345. generateCode(): string;
  118346. /**
  118347. * Serializes this material in a JSON representation
  118348. * @returns the serialized material object
  118349. */
  118350. serialize(): any;
  118351. private _restoreConnections;
  118352. /**
  118353. * Clear the current graph and load a new one from a serialization object
  118354. * @param source defines the JSON representation of the material
  118355. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  118356. */
  118357. loadFromSerialization(source: any, rootUrl?: string): void;
  118358. /**
  118359. * Creates a node material from parsed material data
  118360. * @param source defines the JSON representation of the material
  118361. * @param scene defines the hosting scene
  118362. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  118363. * @returns a new node material
  118364. */
  118365. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  118366. /**
  118367. * Creates a new node material set to default basic configuration
  118368. * @param name defines the name of the material
  118369. * @param scene defines the hosting scene
  118370. * @returns a new NodeMaterial
  118371. */
  118372. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  118373. }
  118374. }
  118375. declare module BABYLON {
  118376. /**
  118377. * Block used to read a texture from a sampler
  118378. */
  118379. export class TextureBlock extends NodeMaterialBlock {
  118380. private _defineName;
  118381. private _samplerName;
  118382. private _transformedUVName;
  118383. private _textureTransformName;
  118384. private _textureInfoName;
  118385. private _mainUVName;
  118386. private _mainUVDefineName;
  118387. /**
  118388. * Gets or sets the texture associated with the node
  118389. */
  118390. texture: Nullable<Texture>;
  118391. /**
  118392. * Create a new TextureBlock
  118393. * @param name defines the block name
  118394. */
  118395. constructor(name: string);
  118396. /**
  118397. * Gets the current class name
  118398. * @returns the class name
  118399. */
  118400. getClassName(): string;
  118401. /**
  118402. * Gets the uv input component
  118403. */
  118404. readonly uv: NodeMaterialConnectionPoint;
  118405. /**
  118406. * Gets the rgba output component
  118407. */
  118408. readonly rgba: NodeMaterialConnectionPoint;
  118409. /**
  118410. * Gets the rgb output component
  118411. */
  118412. readonly rgb: NodeMaterialConnectionPoint;
  118413. /**
  118414. * Gets the r output component
  118415. */
  118416. readonly r: NodeMaterialConnectionPoint;
  118417. /**
  118418. * Gets the g output component
  118419. */
  118420. readonly g: NodeMaterialConnectionPoint;
  118421. /**
  118422. * Gets the b output component
  118423. */
  118424. readonly b: NodeMaterialConnectionPoint;
  118425. /**
  118426. * Gets the a output component
  118427. */
  118428. readonly a: NodeMaterialConnectionPoint;
  118429. readonly target: NodeMaterialBlockTargets;
  118430. autoConfigure(material: NodeMaterial): void;
  118431. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  118432. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118433. isReady(): boolean;
  118434. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118435. private readonly _isMixed;
  118436. private _injectVertexCode;
  118437. private _writeOutput;
  118438. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  118439. protected _dumpPropertiesCode(): string;
  118440. serialize(): any;
  118441. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118442. }
  118443. }
  118444. declare module BABYLON {
  118445. /**
  118446. * Class used to store shared data between 2 NodeMaterialBuildState
  118447. */
  118448. export class NodeMaterialBuildStateSharedData {
  118449. /**
  118450. * Gets the list of emitted varyings
  118451. */
  118452. temps: string[];
  118453. /**
  118454. * Gets the list of emitted varyings
  118455. */
  118456. varyings: string[];
  118457. /**
  118458. * Gets the varying declaration string
  118459. */
  118460. varyingDeclaration: string;
  118461. /**
  118462. * Input blocks
  118463. */
  118464. inputBlocks: InputBlock[];
  118465. /**
  118466. * Input blocks
  118467. */
  118468. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  118469. /**
  118470. * Bindable blocks (Blocks that need to set data to the effect)
  118471. */
  118472. bindableBlocks: NodeMaterialBlock[];
  118473. /**
  118474. * List of blocks that can provide a compilation fallback
  118475. */
  118476. blocksWithFallbacks: NodeMaterialBlock[];
  118477. /**
  118478. * List of blocks that can provide a define update
  118479. */
  118480. blocksWithDefines: NodeMaterialBlock[];
  118481. /**
  118482. * List of blocks that can provide a repeatable content
  118483. */
  118484. repeatableContentBlocks: NodeMaterialBlock[];
  118485. /**
  118486. * List of blocks that can provide a dynamic list of uniforms
  118487. */
  118488. dynamicUniformBlocks: NodeMaterialBlock[];
  118489. /**
  118490. * List of blocks that can block the isReady function for the material
  118491. */
  118492. blockingBlocks: NodeMaterialBlock[];
  118493. /**
  118494. * Gets the list of animated inputs
  118495. */
  118496. animatedInputs: InputBlock[];
  118497. /**
  118498. * Build Id used to avoid multiple recompilations
  118499. */
  118500. buildId: number;
  118501. /** List of emitted variables */
  118502. variableNames: {
  118503. [key: string]: number;
  118504. };
  118505. /** List of emitted defines */
  118506. defineNames: {
  118507. [key: string]: number;
  118508. };
  118509. /** Should emit comments? */
  118510. emitComments: boolean;
  118511. /** Emit build activity */
  118512. verbose: boolean;
  118513. /** Gets or sets the hosting scene */
  118514. scene: Scene;
  118515. /**
  118516. * Gets the compilation hints emitted at compilation time
  118517. */
  118518. hints: {
  118519. needWorldViewMatrix: boolean;
  118520. needWorldViewProjectionMatrix: boolean;
  118521. needAlphaBlending: boolean;
  118522. needAlphaTesting: boolean;
  118523. };
  118524. /**
  118525. * List of compilation checks
  118526. */
  118527. checks: {
  118528. emitVertex: boolean;
  118529. emitFragment: boolean;
  118530. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  118531. };
  118532. /** Creates a new shared data */
  118533. constructor();
  118534. /**
  118535. * Emits console errors and exceptions if there is a failing check
  118536. */
  118537. emitErrors(): void;
  118538. }
  118539. }
  118540. declare module BABYLON {
  118541. /**
  118542. * Class used to store node based material build state
  118543. */
  118544. export class NodeMaterialBuildState {
  118545. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  118546. supportUniformBuffers: boolean;
  118547. /**
  118548. * Gets the list of emitted attributes
  118549. */
  118550. attributes: string[];
  118551. /**
  118552. * Gets the list of emitted uniforms
  118553. */
  118554. uniforms: string[];
  118555. /**
  118556. * Gets the list of emitted constants
  118557. */
  118558. constants: string[];
  118559. /**
  118560. * Gets the list of emitted uniform buffers
  118561. */
  118562. uniformBuffers: string[];
  118563. /**
  118564. * Gets the list of emitted samplers
  118565. */
  118566. samplers: string[];
  118567. /**
  118568. * Gets the list of emitted functions
  118569. */
  118570. functions: {
  118571. [key: string]: string;
  118572. };
  118573. /**
  118574. * Gets the list of emitted extensions
  118575. */
  118576. extensions: {
  118577. [key: string]: string;
  118578. };
  118579. /**
  118580. * Gets the target of the compilation state
  118581. */
  118582. target: NodeMaterialBlockTargets;
  118583. /**
  118584. * Gets the list of emitted counters
  118585. */
  118586. counters: {
  118587. [key: string]: number;
  118588. };
  118589. /**
  118590. * Shared data between multiple NodeMaterialBuildState instances
  118591. */
  118592. sharedData: NodeMaterialBuildStateSharedData;
  118593. /** @hidden */
  118594. _vertexState: NodeMaterialBuildState;
  118595. /** @hidden */
  118596. _attributeDeclaration: string;
  118597. /** @hidden */
  118598. _uniformDeclaration: string;
  118599. /** @hidden */
  118600. _constantDeclaration: string;
  118601. /** @hidden */
  118602. _samplerDeclaration: string;
  118603. /** @hidden */
  118604. _varyingTransfer: string;
  118605. private _repeatableContentAnchorIndex;
  118606. /** @hidden */
  118607. _builtCompilationString: string;
  118608. /**
  118609. * Gets the emitted compilation strings
  118610. */
  118611. compilationString: string;
  118612. /**
  118613. * Finalize the compilation strings
  118614. * @param state defines the current compilation state
  118615. */
  118616. finalize(state: NodeMaterialBuildState): void;
  118617. /** @hidden */
  118618. readonly _repeatableContentAnchor: string;
  118619. /** @hidden */
  118620. _getFreeVariableName(prefix: string): string;
  118621. /** @hidden */
  118622. _getFreeDefineName(prefix: string): string;
  118623. /** @hidden */
  118624. _excludeVariableName(name: string): void;
  118625. /** @hidden */
  118626. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  118627. /** @hidden */
  118628. _emitExtension(name: string, extension: string): void;
  118629. /** @hidden */
  118630. _emitFunction(name: string, code: string, comments: string): void;
  118631. /** @hidden */
  118632. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  118633. replaceStrings?: {
  118634. search: RegExp;
  118635. replace: string;
  118636. }[];
  118637. repeatKey?: string;
  118638. }): string;
  118639. /** @hidden */
  118640. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  118641. repeatKey?: string;
  118642. removeAttributes?: boolean;
  118643. removeUniforms?: boolean;
  118644. removeVaryings?: boolean;
  118645. removeIfDef?: boolean;
  118646. replaceStrings?: {
  118647. search: RegExp;
  118648. replace: string;
  118649. }[];
  118650. }, storeKey?: string): void;
  118651. /** @hidden */
  118652. _registerTempVariable(name: string): boolean;
  118653. /** @hidden */
  118654. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  118655. /** @hidden */
  118656. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  118657. }
  118658. }
  118659. declare module BABYLON {
  118660. /**
  118661. * Defines a block that can be used inside a node based material
  118662. */
  118663. export class NodeMaterialBlock {
  118664. private _buildId;
  118665. private _buildTarget;
  118666. private _target;
  118667. private _isFinalMerger;
  118668. private _isInput;
  118669. /** @hidden */
  118670. _codeVariableName: string;
  118671. /** @hidden */
  118672. _inputs: NodeMaterialConnectionPoint[];
  118673. /** @hidden */
  118674. _outputs: NodeMaterialConnectionPoint[];
  118675. /** @hidden */
  118676. _preparationId: number;
  118677. /**
  118678. * Gets or sets the name of the block
  118679. */
  118680. name: string;
  118681. /**
  118682. * Gets or sets the unique id of the node
  118683. */
  118684. uniqueId: number;
  118685. /**
  118686. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  118687. */
  118688. readonly isFinalMerger: boolean;
  118689. /**
  118690. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  118691. */
  118692. readonly isInput: boolean;
  118693. /**
  118694. * Gets or sets the build Id
  118695. */
  118696. buildId: number;
  118697. /**
  118698. * Gets or sets the target of the block
  118699. */
  118700. target: NodeMaterialBlockTargets;
  118701. /**
  118702. * Gets the list of input points
  118703. */
  118704. readonly inputs: NodeMaterialConnectionPoint[];
  118705. /** Gets the list of output points */
  118706. readonly outputs: NodeMaterialConnectionPoint[];
  118707. /**
  118708. * Find an input by its name
  118709. * @param name defines the name of the input to look for
  118710. * @returns the input or null if not found
  118711. */
  118712. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  118713. /**
  118714. * Find an output by its name
  118715. * @param name defines the name of the outputto look for
  118716. * @returns the output or null if not found
  118717. */
  118718. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  118719. /**
  118720. * Creates a new NodeMaterialBlock
  118721. * @param name defines the block name
  118722. * @param target defines the target of that block (Vertex by default)
  118723. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  118724. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  118725. */
  118726. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  118727. /**
  118728. * Initialize the block and prepare the context for build
  118729. * @param state defines the state that will be used for the build
  118730. */
  118731. initialize(state: NodeMaterialBuildState): void;
  118732. /**
  118733. * Bind data to effect. Will only be called for blocks with isBindable === true
  118734. * @param effect defines the effect to bind data to
  118735. * @param nodeMaterial defines the hosting NodeMaterial
  118736. * @param mesh defines the mesh that will be rendered
  118737. */
  118738. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118739. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  118740. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  118741. protected _writeFloat(value: number): string;
  118742. /**
  118743. * Gets the current class name e.g. "NodeMaterialBlock"
  118744. * @returns the class name
  118745. */
  118746. getClassName(): string;
  118747. /**
  118748. * Register a new input. Must be called inside a block constructor
  118749. * @param name defines the connection point name
  118750. * @param type defines the connection point type
  118751. * @param isOptional defines a boolean indicating that this input can be omitted
  118752. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  118753. * @returns the current block
  118754. */
  118755. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  118756. /**
  118757. * Register a new output. Must be called inside a block constructor
  118758. * @param name defines the connection point name
  118759. * @param type defines the connection point type
  118760. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  118761. * @returns the current block
  118762. */
  118763. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  118764. /**
  118765. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  118766. * @param forOutput defines an optional connection point to check compatibility with
  118767. * @returns the first available input or null
  118768. */
  118769. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  118770. /**
  118771. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  118772. * @param forBlock defines an optional block to check compatibility with
  118773. * @returns the first available input or null
  118774. */
  118775. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  118776. /**
  118777. * Gets the sibling of the given output
  118778. * @param current defines the current output
  118779. * @returns the next output in the list or null
  118780. */
  118781. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  118782. /**
  118783. * Connect current block with another block
  118784. * @param other defines the block to connect with
  118785. * @param options define the various options to help pick the right connections
  118786. * @returns the current block
  118787. */
  118788. connectTo(other: NodeMaterialBlock, options?: {
  118789. input?: string;
  118790. output?: string;
  118791. outputSwizzle?: string;
  118792. }): this | undefined;
  118793. protected _buildBlock(state: NodeMaterialBuildState): void;
  118794. /**
  118795. * Add uniforms, samplers and uniform buffers at compilation time
  118796. * @param state defines the state to update
  118797. * @param nodeMaterial defines the node material requesting the update
  118798. * @param defines defines the material defines to update
  118799. */
  118800. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118801. /**
  118802. * Add potential fallbacks if shader compilation fails
  118803. * @param mesh defines the mesh to be rendered
  118804. * @param fallbacks defines the current prioritized list of fallbacks
  118805. */
  118806. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  118807. /**
  118808. * Initialize defines for shader compilation
  118809. * @param mesh defines the mesh to be rendered
  118810. * @param nodeMaterial defines the node material requesting the update
  118811. * @param defines defines the material defines to update
  118812. * @param useInstances specifies that instances should be used
  118813. */
  118814. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  118815. /**
  118816. * Update defines for shader compilation
  118817. * @param mesh defines the mesh to be rendered
  118818. * @param nodeMaterial defines the node material requesting the update
  118819. * @param defines defines the material defines to update
  118820. * @param useInstances specifies that instances should be used
  118821. */
  118822. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  118823. /**
  118824. * Lets the block try to connect some inputs automatically
  118825. * @param material defines the hosting NodeMaterial
  118826. */
  118827. autoConfigure(material: NodeMaterial): void;
  118828. /**
  118829. * Function called when a block is declared as repeatable content generator
  118830. * @param vertexShaderState defines the current compilation state for the vertex shader
  118831. * @param fragmentShaderState defines the current compilation state for the fragment shader
  118832. * @param mesh defines the mesh to be rendered
  118833. * @param defines defines the material defines to update
  118834. */
  118835. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  118836. /**
  118837. * Checks if the block is ready
  118838. * @param mesh defines the mesh to be rendered
  118839. * @param nodeMaterial defines the node material requesting the update
  118840. * @param defines defines the material defines to update
  118841. * @param useInstances specifies that instances should be used
  118842. * @returns true if the block is ready
  118843. */
  118844. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  118845. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  118846. private _processBuild;
  118847. /**
  118848. * Compile the current node and generate the shader code
  118849. * @param state defines the current compilation state (uniforms, samplers, current string)
  118850. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  118851. * @returns true if already built
  118852. */
  118853. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  118854. protected _inputRename(name: string): string;
  118855. protected _outputRename(name: string): string;
  118856. protected _dumpPropertiesCode(): string;
  118857. /** @hidden */
  118858. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  118859. /**
  118860. * Clone the current block to a new identical block
  118861. * @param scene defines the hosting scene
  118862. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  118863. * @returns a copy of the current block
  118864. */
  118865. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  118866. /**
  118867. * Serializes this block in a JSON representation
  118868. * @returns the serialized block object
  118869. */
  118870. serialize(): any;
  118871. /** @hidden */
  118872. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118873. }
  118874. }
  118875. declare module BABYLON {
  118876. /**
  118877. * Enum defining the type of animations supported by InputBlock
  118878. */
  118879. export enum AnimatedInputBlockTypes {
  118880. /** No animation */
  118881. None = 0,
  118882. /** Time based animation. Will only work for floats */
  118883. Time = 1
  118884. }
  118885. }
  118886. declare module BABYLON {
  118887. /**
  118888. * Block used to expose an input value
  118889. */
  118890. export class InputBlock extends NodeMaterialBlock {
  118891. private _mode;
  118892. private _associatedVariableName;
  118893. private _storedValue;
  118894. private _valueCallback;
  118895. private _type;
  118896. private _animationType;
  118897. /** Gets or set a value used to limit the range of float values */
  118898. min: number;
  118899. /** Gets or set a value used to limit the range of float values */
  118900. max: number;
  118901. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  118902. matrixMode: number;
  118903. /** @hidden */
  118904. _systemValue: Nullable<NodeMaterialSystemValues>;
  118905. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  118906. visibleInInspector: boolean;
  118907. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  118908. isConstant: boolean;
  118909. /**
  118910. * Gets or sets the connection point type (default is float)
  118911. */
  118912. readonly type: NodeMaterialBlockConnectionPointTypes;
  118913. /**
  118914. * Creates a new InputBlock
  118915. * @param name defines the block name
  118916. * @param target defines the target of that block (Vertex by default)
  118917. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  118918. */
  118919. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  118920. /**
  118921. * Gets the output component
  118922. */
  118923. readonly output: NodeMaterialConnectionPoint;
  118924. /**
  118925. * Set the source of this connection point to a vertex attribute
  118926. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  118927. * @returns the current connection point
  118928. */
  118929. setAsAttribute(attributeName?: string): InputBlock;
  118930. /**
  118931. * Set the source of this connection point to a system value
  118932. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  118933. * @returns the current connection point
  118934. */
  118935. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  118936. /**
  118937. * Gets or sets the value of that point.
  118938. * Please note that this value will be ignored if valueCallback is defined
  118939. */
  118940. value: any;
  118941. /**
  118942. * Gets or sets a callback used to get the value of that point.
  118943. * Please note that setting this value will force the connection point to ignore the value property
  118944. */
  118945. valueCallback: () => any;
  118946. /**
  118947. * Gets or sets the associated variable name in the shader
  118948. */
  118949. associatedVariableName: string;
  118950. /** Gets or sets the type of animation applied to the input */
  118951. animationType: AnimatedInputBlockTypes;
  118952. /**
  118953. * Gets a boolean indicating that this connection point not defined yet
  118954. */
  118955. readonly isUndefined: boolean;
  118956. /**
  118957. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  118958. * In this case the connection point name must be the name of the uniform to use.
  118959. * Can only be set on inputs
  118960. */
  118961. isUniform: boolean;
  118962. /**
  118963. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  118964. * In this case the connection point name must be the name of the attribute to use
  118965. * Can only be set on inputs
  118966. */
  118967. isAttribute: boolean;
  118968. /**
  118969. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  118970. * Can only be set on exit points
  118971. */
  118972. isVarying: boolean;
  118973. /**
  118974. * Gets a boolean indicating that the current connection point is a system value
  118975. */
  118976. readonly isSystemValue: boolean;
  118977. /**
  118978. * Gets or sets the current well known value or null if not defined as a system value
  118979. */
  118980. systemValue: Nullable<NodeMaterialSystemValues>;
  118981. /**
  118982. * Gets the current class name
  118983. * @returns the class name
  118984. */
  118985. getClassName(): string;
  118986. /**
  118987. * Animate the input if animationType !== None
  118988. * @param scene defines the rendering scene
  118989. */
  118990. animate(scene: Scene): void;
  118991. private _emitDefine;
  118992. initialize(state: NodeMaterialBuildState): void;
  118993. /**
  118994. * Set the input block to its default value (based on its type)
  118995. */
  118996. setDefaultValue(): void;
  118997. private _emitConstant;
  118998. private _emit;
  118999. /** @hidden */
  119000. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  119001. /** @hidden */
  119002. _transmit(effect: Effect, scene: Scene): void;
  119003. protected _buildBlock(state: NodeMaterialBuildState): void;
  119004. protected _dumpPropertiesCode(): string;
  119005. serialize(): any;
  119006. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119007. }
  119008. }
  119009. declare module BABYLON {
  119010. /**
  119011. * Defines a connection point for a block
  119012. */
  119013. export class NodeMaterialConnectionPoint {
  119014. /** @hidden */
  119015. _ownerBlock: NodeMaterialBlock;
  119016. /** @hidden */
  119017. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  119018. private _endpoints;
  119019. private _associatedVariableName;
  119020. /** @hidden */
  119021. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  119022. /** @hidden */
  119023. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  119024. private _type;
  119025. /** @hidden */
  119026. _enforceAssociatedVariableName: boolean;
  119027. /**
  119028. * Gets or sets the additional types supported by this connection point
  119029. */
  119030. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  119031. /**
  119032. * Gets or sets the additional types excluded by this connection point
  119033. */
  119034. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  119035. /**
  119036. * Gets or sets the associated variable name in the shader
  119037. */
  119038. associatedVariableName: string;
  119039. /**
  119040. * Gets or sets the connection point type (default is float)
  119041. */
  119042. type: NodeMaterialBlockConnectionPointTypes;
  119043. /**
  119044. * Gets or sets the connection point name
  119045. */
  119046. name: string;
  119047. /**
  119048. * Gets or sets a boolean indicating that this connection point can be omitted
  119049. */
  119050. isOptional: boolean;
  119051. /**
  119052. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  119053. */
  119054. define: string;
  119055. /** Gets or sets the target of that connection point */
  119056. target: NodeMaterialBlockTargets;
  119057. /**
  119058. * Gets a boolean indicating that the current point is connected
  119059. */
  119060. readonly isConnected: boolean;
  119061. /**
  119062. * Gets a boolean indicating that the current point is connected to an input block
  119063. */
  119064. readonly isConnectedToInputBlock: boolean;
  119065. /**
  119066. * Gets a the connected input block (if any)
  119067. */
  119068. readonly connectInputBlock: Nullable<InputBlock>;
  119069. /** Get the other side of the connection (if any) */
  119070. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  119071. /** Get the block that owns this connection point */
  119072. readonly ownerBlock: NodeMaterialBlock;
  119073. /** Get the block connected on the other side of this connection (if any) */
  119074. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  119075. /** Get the block connected on the endpoints of this connection (if any) */
  119076. readonly connectedBlocks: Array<NodeMaterialBlock>;
  119077. /** Gets the list of connected endpoints */
  119078. readonly endpoints: NodeMaterialConnectionPoint[];
  119079. /** Gets a boolean indicating if that output point is connected to at least one input */
  119080. readonly hasEndpoints: boolean;
  119081. /**
  119082. * Creates a new connection point
  119083. * @param name defines the connection point name
  119084. * @param ownerBlock defines the block hosting this connection point
  119085. */
  119086. constructor(name: string, ownerBlock: NodeMaterialBlock);
  119087. /**
  119088. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  119089. * @returns the class name
  119090. */
  119091. getClassName(): string;
  119092. /**
  119093. * Gets an boolean indicating if the current point can be connected to another point
  119094. * @param connectionPoint defines the other connection point
  119095. * @returns true if the connection is possible
  119096. */
  119097. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  119098. /**
  119099. * Connect this point to another connection point
  119100. * @param connectionPoint defines the other connection point
  119101. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  119102. * @returns the current connection point
  119103. */
  119104. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  119105. /**
  119106. * Disconnect this point from one of his endpoint
  119107. * @param endpoint defines the other connection point
  119108. * @returns the current connection point
  119109. */
  119110. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  119111. /**
  119112. * Serializes this point in a JSON representation
  119113. * @returns the serialized point object
  119114. */
  119115. serialize(): any;
  119116. }
  119117. }
  119118. declare module BABYLON {
  119119. /**
  119120. * Block used to add support for vertex skinning (bones)
  119121. */
  119122. export class BonesBlock extends NodeMaterialBlock {
  119123. /**
  119124. * Creates a new BonesBlock
  119125. * @param name defines the block name
  119126. */
  119127. constructor(name: string);
  119128. /**
  119129. * Initialize the block and prepare the context for build
  119130. * @param state defines the state that will be used for the build
  119131. */
  119132. initialize(state: NodeMaterialBuildState): void;
  119133. /**
  119134. * Gets the current class name
  119135. * @returns the class name
  119136. */
  119137. getClassName(): string;
  119138. /**
  119139. * Gets the matrix indices input component
  119140. */
  119141. readonly matricesIndices: NodeMaterialConnectionPoint;
  119142. /**
  119143. * Gets the matrix weights input component
  119144. */
  119145. readonly matricesWeights: NodeMaterialConnectionPoint;
  119146. /**
  119147. * Gets the extra matrix indices input component
  119148. */
  119149. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  119150. /**
  119151. * Gets the extra matrix weights input component
  119152. */
  119153. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  119154. /**
  119155. * Gets the world input component
  119156. */
  119157. readonly world: NodeMaterialConnectionPoint;
  119158. /**
  119159. * Gets the output component
  119160. */
  119161. readonly output: NodeMaterialConnectionPoint;
  119162. autoConfigure(material: NodeMaterial): void;
  119163. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  119164. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119165. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119166. protected _buildBlock(state: NodeMaterialBuildState): this;
  119167. }
  119168. }
  119169. declare module BABYLON {
  119170. /**
  119171. * Block used to add support for instances
  119172. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  119173. */
  119174. export class InstancesBlock extends NodeMaterialBlock {
  119175. /**
  119176. * Creates a new InstancesBlock
  119177. * @param name defines the block name
  119178. */
  119179. constructor(name: string);
  119180. /**
  119181. * Gets the current class name
  119182. * @returns the class name
  119183. */
  119184. getClassName(): string;
  119185. /**
  119186. * Gets the first world row input component
  119187. */
  119188. readonly world0: NodeMaterialConnectionPoint;
  119189. /**
  119190. * Gets the second world row input component
  119191. */
  119192. readonly world1: NodeMaterialConnectionPoint;
  119193. /**
  119194. * Gets the third world row input component
  119195. */
  119196. readonly world2: NodeMaterialConnectionPoint;
  119197. /**
  119198. * Gets the forth world row input component
  119199. */
  119200. readonly world3: NodeMaterialConnectionPoint;
  119201. /**
  119202. * Gets the world input component
  119203. */
  119204. readonly world: NodeMaterialConnectionPoint;
  119205. /**
  119206. * Gets the output component
  119207. */
  119208. readonly output: NodeMaterialConnectionPoint;
  119209. autoConfigure(material: NodeMaterial): void;
  119210. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  119211. protected _buildBlock(state: NodeMaterialBuildState): this;
  119212. }
  119213. }
  119214. declare module BABYLON {
  119215. /**
  119216. * Block used to add morph targets support to vertex shader
  119217. */
  119218. export class MorphTargetsBlock extends NodeMaterialBlock {
  119219. private _repeatableContentAnchor;
  119220. private _repeatebleContentGenerated;
  119221. /**
  119222. * Create a new MorphTargetsBlock
  119223. * @param name defines the block name
  119224. */
  119225. constructor(name: string);
  119226. /**
  119227. * Gets the current class name
  119228. * @returns the class name
  119229. */
  119230. getClassName(): string;
  119231. /**
  119232. * Gets the position input component
  119233. */
  119234. readonly position: NodeMaterialConnectionPoint;
  119235. /**
  119236. * Gets the normal input component
  119237. */
  119238. readonly normal: NodeMaterialConnectionPoint;
  119239. /**
  119240. * Gets the tangent input component
  119241. */
  119242. readonly tangent: NodeMaterialConnectionPoint;
  119243. /**
  119244. * Gets the tangent input component
  119245. */
  119246. readonly uv: NodeMaterialConnectionPoint;
  119247. /**
  119248. * Gets the position output component
  119249. */
  119250. readonly positionOutput: NodeMaterialConnectionPoint;
  119251. /**
  119252. * Gets the normal output component
  119253. */
  119254. readonly normalOutput: NodeMaterialConnectionPoint;
  119255. /**
  119256. * Gets the tangent output component
  119257. */
  119258. readonly tangentOutput: NodeMaterialConnectionPoint;
  119259. /**
  119260. * Gets the tangent output component
  119261. */
  119262. readonly uvOutput: NodeMaterialConnectionPoint;
  119263. initialize(state: NodeMaterialBuildState): void;
  119264. autoConfigure(material: NodeMaterial): void;
  119265. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119266. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119267. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  119268. protected _buildBlock(state: NodeMaterialBuildState): this;
  119269. }
  119270. }
  119271. declare module BABYLON {
  119272. /**
  119273. * Block used to get data information from a light
  119274. */
  119275. export class LightInformationBlock extends NodeMaterialBlock {
  119276. private _lightDataUniformName;
  119277. private _lightColorUniformName;
  119278. private _lightTypeDefineName;
  119279. /**
  119280. * Gets or sets the light associated with this block
  119281. */
  119282. light: Nullable<Light>;
  119283. /**
  119284. * Creates a new LightInformationBlock
  119285. * @param name defines the block name
  119286. */
  119287. constructor(name: string);
  119288. /**
  119289. * Gets the current class name
  119290. * @returns the class name
  119291. */
  119292. getClassName(): string;
  119293. /**
  119294. * Gets the world position input component
  119295. */
  119296. readonly worldPosition: NodeMaterialConnectionPoint;
  119297. /**
  119298. * Gets the direction output component
  119299. */
  119300. readonly direction: NodeMaterialConnectionPoint;
  119301. /**
  119302. * Gets the direction output component
  119303. */
  119304. readonly color: NodeMaterialConnectionPoint;
  119305. /**
  119306. * Gets the direction output component
  119307. */
  119308. readonly intensity: NodeMaterialConnectionPoint;
  119309. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119310. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119311. protected _buildBlock(state: NodeMaterialBuildState): this;
  119312. serialize(): any;
  119313. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119314. }
  119315. }
  119316. declare module BABYLON {
  119317. /**
  119318. * Block used to add image processing support to fragment shader
  119319. */
  119320. export class ImageProcessingBlock extends NodeMaterialBlock {
  119321. /**
  119322. * Create a new ImageProcessingBlock
  119323. * @param name defines the block name
  119324. */
  119325. constructor(name: string);
  119326. /**
  119327. * Gets the current class name
  119328. * @returns the class name
  119329. */
  119330. getClassName(): string;
  119331. /**
  119332. * Gets the color input component
  119333. */
  119334. readonly color: NodeMaterialConnectionPoint;
  119335. /**
  119336. * Gets the output component
  119337. */
  119338. readonly output: NodeMaterialConnectionPoint;
  119339. /**
  119340. * Initialize the block and prepare the context for build
  119341. * @param state defines the state that will be used for the build
  119342. */
  119343. initialize(state: NodeMaterialBuildState): void;
  119344. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  119345. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119346. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119347. protected _buildBlock(state: NodeMaterialBuildState): this;
  119348. }
  119349. }
  119350. declare module BABYLON {
  119351. /**
  119352. * Block used to pertub normals based on a normal map
  119353. */
  119354. export class PerturbNormalBlock extends NodeMaterialBlock {
  119355. private _tangentSpaceParameterName;
  119356. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  119357. invertX: boolean;
  119358. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  119359. invertY: boolean;
  119360. /**
  119361. * Create a new PerturbNormalBlock
  119362. * @param name defines the block name
  119363. */
  119364. constructor(name: string);
  119365. /**
  119366. * Gets the current class name
  119367. * @returns the class name
  119368. */
  119369. getClassName(): string;
  119370. /**
  119371. * Gets the world position input component
  119372. */
  119373. readonly worldPosition: NodeMaterialConnectionPoint;
  119374. /**
  119375. * Gets the world normal input component
  119376. */
  119377. readonly worldNormal: NodeMaterialConnectionPoint;
  119378. /**
  119379. * Gets the uv input component
  119380. */
  119381. readonly uv: NodeMaterialConnectionPoint;
  119382. /**
  119383. * Gets the normal map color input component
  119384. */
  119385. readonly normalMapColor: NodeMaterialConnectionPoint;
  119386. /**
  119387. * Gets the strength input component
  119388. */
  119389. readonly strength: NodeMaterialConnectionPoint;
  119390. /**
  119391. * Gets the output component
  119392. */
  119393. readonly output: NodeMaterialConnectionPoint;
  119394. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119395. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119396. autoConfigure(material: NodeMaterial): void;
  119397. protected _buildBlock(state: NodeMaterialBuildState): this;
  119398. protected _dumpPropertiesCode(): string;
  119399. serialize(): any;
  119400. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119401. }
  119402. }
  119403. declare module BABYLON {
  119404. /**
  119405. * Block used to discard a pixel if a value is smaller than a cutoff
  119406. */
  119407. export class DiscardBlock extends NodeMaterialBlock {
  119408. /**
  119409. * Create a new DiscardBlock
  119410. * @param name defines the block name
  119411. */
  119412. constructor(name: string);
  119413. /**
  119414. * Gets the current class name
  119415. * @returns the class name
  119416. */
  119417. getClassName(): string;
  119418. /**
  119419. * Gets the color input component
  119420. */
  119421. readonly value: NodeMaterialConnectionPoint;
  119422. /**
  119423. * Gets the cutoff input component
  119424. */
  119425. readonly cutoff: NodeMaterialConnectionPoint;
  119426. protected _buildBlock(state: NodeMaterialBuildState): this;
  119427. }
  119428. }
  119429. declare module BABYLON {
  119430. /**
  119431. * Block used to add support for scene fog
  119432. */
  119433. export class FogBlock extends NodeMaterialBlock {
  119434. private _fogDistanceName;
  119435. private _fogParameters;
  119436. /**
  119437. * Create a new FogBlock
  119438. * @param name defines the block name
  119439. */
  119440. constructor(name: string);
  119441. /**
  119442. * Gets the current class name
  119443. * @returns the class name
  119444. */
  119445. getClassName(): string;
  119446. /**
  119447. * Gets the world position input component
  119448. */
  119449. readonly worldPosition: NodeMaterialConnectionPoint;
  119450. /**
  119451. * Gets the view input component
  119452. */
  119453. readonly view: NodeMaterialConnectionPoint;
  119454. /**
  119455. * Gets the color input component
  119456. */
  119457. readonly input: NodeMaterialConnectionPoint;
  119458. /**
  119459. * Gets the fog color input component
  119460. */
  119461. readonly fogColor: NodeMaterialConnectionPoint;
  119462. /**
  119463. * Gets the output component
  119464. */
  119465. readonly output: NodeMaterialConnectionPoint;
  119466. autoConfigure(material: NodeMaterial): void;
  119467. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119468. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119469. protected _buildBlock(state: NodeMaterialBuildState): this;
  119470. }
  119471. }
  119472. declare module BABYLON {
  119473. /**
  119474. * Block used to add light in the fragment shader
  119475. */
  119476. export class LightBlock extends NodeMaterialBlock {
  119477. private _lightId;
  119478. /**
  119479. * Gets or sets the light associated with this block
  119480. */
  119481. light: Nullable<Light>;
  119482. /**
  119483. * Create a new LightBlock
  119484. * @param name defines the block name
  119485. */
  119486. constructor(name: string);
  119487. /**
  119488. * Gets the current class name
  119489. * @returns the class name
  119490. */
  119491. getClassName(): string;
  119492. /**
  119493. * Gets the world position input component
  119494. */
  119495. readonly worldPosition: NodeMaterialConnectionPoint;
  119496. /**
  119497. * Gets the world normal input component
  119498. */
  119499. readonly worldNormal: NodeMaterialConnectionPoint;
  119500. /**
  119501. * Gets the camera (or eye) position component
  119502. */
  119503. readonly cameraPosition: NodeMaterialConnectionPoint;
  119504. /**
  119505. * Gets the diffuse output component
  119506. */
  119507. readonly diffuseOutput: NodeMaterialConnectionPoint;
  119508. /**
  119509. * Gets the specular output component
  119510. */
  119511. readonly specularOutput: NodeMaterialConnectionPoint;
  119512. autoConfigure(material: NodeMaterial): void;
  119513. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119514. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119515. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119516. private _injectVertexCode;
  119517. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  119518. serialize(): any;
  119519. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119520. }
  119521. }
  119522. declare module BABYLON {
  119523. /**
  119524. * Block used to multiply 2 values
  119525. */
  119526. export class MultiplyBlock extends NodeMaterialBlock {
  119527. /**
  119528. * Creates a new MultiplyBlock
  119529. * @param name defines the block name
  119530. */
  119531. constructor(name: string);
  119532. /**
  119533. * Gets the current class name
  119534. * @returns the class name
  119535. */
  119536. getClassName(): string;
  119537. /**
  119538. * Gets the left operand input component
  119539. */
  119540. readonly left: NodeMaterialConnectionPoint;
  119541. /**
  119542. * Gets the right operand input component
  119543. */
  119544. readonly right: NodeMaterialConnectionPoint;
  119545. /**
  119546. * Gets the output component
  119547. */
  119548. readonly output: NodeMaterialConnectionPoint;
  119549. protected _buildBlock(state: NodeMaterialBuildState): this;
  119550. }
  119551. }
  119552. declare module BABYLON {
  119553. /**
  119554. * Block used to add 2 vectors
  119555. */
  119556. export class AddBlock extends NodeMaterialBlock {
  119557. /**
  119558. * Creates a new AddBlock
  119559. * @param name defines the block name
  119560. */
  119561. constructor(name: string);
  119562. /**
  119563. * Gets the current class name
  119564. * @returns the class name
  119565. */
  119566. getClassName(): string;
  119567. /**
  119568. * Gets the left operand input component
  119569. */
  119570. readonly left: NodeMaterialConnectionPoint;
  119571. /**
  119572. * Gets the right operand input component
  119573. */
  119574. readonly right: NodeMaterialConnectionPoint;
  119575. /**
  119576. * Gets the output component
  119577. */
  119578. readonly output: NodeMaterialConnectionPoint;
  119579. protected _buildBlock(state: NodeMaterialBuildState): this;
  119580. }
  119581. }
  119582. declare module BABYLON {
  119583. /**
  119584. * Block used to scale a vector by a float
  119585. */
  119586. export class ScaleBlock extends NodeMaterialBlock {
  119587. /**
  119588. * Creates a new ScaleBlock
  119589. * @param name defines the block name
  119590. */
  119591. constructor(name: string);
  119592. /**
  119593. * Gets the current class name
  119594. * @returns the class name
  119595. */
  119596. getClassName(): string;
  119597. /**
  119598. * Gets the input component
  119599. */
  119600. readonly input: NodeMaterialConnectionPoint;
  119601. /**
  119602. * Gets the factor input component
  119603. */
  119604. readonly factor: NodeMaterialConnectionPoint;
  119605. /**
  119606. * Gets the output component
  119607. */
  119608. readonly output: NodeMaterialConnectionPoint;
  119609. protected _buildBlock(state: NodeMaterialBuildState): this;
  119610. }
  119611. }
  119612. declare module BABYLON {
  119613. /**
  119614. * Block used to clamp a float
  119615. */
  119616. export class ClampBlock extends NodeMaterialBlock {
  119617. /** Gets or sets the minimum range */
  119618. minimum: number;
  119619. /** Gets or sets the maximum range */
  119620. maximum: number;
  119621. /**
  119622. * Creates a new ClampBlock
  119623. * @param name defines the block name
  119624. */
  119625. constructor(name: string);
  119626. /**
  119627. * Gets the current class name
  119628. * @returns the class name
  119629. */
  119630. getClassName(): string;
  119631. /**
  119632. * Gets the value input component
  119633. */
  119634. readonly value: NodeMaterialConnectionPoint;
  119635. /**
  119636. * Gets the output component
  119637. */
  119638. readonly output: NodeMaterialConnectionPoint;
  119639. protected _buildBlock(state: NodeMaterialBuildState): this;
  119640. protected _dumpPropertiesCode(): string;
  119641. serialize(): any;
  119642. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119643. }
  119644. }
  119645. declare module BABYLON {
  119646. /**
  119647. * Block used to apply a cross product between 2 vectors
  119648. */
  119649. export class CrossBlock extends NodeMaterialBlock {
  119650. /**
  119651. * Creates a new CrossBlock
  119652. * @param name defines the block name
  119653. */
  119654. constructor(name: string);
  119655. /**
  119656. * Gets the current class name
  119657. * @returns the class name
  119658. */
  119659. getClassName(): string;
  119660. /**
  119661. * Gets the left operand input component
  119662. */
  119663. readonly left: NodeMaterialConnectionPoint;
  119664. /**
  119665. * Gets the right operand input component
  119666. */
  119667. readonly right: NodeMaterialConnectionPoint;
  119668. /**
  119669. * Gets the output component
  119670. */
  119671. readonly output: NodeMaterialConnectionPoint;
  119672. protected _buildBlock(state: NodeMaterialBuildState): this;
  119673. }
  119674. }
  119675. declare module BABYLON {
  119676. /**
  119677. * Block used to apply a dot product between 2 vectors
  119678. */
  119679. export class DotBlock extends NodeMaterialBlock {
  119680. /**
  119681. * Creates a new DotBlock
  119682. * @param name defines the block name
  119683. */
  119684. constructor(name: string);
  119685. /**
  119686. * Gets the current class name
  119687. * @returns the class name
  119688. */
  119689. getClassName(): string;
  119690. /**
  119691. * Gets the left operand input component
  119692. */
  119693. readonly left: NodeMaterialConnectionPoint;
  119694. /**
  119695. * Gets the right operand input component
  119696. */
  119697. readonly right: NodeMaterialConnectionPoint;
  119698. /**
  119699. * Gets the output component
  119700. */
  119701. readonly output: NodeMaterialConnectionPoint;
  119702. protected _buildBlock(state: NodeMaterialBuildState): this;
  119703. }
  119704. }
  119705. declare module BABYLON {
  119706. /**
  119707. * Block used to remap a float from a range to a new one
  119708. */
  119709. export class RemapBlock extends NodeMaterialBlock {
  119710. /**
  119711. * Gets or sets the source range
  119712. */
  119713. sourceRange: Vector2;
  119714. /**
  119715. * Gets or sets the target range
  119716. */
  119717. targetRange: Vector2;
  119718. /**
  119719. * Creates a new RemapBlock
  119720. * @param name defines the block name
  119721. */
  119722. constructor(name: string);
  119723. /**
  119724. * Gets the current class name
  119725. * @returns the class name
  119726. */
  119727. getClassName(): string;
  119728. /**
  119729. * Gets the input component
  119730. */
  119731. readonly input: NodeMaterialConnectionPoint;
  119732. /**
  119733. * Gets the source min input component
  119734. */
  119735. readonly sourceMin: NodeMaterialConnectionPoint;
  119736. /**
  119737. * Gets the source max input component
  119738. */
  119739. readonly sourceMax: NodeMaterialConnectionPoint;
  119740. /**
  119741. * Gets the target min input component
  119742. */
  119743. readonly targetMin: NodeMaterialConnectionPoint;
  119744. /**
  119745. * Gets the target max input component
  119746. */
  119747. readonly targetMax: NodeMaterialConnectionPoint;
  119748. /**
  119749. * Gets the output component
  119750. */
  119751. readonly output: NodeMaterialConnectionPoint;
  119752. protected _buildBlock(state: NodeMaterialBuildState): this;
  119753. protected _dumpPropertiesCode(): string;
  119754. serialize(): any;
  119755. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119756. }
  119757. }
  119758. declare module BABYLON {
  119759. /**
  119760. * Block used to normalize a vector
  119761. */
  119762. export class NormalizeBlock extends NodeMaterialBlock {
  119763. /**
  119764. * Creates a new NormalizeBlock
  119765. * @param name defines the block name
  119766. */
  119767. constructor(name: string);
  119768. /**
  119769. * Gets the current class name
  119770. * @returns the class name
  119771. */
  119772. getClassName(): string;
  119773. /**
  119774. * Gets the input component
  119775. */
  119776. readonly input: NodeMaterialConnectionPoint;
  119777. /**
  119778. * Gets the output component
  119779. */
  119780. readonly output: NodeMaterialConnectionPoint;
  119781. protected _buildBlock(state: NodeMaterialBuildState): this;
  119782. }
  119783. }
  119784. declare module BABYLON {
  119785. /**
  119786. * Operations supported by the Trigonometry block
  119787. */
  119788. export enum TrigonometryBlockOperations {
  119789. /** Cos */
  119790. Cos = 0,
  119791. /** Sin */
  119792. Sin = 1,
  119793. /** Abs */
  119794. Abs = 2,
  119795. /** Exp */
  119796. Exp = 3,
  119797. /** Exp2 */
  119798. Exp2 = 4,
  119799. /** Round */
  119800. Round = 5,
  119801. /** Floor */
  119802. Floor = 6,
  119803. /** Ceiling */
  119804. Ceiling = 7,
  119805. /** Square root */
  119806. Sqrt = 8
  119807. }
  119808. /**
  119809. * Block used to apply trigonometry operation to floats
  119810. */
  119811. export class TrigonometryBlock extends NodeMaterialBlock {
  119812. /**
  119813. * Gets or sets the operation applied by the block
  119814. */
  119815. operation: TrigonometryBlockOperations;
  119816. /**
  119817. * Creates a new TrigonometryBlock
  119818. * @param name defines the block name
  119819. */
  119820. constructor(name: string);
  119821. /**
  119822. * Gets the current class name
  119823. * @returns the class name
  119824. */
  119825. getClassName(): string;
  119826. /**
  119827. * Gets the input component
  119828. */
  119829. readonly input: NodeMaterialConnectionPoint;
  119830. /**
  119831. * Gets the output component
  119832. */
  119833. readonly output: NodeMaterialConnectionPoint;
  119834. protected _buildBlock(state: NodeMaterialBuildState): this;
  119835. serialize(): any;
  119836. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119837. }
  119838. }
  119839. declare module BABYLON {
  119840. /**
  119841. * Block used to create a Color3/4 out of individual inputs (one for each component)
  119842. */
  119843. export class ColorMergerBlock extends NodeMaterialBlock {
  119844. /**
  119845. * Create a new ColorMergerBlock
  119846. * @param name defines the block name
  119847. */
  119848. constructor(name: string);
  119849. /**
  119850. * Gets the current class name
  119851. * @returns the class name
  119852. */
  119853. getClassName(): string;
  119854. /**
  119855. * Gets the r component (input)
  119856. */
  119857. readonly r: NodeMaterialConnectionPoint;
  119858. /**
  119859. * Gets the g component (input)
  119860. */
  119861. readonly g: NodeMaterialConnectionPoint;
  119862. /**
  119863. * Gets the b component (input)
  119864. */
  119865. readonly b: NodeMaterialConnectionPoint;
  119866. /**
  119867. * Gets the a component (input)
  119868. */
  119869. readonly a: NodeMaterialConnectionPoint;
  119870. /**
  119871. * Gets the rgba component (output)
  119872. */
  119873. readonly rgba: NodeMaterialConnectionPoint;
  119874. /**
  119875. * Gets the rgb component (output)
  119876. */
  119877. readonly rgb: NodeMaterialConnectionPoint;
  119878. protected _buildBlock(state: NodeMaterialBuildState): this;
  119879. }
  119880. }
  119881. declare module BABYLON {
  119882. /**
  119883. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  119884. */
  119885. export class VectorMergerBlock extends NodeMaterialBlock {
  119886. /**
  119887. * Create a new VectorMergerBlock
  119888. * @param name defines the block name
  119889. */
  119890. constructor(name: string);
  119891. /**
  119892. * Gets the current class name
  119893. * @returns the class name
  119894. */
  119895. getClassName(): string;
  119896. /**
  119897. * Gets the x component (input)
  119898. */
  119899. readonly x: NodeMaterialConnectionPoint;
  119900. /**
  119901. * Gets the y component (input)
  119902. */
  119903. readonly y: NodeMaterialConnectionPoint;
  119904. /**
  119905. * Gets the z component (input)
  119906. */
  119907. readonly z: NodeMaterialConnectionPoint;
  119908. /**
  119909. * Gets the w component (input)
  119910. */
  119911. readonly w: NodeMaterialConnectionPoint;
  119912. /**
  119913. * Gets the xyzw component (output)
  119914. */
  119915. readonly xyzw: NodeMaterialConnectionPoint;
  119916. /**
  119917. * Gets the xyz component (output)
  119918. */
  119919. readonly xyz: NodeMaterialConnectionPoint;
  119920. /**
  119921. * Gets the xy component (output)
  119922. */
  119923. readonly xy: NodeMaterialConnectionPoint;
  119924. protected _buildBlock(state: NodeMaterialBuildState): this;
  119925. }
  119926. }
  119927. declare module BABYLON {
  119928. /**
  119929. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  119930. */
  119931. export class ColorSplitterBlock extends NodeMaterialBlock {
  119932. /**
  119933. * Create a new ColorSplitterBlock
  119934. * @param name defines the block name
  119935. */
  119936. constructor(name: string);
  119937. /**
  119938. * Gets the current class name
  119939. * @returns the class name
  119940. */
  119941. getClassName(): string;
  119942. /**
  119943. * Gets the rgba component (input)
  119944. */
  119945. readonly rgba: NodeMaterialConnectionPoint;
  119946. /**
  119947. * Gets the rgb component (input)
  119948. */
  119949. readonly rgbIn: NodeMaterialConnectionPoint;
  119950. /**
  119951. * Gets the rgb component (output)
  119952. */
  119953. readonly rgbOut: NodeMaterialConnectionPoint;
  119954. /**
  119955. * Gets the r component (output)
  119956. */
  119957. readonly r: NodeMaterialConnectionPoint;
  119958. /**
  119959. * Gets the g component (output)
  119960. */
  119961. readonly g: NodeMaterialConnectionPoint;
  119962. /**
  119963. * Gets the b component (output)
  119964. */
  119965. readonly b: NodeMaterialConnectionPoint;
  119966. /**
  119967. * Gets the a component (output)
  119968. */
  119969. readonly a: NodeMaterialConnectionPoint;
  119970. protected _inputRename(name: string): string;
  119971. protected _outputRename(name: string): string;
  119972. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  119973. }
  119974. }
  119975. declare module BABYLON {
  119976. /**
  119977. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  119978. */
  119979. export class VectorSplitterBlock extends NodeMaterialBlock {
  119980. /**
  119981. * Create a new VectorSplitterBlock
  119982. * @param name defines the block name
  119983. */
  119984. constructor(name: string);
  119985. /**
  119986. * Gets the current class name
  119987. * @returns the class name
  119988. */
  119989. getClassName(): string;
  119990. /**
  119991. * Gets the xyzw component (input)
  119992. */
  119993. readonly xyzw: NodeMaterialConnectionPoint;
  119994. /**
  119995. * Gets the xyz component (input)
  119996. */
  119997. readonly xyzIn: NodeMaterialConnectionPoint;
  119998. /**
  119999. * Gets the xy component (input)
  120000. */
  120001. readonly xyIn: NodeMaterialConnectionPoint;
  120002. /**
  120003. * Gets the xyz component (output)
  120004. */
  120005. readonly xyzOut: NodeMaterialConnectionPoint;
  120006. /**
  120007. * Gets the xy component (output)
  120008. */
  120009. readonly xyOut: NodeMaterialConnectionPoint;
  120010. /**
  120011. * Gets the x component (output)
  120012. */
  120013. readonly x: NodeMaterialConnectionPoint;
  120014. /**
  120015. * Gets the y component (output)
  120016. */
  120017. readonly y: NodeMaterialConnectionPoint;
  120018. /**
  120019. * Gets the z component (output)
  120020. */
  120021. readonly z: NodeMaterialConnectionPoint;
  120022. /**
  120023. * Gets the w component (output)
  120024. */
  120025. readonly w: NodeMaterialConnectionPoint;
  120026. protected _inputRename(name: string): string;
  120027. protected _outputRename(name: string): string;
  120028. protected _buildBlock(state: NodeMaterialBuildState): this;
  120029. }
  120030. }
  120031. declare module BABYLON {
  120032. /**
  120033. * Block used to lerp 2 values
  120034. */
  120035. export class LerpBlock extends NodeMaterialBlock {
  120036. /**
  120037. * Creates a new LerpBlock
  120038. * @param name defines the block name
  120039. */
  120040. constructor(name: string);
  120041. /**
  120042. * Gets the current class name
  120043. * @returns the class name
  120044. */
  120045. getClassName(): string;
  120046. /**
  120047. * Gets the left operand input component
  120048. */
  120049. readonly left: NodeMaterialConnectionPoint;
  120050. /**
  120051. * Gets the right operand input component
  120052. */
  120053. readonly right: NodeMaterialConnectionPoint;
  120054. /**
  120055. * Gets the gradient operand input component
  120056. */
  120057. readonly gradient: NodeMaterialConnectionPoint;
  120058. /**
  120059. * Gets the output component
  120060. */
  120061. readonly output: NodeMaterialConnectionPoint;
  120062. protected _buildBlock(state: NodeMaterialBuildState): this;
  120063. }
  120064. }
  120065. declare module BABYLON {
  120066. /**
  120067. * Block used to divide 2 vectors
  120068. */
  120069. export class DivideBlock extends NodeMaterialBlock {
  120070. /**
  120071. * Creates a new DivideBlock
  120072. * @param name defines the block name
  120073. */
  120074. constructor(name: string);
  120075. /**
  120076. * Gets the current class name
  120077. * @returns the class name
  120078. */
  120079. getClassName(): string;
  120080. /**
  120081. * Gets the left operand input component
  120082. */
  120083. readonly left: NodeMaterialConnectionPoint;
  120084. /**
  120085. * Gets the right operand input component
  120086. */
  120087. readonly right: NodeMaterialConnectionPoint;
  120088. /**
  120089. * Gets the output component
  120090. */
  120091. readonly output: NodeMaterialConnectionPoint;
  120092. protected _buildBlock(state: NodeMaterialBuildState): this;
  120093. }
  120094. }
  120095. declare module BABYLON {
  120096. /**
  120097. * Block used to subtract 2 vectors
  120098. */
  120099. export class SubtractBlock extends NodeMaterialBlock {
  120100. /**
  120101. * Creates a new SubtractBlock
  120102. * @param name defines the block name
  120103. */
  120104. constructor(name: string);
  120105. /**
  120106. * Gets the current class name
  120107. * @returns the class name
  120108. */
  120109. getClassName(): string;
  120110. /**
  120111. * Gets the left operand input component
  120112. */
  120113. readonly left: NodeMaterialConnectionPoint;
  120114. /**
  120115. * Gets the right operand input component
  120116. */
  120117. readonly right: NodeMaterialConnectionPoint;
  120118. /**
  120119. * Gets the output component
  120120. */
  120121. readonly output: NodeMaterialConnectionPoint;
  120122. protected _buildBlock(state: NodeMaterialBuildState): this;
  120123. }
  120124. }
  120125. declare module BABYLON {
  120126. /**
  120127. * Block used to step a value
  120128. */
  120129. export class StepBlock extends NodeMaterialBlock {
  120130. /**
  120131. * Creates a new AddBlock
  120132. * @param name defines the block name
  120133. */
  120134. constructor(name: string);
  120135. /**
  120136. * Gets the current class name
  120137. * @returns the class name
  120138. */
  120139. getClassName(): string;
  120140. /**
  120141. * Gets the value operand input component
  120142. */
  120143. readonly value: NodeMaterialConnectionPoint;
  120144. /**
  120145. * Gets the edge operand input component
  120146. */
  120147. readonly edge: NodeMaterialConnectionPoint;
  120148. /**
  120149. * Gets the output component
  120150. */
  120151. readonly output: NodeMaterialConnectionPoint;
  120152. protected _buildBlock(state: NodeMaterialBuildState): this;
  120153. }
  120154. }
  120155. declare module BABYLON {
  120156. /**
  120157. * Block used to get the opposite (1 - x) of a value
  120158. */
  120159. export class OneMinusBlock extends NodeMaterialBlock {
  120160. /**
  120161. * Creates a new OneMinusBlock
  120162. * @param name defines the block name
  120163. */
  120164. constructor(name: string);
  120165. /**
  120166. * Gets the current class name
  120167. * @returns the class name
  120168. */
  120169. getClassName(): string;
  120170. /**
  120171. * Gets the input component
  120172. */
  120173. readonly input: NodeMaterialConnectionPoint;
  120174. /**
  120175. * Gets the output component
  120176. */
  120177. readonly output: NodeMaterialConnectionPoint;
  120178. protected _buildBlock(state: NodeMaterialBuildState): this;
  120179. }
  120180. }
  120181. declare module BABYLON {
  120182. /**
  120183. * Block used to get the view direction
  120184. */
  120185. export class ViewDirectionBlock extends NodeMaterialBlock {
  120186. /**
  120187. * Creates a new ViewDirectionBlock
  120188. * @param name defines the block name
  120189. */
  120190. constructor(name: string);
  120191. /**
  120192. * Gets the current class name
  120193. * @returns the class name
  120194. */
  120195. getClassName(): string;
  120196. /**
  120197. * Gets the world position component
  120198. */
  120199. readonly worldPosition: NodeMaterialConnectionPoint;
  120200. /**
  120201. * Gets the camera position component
  120202. */
  120203. readonly cameraPosition: NodeMaterialConnectionPoint;
  120204. /**
  120205. * Gets the output component
  120206. */
  120207. readonly output: NodeMaterialConnectionPoint;
  120208. autoConfigure(material: NodeMaterial): void;
  120209. protected _buildBlock(state: NodeMaterialBuildState): this;
  120210. }
  120211. }
  120212. declare module BABYLON {
  120213. /**
  120214. * Block used to compute fresnel value
  120215. */
  120216. export class FresnelBlock extends NodeMaterialBlock {
  120217. /**
  120218. * Create a new FresnelBlock
  120219. * @param name defines the block name
  120220. */
  120221. constructor(name: string);
  120222. /**
  120223. * Gets the current class name
  120224. * @returns the class name
  120225. */
  120226. getClassName(): string;
  120227. /**
  120228. * Gets the world normal input component
  120229. */
  120230. readonly worldNormal: NodeMaterialConnectionPoint;
  120231. /**
  120232. * Gets the view direction input component
  120233. */
  120234. readonly viewDirection: NodeMaterialConnectionPoint;
  120235. /**
  120236. * Gets the bias input component
  120237. */
  120238. readonly bias: NodeMaterialConnectionPoint;
  120239. /**
  120240. * Gets the camera (or eye) position component
  120241. */
  120242. readonly power: NodeMaterialConnectionPoint;
  120243. /**
  120244. * Gets the fresnel output component
  120245. */
  120246. readonly fresnel: NodeMaterialConnectionPoint;
  120247. autoConfigure(material: NodeMaterial): void;
  120248. protected _buildBlock(state: NodeMaterialBuildState): this;
  120249. }
  120250. }
  120251. declare module BABYLON {
  120252. /**
  120253. * Block used to get the max of 2 values
  120254. */
  120255. export class MaxBlock extends NodeMaterialBlock {
  120256. /**
  120257. * Creates a new MaxBlock
  120258. * @param name defines the block name
  120259. */
  120260. constructor(name: string);
  120261. /**
  120262. * Gets the current class name
  120263. * @returns the class name
  120264. */
  120265. getClassName(): string;
  120266. /**
  120267. * Gets the left operand input component
  120268. */
  120269. readonly left: NodeMaterialConnectionPoint;
  120270. /**
  120271. * Gets the right operand input component
  120272. */
  120273. readonly right: NodeMaterialConnectionPoint;
  120274. /**
  120275. * Gets the output component
  120276. */
  120277. readonly output: NodeMaterialConnectionPoint;
  120278. protected _buildBlock(state: NodeMaterialBuildState): this;
  120279. }
  120280. }
  120281. declare module BABYLON {
  120282. /**
  120283. * Block used to get the min of 2 values
  120284. */
  120285. export class MinBlock extends NodeMaterialBlock {
  120286. /**
  120287. * Creates a new MinBlock
  120288. * @param name defines the block name
  120289. */
  120290. constructor(name: string);
  120291. /**
  120292. * Gets the current class name
  120293. * @returns the class name
  120294. */
  120295. getClassName(): string;
  120296. /**
  120297. * Gets the left operand input component
  120298. */
  120299. readonly left: NodeMaterialConnectionPoint;
  120300. /**
  120301. * Gets the right operand input component
  120302. */
  120303. readonly right: NodeMaterialConnectionPoint;
  120304. /**
  120305. * Gets the output component
  120306. */
  120307. readonly output: NodeMaterialConnectionPoint;
  120308. protected _buildBlock(state: NodeMaterialBuildState): this;
  120309. }
  120310. }
  120311. declare module BABYLON {
  120312. /**
  120313. * Block used to get the distance between 2 values
  120314. */
  120315. export class DistanceBlock extends NodeMaterialBlock {
  120316. /**
  120317. * Creates a new DistanceBlock
  120318. * @param name defines the block name
  120319. */
  120320. constructor(name: string);
  120321. /**
  120322. * Gets the current class name
  120323. * @returns the class name
  120324. */
  120325. getClassName(): string;
  120326. /**
  120327. * Gets the left operand input component
  120328. */
  120329. readonly left: NodeMaterialConnectionPoint;
  120330. /**
  120331. * Gets the right operand input component
  120332. */
  120333. readonly right: NodeMaterialConnectionPoint;
  120334. /**
  120335. * Gets the output component
  120336. */
  120337. readonly output: NodeMaterialConnectionPoint;
  120338. protected _buildBlock(state: NodeMaterialBuildState): this;
  120339. }
  120340. }
  120341. declare module BABYLON {
  120342. /**
  120343. * Block used to get the length of a vector
  120344. */
  120345. export class LengthBlock extends NodeMaterialBlock {
  120346. /**
  120347. * Creates a new LengthBlock
  120348. * @param name defines the block name
  120349. */
  120350. constructor(name: string);
  120351. /**
  120352. * Gets the current class name
  120353. * @returns the class name
  120354. */
  120355. getClassName(): string;
  120356. /**
  120357. * Gets the value input component
  120358. */
  120359. readonly value: NodeMaterialConnectionPoint;
  120360. /**
  120361. * Gets the output component
  120362. */
  120363. readonly output: NodeMaterialConnectionPoint;
  120364. protected _buildBlock(state: NodeMaterialBuildState): this;
  120365. }
  120366. }
  120367. declare module BABYLON {
  120368. /**
  120369. * Block used to get negative version of a value (i.e. x * -1)
  120370. */
  120371. export class NegateBlock extends NodeMaterialBlock {
  120372. /**
  120373. * Creates a new NegateBlock
  120374. * @param name defines the block name
  120375. */
  120376. constructor(name: string);
  120377. /**
  120378. * Gets the current class name
  120379. * @returns the class name
  120380. */
  120381. getClassName(): string;
  120382. /**
  120383. * Gets the value input component
  120384. */
  120385. readonly value: NodeMaterialConnectionPoint;
  120386. /**
  120387. * Gets the output component
  120388. */
  120389. readonly output: NodeMaterialConnectionPoint;
  120390. protected _buildBlock(state: NodeMaterialBuildState): this;
  120391. }
  120392. }
  120393. declare module BABYLON {
  120394. /**
  120395. * Block used to get the value of the first parameter raised to the power of the second
  120396. */
  120397. export class PowBlock extends NodeMaterialBlock {
  120398. /**
  120399. * Creates a new PowBlock
  120400. * @param name defines the block name
  120401. */
  120402. constructor(name: string);
  120403. /**
  120404. * Gets the current class name
  120405. * @returns the class name
  120406. */
  120407. getClassName(): string;
  120408. /**
  120409. * Gets the value operand input component
  120410. */
  120411. readonly value: NodeMaterialConnectionPoint;
  120412. /**
  120413. * Gets the power operand input component
  120414. */
  120415. readonly power: NodeMaterialConnectionPoint;
  120416. /**
  120417. * Gets the output component
  120418. */
  120419. readonly output: NodeMaterialConnectionPoint;
  120420. protected _buildBlock(state: NodeMaterialBuildState): this;
  120421. }
  120422. }
  120423. declare module BABYLON {
  120424. /**
  120425. * Effect Render Options
  120426. */
  120427. export interface IEffectRendererOptions {
  120428. /**
  120429. * Defines the vertices positions.
  120430. */
  120431. positions?: number[];
  120432. /**
  120433. * Defines the indices.
  120434. */
  120435. indices?: number[];
  120436. }
  120437. /**
  120438. * Helper class to render one or more effects
  120439. */
  120440. export class EffectRenderer {
  120441. private engine;
  120442. private static _DefaultOptions;
  120443. private _vertexBuffers;
  120444. private _indexBuffer;
  120445. private _ringBufferIndex;
  120446. private _ringScreenBuffer;
  120447. private _fullscreenViewport;
  120448. private _getNextFrameBuffer;
  120449. /**
  120450. * Creates an effect renderer
  120451. * @param engine the engine to use for rendering
  120452. * @param options defines the options of the effect renderer
  120453. */
  120454. constructor(engine: Engine, options?: IEffectRendererOptions);
  120455. /**
  120456. * Sets the current viewport in normalized coordinates 0-1
  120457. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  120458. */
  120459. setViewport(viewport?: Viewport): void;
  120460. /**
  120461. * Binds the embedded attributes buffer to the effect.
  120462. * @param effect Defines the effect to bind the attributes for
  120463. */
  120464. bindBuffers(effect: Effect): void;
  120465. /**
  120466. * Sets the current effect wrapper to use during draw.
  120467. * The effect needs to be ready before calling this api.
  120468. * This also sets the default full screen position attribute.
  120469. * @param effectWrapper Defines the effect to draw with
  120470. */
  120471. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  120472. /**
  120473. * Draws a full screen quad.
  120474. */
  120475. draw(): void;
  120476. /**
  120477. * renders one or more effects to a specified texture
  120478. * @param effectWrappers list of effects to renderer
  120479. * @param outputTexture texture to draw to, if null it will render to the screen
  120480. */
  120481. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  120482. /**
  120483. * Disposes of the effect renderer
  120484. */
  120485. dispose(): void;
  120486. }
  120487. /**
  120488. * Options to create an EffectWrapper
  120489. */
  120490. interface EffectWrapperCreationOptions {
  120491. /**
  120492. * Engine to use to create the effect
  120493. */
  120494. engine: Engine;
  120495. /**
  120496. * Fragment shader for the effect
  120497. */
  120498. fragmentShader: string;
  120499. /**
  120500. * Vertex shader for the effect
  120501. */
  120502. vertexShader?: string;
  120503. /**
  120504. * Attributes to use in the shader
  120505. */
  120506. attributeNames?: Array<string>;
  120507. /**
  120508. * Uniforms to use in the shader
  120509. */
  120510. uniformNames?: Array<string>;
  120511. /**
  120512. * Texture sampler names to use in the shader
  120513. */
  120514. samplerNames?: Array<string>;
  120515. /**
  120516. * The friendly name of the effect displayed in Spector.
  120517. */
  120518. name?: string;
  120519. }
  120520. /**
  120521. * Wraps an effect to be used for rendering
  120522. */
  120523. export class EffectWrapper {
  120524. /**
  120525. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  120526. */
  120527. onApplyObservable: Observable<{}>;
  120528. /**
  120529. * The underlying effect
  120530. */
  120531. effect: Effect;
  120532. /**
  120533. * Creates an effect to be renderer
  120534. * @param creationOptions options to create the effect
  120535. */
  120536. constructor(creationOptions: EffectWrapperCreationOptions);
  120537. /**
  120538. * Disposes of the effect wrapper
  120539. */
  120540. dispose(): void;
  120541. }
  120542. }
  120543. declare module BABYLON {
  120544. /**
  120545. * Helper class to push actions to a pool of workers.
  120546. */
  120547. export class WorkerPool implements IDisposable {
  120548. private _workerInfos;
  120549. private _pendingActions;
  120550. /**
  120551. * Constructor
  120552. * @param workers Array of workers to use for actions
  120553. */
  120554. constructor(workers: Array<Worker>);
  120555. /**
  120556. * Terminates all workers and clears any pending actions.
  120557. */
  120558. dispose(): void;
  120559. /**
  120560. * Pushes an action to the worker pool. If all the workers are active, the action will be
  120561. * pended until a worker has completed its action.
  120562. * @param action The action to perform. Call onComplete when the action is complete.
  120563. */
  120564. push(action: (worker: Worker, onComplete: () => void) => void): void;
  120565. private _execute;
  120566. }
  120567. }
  120568. declare module BABYLON {
  120569. /**
  120570. * Configuration for Draco compression
  120571. */
  120572. export interface IDracoCompressionConfiguration {
  120573. /**
  120574. * Configuration for the decoder.
  120575. */
  120576. decoder: {
  120577. /**
  120578. * The url to the WebAssembly module.
  120579. */
  120580. wasmUrl?: string;
  120581. /**
  120582. * The url to the WebAssembly binary.
  120583. */
  120584. wasmBinaryUrl?: string;
  120585. /**
  120586. * The url to the fallback JavaScript module.
  120587. */
  120588. fallbackUrl?: string;
  120589. };
  120590. }
  120591. /**
  120592. * Draco compression (https://google.github.io/draco/)
  120593. *
  120594. * This class wraps the Draco module.
  120595. *
  120596. * **Encoder**
  120597. *
  120598. * The encoder is not currently implemented.
  120599. *
  120600. * **Decoder**
  120601. *
  120602. * 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.
  120603. *
  120604. * To update the configuration, use the following code:
  120605. * ```javascript
  120606. * DracoCompression.Configuration = {
  120607. * decoder: {
  120608. * wasmUrl: "<url to the WebAssembly library>",
  120609. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  120610. * fallbackUrl: "<url to the fallback JavaScript library>",
  120611. * }
  120612. * };
  120613. * ```
  120614. *
  120615. * 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.
  120616. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  120617. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  120618. *
  120619. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  120620. * ```javascript
  120621. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  120622. * ```
  120623. *
  120624. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  120625. */
  120626. export class DracoCompression implements IDisposable {
  120627. private _workerPoolPromise?;
  120628. private _decoderModulePromise?;
  120629. /**
  120630. * The configuration. Defaults to the following urls:
  120631. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  120632. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  120633. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  120634. */
  120635. static Configuration: IDracoCompressionConfiguration;
  120636. /**
  120637. * Returns true if the decoder configuration is available.
  120638. */
  120639. static readonly DecoderAvailable: boolean;
  120640. /**
  120641. * Default number of workers to create when creating the draco compression object.
  120642. */
  120643. static DefaultNumWorkers: number;
  120644. private static GetDefaultNumWorkers;
  120645. private static _Default;
  120646. /**
  120647. * Default instance for the draco compression object.
  120648. */
  120649. static readonly Default: DracoCompression;
  120650. /**
  120651. * Constructor
  120652. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  120653. */
  120654. constructor(numWorkers?: number);
  120655. /**
  120656. * Stop all async operations and release resources.
  120657. */
  120658. dispose(): void;
  120659. /**
  120660. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  120661. * @returns a promise that resolves when ready
  120662. */
  120663. whenReadyAsync(): Promise<void>;
  120664. /**
  120665. * Decode Draco compressed mesh data to vertex data.
  120666. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  120667. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  120668. * @returns A promise that resolves with the decoded vertex data
  120669. */
  120670. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  120671. [kind: string]: number;
  120672. }): Promise<VertexData>;
  120673. }
  120674. }
  120675. declare module BABYLON {
  120676. /**
  120677. * Class for building Constructive Solid Geometry
  120678. */
  120679. export class CSG {
  120680. private polygons;
  120681. /**
  120682. * The world matrix
  120683. */
  120684. matrix: Matrix;
  120685. /**
  120686. * Stores the position
  120687. */
  120688. position: Vector3;
  120689. /**
  120690. * Stores the rotation
  120691. */
  120692. rotation: Vector3;
  120693. /**
  120694. * Stores the rotation quaternion
  120695. */
  120696. rotationQuaternion: Nullable<Quaternion>;
  120697. /**
  120698. * Stores the scaling vector
  120699. */
  120700. scaling: Vector3;
  120701. /**
  120702. * Convert the Mesh to CSG
  120703. * @param mesh The Mesh to convert to CSG
  120704. * @returns A new CSG from the Mesh
  120705. */
  120706. static FromMesh(mesh: Mesh): CSG;
  120707. /**
  120708. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  120709. * @param polygons Polygons used to construct a CSG solid
  120710. */
  120711. private static FromPolygons;
  120712. /**
  120713. * Clones, or makes a deep copy, of the CSG
  120714. * @returns A new CSG
  120715. */
  120716. clone(): CSG;
  120717. /**
  120718. * Unions this CSG with another CSG
  120719. * @param csg The CSG to union against this CSG
  120720. * @returns The unioned CSG
  120721. */
  120722. union(csg: CSG): CSG;
  120723. /**
  120724. * Unions this CSG with another CSG in place
  120725. * @param csg The CSG to union against this CSG
  120726. */
  120727. unionInPlace(csg: CSG): void;
  120728. /**
  120729. * Subtracts this CSG with another CSG
  120730. * @param csg The CSG to subtract against this CSG
  120731. * @returns A new CSG
  120732. */
  120733. subtract(csg: CSG): CSG;
  120734. /**
  120735. * Subtracts this CSG with another CSG in place
  120736. * @param csg The CSG to subtact against this CSG
  120737. */
  120738. subtractInPlace(csg: CSG): void;
  120739. /**
  120740. * Intersect this CSG with another CSG
  120741. * @param csg The CSG to intersect against this CSG
  120742. * @returns A new CSG
  120743. */
  120744. intersect(csg: CSG): CSG;
  120745. /**
  120746. * Intersects this CSG with another CSG in place
  120747. * @param csg The CSG to intersect against this CSG
  120748. */
  120749. intersectInPlace(csg: CSG): void;
  120750. /**
  120751. * Return a new CSG solid with solid and empty space switched. This solid is
  120752. * not modified.
  120753. * @returns A new CSG solid with solid and empty space switched
  120754. */
  120755. inverse(): CSG;
  120756. /**
  120757. * Inverses the CSG in place
  120758. */
  120759. inverseInPlace(): void;
  120760. /**
  120761. * This is used to keep meshes transformations so they can be restored
  120762. * when we build back a Babylon Mesh
  120763. * NB : All CSG operations are performed in world coordinates
  120764. * @param csg The CSG to copy the transform attributes from
  120765. * @returns This CSG
  120766. */
  120767. copyTransformAttributes(csg: CSG): CSG;
  120768. /**
  120769. * Build Raw mesh from CSG
  120770. * Coordinates here are in world space
  120771. * @param name The name of the mesh geometry
  120772. * @param scene The Scene
  120773. * @param keepSubMeshes Specifies if the submeshes should be kept
  120774. * @returns A new Mesh
  120775. */
  120776. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  120777. /**
  120778. * Build Mesh from CSG taking material and transforms into account
  120779. * @param name The name of the Mesh
  120780. * @param material The material of the Mesh
  120781. * @param scene The Scene
  120782. * @param keepSubMeshes Specifies if submeshes should be kept
  120783. * @returns The new Mesh
  120784. */
  120785. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  120786. }
  120787. }
  120788. declare module BABYLON {
  120789. /**
  120790. * Class used to create a trail following a mesh
  120791. */
  120792. export class TrailMesh extends Mesh {
  120793. private _generator;
  120794. private _autoStart;
  120795. private _running;
  120796. private _diameter;
  120797. private _length;
  120798. private _sectionPolygonPointsCount;
  120799. private _sectionVectors;
  120800. private _sectionNormalVectors;
  120801. private _beforeRenderObserver;
  120802. /**
  120803. * @constructor
  120804. * @param name The value used by scene.getMeshByName() to do a lookup.
  120805. * @param generator The mesh to generate a trail.
  120806. * @param scene The scene to add this mesh to.
  120807. * @param diameter Diameter of trailing mesh. Default is 1.
  120808. * @param length Length of trailing mesh. Default is 60.
  120809. * @param autoStart Automatically start trailing mesh. Default true.
  120810. */
  120811. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  120812. /**
  120813. * "TrailMesh"
  120814. * @returns "TrailMesh"
  120815. */
  120816. getClassName(): string;
  120817. private _createMesh;
  120818. /**
  120819. * Start trailing mesh.
  120820. */
  120821. start(): void;
  120822. /**
  120823. * Stop trailing mesh.
  120824. */
  120825. stop(): void;
  120826. /**
  120827. * Update trailing mesh geometry.
  120828. */
  120829. update(): void;
  120830. /**
  120831. * Returns a new TrailMesh object.
  120832. * @param name is a string, the name given to the new mesh
  120833. * @param newGenerator use new generator object for cloned trail mesh
  120834. * @returns a new mesh
  120835. */
  120836. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  120837. /**
  120838. * Serializes this trail mesh
  120839. * @param serializationObject object to write serialization to
  120840. */
  120841. serialize(serializationObject: any): void;
  120842. /**
  120843. * Parses a serialized trail mesh
  120844. * @param parsedMesh the serialized mesh
  120845. * @param scene the scene to create the trail mesh in
  120846. * @returns the created trail mesh
  120847. */
  120848. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  120849. }
  120850. }
  120851. declare module BABYLON {
  120852. /**
  120853. * Class containing static functions to help procedurally build meshes
  120854. */
  120855. export class TiledBoxBuilder {
  120856. /**
  120857. * Creates a box mesh
  120858. * 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)
  120859. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  120860. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120861. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120863. * @param name defines the name of the mesh
  120864. * @param options defines the options used to create the mesh
  120865. * @param scene defines the hosting scene
  120866. * @returns the box mesh
  120867. */
  120868. static CreateTiledBox(name: string, options: {
  120869. pattern?: number;
  120870. width?: number;
  120871. height?: number;
  120872. depth?: number;
  120873. tileSize?: number;
  120874. tileWidth?: number;
  120875. tileHeight?: number;
  120876. alignHorizontal?: number;
  120877. alignVertical?: number;
  120878. faceUV?: Vector4[];
  120879. faceColors?: Color4[];
  120880. sideOrientation?: number;
  120881. updatable?: boolean;
  120882. }, scene?: Nullable<Scene>): Mesh;
  120883. }
  120884. }
  120885. declare module BABYLON {
  120886. /**
  120887. * Class containing static functions to help procedurally build meshes
  120888. */
  120889. export class TorusKnotBuilder {
  120890. /**
  120891. * Creates a torus knot mesh
  120892. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  120893. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  120894. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  120895. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  120896. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120897. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120898. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  120899. * @param name defines the name of the mesh
  120900. * @param options defines the options used to create the mesh
  120901. * @param scene defines the hosting scene
  120902. * @returns the torus knot mesh
  120903. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  120904. */
  120905. static CreateTorusKnot(name: string, options: {
  120906. radius?: number;
  120907. tube?: number;
  120908. radialSegments?: number;
  120909. tubularSegments?: number;
  120910. p?: number;
  120911. q?: number;
  120912. updatable?: boolean;
  120913. sideOrientation?: number;
  120914. frontUVs?: Vector4;
  120915. backUVs?: Vector4;
  120916. }, scene: any): Mesh;
  120917. }
  120918. }
  120919. declare module BABYLON {
  120920. /**
  120921. * Polygon
  120922. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  120923. */
  120924. export class Polygon {
  120925. /**
  120926. * Creates a rectangle
  120927. * @param xmin bottom X coord
  120928. * @param ymin bottom Y coord
  120929. * @param xmax top X coord
  120930. * @param ymax top Y coord
  120931. * @returns points that make the resulting rectation
  120932. */
  120933. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  120934. /**
  120935. * Creates a circle
  120936. * @param radius radius of circle
  120937. * @param cx scale in x
  120938. * @param cy scale in y
  120939. * @param numberOfSides number of sides that make up the circle
  120940. * @returns points that make the resulting circle
  120941. */
  120942. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  120943. /**
  120944. * Creates a polygon from input string
  120945. * @param input Input polygon data
  120946. * @returns the parsed points
  120947. */
  120948. static Parse(input: string): Vector2[];
  120949. /**
  120950. * Starts building a polygon from x and y coordinates
  120951. * @param x x coordinate
  120952. * @param y y coordinate
  120953. * @returns the started path2
  120954. */
  120955. static StartingAt(x: number, y: number): Path2;
  120956. }
  120957. /**
  120958. * Builds a polygon
  120959. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  120960. */
  120961. export class PolygonMeshBuilder {
  120962. private _points;
  120963. private _outlinepoints;
  120964. private _holes;
  120965. private _name;
  120966. private _scene;
  120967. private _epoints;
  120968. private _eholes;
  120969. private _addToepoint;
  120970. /**
  120971. * Babylon reference to the earcut plugin.
  120972. */
  120973. bjsEarcut: any;
  120974. /**
  120975. * Creates a PolygonMeshBuilder
  120976. * @param name name of the builder
  120977. * @param contours Path of the polygon
  120978. * @param scene scene to add to when creating the mesh
  120979. * @param earcutInjection can be used to inject your own earcut reference
  120980. */
  120981. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  120982. /**
  120983. * Adds a whole within the polygon
  120984. * @param hole Array of points defining the hole
  120985. * @returns this
  120986. */
  120987. addHole(hole: Vector2[]): PolygonMeshBuilder;
  120988. /**
  120989. * Creates the polygon
  120990. * @param updatable If the mesh should be updatable
  120991. * @param depth The depth of the mesh created
  120992. * @returns the created mesh
  120993. */
  120994. build(updatable?: boolean, depth?: number): Mesh;
  120995. /**
  120996. * Creates the polygon
  120997. * @param depth The depth of the mesh created
  120998. * @returns the created VertexData
  120999. */
  121000. buildVertexData(depth?: number): VertexData;
  121001. /**
  121002. * Adds a side to the polygon
  121003. * @param positions points that make the polygon
  121004. * @param normals normals of the polygon
  121005. * @param uvs uvs of the polygon
  121006. * @param indices indices of the polygon
  121007. * @param bounds bounds of the polygon
  121008. * @param points points of the polygon
  121009. * @param depth depth of the polygon
  121010. * @param flip flip of the polygon
  121011. */
  121012. private addSide;
  121013. }
  121014. }
  121015. declare module BABYLON {
  121016. /**
  121017. * Class containing static functions to help procedurally build meshes
  121018. */
  121019. export class PolygonBuilder {
  121020. /**
  121021. * Creates a polygon mesh
  121022. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  121023. * * 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
  121024. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  121025. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121026. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  121027. * * Remember you can only change the shape positions, not their number when updating a polygon
  121028. * @param name defines the name of the mesh
  121029. * @param options defines the options used to create the mesh
  121030. * @param scene defines the hosting scene
  121031. * @param earcutInjection can be used to inject your own earcut reference
  121032. * @returns the polygon mesh
  121033. */
  121034. static CreatePolygon(name: string, options: {
  121035. shape: Vector3[];
  121036. holes?: Vector3[][];
  121037. depth?: number;
  121038. faceUV?: Vector4[];
  121039. faceColors?: Color4[];
  121040. updatable?: boolean;
  121041. sideOrientation?: number;
  121042. frontUVs?: Vector4;
  121043. backUVs?: Vector4;
  121044. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  121045. /**
  121046. * Creates an extruded polygon mesh, with depth in the Y direction.
  121047. * * 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)
  121048. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  121049. * @param name defines the name of the mesh
  121050. * @param options defines the options used to create the mesh
  121051. * @param scene defines the hosting scene
  121052. * @param earcutInjection can be used to inject your own earcut reference
  121053. * @returns the polygon mesh
  121054. */
  121055. static ExtrudePolygon(name: string, options: {
  121056. shape: Vector3[];
  121057. holes?: Vector3[][];
  121058. depth?: number;
  121059. faceUV?: Vector4[];
  121060. faceColors?: Color4[];
  121061. updatable?: boolean;
  121062. sideOrientation?: number;
  121063. frontUVs?: Vector4;
  121064. backUVs?: Vector4;
  121065. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  121066. }
  121067. }
  121068. declare module BABYLON {
  121069. /**
  121070. * Class containing static functions to help procedurally build meshes
  121071. */
  121072. export class LatheBuilder {
  121073. /**
  121074. * Creates lathe mesh.
  121075. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  121076. * * 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
  121077. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  121078. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  121079. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  121080. * * 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
  121081. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  121082. * * 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
  121083. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121084. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121085. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121086. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121087. * @param name defines the name of the mesh
  121088. * @param options defines the options used to create the mesh
  121089. * @param scene defines the hosting scene
  121090. * @returns the lathe mesh
  121091. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  121092. */
  121093. static CreateLathe(name: string, options: {
  121094. shape: Vector3[];
  121095. radius?: number;
  121096. tessellation?: number;
  121097. clip?: number;
  121098. arc?: number;
  121099. closed?: boolean;
  121100. updatable?: boolean;
  121101. sideOrientation?: number;
  121102. frontUVs?: Vector4;
  121103. backUVs?: Vector4;
  121104. cap?: number;
  121105. invertUV?: boolean;
  121106. }, scene?: Nullable<Scene>): Mesh;
  121107. }
  121108. }
  121109. declare module BABYLON {
  121110. /**
  121111. * Class containing static functions to help procedurally build meshes
  121112. */
  121113. export class TiledPlaneBuilder {
  121114. /**
  121115. * Creates a tiled plane mesh
  121116. * * The parameter `pattern` will, depending on value, do nothing or
  121117. * * * flip (reflect about central vertical) alternate tiles across and up
  121118. * * * flip every tile on alternate rows
  121119. * * * rotate (180 degs) alternate tiles across and up
  121120. * * * rotate every tile on alternate rows
  121121. * * * flip and rotate alternate tiles across and up
  121122. * * * flip and rotate every tile on alternate rows
  121123. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  121124. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  121125. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121126. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  121127. * * 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)
  121128. * * 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)
  121129. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  121130. * @param name defines the name of the mesh
  121131. * @param options defines the options used to create the mesh
  121132. * @param scene defines the hosting scene
  121133. * @returns the box mesh
  121134. */
  121135. static CreateTiledPlane(name: string, options: {
  121136. pattern?: number;
  121137. tileSize?: number;
  121138. tileWidth?: number;
  121139. tileHeight?: number;
  121140. size?: number;
  121141. width?: number;
  121142. height?: number;
  121143. alignHorizontal?: number;
  121144. alignVertical?: number;
  121145. sideOrientation?: number;
  121146. frontUVs?: Vector4;
  121147. backUVs?: Vector4;
  121148. updatable?: boolean;
  121149. }, scene?: Nullable<Scene>): Mesh;
  121150. }
  121151. }
  121152. declare module BABYLON {
  121153. /**
  121154. * Class containing static functions to help procedurally build meshes
  121155. */
  121156. export class TubeBuilder {
  121157. /**
  121158. * Creates a tube mesh.
  121159. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  121160. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  121161. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  121162. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  121163. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  121164. * * 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)
  121165. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  121166. * * 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
  121167. * * 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
  121168. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121169. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121170. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121171. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121172. * @param name defines the name of the mesh
  121173. * @param options defines the options used to create the mesh
  121174. * @param scene defines the hosting scene
  121175. * @returns the tube mesh
  121176. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121177. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  121178. */
  121179. static CreateTube(name: string, options: {
  121180. path: Vector3[];
  121181. radius?: number;
  121182. tessellation?: number;
  121183. radiusFunction?: {
  121184. (i: number, distance: number): number;
  121185. };
  121186. cap?: number;
  121187. arc?: number;
  121188. updatable?: boolean;
  121189. sideOrientation?: number;
  121190. frontUVs?: Vector4;
  121191. backUVs?: Vector4;
  121192. instance?: Mesh;
  121193. invertUV?: boolean;
  121194. }, scene?: Nullable<Scene>): Mesh;
  121195. }
  121196. }
  121197. declare module BABYLON {
  121198. /**
  121199. * Class containing static functions to help procedurally build meshes
  121200. */
  121201. export class IcoSphereBuilder {
  121202. /**
  121203. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  121204. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  121205. * * 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`)
  121206. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  121207. * * 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
  121208. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121209. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121210. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121211. * @param name defines the name of the mesh
  121212. * @param options defines the options used to create the mesh
  121213. * @param scene defines the hosting scene
  121214. * @returns the icosahedron mesh
  121215. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  121216. */
  121217. static CreateIcoSphere(name: string, options: {
  121218. radius?: number;
  121219. radiusX?: number;
  121220. radiusY?: number;
  121221. radiusZ?: number;
  121222. flat?: boolean;
  121223. subdivisions?: number;
  121224. sideOrientation?: number;
  121225. frontUVs?: Vector4;
  121226. backUVs?: Vector4;
  121227. updatable?: boolean;
  121228. }, scene?: Nullable<Scene>): Mesh;
  121229. }
  121230. }
  121231. declare module BABYLON {
  121232. /**
  121233. * Class containing static functions to help procedurally build meshes
  121234. */
  121235. export class DecalBuilder {
  121236. /**
  121237. * Creates a decal mesh.
  121238. * 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
  121239. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  121240. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  121241. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  121242. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  121243. * @param name defines the name of the mesh
  121244. * @param sourceMesh defines the mesh where the decal must be applied
  121245. * @param options defines the options used to create the mesh
  121246. * @param scene defines the hosting scene
  121247. * @returns the decal mesh
  121248. * @see https://doc.babylonjs.com/how_to/decals
  121249. */
  121250. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  121251. position?: Vector3;
  121252. normal?: Vector3;
  121253. size?: Vector3;
  121254. angle?: number;
  121255. }): Mesh;
  121256. }
  121257. }
  121258. declare module BABYLON {
  121259. /**
  121260. * Class containing static functions to help procedurally build meshes
  121261. */
  121262. export class MeshBuilder {
  121263. /**
  121264. * Creates a box mesh
  121265. * * The parameter `size` sets the size (float) of each box side (default 1)
  121266. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  121267. * * 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)
  121268. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  121269. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121270. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121271. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121272. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  121273. * @param name defines the name of the mesh
  121274. * @param options defines the options used to create the mesh
  121275. * @param scene defines the hosting scene
  121276. * @returns the box mesh
  121277. */
  121278. static CreateBox(name: string, options: {
  121279. size?: number;
  121280. width?: number;
  121281. height?: number;
  121282. depth?: number;
  121283. faceUV?: Vector4[];
  121284. faceColors?: Color4[];
  121285. sideOrientation?: number;
  121286. frontUVs?: Vector4;
  121287. backUVs?: Vector4;
  121288. updatable?: boolean;
  121289. }, scene?: Nullable<Scene>): Mesh;
  121290. /**
  121291. * Creates a tiled box mesh
  121292. * * faceTiles sets the pattern, tile size and number of tiles for a face
  121293. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121294. * @param name defines the name of the mesh
  121295. * @param options defines the options used to create the mesh
  121296. * @param scene defines the hosting scene
  121297. * @returns the tiled box mesh
  121298. */
  121299. static CreateTiledBox(name: string, options: {
  121300. pattern?: number;
  121301. size?: number;
  121302. width?: number;
  121303. height?: number;
  121304. depth: number;
  121305. tileSize?: number;
  121306. tileWidth?: number;
  121307. tileHeight?: number;
  121308. faceUV?: Vector4[];
  121309. faceColors?: Color4[];
  121310. alignHorizontal?: number;
  121311. alignVertical?: number;
  121312. sideOrientation?: number;
  121313. updatable?: boolean;
  121314. }, scene?: Nullable<Scene>): Mesh;
  121315. /**
  121316. * Creates a sphere mesh
  121317. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  121318. * * 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`)
  121319. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  121320. * * 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
  121321. * * 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)
  121322. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121323. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121324. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121325. * @param name defines the name of the mesh
  121326. * @param options defines the options used to create the mesh
  121327. * @param scene defines the hosting scene
  121328. * @returns the sphere mesh
  121329. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  121330. */
  121331. static CreateSphere(name: string, options: {
  121332. segments?: number;
  121333. diameter?: number;
  121334. diameterX?: number;
  121335. diameterY?: number;
  121336. diameterZ?: number;
  121337. arc?: number;
  121338. slice?: number;
  121339. sideOrientation?: number;
  121340. frontUVs?: Vector4;
  121341. backUVs?: Vector4;
  121342. updatable?: boolean;
  121343. }, scene?: Nullable<Scene>): Mesh;
  121344. /**
  121345. * Creates a plane polygonal mesh. By default, this is a disc
  121346. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  121347. * * 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
  121348. * * 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
  121349. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121350. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121351. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121352. * @param name defines the name of the mesh
  121353. * @param options defines the options used to create the mesh
  121354. * @param scene defines the hosting scene
  121355. * @returns the plane polygonal mesh
  121356. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  121357. */
  121358. static CreateDisc(name: string, options: {
  121359. radius?: number;
  121360. tessellation?: number;
  121361. arc?: number;
  121362. updatable?: boolean;
  121363. sideOrientation?: number;
  121364. frontUVs?: Vector4;
  121365. backUVs?: Vector4;
  121366. }, scene?: Nullable<Scene>): Mesh;
  121367. /**
  121368. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  121369. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  121370. * * 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`)
  121371. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  121372. * * 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
  121373. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121374. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121375. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121376. * @param name defines the name of the mesh
  121377. * @param options defines the options used to create the mesh
  121378. * @param scene defines the hosting scene
  121379. * @returns the icosahedron mesh
  121380. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  121381. */
  121382. static CreateIcoSphere(name: string, options: {
  121383. radius?: number;
  121384. radiusX?: number;
  121385. radiusY?: number;
  121386. radiusZ?: number;
  121387. flat?: boolean;
  121388. subdivisions?: number;
  121389. sideOrientation?: number;
  121390. frontUVs?: Vector4;
  121391. backUVs?: Vector4;
  121392. updatable?: boolean;
  121393. }, scene?: Nullable<Scene>): Mesh;
  121394. /**
  121395. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  121396. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  121397. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  121398. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  121399. * * 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
  121400. * * 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
  121401. * * 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
  121402. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121403. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121404. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121405. * * 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
  121406. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  121407. * * 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
  121408. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  121409. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121410. * @param name defines the name of the mesh
  121411. * @param options defines the options used to create the mesh
  121412. * @param scene defines the hosting scene
  121413. * @returns the ribbon mesh
  121414. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  121415. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121416. */
  121417. static CreateRibbon(name: string, options: {
  121418. pathArray: Vector3[][];
  121419. closeArray?: boolean;
  121420. closePath?: boolean;
  121421. offset?: number;
  121422. updatable?: boolean;
  121423. sideOrientation?: number;
  121424. frontUVs?: Vector4;
  121425. backUVs?: Vector4;
  121426. instance?: Mesh;
  121427. invertUV?: boolean;
  121428. uvs?: Vector2[];
  121429. colors?: Color4[];
  121430. }, scene?: Nullable<Scene>): Mesh;
  121431. /**
  121432. * Creates a cylinder or a cone mesh
  121433. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  121434. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  121435. * * 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.
  121436. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  121437. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  121438. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  121439. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  121440. * * 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).
  121441. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  121442. * * 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).
  121443. * * 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
  121444. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  121445. * * 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
  121446. * * 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.
  121447. * * If `enclose` is false, a ring surface is one element.
  121448. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  121449. * * 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
  121450. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121451. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121452. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121453. * @param name defines the name of the mesh
  121454. * @param options defines the options used to create the mesh
  121455. * @param scene defines the hosting scene
  121456. * @returns the cylinder mesh
  121457. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  121458. */
  121459. static CreateCylinder(name: string, options: {
  121460. height?: number;
  121461. diameterTop?: number;
  121462. diameterBottom?: number;
  121463. diameter?: number;
  121464. tessellation?: number;
  121465. subdivisions?: number;
  121466. arc?: number;
  121467. faceColors?: Color4[];
  121468. faceUV?: Vector4[];
  121469. updatable?: boolean;
  121470. hasRings?: boolean;
  121471. enclose?: boolean;
  121472. cap?: number;
  121473. sideOrientation?: number;
  121474. frontUVs?: Vector4;
  121475. backUVs?: Vector4;
  121476. }, scene?: Nullable<Scene>): Mesh;
  121477. /**
  121478. * Creates a torus mesh
  121479. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  121480. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  121481. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  121482. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121483. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121484. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121485. * @param name defines the name of the mesh
  121486. * @param options defines the options used to create the mesh
  121487. * @param scene defines the hosting scene
  121488. * @returns the torus mesh
  121489. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  121490. */
  121491. static CreateTorus(name: string, options: {
  121492. diameter?: number;
  121493. thickness?: number;
  121494. tessellation?: number;
  121495. updatable?: boolean;
  121496. sideOrientation?: number;
  121497. frontUVs?: Vector4;
  121498. backUVs?: Vector4;
  121499. }, scene?: Nullable<Scene>): Mesh;
  121500. /**
  121501. * Creates a torus knot mesh
  121502. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  121503. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  121504. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  121505. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  121506. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121507. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121508. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121509. * @param name defines the name of the mesh
  121510. * @param options defines the options used to create the mesh
  121511. * @param scene defines the hosting scene
  121512. * @returns the torus knot mesh
  121513. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  121514. */
  121515. static CreateTorusKnot(name: string, options: {
  121516. radius?: number;
  121517. tube?: number;
  121518. radialSegments?: number;
  121519. tubularSegments?: number;
  121520. p?: number;
  121521. q?: number;
  121522. updatable?: boolean;
  121523. sideOrientation?: number;
  121524. frontUVs?: Vector4;
  121525. backUVs?: Vector4;
  121526. }, scene?: Nullable<Scene>): Mesh;
  121527. /**
  121528. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  121529. * * 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
  121530. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  121531. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  121532. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  121533. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  121534. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  121535. * * 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
  121536. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  121537. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121538. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  121539. * @param name defines the name of the new line system
  121540. * @param options defines the options used to create the line system
  121541. * @param scene defines the hosting scene
  121542. * @returns a new line system mesh
  121543. */
  121544. static CreateLineSystem(name: string, options: {
  121545. lines: Vector3[][];
  121546. updatable?: boolean;
  121547. instance?: Nullable<LinesMesh>;
  121548. colors?: Nullable<Color4[][]>;
  121549. useVertexAlpha?: boolean;
  121550. }, scene: Nullable<Scene>): LinesMesh;
  121551. /**
  121552. * Creates a line mesh
  121553. * 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
  121554. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  121555. * * The parameter `points` is an array successive Vector3
  121556. * * 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
  121557. * * The optional parameter `colors` is an array of successive Color4, one per line point
  121558. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  121559. * * When updating an instance, remember that only point positions can change, not the number of points
  121560. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121561. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  121562. * @param name defines the name of the new line system
  121563. * @param options defines the options used to create the line system
  121564. * @param scene defines the hosting scene
  121565. * @returns a new line mesh
  121566. */
  121567. static CreateLines(name: string, options: {
  121568. points: Vector3[];
  121569. updatable?: boolean;
  121570. instance?: Nullable<LinesMesh>;
  121571. colors?: Color4[];
  121572. useVertexAlpha?: boolean;
  121573. }, scene?: Nullable<Scene>): LinesMesh;
  121574. /**
  121575. * Creates a dashed line mesh
  121576. * * 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
  121577. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  121578. * * The parameter `points` is an array successive Vector3
  121579. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  121580. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  121581. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  121582. * * 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
  121583. * * When updating an instance, remember that only point positions can change, not the number of points
  121584. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121585. * @param name defines the name of the mesh
  121586. * @param options defines the options used to create the mesh
  121587. * @param scene defines the hosting scene
  121588. * @returns the dashed line mesh
  121589. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  121590. */
  121591. static CreateDashedLines(name: string, options: {
  121592. points: Vector3[];
  121593. dashSize?: number;
  121594. gapSize?: number;
  121595. dashNb?: number;
  121596. updatable?: boolean;
  121597. instance?: LinesMesh;
  121598. }, scene?: Nullable<Scene>): LinesMesh;
  121599. /**
  121600. * 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.
  121601. * * 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.
  121602. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  121603. * * 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.
  121604. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  121605. * * 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
  121606. * * 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
  121607. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  121608. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121609. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121610. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  121611. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121612. * @param name defines the name of the mesh
  121613. * @param options defines the options used to create the mesh
  121614. * @param scene defines the hosting scene
  121615. * @returns the extruded shape mesh
  121616. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121617. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  121618. */
  121619. static ExtrudeShape(name: string, options: {
  121620. shape: Vector3[];
  121621. path: Vector3[];
  121622. scale?: number;
  121623. rotation?: number;
  121624. cap?: number;
  121625. updatable?: boolean;
  121626. sideOrientation?: number;
  121627. frontUVs?: Vector4;
  121628. backUVs?: Vector4;
  121629. instance?: Mesh;
  121630. invertUV?: boolean;
  121631. }, scene?: Nullable<Scene>): Mesh;
  121632. /**
  121633. * Creates an custom extruded shape mesh.
  121634. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  121635. * * 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.
  121636. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  121637. * * 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
  121638. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  121639. * * 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
  121640. * * It must returns a float value that will be the scale value applied to the shape on each path point
  121641. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  121642. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  121643. * * 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
  121644. * * 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
  121645. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  121646. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121647. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121648. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121649. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121650. * @param name defines the name of the mesh
  121651. * @param options defines the options used to create the mesh
  121652. * @param scene defines the hosting scene
  121653. * @returns the custom extruded shape mesh
  121654. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  121655. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121656. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  121657. */
  121658. static ExtrudeShapeCustom(name: string, options: {
  121659. shape: Vector3[];
  121660. path: Vector3[];
  121661. scaleFunction?: any;
  121662. rotationFunction?: any;
  121663. ribbonCloseArray?: boolean;
  121664. ribbonClosePath?: boolean;
  121665. cap?: number;
  121666. updatable?: boolean;
  121667. sideOrientation?: number;
  121668. frontUVs?: Vector4;
  121669. backUVs?: Vector4;
  121670. instance?: Mesh;
  121671. invertUV?: boolean;
  121672. }, scene?: Nullable<Scene>): Mesh;
  121673. /**
  121674. * Creates lathe mesh.
  121675. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  121676. * * 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
  121677. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  121678. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  121679. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  121680. * * 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
  121681. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  121682. * * 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
  121683. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121684. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121685. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121686. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121687. * @param name defines the name of the mesh
  121688. * @param options defines the options used to create the mesh
  121689. * @param scene defines the hosting scene
  121690. * @returns the lathe mesh
  121691. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  121692. */
  121693. static CreateLathe(name: string, options: {
  121694. shape: Vector3[];
  121695. radius?: number;
  121696. tessellation?: number;
  121697. clip?: number;
  121698. arc?: number;
  121699. closed?: boolean;
  121700. updatable?: boolean;
  121701. sideOrientation?: number;
  121702. frontUVs?: Vector4;
  121703. backUVs?: Vector4;
  121704. cap?: number;
  121705. invertUV?: boolean;
  121706. }, scene?: Nullable<Scene>): Mesh;
  121707. /**
  121708. * Creates a tiled plane mesh
  121709. * * You can set a limited pattern arrangement with the tiles
  121710. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121711. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121712. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121713. * @param name defines the name of the mesh
  121714. * @param options defines the options used to create the mesh
  121715. * @param scene defines the hosting scene
  121716. * @returns the plane mesh
  121717. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  121718. */
  121719. static CreateTiledPlane(name: string, options: {
  121720. pattern?: number;
  121721. tileSize?: number;
  121722. tileWidth?: number;
  121723. tileHeight?: number;
  121724. size?: number;
  121725. width?: number;
  121726. height?: number;
  121727. alignHorizontal?: number;
  121728. alignVertical?: number;
  121729. sideOrientation?: number;
  121730. frontUVs?: Vector4;
  121731. backUVs?: Vector4;
  121732. updatable?: boolean;
  121733. }, scene?: Nullable<Scene>): Mesh;
  121734. /**
  121735. * Creates a plane mesh
  121736. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  121737. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  121738. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  121739. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121740. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121741. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121742. * @param name defines the name of the mesh
  121743. * @param options defines the options used to create the mesh
  121744. * @param scene defines the hosting scene
  121745. * @returns the plane mesh
  121746. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  121747. */
  121748. static CreatePlane(name: string, options: {
  121749. size?: number;
  121750. width?: number;
  121751. height?: number;
  121752. sideOrientation?: number;
  121753. frontUVs?: Vector4;
  121754. backUVs?: Vector4;
  121755. updatable?: boolean;
  121756. sourcePlane?: Plane;
  121757. }, scene?: Nullable<Scene>): Mesh;
  121758. /**
  121759. * Creates a ground mesh
  121760. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  121761. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  121762. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121763. * @param name defines the name of the mesh
  121764. * @param options defines the options used to create the mesh
  121765. * @param scene defines the hosting scene
  121766. * @returns the ground mesh
  121767. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  121768. */
  121769. static CreateGround(name: string, options: {
  121770. width?: number;
  121771. height?: number;
  121772. subdivisions?: number;
  121773. subdivisionsX?: number;
  121774. subdivisionsY?: number;
  121775. updatable?: boolean;
  121776. }, scene?: Nullable<Scene>): Mesh;
  121777. /**
  121778. * Creates a tiled ground mesh
  121779. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  121780. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  121781. * * 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
  121782. * * 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
  121783. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121784. * @param name defines the name of the mesh
  121785. * @param options defines the options used to create the mesh
  121786. * @param scene defines the hosting scene
  121787. * @returns the tiled ground mesh
  121788. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  121789. */
  121790. static CreateTiledGround(name: string, options: {
  121791. xmin: number;
  121792. zmin: number;
  121793. xmax: number;
  121794. zmax: number;
  121795. subdivisions?: {
  121796. w: number;
  121797. h: number;
  121798. };
  121799. precision?: {
  121800. w: number;
  121801. h: number;
  121802. };
  121803. updatable?: boolean;
  121804. }, scene?: Nullable<Scene>): Mesh;
  121805. /**
  121806. * Creates a ground mesh from a height map
  121807. * * The parameter `url` sets the URL of the height map image resource.
  121808. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  121809. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  121810. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  121811. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  121812. * * 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.
  121813. * * 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).
  121814. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  121815. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121816. * @param name defines the name of the mesh
  121817. * @param url defines the url to the height map
  121818. * @param options defines the options used to create the mesh
  121819. * @param scene defines the hosting scene
  121820. * @returns the ground mesh
  121821. * @see https://doc.babylonjs.com/babylon101/height_map
  121822. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  121823. */
  121824. static CreateGroundFromHeightMap(name: string, url: string, options: {
  121825. width?: number;
  121826. height?: number;
  121827. subdivisions?: number;
  121828. minHeight?: number;
  121829. maxHeight?: number;
  121830. colorFilter?: Color3;
  121831. alphaFilter?: number;
  121832. updatable?: boolean;
  121833. onReady?: (mesh: GroundMesh) => void;
  121834. }, scene?: Nullable<Scene>): GroundMesh;
  121835. /**
  121836. * Creates a polygon mesh
  121837. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  121838. * * 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
  121839. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  121840. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121841. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  121842. * * Remember you can only change the shape positions, not their number when updating a polygon
  121843. * @param name defines the name of the mesh
  121844. * @param options defines the options used to create the mesh
  121845. * @param scene defines the hosting scene
  121846. * @param earcutInjection can be used to inject your own earcut reference
  121847. * @returns the polygon mesh
  121848. */
  121849. static CreatePolygon(name: string, options: {
  121850. shape: Vector3[];
  121851. holes?: Vector3[][];
  121852. depth?: number;
  121853. faceUV?: Vector4[];
  121854. faceColors?: Color4[];
  121855. updatable?: boolean;
  121856. sideOrientation?: number;
  121857. frontUVs?: Vector4;
  121858. backUVs?: Vector4;
  121859. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  121860. /**
  121861. * Creates an extruded polygon mesh, with depth in the Y direction.
  121862. * * 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)
  121863. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  121864. * @param name defines the name of the mesh
  121865. * @param options defines the options used to create the mesh
  121866. * @param scene defines the hosting scene
  121867. * @param earcutInjection can be used to inject your own earcut reference
  121868. * @returns the polygon mesh
  121869. */
  121870. static ExtrudePolygon(name: string, options: {
  121871. shape: Vector3[];
  121872. holes?: Vector3[][];
  121873. depth?: number;
  121874. faceUV?: Vector4[];
  121875. faceColors?: Color4[];
  121876. updatable?: boolean;
  121877. sideOrientation?: number;
  121878. frontUVs?: Vector4;
  121879. backUVs?: Vector4;
  121880. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  121881. /**
  121882. * Creates a tube mesh.
  121883. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  121884. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  121885. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  121886. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  121887. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  121888. * * 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)
  121889. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  121890. * * 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
  121891. * * 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
  121892. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121893. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121894. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121895. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121896. * @param name defines the name of the mesh
  121897. * @param options defines the options used to create the mesh
  121898. * @param scene defines the hosting scene
  121899. * @returns the tube mesh
  121900. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121901. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  121902. */
  121903. static CreateTube(name: string, options: {
  121904. path: Vector3[];
  121905. radius?: number;
  121906. tessellation?: number;
  121907. radiusFunction?: {
  121908. (i: number, distance: number): number;
  121909. };
  121910. cap?: number;
  121911. arc?: number;
  121912. updatable?: boolean;
  121913. sideOrientation?: number;
  121914. frontUVs?: Vector4;
  121915. backUVs?: Vector4;
  121916. instance?: Mesh;
  121917. invertUV?: boolean;
  121918. }, scene?: Nullable<Scene>): Mesh;
  121919. /**
  121920. * Creates a polyhedron mesh
  121921. * * 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
  121922. * * The parameter `size` (positive float, default 1) sets the polygon size
  121923. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  121924. * * 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`
  121925. * * 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
  121926. * * 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)`)
  121927. * * 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
  121928. * * 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
  121929. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121930. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121931. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121932. * @param name defines the name of the mesh
  121933. * @param options defines the options used to create the mesh
  121934. * @param scene defines the hosting scene
  121935. * @returns the polyhedron mesh
  121936. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  121937. */
  121938. static CreatePolyhedron(name: string, options: {
  121939. type?: number;
  121940. size?: number;
  121941. sizeX?: number;
  121942. sizeY?: number;
  121943. sizeZ?: number;
  121944. custom?: any;
  121945. faceUV?: Vector4[];
  121946. faceColors?: Color4[];
  121947. flat?: boolean;
  121948. updatable?: boolean;
  121949. sideOrientation?: number;
  121950. frontUVs?: Vector4;
  121951. backUVs?: Vector4;
  121952. }, scene?: Nullable<Scene>): Mesh;
  121953. /**
  121954. * Creates a decal mesh.
  121955. * 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
  121956. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  121957. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  121958. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  121959. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  121960. * @param name defines the name of the mesh
  121961. * @param sourceMesh defines the mesh where the decal must be applied
  121962. * @param options defines the options used to create the mesh
  121963. * @param scene defines the hosting scene
  121964. * @returns the decal mesh
  121965. * @see https://doc.babylonjs.com/how_to/decals
  121966. */
  121967. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  121968. position?: Vector3;
  121969. normal?: Vector3;
  121970. size?: Vector3;
  121971. angle?: number;
  121972. }): Mesh;
  121973. }
  121974. }
  121975. declare module BABYLON {
  121976. /**
  121977. * A simplifier interface for future simplification implementations
  121978. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  121979. */
  121980. export interface ISimplifier {
  121981. /**
  121982. * Simplification of a given mesh according to the given settings.
  121983. * Since this requires computation, it is assumed that the function runs async.
  121984. * @param settings The settings of the simplification, including quality and distance
  121985. * @param successCallback A callback that will be called after the mesh was simplified.
  121986. * @param errorCallback in case of an error, this callback will be called. optional.
  121987. */
  121988. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  121989. }
  121990. /**
  121991. * Expected simplification settings.
  121992. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  121993. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  121994. */
  121995. export interface ISimplificationSettings {
  121996. /**
  121997. * Gets or sets the expected quality
  121998. */
  121999. quality: number;
  122000. /**
  122001. * Gets or sets the distance when this optimized version should be used
  122002. */
  122003. distance: number;
  122004. /**
  122005. * Gets an already optimized mesh
  122006. */
  122007. optimizeMesh?: boolean;
  122008. }
  122009. /**
  122010. * Class used to specify simplification options
  122011. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  122012. */
  122013. export class SimplificationSettings implements ISimplificationSettings {
  122014. /** expected quality */
  122015. quality: number;
  122016. /** distance when this optimized version should be used */
  122017. distance: number;
  122018. /** already optimized mesh */
  122019. optimizeMesh?: boolean | undefined;
  122020. /**
  122021. * Creates a SimplificationSettings
  122022. * @param quality expected quality
  122023. * @param distance distance when this optimized version should be used
  122024. * @param optimizeMesh already optimized mesh
  122025. */
  122026. constructor(
  122027. /** expected quality */
  122028. quality: number,
  122029. /** distance when this optimized version should be used */
  122030. distance: number,
  122031. /** already optimized mesh */
  122032. optimizeMesh?: boolean | undefined);
  122033. }
  122034. /**
  122035. * Interface used to define a simplification task
  122036. */
  122037. export interface ISimplificationTask {
  122038. /**
  122039. * Array of settings
  122040. */
  122041. settings: Array<ISimplificationSettings>;
  122042. /**
  122043. * Simplification type
  122044. */
  122045. simplificationType: SimplificationType;
  122046. /**
  122047. * Mesh to simplify
  122048. */
  122049. mesh: Mesh;
  122050. /**
  122051. * Callback called on success
  122052. */
  122053. successCallback?: () => void;
  122054. /**
  122055. * Defines if parallel processing can be used
  122056. */
  122057. parallelProcessing: boolean;
  122058. }
  122059. /**
  122060. * Queue used to order the simplification tasks
  122061. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  122062. */
  122063. export class SimplificationQueue {
  122064. private _simplificationArray;
  122065. /**
  122066. * Gets a boolean indicating that the process is still running
  122067. */
  122068. running: boolean;
  122069. /**
  122070. * Creates a new queue
  122071. */
  122072. constructor();
  122073. /**
  122074. * Adds a new simplification task
  122075. * @param task defines a task to add
  122076. */
  122077. addTask(task: ISimplificationTask): void;
  122078. /**
  122079. * Execute next task
  122080. */
  122081. executeNext(): void;
  122082. /**
  122083. * Execute a simplification task
  122084. * @param task defines the task to run
  122085. */
  122086. runSimplification(task: ISimplificationTask): void;
  122087. private getSimplifier;
  122088. }
  122089. /**
  122090. * The implemented types of simplification
  122091. * At the moment only Quadratic Error Decimation is implemented
  122092. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  122093. */
  122094. export enum SimplificationType {
  122095. /** Quadratic error decimation */
  122096. QUADRATIC = 0
  122097. }
  122098. }
  122099. declare module BABYLON {
  122100. interface Scene {
  122101. /** @hidden (Backing field) */
  122102. _simplificationQueue: SimplificationQueue;
  122103. /**
  122104. * Gets or sets the simplification queue attached to the scene
  122105. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  122106. */
  122107. simplificationQueue: SimplificationQueue;
  122108. }
  122109. interface Mesh {
  122110. /**
  122111. * Simplify the mesh according to the given array of settings.
  122112. * Function will return immediately and will simplify async
  122113. * @param settings a collection of simplification settings
  122114. * @param parallelProcessing should all levels calculate parallel or one after the other
  122115. * @param simplificationType the type of simplification to run
  122116. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  122117. * @returns the current mesh
  122118. */
  122119. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  122120. }
  122121. /**
  122122. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  122123. * created in a scene
  122124. */
  122125. export class SimplicationQueueSceneComponent implements ISceneComponent {
  122126. /**
  122127. * The component name helpfull to identify the component in the list of scene components.
  122128. */
  122129. readonly name: string;
  122130. /**
  122131. * The scene the component belongs to.
  122132. */
  122133. scene: Scene;
  122134. /**
  122135. * Creates a new instance of the component for the given scene
  122136. * @param scene Defines the scene to register the component in
  122137. */
  122138. constructor(scene: Scene);
  122139. /**
  122140. * Registers the component in a given scene
  122141. */
  122142. register(): void;
  122143. /**
  122144. * Rebuilds the elements related to this component in case of
  122145. * context lost for instance.
  122146. */
  122147. rebuild(): void;
  122148. /**
  122149. * Disposes the component and the associated ressources
  122150. */
  122151. dispose(): void;
  122152. private _beforeCameraUpdate;
  122153. }
  122154. }
  122155. declare module BABYLON {
  122156. /**
  122157. * Navigation plugin interface to add navigation constrained by a navigation mesh
  122158. */
  122159. export interface INavigationEnginePlugin {
  122160. /**
  122161. * plugin name
  122162. */
  122163. name: string;
  122164. /**
  122165. * Creates a navigation mesh
  122166. * @param meshes array of all the geometry used to compute the navigatio mesh
  122167. * @param parameters bunch of parameters used to filter geometry
  122168. */
  122169. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  122170. /**
  122171. * Create a navigation mesh debug mesh
  122172. * @param scene is where the mesh will be added
  122173. * @returns debug display mesh
  122174. */
  122175. createDebugNavMesh(scene: Scene): Mesh;
  122176. /**
  122177. * Get a navigation mesh constrained position, closest to the parameter position
  122178. * @param position world position
  122179. * @returns the closest point to position constrained by the navigation mesh
  122180. */
  122181. getClosestPoint(position: Vector3): Vector3;
  122182. /**
  122183. * Get a navigation mesh constrained position, within a particular radius
  122184. * @param position world position
  122185. * @param maxRadius the maximum distance to the constrained world position
  122186. * @returns the closest point to position constrained by the navigation mesh
  122187. */
  122188. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  122189. /**
  122190. * Compute the final position from a segment made of destination-position
  122191. * @param position world position
  122192. * @param destination world position
  122193. * @returns the resulting point along the navmesh
  122194. */
  122195. moveAlong(position: Vector3, destination: Vector3): Vector3;
  122196. /**
  122197. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  122198. * @param start world position
  122199. * @param end world position
  122200. * @returns array containing world position composing the path
  122201. */
  122202. computePath(start: Vector3, end: Vector3): Vector3[];
  122203. /**
  122204. * If this plugin is supported
  122205. * @returns true if plugin is supported
  122206. */
  122207. isSupported(): boolean;
  122208. /**
  122209. * Create a new Crowd so you can add agents
  122210. * @param maxAgents the maximum agent count in the crowd
  122211. * @param maxAgentRadius the maximum radius an agent can have
  122212. * @param scene to attach the crowd to
  122213. * @returns the crowd you can add agents to
  122214. */
  122215. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  122216. /**
  122217. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  122218. * The queries will try to find a solution within those bounds
  122219. * default is (1,1,1)
  122220. * @param extent x,y,z value that define the extent around the queries point of reference
  122221. */
  122222. setDefaultQueryExtent(extent: Vector3): void;
  122223. /**
  122224. * Get the Bounding box extent specified by setDefaultQueryExtent
  122225. * @returns the box extent values
  122226. */
  122227. getDefaultQueryExtent(): Vector3;
  122228. /**
  122229. * Release all resources
  122230. */
  122231. dispose(): void;
  122232. }
  122233. /**
  122234. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  122235. */
  122236. export interface ICrowd {
  122237. /**
  122238. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  122239. * You can attach anything to that node. The node position is updated in the scene update tick.
  122240. * @param pos world position that will be constrained by the navigation mesh
  122241. * @param parameters agent parameters
  122242. * @param transform hooked to the agent that will be update by the scene
  122243. * @returns agent index
  122244. */
  122245. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  122246. /**
  122247. * Returns the agent position in world space
  122248. * @param index agent index returned by addAgent
  122249. * @returns world space position
  122250. */
  122251. getAgentPosition(index: number): Vector3;
  122252. /**
  122253. * Gets the agent velocity in world space
  122254. * @param index agent index returned by addAgent
  122255. * @returns world space velocity
  122256. */
  122257. getAgentVelocity(index: number): Vector3;
  122258. /**
  122259. * remove a particular agent previously created
  122260. * @param index agent index returned by addAgent
  122261. */
  122262. removeAgent(index: number): void;
  122263. /**
  122264. * get the list of all agents attached to this crowd
  122265. * @returns list of agent indices
  122266. */
  122267. getAgents(): number[];
  122268. /**
  122269. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  122270. * @param deltaTime in seconds
  122271. */
  122272. update(deltaTime: number): void;
  122273. /**
  122274. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  122275. * @param index agent index returned by addAgent
  122276. * @param destination targeted world position
  122277. */
  122278. agentGoto(index: number, destination: Vector3): void;
  122279. /**
  122280. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  122281. * The queries will try to find a solution within those bounds
  122282. * default is (1,1,1)
  122283. * @param extent x,y,z value that define the extent around the queries point of reference
  122284. */
  122285. setDefaultQueryExtent(extent: Vector3): void;
  122286. /**
  122287. * Get the Bounding box extent specified by setDefaultQueryExtent
  122288. * @returns the box extent values
  122289. */
  122290. getDefaultQueryExtent(): Vector3;
  122291. /**
  122292. * Release all resources
  122293. */
  122294. dispose(): void;
  122295. }
  122296. /**
  122297. * Configures an agent
  122298. */
  122299. export interface IAgentParameters {
  122300. /**
  122301. * Agent radius. [Limit: >= 0]
  122302. */
  122303. radius: number;
  122304. /**
  122305. * Agent height. [Limit: > 0]
  122306. */
  122307. height: number;
  122308. /**
  122309. * Maximum allowed acceleration. [Limit: >= 0]
  122310. */
  122311. maxAcceleration: number;
  122312. /**
  122313. * Maximum allowed speed. [Limit: >= 0]
  122314. */
  122315. maxSpeed: number;
  122316. /**
  122317. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  122318. */
  122319. collisionQueryRange: number;
  122320. /**
  122321. * The path visibility optimization range. [Limit: > 0]
  122322. */
  122323. pathOptimizationRange: number;
  122324. /**
  122325. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  122326. */
  122327. separationWeight: number;
  122328. }
  122329. /**
  122330. * Configures the navigation mesh creation
  122331. */
  122332. export interface INavMeshParameters {
  122333. /**
  122334. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  122335. */
  122336. cs: number;
  122337. /**
  122338. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  122339. */
  122340. ch: number;
  122341. /**
  122342. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  122343. */
  122344. walkableSlopeAngle: number;
  122345. /**
  122346. * Minimum floor to 'ceiling' height that will still allow the floor area to
  122347. * be considered walkable. [Limit: >= 3] [Units: vx]
  122348. */
  122349. walkableHeight: number;
  122350. /**
  122351. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  122352. */
  122353. walkableClimb: number;
  122354. /**
  122355. * The distance to erode/shrink the walkable area of the heightfield away from
  122356. * obstructions. [Limit: >=0] [Units: vx]
  122357. */
  122358. walkableRadius: number;
  122359. /**
  122360. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  122361. */
  122362. maxEdgeLen: number;
  122363. /**
  122364. * The maximum distance a simplfied contour's border edges should deviate
  122365. * the original raw contour. [Limit: >=0] [Units: vx]
  122366. */
  122367. maxSimplificationError: number;
  122368. /**
  122369. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  122370. */
  122371. minRegionArea: number;
  122372. /**
  122373. * Any regions with a span count smaller than this value will, if possible,
  122374. * be merged with larger regions. [Limit: >=0] [Units: vx]
  122375. */
  122376. mergeRegionArea: number;
  122377. /**
  122378. * The maximum number of vertices allowed for polygons generated during the
  122379. * contour to polygon conversion process. [Limit: >= 3]
  122380. */
  122381. maxVertsPerPoly: number;
  122382. /**
  122383. * Sets the sampling distance to use when generating the detail mesh.
  122384. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  122385. */
  122386. detailSampleDist: number;
  122387. /**
  122388. * The maximum distance the detail mesh surface should deviate from heightfield
  122389. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  122390. */
  122391. detailSampleMaxError: number;
  122392. }
  122393. }
  122394. declare module BABYLON {
  122395. /**
  122396. * RecastJS navigation plugin
  122397. */
  122398. export class RecastJSPlugin implements INavigationEnginePlugin {
  122399. /**
  122400. * Reference to the Recast library
  122401. */
  122402. bjsRECAST: any;
  122403. /**
  122404. * plugin name
  122405. */
  122406. name: string;
  122407. /**
  122408. * the first navmesh created. We might extend this to support multiple navmeshes
  122409. */
  122410. navMesh: any;
  122411. /**
  122412. * Initializes the recastJS plugin
  122413. * @param recastInjection can be used to inject your own recast reference
  122414. */
  122415. constructor(recastInjection?: any);
  122416. /**
  122417. * Creates a navigation mesh
  122418. * @param meshes array of all the geometry used to compute the navigatio mesh
  122419. * @param parameters bunch of parameters used to filter geometry
  122420. */
  122421. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  122422. /**
  122423. * Create a navigation mesh debug mesh
  122424. * @param scene is where the mesh will be added
  122425. * @returns debug display mesh
  122426. */
  122427. createDebugNavMesh(scene: Scene): Mesh;
  122428. /**
  122429. * Get a navigation mesh constrained position, closest to the parameter position
  122430. * @param position world position
  122431. * @returns the closest point to position constrained by the navigation mesh
  122432. */
  122433. getClosestPoint(position: Vector3): Vector3;
  122434. /**
  122435. * Get a navigation mesh constrained position, within a particular radius
  122436. * @param position world position
  122437. * @param maxRadius the maximum distance to the constrained world position
  122438. * @returns the closest point to position constrained by the navigation mesh
  122439. */
  122440. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  122441. /**
  122442. * Compute the final position from a segment made of destination-position
  122443. * @param position world position
  122444. * @param destination world position
  122445. * @returns the resulting point along the navmesh
  122446. */
  122447. moveAlong(position: Vector3, destination: Vector3): Vector3;
  122448. /**
  122449. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  122450. * @param start world position
  122451. * @param end world position
  122452. * @returns array containing world position composing the path
  122453. */
  122454. computePath(start: Vector3, end: Vector3): Vector3[];
  122455. /**
  122456. * Create a new Crowd so you can add agents
  122457. * @param maxAgents the maximum agent count in the crowd
  122458. * @param maxAgentRadius the maximum radius an agent can have
  122459. * @param scene to attach the crowd to
  122460. * @returns the crowd you can add agents to
  122461. */
  122462. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  122463. /**
  122464. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  122465. * The queries will try to find a solution within those bounds
  122466. * default is (1,1,1)
  122467. * @param extent x,y,z value that define the extent around the queries point of reference
  122468. */
  122469. setDefaultQueryExtent(extent: Vector3): void;
  122470. /**
  122471. * Get the Bounding box extent specified by setDefaultQueryExtent
  122472. * @returns the box extent values
  122473. */
  122474. getDefaultQueryExtent(): Vector3;
  122475. /**
  122476. * Disposes
  122477. */
  122478. dispose(): void;
  122479. /**
  122480. * If this plugin is supported
  122481. * @returns true if plugin is supported
  122482. */
  122483. isSupported(): boolean;
  122484. }
  122485. /**
  122486. * Recast detour crowd implementation
  122487. */
  122488. export class RecastJSCrowd implements ICrowd {
  122489. /**
  122490. * Recast/detour plugin
  122491. */
  122492. bjsRECASTPlugin: RecastJSPlugin;
  122493. /**
  122494. * Link to the detour crowd
  122495. */
  122496. recastCrowd: any;
  122497. /**
  122498. * One transform per agent
  122499. */
  122500. transforms: TransformNode[];
  122501. /**
  122502. * All agents created
  122503. */
  122504. agents: number[];
  122505. /**
  122506. * Link to the scene is kept to unregister the crowd from the scene
  122507. */
  122508. private _scene;
  122509. /**
  122510. * Observer for crowd updates
  122511. */
  122512. private _onBeforeAnimationsObserver;
  122513. /**
  122514. * Constructor
  122515. * @param plugin recastJS plugin
  122516. * @param maxAgents the maximum agent count in the crowd
  122517. * @param maxAgentRadius the maximum radius an agent can have
  122518. * @param scene to attach the crowd to
  122519. * @returns the crowd you can add agents to
  122520. */
  122521. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  122522. /**
  122523. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  122524. * You can attach anything to that node. The node position is updated in the scene update tick.
  122525. * @param pos world position that will be constrained by the navigation mesh
  122526. * @param parameters agent parameters
  122527. * @param transform hooked to the agent that will be update by the scene
  122528. * @returns agent index
  122529. */
  122530. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  122531. /**
  122532. * Returns the agent position in world space
  122533. * @param index agent index returned by addAgent
  122534. * @returns world space position
  122535. */
  122536. getAgentPosition(index: number): Vector3;
  122537. /**
  122538. * Returns the agent velocity in world space
  122539. * @param index agent index returned by addAgent
  122540. * @returns world space velocity
  122541. */
  122542. getAgentVelocity(index: number): Vector3;
  122543. /**
  122544. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  122545. * @param index agent index returned by addAgent
  122546. * @param destination targeted world position
  122547. */
  122548. agentGoto(index: number, destination: Vector3): void;
  122549. /**
  122550. * remove a particular agent previously created
  122551. * @param index agent index returned by addAgent
  122552. */
  122553. removeAgent(index: number): void;
  122554. /**
  122555. * get the list of all agents attached to this crowd
  122556. * @returns list of agent indices
  122557. */
  122558. getAgents(): number[];
  122559. /**
  122560. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  122561. * @param deltaTime in seconds
  122562. */
  122563. update(deltaTime: number): void;
  122564. /**
  122565. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  122566. * The queries will try to find a solution within those bounds
  122567. * default is (1,1,1)
  122568. * @param extent x,y,z value that define the extent around the queries point of reference
  122569. */
  122570. setDefaultQueryExtent(extent: Vector3): void;
  122571. /**
  122572. * Get the Bounding box extent specified by setDefaultQueryExtent
  122573. * @returns the box extent values
  122574. */
  122575. getDefaultQueryExtent(): Vector3;
  122576. /**
  122577. * Release all resources
  122578. */
  122579. dispose(): void;
  122580. }
  122581. }
  122582. declare module BABYLON {
  122583. /**
  122584. * Class used to enable access to IndexedDB
  122585. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  122586. */
  122587. export class Database implements IOfflineProvider {
  122588. private _callbackManifestChecked;
  122589. private _currentSceneUrl;
  122590. private _db;
  122591. private _enableSceneOffline;
  122592. private _enableTexturesOffline;
  122593. private _manifestVersionFound;
  122594. private _mustUpdateRessources;
  122595. private _hasReachedQuota;
  122596. private _isSupported;
  122597. private _idbFactory;
  122598. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  122599. private static IsUASupportingBlobStorage;
  122600. /**
  122601. * Gets a boolean indicating if Database storate is enabled (off by default)
  122602. */
  122603. static IDBStorageEnabled: boolean;
  122604. /**
  122605. * Gets a boolean indicating if scene must be saved in the database
  122606. */
  122607. readonly enableSceneOffline: boolean;
  122608. /**
  122609. * Gets a boolean indicating if textures must be saved in the database
  122610. */
  122611. readonly enableTexturesOffline: boolean;
  122612. /**
  122613. * Creates a new Database
  122614. * @param urlToScene defines the url to load the scene
  122615. * @param callbackManifestChecked defines the callback to use when manifest is checked
  122616. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  122617. */
  122618. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  122619. private static _ParseURL;
  122620. private static _ReturnFullUrlLocation;
  122621. private _checkManifestFile;
  122622. /**
  122623. * Open the database and make it available
  122624. * @param successCallback defines the callback to call on success
  122625. * @param errorCallback defines the callback to call on error
  122626. */
  122627. open(successCallback: () => void, errorCallback: () => void): void;
  122628. /**
  122629. * Loads an image from the database
  122630. * @param url defines the url to load from
  122631. * @param image defines the target DOM image
  122632. */
  122633. loadImage(url: string, image: HTMLImageElement): void;
  122634. private _loadImageFromDBAsync;
  122635. private _saveImageIntoDBAsync;
  122636. private _checkVersionFromDB;
  122637. private _loadVersionFromDBAsync;
  122638. private _saveVersionIntoDBAsync;
  122639. /**
  122640. * Loads a file from database
  122641. * @param url defines the URL to load from
  122642. * @param sceneLoaded defines a callback to call on success
  122643. * @param progressCallBack defines a callback to call when progress changed
  122644. * @param errorCallback defines a callback to call on error
  122645. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  122646. */
  122647. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  122648. private _loadFileAsync;
  122649. private _saveFileAsync;
  122650. /**
  122651. * Validates if xhr data is correct
  122652. * @param xhr defines the request to validate
  122653. * @param dataType defines the expected data type
  122654. * @returns true if data is correct
  122655. */
  122656. private static _ValidateXHRData;
  122657. }
  122658. }
  122659. declare module BABYLON {
  122660. /** @hidden */
  122661. export var gpuUpdateParticlesPixelShader: {
  122662. name: string;
  122663. shader: string;
  122664. };
  122665. }
  122666. declare module BABYLON {
  122667. /** @hidden */
  122668. export var gpuUpdateParticlesVertexShader: {
  122669. name: string;
  122670. shader: string;
  122671. };
  122672. }
  122673. declare module BABYLON {
  122674. /** @hidden */
  122675. export var clipPlaneFragmentDeclaration2: {
  122676. name: string;
  122677. shader: string;
  122678. };
  122679. }
  122680. declare module BABYLON {
  122681. /** @hidden */
  122682. export var gpuRenderParticlesPixelShader: {
  122683. name: string;
  122684. shader: string;
  122685. };
  122686. }
  122687. declare module BABYLON {
  122688. /** @hidden */
  122689. export var clipPlaneVertexDeclaration2: {
  122690. name: string;
  122691. shader: string;
  122692. };
  122693. }
  122694. declare module BABYLON {
  122695. /** @hidden */
  122696. export var gpuRenderParticlesVertexShader: {
  122697. name: string;
  122698. shader: string;
  122699. };
  122700. }
  122701. declare module BABYLON {
  122702. /**
  122703. * This represents a GPU particle system in Babylon
  122704. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  122705. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  122706. */
  122707. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  122708. /**
  122709. * The layer mask we are rendering the particles through.
  122710. */
  122711. layerMask: number;
  122712. private _capacity;
  122713. private _activeCount;
  122714. private _currentActiveCount;
  122715. private _accumulatedCount;
  122716. private _renderEffect;
  122717. private _updateEffect;
  122718. private _buffer0;
  122719. private _buffer1;
  122720. private _spriteBuffer;
  122721. private _updateVAO;
  122722. private _renderVAO;
  122723. private _targetIndex;
  122724. private _sourceBuffer;
  122725. private _targetBuffer;
  122726. private _engine;
  122727. private _currentRenderId;
  122728. private _started;
  122729. private _stopped;
  122730. private _timeDelta;
  122731. private _randomTexture;
  122732. private _randomTexture2;
  122733. private _attributesStrideSize;
  122734. private _updateEffectOptions;
  122735. private _randomTextureSize;
  122736. private _actualFrame;
  122737. private readonly _rawTextureWidth;
  122738. /**
  122739. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  122740. */
  122741. static readonly IsSupported: boolean;
  122742. /**
  122743. * An event triggered when the system is disposed.
  122744. */
  122745. onDisposeObservable: Observable<GPUParticleSystem>;
  122746. /**
  122747. * Gets the maximum number of particles active at the same time.
  122748. * @returns The max number of active particles.
  122749. */
  122750. getCapacity(): number;
  122751. /**
  122752. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  122753. * to override the particles.
  122754. */
  122755. forceDepthWrite: boolean;
  122756. /**
  122757. * Gets or set the number of active particles
  122758. */
  122759. activeParticleCount: number;
  122760. private _preWarmDone;
  122761. /**
  122762. * Is this system ready to be used/rendered
  122763. * @return true if the system is ready
  122764. */
  122765. isReady(): boolean;
  122766. /**
  122767. * Gets if the system has been started. (Note: this will still be true after stop is called)
  122768. * @returns True if it has been started, otherwise false.
  122769. */
  122770. isStarted(): boolean;
  122771. /**
  122772. * Starts the particle system and begins to emit
  122773. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  122774. */
  122775. start(delay?: number): void;
  122776. /**
  122777. * Stops the particle system.
  122778. */
  122779. stop(): void;
  122780. /**
  122781. * Remove all active particles
  122782. */
  122783. reset(): void;
  122784. /**
  122785. * Returns the string "GPUParticleSystem"
  122786. * @returns a string containing the class name
  122787. */
  122788. getClassName(): string;
  122789. private _colorGradientsTexture;
  122790. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  122791. /**
  122792. * Adds a new color gradient
  122793. * @param gradient defines the gradient to use (between 0 and 1)
  122794. * @param color1 defines the color to affect to the specified gradient
  122795. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  122796. * @returns the current particle system
  122797. */
  122798. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  122799. /**
  122800. * Remove a specific color gradient
  122801. * @param gradient defines the gradient to remove
  122802. * @returns the current particle system
  122803. */
  122804. removeColorGradient(gradient: number): GPUParticleSystem;
  122805. private _angularSpeedGradientsTexture;
  122806. private _sizeGradientsTexture;
  122807. private _velocityGradientsTexture;
  122808. private _limitVelocityGradientsTexture;
  122809. private _dragGradientsTexture;
  122810. private _addFactorGradient;
  122811. /**
  122812. * Adds a new size gradient
  122813. * @param gradient defines the gradient to use (between 0 and 1)
  122814. * @param factor defines the size factor to affect to the specified gradient
  122815. * @returns the current particle system
  122816. */
  122817. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  122818. /**
  122819. * Remove a specific size gradient
  122820. * @param gradient defines the gradient to remove
  122821. * @returns the current particle system
  122822. */
  122823. removeSizeGradient(gradient: number): GPUParticleSystem;
  122824. /**
  122825. * Adds a new angular speed gradient
  122826. * @param gradient defines the gradient to use (between 0 and 1)
  122827. * @param factor defines the angular speed to affect to the specified gradient
  122828. * @returns the current particle system
  122829. */
  122830. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  122831. /**
  122832. * Remove a specific angular speed gradient
  122833. * @param gradient defines the gradient to remove
  122834. * @returns the current particle system
  122835. */
  122836. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  122837. /**
  122838. * Adds a new velocity gradient
  122839. * @param gradient defines the gradient to use (between 0 and 1)
  122840. * @param factor defines the velocity to affect to the specified gradient
  122841. * @returns the current particle system
  122842. */
  122843. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  122844. /**
  122845. * Remove a specific velocity gradient
  122846. * @param gradient defines the gradient to remove
  122847. * @returns the current particle system
  122848. */
  122849. removeVelocityGradient(gradient: number): GPUParticleSystem;
  122850. /**
  122851. * Adds a new limit velocity gradient
  122852. * @param gradient defines the gradient to use (between 0 and 1)
  122853. * @param factor defines the limit velocity value to affect to the specified gradient
  122854. * @returns the current particle system
  122855. */
  122856. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  122857. /**
  122858. * Remove a specific limit velocity gradient
  122859. * @param gradient defines the gradient to remove
  122860. * @returns the current particle system
  122861. */
  122862. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  122863. /**
  122864. * Adds a new drag gradient
  122865. * @param gradient defines the gradient to use (between 0 and 1)
  122866. * @param factor defines the drag value to affect to the specified gradient
  122867. * @returns the current particle system
  122868. */
  122869. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  122870. /**
  122871. * Remove a specific drag gradient
  122872. * @param gradient defines the gradient to remove
  122873. * @returns the current particle system
  122874. */
  122875. removeDragGradient(gradient: number): GPUParticleSystem;
  122876. /**
  122877. * Not supported by GPUParticleSystem
  122878. * @param gradient defines the gradient to use (between 0 and 1)
  122879. * @param factor defines the emit rate value to affect to the specified gradient
  122880. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  122881. * @returns the current particle system
  122882. */
  122883. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  122884. /**
  122885. * Not supported by GPUParticleSystem
  122886. * @param gradient defines the gradient to remove
  122887. * @returns the current particle system
  122888. */
  122889. removeEmitRateGradient(gradient: number): IParticleSystem;
  122890. /**
  122891. * Not supported by GPUParticleSystem
  122892. * @param gradient defines the gradient to use (between 0 and 1)
  122893. * @param factor defines the start size value to affect to the specified gradient
  122894. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  122895. * @returns the current particle system
  122896. */
  122897. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  122898. /**
  122899. * Not supported by GPUParticleSystem
  122900. * @param gradient defines the gradient to remove
  122901. * @returns the current particle system
  122902. */
  122903. removeStartSizeGradient(gradient: number): IParticleSystem;
  122904. /**
  122905. * Not supported by GPUParticleSystem
  122906. * @param gradient defines the gradient to use (between 0 and 1)
  122907. * @param min defines the color remap minimal range
  122908. * @param max defines the color remap maximal range
  122909. * @returns the current particle system
  122910. */
  122911. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  122912. /**
  122913. * Not supported by GPUParticleSystem
  122914. * @param gradient defines the gradient to remove
  122915. * @returns the current particle system
  122916. */
  122917. removeColorRemapGradient(): IParticleSystem;
  122918. /**
  122919. * Not supported by GPUParticleSystem
  122920. * @param gradient defines the gradient to use (between 0 and 1)
  122921. * @param min defines the alpha remap minimal range
  122922. * @param max defines the alpha remap maximal range
  122923. * @returns the current particle system
  122924. */
  122925. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  122926. /**
  122927. * Not supported by GPUParticleSystem
  122928. * @param gradient defines the gradient to remove
  122929. * @returns the current particle system
  122930. */
  122931. removeAlphaRemapGradient(): IParticleSystem;
  122932. /**
  122933. * Not supported by GPUParticleSystem
  122934. * @param gradient defines the gradient to use (between 0 and 1)
  122935. * @param color defines the color to affect to the specified gradient
  122936. * @returns the current particle system
  122937. */
  122938. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  122939. /**
  122940. * Not supported by GPUParticleSystem
  122941. * @param gradient defines the gradient to remove
  122942. * @returns the current particle system
  122943. */
  122944. removeRampGradient(): IParticleSystem;
  122945. /**
  122946. * Not supported by GPUParticleSystem
  122947. * @returns the list of ramp gradients
  122948. */
  122949. getRampGradients(): Nullable<Array<Color3Gradient>>;
  122950. /**
  122951. * Not supported by GPUParticleSystem
  122952. * Gets or sets a boolean indicating that ramp gradients must be used
  122953. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  122954. */
  122955. useRampGradients: boolean;
  122956. /**
  122957. * Not supported by GPUParticleSystem
  122958. * @param gradient defines the gradient to use (between 0 and 1)
  122959. * @param factor defines the life time factor to affect to the specified gradient
  122960. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  122961. * @returns the current particle system
  122962. */
  122963. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  122964. /**
  122965. * Not supported by GPUParticleSystem
  122966. * @param gradient defines the gradient to remove
  122967. * @returns the current particle system
  122968. */
  122969. removeLifeTimeGradient(gradient: number): IParticleSystem;
  122970. /**
  122971. * Instantiates a GPU particle system.
  122972. * 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.
  122973. * @param name The name of the particle system
  122974. * @param options The options used to create the system
  122975. * @param scene The scene the particle system belongs to
  122976. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  122977. */
  122978. constructor(name: string, options: Partial<{
  122979. capacity: number;
  122980. randomTextureSize: number;
  122981. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  122982. protected _reset(): void;
  122983. private _createUpdateVAO;
  122984. private _createRenderVAO;
  122985. private _initialize;
  122986. /** @hidden */
  122987. _recreateUpdateEffect(): void;
  122988. /** @hidden */
  122989. _recreateRenderEffect(): void;
  122990. /**
  122991. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  122992. * @param preWarm defines if we are in the pre-warmimg phase
  122993. */
  122994. animate(preWarm?: boolean): void;
  122995. private _createFactorGradientTexture;
  122996. private _createSizeGradientTexture;
  122997. private _createAngularSpeedGradientTexture;
  122998. private _createVelocityGradientTexture;
  122999. private _createLimitVelocityGradientTexture;
  123000. private _createDragGradientTexture;
  123001. private _createColorGradientTexture;
  123002. /**
  123003. * Renders the particle system in its current state
  123004. * @param preWarm defines if the system should only update the particles but not render them
  123005. * @returns the current number of particles
  123006. */
  123007. render(preWarm?: boolean): number;
  123008. /**
  123009. * Rebuilds the particle system
  123010. */
  123011. rebuild(): void;
  123012. private _releaseBuffers;
  123013. private _releaseVAOs;
  123014. /**
  123015. * Disposes the particle system and free the associated resources
  123016. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  123017. */
  123018. dispose(disposeTexture?: boolean): void;
  123019. /**
  123020. * Clones the particle system.
  123021. * @param name The name of the cloned object
  123022. * @param newEmitter The new emitter to use
  123023. * @returns the cloned particle system
  123024. */
  123025. clone(name: string, newEmitter: any): GPUParticleSystem;
  123026. /**
  123027. * Serializes the particle system to a JSON object.
  123028. * @returns the JSON object
  123029. */
  123030. serialize(): any;
  123031. /**
  123032. * Parses a JSON object to create a GPU particle system.
  123033. * @param parsedParticleSystem The JSON object to parse
  123034. * @param scene The scene to create the particle system in
  123035. * @param rootUrl The root url to use to load external dependencies like texture
  123036. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  123037. * @returns the parsed GPU particle system
  123038. */
  123039. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  123040. }
  123041. }
  123042. declare module BABYLON {
  123043. /**
  123044. * Represents a set of particle systems working together to create a specific effect
  123045. */
  123046. export class ParticleSystemSet implements IDisposable {
  123047. private _emitterCreationOptions;
  123048. private _emitterNode;
  123049. /**
  123050. * Gets the particle system list
  123051. */
  123052. systems: IParticleSystem[];
  123053. /**
  123054. * Gets the emitter node used with this set
  123055. */
  123056. readonly emitterNode: Nullable<TransformNode>;
  123057. /**
  123058. * Creates a new emitter mesh as a sphere
  123059. * @param options defines the options used to create the sphere
  123060. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  123061. * @param scene defines the hosting scene
  123062. */
  123063. setEmitterAsSphere(options: {
  123064. diameter: number;
  123065. segments: number;
  123066. color: Color3;
  123067. }, renderingGroupId: number, scene: Scene): void;
  123068. /**
  123069. * Starts all particle systems of the set
  123070. * @param emitter defines an optional mesh to use as emitter for the particle systems
  123071. */
  123072. start(emitter?: AbstractMesh): void;
  123073. /**
  123074. * Release all associated resources
  123075. */
  123076. dispose(): void;
  123077. /**
  123078. * Serialize the set into a JSON compatible object
  123079. * @returns a JSON compatible representation of the set
  123080. */
  123081. serialize(): any;
  123082. /**
  123083. * Parse a new ParticleSystemSet from a serialized source
  123084. * @param data defines a JSON compatible representation of the set
  123085. * @param scene defines the hosting scene
  123086. * @param gpu defines if we want GPU particles or CPU particles
  123087. * @returns a new ParticleSystemSet
  123088. */
  123089. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  123090. }
  123091. }
  123092. declare module BABYLON {
  123093. /**
  123094. * This class is made for on one-liner static method to help creating particle system set.
  123095. */
  123096. export class ParticleHelper {
  123097. /**
  123098. * Gets or sets base Assets URL
  123099. */
  123100. static BaseAssetsUrl: string;
  123101. /**
  123102. * Create a default particle system that you can tweak
  123103. * @param emitter defines the emitter to use
  123104. * @param capacity defines the system capacity (default is 500 particles)
  123105. * @param scene defines the hosting scene
  123106. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  123107. * @returns the new Particle system
  123108. */
  123109. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  123110. /**
  123111. * This is the main static method (one-liner) of this helper to create different particle systems
  123112. * @param type This string represents the type to the particle system to create
  123113. * @param scene The scene where the particle system should live
  123114. * @param gpu If the system will use gpu
  123115. * @returns the ParticleSystemSet created
  123116. */
  123117. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  123118. /**
  123119. * Static function used to export a particle system to a ParticleSystemSet variable.
  123120. * Please note that the emitter shape is not exported
  123121. * @param systems defines the particle systems to export
  123122. * @returns the created particle system set
  123123. */
  123124. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  123125. }
  123126. }
  123127. declare module BABYLON {
  123128. interface Engine {
  123129. /**
  123130. * Create an effect to use with particle systems.
  123131. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  123132. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  123133. * @param uniformsNames defines a list of attribute names
  123134. * @param samplers defines an array of string used to represent textures
  123135. * @param defines defines the string containing the defines to use to compile the shaders
  123136. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  123137. * @param onCompiled defines a function to call when the effect creation is successful
  123138. * @param onError defines a function to call when the effect creation has failed
  123139. * @returns the new Effect
  123140. */
  123141. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  123142. }
  123143. interface Mesh {
  123144. /**
  123145. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  123146. * @returns an array of IParticleSystem
  123147. */
  123148. getEmittedParticleSystems(): IParticleSystem[];
  123149. /**
  123150. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  123151. * @returns an array of IParticleSystem
  123152. */
  123153. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  123154. }
  123155. /**
  123156. * @hidden
  123157. */
  123158. export var _IDoNeedToBeInTheBuild: number;
  123159. }
  123160. declare module BABYLON {
  123161. interface Scene {
  123162. /** @hidden (Backing field) */
  123163. _physicsEngine: Nullable<IPhysicsEngine>;
  123164. /**
  123165. * Gets the current physics engine
  123166. * @returns a IPhysicsEngine or null if none attached
  123167. */
  123168. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  123169. /**
  123170. * Enables physics to the current scene
  123171. * @param gravity defines the scene's gravity for the physics engine
  123172. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  123173. * @return a boolean indicating if the physics engine was initialized
  123174. */
  123175. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  123176. /**
  123177. * Disables and disposes the physics engine associated with the scene
  123178. */
  123179. disablePhysicsEngine(): void;
  123180. /**
  123181. * Gets a boolean indicating if there is an active physics engine
  123182. * @returns a boolean indicating if there is an active physics engine
  123183. */
  123184. isPhysicsEnabled(): boolean;
  123185. /**
  123186. * Deletes a physics compound impostor
  123187. * @param compound defines the compound to delete
  123188. */
  123189. deleteCompoundImpostor(compound: any): void;
  123190. /**
  123191. * An event triggered when physic simulation is about to be run
  123192. */
  123193. onBeforePhysicsObservable: Observable<Scene>;
  123194. /**
  123195. * An event triggered when physic simulation has been done
  123196. */
  123197. onAfterPhysicsObservable: Observable<Scene>;
  123198. }
  123199. interface AbstractMesh {
  123200. /** @hidden */
  123201. _physicsImpostor: Nullable<PhysicsImpostor>;
  123202. /**
  123203. * Gets or sets impostor used for physic simulation
  123204. * @see http://doc.babylonjs.com/features/physics_engine
  123205. */
  123206. physicsImpostor: Nullable<PhysicsImpostor>;
  123207. /**
  123208. * Gets the current physics impostor
  123209. * @see http://doc.babylonjs.com/features/physics_engine
  123210. * @returns a physics impostor or null
  123211. */
  123212. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  123213. /** Apply a physic impulse to the mesh
  123214. * @param force defines the force to apply
  123215. * @param contactPoint defines where to apply the force
  123216. * @returns the current mesh
  123217. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  123218. */
  123219. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  123220. /**
  123221. * Creates a physic joint between two meshes
  123222. * @param otherMesh defines the other mesh to use
  123223. * @param pivot1 defines the pivot to use on this mesh
  123224. * @param pivot2 defines the pivot to use on the other mesh
  123225. * @param options defines additional options (can be plugin dependent)
  123226. * @returns the current mesh
  123227. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  123228. */
  123229. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  123230. /** @hidden */
  123231. _disposePhysicsObserver: Nullable<Observer<Node>>;
  123232. }
  123233. /**
  123234. * Defines the physics engine scene component responsible to manage a physics engine
  123235. */
  123236. export class PhysicsEngineSceneComponent implements ISceneComponent {
  123237. /**
  123238. * The component name helpful to identify the component in the list of scene components.
  123239. */
  123240. readonly name: string;
  123241. /**
  123242. * The scene the component belongs to.
  123243. */
  123244. scene: Scene;
  123245. /**
  123246. * Creates a new instance of the component for the given scene
  123247. * @param scene Defines the scene to register the component in
  123248. */
  123249. constructor(scene: Scene);
  123250. /**
  123251. * Registers the component in a given scene
  123252. */
  123253. register(): void;
  123254. /**
  123255. * Rebuilds the elements related to this component in case of
  123256. * context lost for instance.
  123257. */
  123258. rebuild(): void;
  123259. /**
  123260. * Disposes the component and the associated ressources
  123261. */
  123262. dispose(): void;
  123263. }
  123264. }
  123265. declare module BABYLON {
  123266. /**
  123267. * A helper for physics simulations
  123268. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123269. */
  123270. export class PhysicsHelper {
  123271. private _scene;
  123272. private _physicsEngine;
  123273. /**
  123274. * Initializes the Physics helper
  123275. * @param scene Babylon.js scene
  123276. */
  123277. constructor(scene: Scene);
  123278. /**
  123279. * Applies a radial explosion impulse
  123280. * @param origin the origin of the explosion
  123281. * @param radiusOrEventOptions the radius or the options of radial explosion
  123282. * @param strength the explosion strength
  123283. * @param falloff possible options: Constant & Linear. Defaults to Constant
  123284. * @returns A physics radial explosion event, or null
  123285. */
  123286. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  123287. /**
  123288. * Applies a radial explosion force
  123289. * @param origin the origin of the explosion
  123290. * @param radiusOrEventOptions the radius or the options of radial explosion
  123291. * @param strength the explosion strength
  123292. * @param falloff possible options: Constant & Linear. Defaults to Constant
  123293. * @returns A physics radial explosion event, or null
  123294. */
  123295. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  123296. /**
  123297. * Creates a gravitational field
  123298. * @param origin the origin of the explosion
  123299. * @param radiusOrEventOptions the radius or the options of radial explosion
  123300. * @param strength the explosion strength
  123301. * @param falloff possible options: Constant & Linear. Defaults to Constant
  123302. * @returns A physics gravitational field event, or null
  123303. */
  123304. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  123305. /**
  123306. * Creates a physics updraft event
  123307. * @param origin the origin of the updraft
  123308. * @param radiusOrEventOptions the radius or the options of the updraft
  123309. * @param strength the strength of the updraft
  123310. * @param height the height of the updraft
  123311. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  123312. * @returns A physics updraft event, or null
  123313. */
  123314. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  123315. /**
  123316. * Creates a physics vortex event
  123317. * @param origin the of the vortex
  123318. * @param radiusOrEventOptions the radius or the options of the vortex
  123319. * @param strength the strength of the vortex
  123320. * @param height the height of the vortex
  123321. * @returns a Physics vortex event, or null
  123322. * A physics vortex event or null
  123323. */
  123324. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  123325. }
  123326. /**
  123327. * Represents a physics radial explosion event
  123328. */
  123329. class PhysicsRadialExplosionEvent {
  123330. private _scene;
  123331. private _options;
  123332. private _sphere;
  123333. private _dataFetched;
  123334. /**
  123335. * Initializes a radial explosioin event
  123336. * @param _scene BabylonJS scene
  123337. * @param _options The options for the vortex event
  123338. */
  123339. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  123340. /**
  123341. * Returns the data related to the radial explosion event (sphere).
  123342. * @returns The radial explosion event data
  123343. */
  123344. getData(): PhysicsRadialExplosionEventData;
  123345. /**
  123346. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  123347. * @param impostor A physics imposter
  123348. * @param origin the origin of the explosion
  123349. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  123350. */
  123351. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  123352. /**
  123353. * Triggers affecterd impostors callbacks
  123354. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  123355. */
  123356. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  123357. /**
  123358. * Disposes the sphere.
  123359. * @param force Specifies if the sphere should be disposed by force
  123360. */
  123361. dispose(force?: boolean): void;
  123362. /*** Helpers ***/
  123363. private _prepareSphere;
  123364. private _intersectsWithSphere;
  123365. }
  123366. /**
  123367. * Represents a gravitational field event
  123368. */
  123369. class PhysicsGravitationalFieldEvent {
  123370. private _physicsHelper;
  123371. private _scene;
  123372. private _origin;
  123373. private _options;
  123374. private _tickCallback;
  123375. private _sphere;
  123376. private _dataFetched;
  123377. /**
  123378. * Initializes the physics gravitational field event
  123379. * @param _physicsHelper A physics helper
  123380. * @param _scene BabylonJS scene
  123381. * @param _origin The origin position of the gravitational field event
  123382. * @param _options The options for the vortex event
  123383. */
  123384. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  123385. /**
  123386. * Returns the data related to the gravitational field event (sphere).
  123387. * @returns A gravitational field event
  123388. */
  123389. getData(): PhysicsGravitationalFieldEventData;
  123390. /**
  123391. * Enables the gravitational field.
  123392. */
  123393. enable(): void;
  123394. /**
  123395. * Disables the gravitational field.
  123396. */
  123397. disable(): void;
  123398. /**
  123399. * Disposes the sphere.
  123400. * @param force The force to dispose from the gravitational field event
  123401. */
  123402. dispose(force?: boolean): void;
  123403. private _tick;
  123404. }
  123405. /**
  123406. * Represents a physics updraft event
  123407. */
  123408. class PhysicsUpdraftEvent {
  123409. private _scene;
  123410. private _origin;
  123411. private _options;
  123412. private _physicsEngine;
  123413. private _originTop;
  123414. private _originDirection;
  123415. private _tickCallback;
  123416. private _cylinder;
  123417. private _cylinderPosition;
  123418. private _dataFetched;
  123419. /**
  123420. * Initializes the physics updraft event
  123421. * @param _scene BabylonJS scene
  123422. * @param _origin The origin position of the updraft
  123423. * @param _options The options for the updraft event
  123424. */
  123425. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  123426. /**
  123427. * Returns the data related to the updraft event (cylinder).
  123428. * @returns A physics updraft event
  123429. */
  123430. getData(): PhysicsUpdraftEventData;
  123431. /**
  123432. * Enables the updraft.
  123433. */
  123434. enable(): void;
  123435. /**
  123436. * Disables the updraft.
  123437. */
  123438. disable(): void;
  123439. /**
  123440. * Disposes the cylinder.
  123441. * @param force Specifies if the updraft should be disposed by force
  123442. */
  123443. dispose(force?: boolean): void;
  123444. private getImpostorHitData;
  123445. private _tick;
  123446. /*** Helpers ***/
  123447. private _prepareCylinder;
  123448. private _intersectsWithCylinder;
  123449. }
  123450. /**
  123451. * Represents a physics vortex event
  123452. */
  123453. class PhysicsVortexEvent {
  123454. private _scene;
  123455. private _origin;
  123456. private _options;
  123457. private _physicsEngine;
  123458. private _originTop;
  123459. private _tickCallback;
  123460. private _cylinder;
  123461. private _cylinderPosition;
  123462. private _dataFetched;
  123463. /**
  123464. * Initializes the physics vortex event
  123465. * @param _scene The BabylonJS scene
  123466. * @param _origin The origin position of the vortex
  123467. * @param _options The options for the vortex event
  123468. */
  123469. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  123470. /**
  123471. * Returns the data related to the vortex event (cylinder).
  123472. * @returns The physics vortex event data
  123473. */
  123474. getData(): PhysicsVortexEventData;
  123475. /**
  123476. * Enables the vortex.
  123477. */
  123478. enable(): void;
  123479. /**
  123480. * Disables the cortex.
  123481. */
  123482. disable(): void;
  123483. /**
  123484. * Disposes the sphere.
  123485. * @param force
  123486. */
  123487. dispose(force?: boolean): void;
  123488. private getImpostorHitData;
  123489. private _tick;
  123490. /*** Helpers ***/
  123491. private _prepareCylinder;
  123492. private _intersectsWithCylinder;
  123493. }
  123494. /**
  123495. * Options fot the radial explosion event
  123496. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123497. */
  123498. export class PhysicsRadialExplosionEventOptions {
  123499. /**
  123500. * The radius of the sphere for the radial explosion.
  123501. */
  123502. radius: number;
  123503. /**
  123504. * The strenth of the explosion.
  123505. */
  123506. strength: number;
  123507. /**
  123508. * The strenght of the force in correspondence to the distance of the affected object
  123509. */
  123510. falloff: PhysicsRadialImpulseFalloff;
  123511. /**
  123512. * Sphere options for the radial explosion.
  123513. */
  123514. sphere: {
  123515. segments: number;
  123516. diameter: number;
  123517. };
  123518. /**
  123519. * Sphere options for the radial explosion.
  123520. */
  123521. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  123522. }
  123523. /**
  123524. * Options fot the updraft event
  123525. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123526. */
  123527. export class PhysicsUpdraftEventOptions {
  123528. /**
  123529. * The radius of the cylinder for the vortex
  123530. */
  123531. radius: number;
  123532. /**
  123533. * The strenth of the updraft.
  123534. */
  123535. strength: number;
  123536. /**
  123537. * The height of the cylinder for the updraft.
  123538. */
  123539. height: number;
  123540. /**
  123541. * The mode for the the updraft.
  123542. */
  123543. updraftMode: PhysicsUpdraftMode;
  123544. }
  123545. /**
  123546. * Options fot the vortex event
  123547. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123548. */
  123549. export class PhysicsVortexEventOptions {
  123550. /**
  123551. * The radius of the cylinder for the vortex
  123552. */
  123553. radius: number;
  123554. /**
  123555. * The strenth of the vortex.
  123556. */
  123557. strength: number;
  123558. /**
  123559. * The height of the cylinder for the vortex.
  123560. */
  123561. height: number;
  123562. /**
  123563. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  123564. */
  123565. centripetalForceThreshold: number;
  123566. /**
  123567. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  123568. */
  123569. centripetalForceMultiplier: number;
  123570. /**
  123571. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  123572. */
  123573. centrifugalForceMultiplier: number;
  123574. /**
  123575. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  123576. */
  123577. updraftForceMultiplier: number;
  123578. }
  123579. /**
  123580. * The strenght of the force in correspondence to the distance of the affected object
  123581. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123582. */
  123583. export enum PhysicsRadialImpulseFalloff {
  123584. /** Defines that impulse is constant in strength across it's whole radius */
  123585. Constant = 0,
  123586. /** Defines that impulse gets weaker if it's further from the origin */
  123587. Linear = 1
  123588. }
  123589. /**
  123590. * The strength of the force in correspondence to the distance of the affected object
  123591. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123592. */
  123593. export enum PhysicsUpdraftMode {
  123594. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  123595. Center = 0,
  123596. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  123597. Perpendicular = 1
  123598. }
  123599. /**
  123600. * Interface for a physics hit data
  123601. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123602. */
  123603. export interface PhysicsHitData {
  123604. /**
  123605. * The force applied at the contact point
  123606. */
  123607. force: Vector3;
  123608. /**
  123609. * The contact point
  123610. */
  123611. contactPoint: Vector3;
  123612. /**
  123613. * The distance from the origin to the contact point
  123614. */
  123615. distanceFromOrigin: number;
  123616. }
  123617. /**
  123618. * Interface for radial explosion event data
  123619. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123620. */
  123621. export interface PhysicsRadialExplosionEventData {
  123622. /**
  123623. * A sphere used for the radial explosion event
  123624. */
  123625. sphere: Mesh;
  123626. }
  123627. /**
  123628. * Interface for gravitational field event data
  123629. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123630. */
  123631. export interface PhysicsGravitationalFieldEventData {
  123632. /**
  123633. * A sphere mesh used for the gravitational field event
  123634. */
  123635. sphere: Mesh;
  123636. }
  123637. /**
  123638. * Interface for updraft event data
  123639. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123640. */
  123641. export interface PhysicsUpdraftEventData {
  123642. /**
  123643. * A cylinder used for the updraft event
  123644. */
  123645. cylinder: Mesh;
  123646. }
  123647. /**
  123648. * Interface for vortex event data
  123649. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123650. */
  123651. export interface PhysicsVortexEventData {
  123652. /**
  123653. * A cylinder used for the vortex event
  123654. */
  123655. cylinder: Mesh;
  123656. }
  123657. /**
  123658. * Interface for an affected physics impostor
  123659. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123660. */
  123661. export interface PhysicsAffectedImpostorWithData {
  123662. /**
  123663. * The impostor affected by the effect
  123664. */
  123665. impostor: PhysicsImpostor;
  123666. /**
  123667. * The data about the hit/horce from the explosion
  123668. */
  123669. hitData: PhysicsHitData;
  123670. }
  123671. }
  123672. declare module BABYLON {
  123673. /** @hidden */
  123674. export var blackAndWhitePixelShader: {
  123675. name: string;
  123676. shader: string;
  123677. };
  123678. }
  123679. declare module BABYLON {
  123680. /**
  123681. * Post process used to render in black and white
  123682. */
  123683. export class BlackAndWhitePostProcess extends PostProcess {
  123684. /**
  123685. * Linear about to convert he result to black and white (default: 1)
  123686. */
  123687. degree: number;
  123688. /**
  123689. * Creates a black and white post process
  123690. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  123691. * @param name The name of the effect.
  123692. * @param options The required width/height ratio to downsize to before computing the render pass.
  123693. * @param camera The camera to apply the render pass to.
  123694. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123695. * @param engine The engine which the post process will be applied. (default: current engine)
  123696. * @param reusable If the post process can be reused on the same frame. (default: false)
  123697. */
  123698. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  123699. }
  123700. }
  123701. declare module BABYLON {
  123702. /**
  123703. * This represents a set of one or more post processes in Babylon.
  123704. * A post process can be used to apply a shader to a texture after it is rendered.
  123705. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  123706. */
  123707. export class PostProcessRenderEffect {
  123708. private _postProcesses;
  123709. private _getPostProcesses;
  123710. private _singleInstance;
  123711. private _cameras;
  123712. private _indicesForCamera;
  123713. /**
  123714. * Name of the effect
  123715. * @hidden
  123716. */
  123717. _name: string;
  123718. /**
  123719. * Instantiates a post process render effect.
  123720. * A post process can be used to apply a shader to a texture after it is rendered.
  123721. * @param engine The engine the effect is tied to
  123722. * @param name The name of the effect
  123723. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  123724. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  123725. */
  123726. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  123727. /**
  123728. * Checks if all the post processes in the effect are supported.
  123729. */
  123730. readonly isSupported: boolean;
  123731. /**
  123732. * Updates the current state of the effect
  123733. * @hidden
  123734. */
  123735. _update(): void;
  123736. /**
  123737. * Attaches the effect on cameras
  123738. * @param cameras The camera to attach to.
  123739. * @hidden
  123740. */
  123741. _attachCameras(cameras: Camera): void;
  123742. /**
  123743. * Attaches the effect on cameras
  123744. * @param cameras The camera to attach to.
  123745. * @hidden
  123746. */
  123747. _attachCameras(cameras: Camera[]): void;
  123748. /**
  123749. * Detaches the effect on cameras
  123750. * @param cameras The camera to detatch from.
  123751. * @hidden
  123752. */
  123753. _detachCameras(cameras: Camera): void;
  123754. /**
  123755. * Detatches the effect on cameras
  123756. * @param cameras The camera to detatch from.
  123757. * @hidden
  123758. */
  123759. _detachCameras(cameras: Camera[]): void;
  123760. /**
  123761. * Enables the effect on given cameras
  123762. * @param cameras The camera to enable.
  123763. * @hidden
  123764. */
  123765. _enable(cameras: Camera): void;
  123766. /**
  123767. * Enables the effect on given cameras
  123768. * @param cameras The camera to enable.
  123769. * @hidden
  123770. */
  123771. _enable(cameras: Nullable<Camera[]>): void;
  123772. /**
  123773. * Disables the effect on the given cameras
  123774. * @param cameras The camera to disable.
  123775. * @hidden
  123776. */
  123777. _disable(cameras: Camera): void;
  123778. /**
  123779. * Disables the effect on the given cameras
  123780. * @param cameras The camera to disable.
  123781. * @hidden
  123782. */
  123783. _disable(cameras: Nullable<Camera[]>): void;
  123784. /**
  123785. * Gets a list of the post processes contained in the effect.
  123786. * @param camera The camera to get the post processes on.
  123787. * @returns The list of the post processes in the effect.
  123788. */
  123789. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  123790. }
  123791. }
  123792. declare module BABYLON {
  123793. /** @hidden */
  123794. export var extractHighlightsPixelShader: {
  123795. name: string;
  123796. shader: string;
  123797. };
  123798. }
  123799. declare module BABYLON {
  123800. /**
  123801. * 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.
  123802. */
  123803. export class ExtractHighlightsPostProcess extends PostProcess {
  123804. /**
  123805. * The luminance threshold, pixels below this value will be set to black.
  123806. */
  123807. threshold: number;
  123808. /** @hidden */
  123809. _exposure: number;
  123810. /**
  123811. * Post process which has the input texture to be used when performing highlight extraction
  123812. * @hidden
  123813. */
  123814. _inputPostProcess: Nullable<PostProcess>;
  123815. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123816. }
  123817. }
  123818. declare module BABYLON {
  123819. /** @hidden */
  123820. export var bloomMergePixelShader: {
  123821. name: string;
  123822. shader: string;
  123823. };
  123824. }
  123825. declare module BABYLON {
  123826. /**
  123827. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  123828. */
  123829. export class BloomMergePostProcess extends PostProcess {
  123830. /** Weight of the bloom to be added to the original input. */
  123831. weight: number;
  123832. /**
  123833. * Creates a new instance of @see BloomMergePostProcess
  123834. * @param name The name of the effect.
  123835. * @param originalFromInput Post process which's input will be used for the merge.
  123836. * @param blurred Blurred highlights post process which's output will be used.
  123837. * @param weight Weight of the bloom to be added to the original input.
  123838. * @param options The required width/height ratio to downsize to before computing the render pass.
  123839. * @param camera The camera to apply the render pass to.
  123840. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123841. * @param engine The engine which the post process will be applied. (default: current engine)
  123842. * @param reusable If the post process can be reused on the same frame. (default: false)
  123843. * @param textureType Type of textures used when performing the post process. (default: 0)
  123844. * @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)
  123845. */
  123846. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  123847. /** Weight of the bloom to be added to the original input. */
  123848. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123849. }
  123850. }
  123851. declare module BABYLON {
  123852. /**
  123853. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  123854. */
  123855. export class BloomEffect extends PostProcessRenderEffect {
  123856. private bloomScale;
  123857. /**
  123858. * @hidden Internal
  123859. */
  123860. _effects: Array<PostProcess>;
  123861. /**
  123862. * @hidden Internal
  123863. */
  123864. _downscale: ExtractHighlightsPostProcess;
  123865. private _blurX;
  123866. private _blurY;
  123867. private _merge;
  123868. /**
  123869. * The luminance threshold to find bright areas of the image to bloom.
  123870. */
  123871. threshold: number;
  123872. /**
  123873. * The strength of the bloom.
  123874. */
  123875. weight: number;
  123876. /**
  123877. * Specifies the size of the bloom blur kernel, relative to the final output size
  123878. */
  123879. kernel: number;
  123880. /**
  123881. * Creates a new instance of @see BloomEffect
  123882. * @param scene The scene the effect belongs to.
  123883. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  123884. * @param bloomKernel The size of the kernel to be used when applying the blur.
  123885. * @param bloomWeight The the strength of bloom.
  123886. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  123887. * @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)
  123888. */
  123889. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  123890. /**
  123891. * Disposes each of the internal effects for a given camera.
  123892. * @param camera The camera to dispose the effect on.
  123893. */
  123894. disposeEffects(camera: Camera): void;
  123895. /**
  123896. * @hidden Internal
  123897. */
  123898. _updateEffects(): void;
  123899. /**
  123900. * Internal
  123901. * @returns if all the contained post processes are ready.
  123902. * @hidden
  123903. */
  123904. _isReady(): boolean;
  123905. }
  123906. }
  123907. declare module BABYLON {
  123908. /** @hidden */
  123909. export var chromaticAberrationPixelShader: {
  123910. name: string;
  123911. shader: string;
  123912. };
  123913. }
  123914. declare module BABYLON {
  123915. /**
  123916. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  123917. */
  123918. export class ChromaticAberrationPostProcess extends PostProcess {
  123919. /**
  123920. * The amount of seperation of rgb channels (default: 30)
  123921. */
  123922. aberrationAmount: number;
  123923. /**
  123924. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  123925. */
  123926. radialIntensity: number;
  123927. /**
  123928. * 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))
  123929. */
  123930. direction: Vector2;
  123931. /**
  123932. * 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))
  123933. */
  123934. centerPosition: Vector2;
  123935. /**
  123936. * Creates a new instance ChromaticAberrationPostProcess
  123937. * @param name The name of the effect.
  123938. * @param screenWidth The width of the screen to apply the effect on.
  123939. * @param screenHeight The height of the screen to apply the effect on.
  123940. * @param options The required width/height ratio to downsize to before computing the render pass.
  123941. * @param camera The camera to apply the render pass to.
  123942. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123943. * @param engine The engine which the post process will be applied. (default: current engine)
  123944. * @param reusable If the post process can be reused on the same frame. (default: false)
  123945. * @param textureType Type of textures used when performing the post process. (default: 0)
  123946. * @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)
  123947. */
  123948. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123949. }
  123950. }
  123951. declare module BABYLON {
  123952. /** @hidden */
  123953. export var circleOfConfusionPixelShader: {
  123954. name: string;
  123955. shader: string;
  123956. };
  123957. }
  123958. declare module BABYLON {
  123959. /**
  123960. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  123961. */
  123962. export class CircleOfConfusionPostProcess extends PostProcess {
  123963. /**
  123964. * 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.
  123965. */
  123966. lensSize: number;
  123967. /**
  123968. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  123969. */
  123970. fStop: number;
  123971. /**
  123972. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  123973. */
  123974. focusDistance: number;
  123975. /**
  123976. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  123977. */
  123978. focalLength: number;
  123979. private _depthTexture;
  123980. /**
  123981. * Creates a new instance CircleOfConfusionPostProcess
  123982. * @param name The name of the effect.
  123983. * @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.
  123984. * @param options The required width/height ratio to downsize to before computing the render pass.
  123985. * @param camera The camera to apply the render pass to.
  123986. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123987. * @param engine The engine which the post process will be applied. (default: current engine)
  123988. * @param reusable If the post process can be reused on the same frame. (default: false)
  123989. * @param textureType Type of textures used when performing the post process. (default: 0)
  123990. * @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)
  123991. */
  123992. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123993. /**
  123994. * 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.
  123995. */
  123996. depthTexture: RenderTargetTexture;
  123997. }
  123998. }
  123999. declare module BABYLON {
  124000. /** @hidden */
  124001. export var colorCorrectionPixelShader: {
  124002. name: string;
  124003. shader: string;
  124004. };
  124005. }
  124006. declare module BABYLON {
  124007. /**
  124008. *
  124009. * This post-process allows the modification of rendered colors by using
  124010. * a 'look-up table' (LUT). This effect is also called Color Grading.
  124011. *
  124012. * The object needs to be provided an url to a texture containing the color
  124013. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  124014. * Use an image editing software to tweak the LUT to match your needs.
  124015. *
  124016. * For an example of a color LUT, see here:
  124017. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  124018. * For explanations on color grading, see here:
  124019. * @see http://udn.epicgames.com/Three/ColorGrading.html
  124020. *
  124021. */
  124022. export class ColorCorrectionPostProcess extends PostProcess {
  124023. private _colorTableTexture;
  124024. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  124025. }
  124026. }
  124027. declare module BABYLON {
  124028. /** @hidden */
  124029. export var convolutionPixelShader: {
  124030. name: string;
  124031. shader: string;
  124032. };
  124033. }
  124034. declare module BABYLON {
  124035. /**
  124036. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  124037. * input texture to perform effects such as edge detection or sharpening
  124038. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  124039. */
  124040. export class ConvolutionPostProcess extends PostProcess {
  124041. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  124042. kernel: number[];
  124043. /**
  124044. * Creates a new instance ConvolutionPostProcess
  124045. * @param name The name of the effect.
  124046. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  124047. * @param options The required width/height ratio to downsize to before computing the render pass.
  124048. * @param camera The camera to apply the render pass to.
  124049. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124050. * @param engine The engine which the post process will be applied. (default: current engine)
  124051. * @param reusable If the post process can be reused on the same frame. (default: false)
  124052. * @param textureType Type of textures used when performing the post process. (default: 0)
  124053. */
  124054. constructor(name: string,
  124055. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  124056. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  124057. /**
  124058. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124059. */
  124060. static EdgeDetect0Kernel: number[];
  124061. /**
  124062. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124063. */
  124064. static EdgeDetect1Kernel: number[];
  124065. /**
  124066. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124067. */
  124068. static EdgeDetect2Kernel: number[];
  124069. /**
  124070. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124071. */
  124072. static SharpenKernel: number[];
  124073. /**
  124074. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124075. */
  124076. static EmbossKernel: number[];
  124077. /**
  124078. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124079. */
  124080. static GaussianKernel: number[];
  124081. }
  124082. }
  124083. declare module BABYLON {
  124084. /**
  124085. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  124086. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  124087. * based on samples that have a large difference in distance than the center pixel.
  124088. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  124089. */
  124090. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  124091. direction: Vector2;
  124092. /**
  124093. * Creates a new instance CircleOfConfusionPostProcess
  124094. * @param name The name of the effect.
  124095. * @param scene The scene the effect belongs to.
  124096. * @param direction The direction the blur should be applied.
  124097. * @param kernel The size of the kernel used to blur.
  124098. * @param options The required width/height ratio to downsize to before computing the render pass.
  124099. * @param camera The camera to apply the render pass to.
  124100. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  124101. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  124102. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124103. * @param engine The engine which the post process will be applied. (default: current engine)
  124104. * @param reusable If the post process can be reused on the same frame. (default: false)
  124105. * @param textureType Type of textures used when performing the post process. (default: 0)
  124106. * @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)
  124107. */
  124108. 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);
  124109. }
  124110. }
  124111. declare module BABYLON {
  124112. /** @hidden */
  124113. export var depthOfFieldMergePixelShader: {
  124114. name: string;
  124115. shader: string;
  124116. };
  124117. }
  124118. declare module BABYLON {
  124119. /**
  124120. * Options to be set when merging outputs from the default pipeline.
  124121. */
  124122. export class DepthOfFieldMergePostProcessOptions {
  124123. /**
  124124. * The original image to merge on top of
  124125. */
  124126. originalFromInput: PostProcess;
  124127. /**
  124128. * Parameters to perform the merge of the depth of field effect
  124129. */
  124130. depthOfField?: {
  124131. circleOfConfusion: PostProcess;
  124132. blurSteps: Array<PostProcess>;
  124133. };
  124134. /**
  124135. * Parameters to perform the merge of bloom effect
  124136. */
  124137. bloom?: {
  124138. blurred: PostProcess;
  124139. weight: number;
  124140. };
  124141. }
  124142. /**
  124143. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  124144. */
  124145. export class DepthOfFieldMergePostProcess extends PostProcess {
  124146. private blurSteps;
  124147. /**
  124148. * Creates a new instance of DepthOfFieldMergePostProcess
  124149. * @param name The name of the effect.
  124150. * @param originalFromInput Post process which's input will be used for the merge.
  124151. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  124152. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  124153. * @param options The required width/height ratio to downsize to before computing the render pass.
  124154. * @param camera The camera to apply the render pass to.
  124155. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124156. * @param engine The engine which the post process will be applied. (default: current engine)
  124157. * @param reusable If the post process can be reused on the same frame. (default: false)
  124158. * @param textureType Type of textures used when performing the post process. (default: 0)
  124159. * @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)
  124160. */
  124161. 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);
  124162. /**
  124163. * Updates the effect with the current post process compile time values and recompiles the shader.
  124164. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  124165. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  124166. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  124167. * @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
  124168. * @param onCompiled Called when the shader has been compiled.
  124169. * @param onError Called if there is an error when compiling a shader.
  124170. */
  124171. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  124172. }
  124173. }
  124174. declare module BABYLON {
  124175. /**
  124176. * Specifies the level of max blur that should be applied when using the depth of field effect
  124177. */
  124178. export enum DepthOfFieldEffectBlurLevel {
  124179. /**
  124180. * Subtle blur
  124181. */
  124182. Low = 0,
  124183. /**
  124184. * Medium blur
  124185. */
  124186. Medium = 1,
  124187. /**
  124188. * Large blur
  124189. */
  124190. High = 2
  124191. }
  124192. /**
  124193. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  124194. */
  124195. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  124196. private _circleOfConfusion;
  124197. /**
  124198. * @hidden Internal, blurs from high to low
  124199. */
  124200. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  124201. private _depthOfFieldBlurY;
  124202. private _dofMerge;
  124203. /**
  124204. * @hidden Internal post processes in depth of field effect
  124205. */
  124206. _effects: Array<PostProcess>;
  124207. /**
  124208. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  124209. */
  124210. focalLength: number;
  124211. /**
  124212. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  124213. */
  124214. fStop: number;
  124215. /**
  124216. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  124217. */
  124218. focusDistance: number;
  124219. /**
  124220. * 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.
  124221. */
  124222. lensSize: number;
  124223. /**
  124224. * Creates a new instance DepthOfFieldEffect
  124225. * @param scene The scene the effect belongs to.
  124226. * @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.
  124227. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  124228. * @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)
  124229. */
  124230. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  124231. /**
  124232. * Get the current class name of the current effet
  124233. * @returns "DepthOfFieldEffect"
  124234. */
  124235. getClassName(): string;
  124236. /**
  124237. * 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.
  124238. */
  124239. depthTexture: RenderTargetTexture;
  124240. /**
  124241. * Disposes each of the internal effects for a given camera.
  124242. * @param camera The camera to dispose the effect on.
  124243. */
  124244. disposeEffects(camera: Camera): void;
  124245. /**
  124246. * @hidden Internal
  124247. */
  124248. _updateEffects(): void;
  124249. /**
  124250. * Internal
  124251. * @returns if all the contained post processes are ready.
  124252. * @hidden
  124253. */
  124254. _isReady(): boolean;
  124255. }
  124256. }
  124257. declare module BABYLON {
  124258. /** @hidden */
  124259. export var displayPassPixelShader: {
  124260. name: string;
  124261. shader: string;
  124262. };
  124263. }
  124264. declare module BABYLON {
  124265. /**
  124266. * DisplayPassPostProcess which produces an output the same as it's input
  124267. */
  124268. export class DisplayPassPostProcess extends PostProcess {
  124269. /**
  124270. * Creates the DisplayPassPostProcess
  124271. * @param name The name of the effect.
  124272. * @param options The required width/height ratio to downsize to before computing the render pass.
  124273. * @param camera The camera to apply the render pass to.
  124274. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124275. * @param engine The engine which the post process will be applied. (default: current engine)
  124276. * @param reusable If the post process can be reused on the same frame. (default: false)
  124277. */
  124278. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  124279. }
  124280. }
  124281. declare module BABYLON {
  124282. /** @hidden */
  124283. export var filterPixelShader: {
  124284. name: string;
  124285. shader: string;
  124286. };
  124287. }
  124288. declare module BABYLON {
  124289. /**
  124290. * Applies a kernel filter to the image
  124291. */
  124292. export class FilterPostProcess extends PostProcess {
  124293. /** The matrix to be applied to the image */
  124294. kernelMatrix: Matrix;
  124295. /**
  124296. *
  124297. * @param name The name of the effect.
  124298. * @param kernelMatrix The matrix to be applied to the image
  124299. * @param options The required width/height ratio to downsize to before computing the render pass.
  124300. * @param camera The camera to apply the render pass to.
  124301. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124302. * @param engine The engine which the post process will be applied. (default: current engine)
  124303. * @param reusable If the post process can be reused on the same frame. (default: false)
  124304. */
  124305. constructor(name: string,
  124306. /** The matrix to be applied to the image */
  124307. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  124308. }
  124309. }
  124310. declare module BABYLON {
  124311. /** @hidden */
  124312. export var fxaaPixelShader: {
  124313. name: string;
  124314. shader: string;
  124315. };
  124316. }
  124317. declare module BABYLON {
  124318. /** @hidden */
  124319. export var fxaaVertexShader: {
  124320. name: string;
  124321. shader: string;
  124322. };
  124323. }
  124324. declare module BABYLON {
  124325. /**
  124326. * Fxaa post process
  124327. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  124328. */
  124329. export class FxaaPostProcess extends PostProcess {
  124330. /** @hidden */
  124331. texelWidth: number;
  124332. /** @hidden */
  124333. texelHeight: number;
  124334. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  124335. private _getDefines;
  124336. }
  124337. }
  124338. declare module BABYLON {
  124339. /** @hidden */
  124340. export var grainPixelShader: {
  124341. name: string;
  124342. shader: string;
  124343. };
  124344. }
  124345. declare module BABYLON {
  124346. /**
  124347. * The GrainPostProcess adds noise to the image at mid luminance levels
  124348. */
  124349. export class GrainPostProcess extends PostProcess {
  124350. /**
  124351. * The intensity of the grain added (default: 30)
  124352. */
  124353. intensity: number;
  124354. /**
  124355. * If the grain should be randomized on every frame
  124356. */
  124357. animated: boolean;
  124358. /**
  124359. * Creates a new instance of @see GrainPostProcess
  124360. * @param name The name of the effect.
  124361. * @param options The required width/height ratio to downsize to before computing the render pass.
  124362. * @param camera The camera to apply the render pass to.
  124363. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124364. * @param engine The engine which the post process will be applied. (default: current engine)
  124365. * @param reusable If the post process can be reused on the same frame. (default: false)
  124366. * @param textureType Type of textures used when performing the post process. (default: 0)
  124367. * @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)
  124368. */
  124369. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124370. }
  124371. }
  124372. declare module BABYLON {
  124373. /** @hidden */
  124374. export var highlightsPixelShader: {
  124375. name: string;
  124376. shader: string;
  124377. };
  124378. }
  124379. declare module BABYLON {
  124380. /**
  124381. * Extracts highlights from the image
  124382. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  124383. */
  124384. export class HighlightsPostProcess extends PostProcess {
  124385. /**
  124386. * Extracts highlights from the image
  124387. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  124388. * @param name The name of the effect.
  124389. * @param options The required width/height ratio to downsize to before computing the render pass.
  124390. * @param camera The camera to apply the render pass to.
  124391. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124392. * @param engine The engine which the post process will be applied. (default: current engine)
  124393. * @param reusable If the post process can be reused on the same frame. (default: false)
  124394. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  124395. */
  124396. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  124397. }
  124398. }
  124399. declare module BABYLON {
  124400. /** @hidden */
  124401. export var mrtFragmentDeclaration: {
  124402. name: string;
  124403. shader: string;
  124404. };
  124405. }
  124406. declare module BABYLON {
  124407. /** @hidden */
  124408. export var geometryPixelShader: {
  124409. name: string;
  124410. shader: string;
  124411. };
  124412. }
  124413. declare module BABYLON {
  124414. /** @hidden */
  124415. export var geometryVertexShader: {
  124416. name: string;
  124417. shader: string;
  124418. };
  124419. }
  124420. declare module BABYLON {
  124421. /** @hidden */
  124422. interface ISavedTransformationMatrix {
  124423. world: Matrix;
  124424. viewProjection: Matrix;
  124425. }
  124426. /**
  124427. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  124428. */
  124429. export class GeometryBufferRenderer {
  124430. /**
  124431. * Constant used to retrieve the position texture index in the G-Buffer textures array
  124432. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  124433. */
  124434. static readonly POSITION_TEXTURE_TYPE: number;
  124435. /**
  124436. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  124437. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  124438. */
  124439. static readonly VELOCITY_TEXTURE_TYPE: number;
  124440. /**
  124441. * Dictionary used to store the previous transformation matrices of each rendered mesh
  124442. * in order to compute objects velocities when enableVelocity is set to "true"
  124443. * @hidden
  124444. */
  124445. _previousTransformationMatrices: {
  124446. [index: number]: ISavedTransformationMatrix;
  124447. };
  124448. /**
  124449. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  124450. * in order to compute objects velocities when enableVelocity is set to "true"
  124451. * @hidden
  124452. */
  124453. _previousBonesTransformationMatrices: {
  124454. [index: number]: Float32Array;
  124455. };
  124456. /**
  124457. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  124458. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  124459. */
  124460. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  124461. private _scene;
  124462. private _multiRenderTarget;
  124463. private _ratio;
  124464. private _enablePosition;
  124465. private _enableVelocity;
  124466. private _positionIndex;
  124467. private _velocityIndex;
  124468. protected _effect: Effect;
  124469. protected _cachedDefines: string;
  124470. /**
  124471. * Set the render list (meshes to be rendered) used in the G buffer.
  124472. */
  124473. renderList: Mesh[];
  124474. /**
  124475. * Gets wether or not G buffer are supported by the running hardware.
  124476. * This requires draw buffer supports
  124477. */
  124478. readonly isSupported: boolean;
  124479. /**
  124480. * Returns the index of the given texture type in the G-Buffer textures array
  124481. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  124482. * @returns the index of the given texture type in the G-Buffer textures array
  124483. */
  124484. getTextureIndex(textureType: number): number;
  124485. /**
  124486. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  124487. */
  124488. /**
  124489. * Sets whether or not objects positions are enabled for the G buffer.
  124490. */
  124491. enablePosition: boolean;
  124492. /**
  124493. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  124494. */
  124495. /**
  124496. * Sets wether or not objects velocities are enabled for the G buffer.
  124497. */
  124498. enableVelocity: boolean;
  124499. /**
  124500. * Gets the scene associated with the buffer.
  124501. */
  124502. readonly scene: Scene;
  124503. /**
  124504. * Gets the ratio used by the buffer during its creation.
  124505. * How big is the buffer related to the main canvas.
  124506. */
  124507. readonly ratio: number;
  124508. /** @hidden */
  124509. static _SceneComponentInitialization: (scene: Scene) => void;
  124510. /**
  124511. * Creates a new G Buffer for the scene
  124512. * @param scene The scene the buffer belongs to
  124513. * @param ratio How big is the buffer related to the main canvas.
  124514. */
  124515. constructor(scene: Scene, ratio?: number);
  124516. /**
  124517. * Checks wether everything is ready to render a submesh to the G buffer.
  124518. * @param subMesh the submesh to check readiness for
  124519. * @param useInstances is the mesh drawn using instance or not
  124520. * @returns true if ready otherwise false
  124521. */
  124522. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  124523. /**
  124524. * Gets the current underlying G Buffer.
  124525. * @returns the buffer
  124526. */
  124527. getGBuffer(): MultiRenderTarget;
  124528. /**
  124529. * Gets the number of samples used to render the buffer (anti aliasing).
  124530. */
  124531. /**
  124532. * Sets the number of samples used to render the buffer (anti aliasing).
  124533. */
  124534. samples: number;
  124535. /**
  124536. * Disposes the renderer and frees up associated resources.
  124537. */
  124538. dispose(): void;
  124539. protected _createRenderTargets(): void;
  124540. private _copyBonesTransformationMatrices;
  124541. }
  124542. }
  124543. declare module BABYLON {
  124544. interface Scene {
  124545. /** @hidden (Backing field) */
  124546. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  124547. /**
  124548. * Gets or Sets the current geometry buffer associated to the scene.
  124549. */
  124550. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  124551. /**
  124552. * Enables a GeometryBufferRender and associates it with the scene
  124553. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  124554. * @returns the GeometryBufferRenderer
  124555. */
  124556. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  124557. /**
  124558. * Disables the GeometryBufferRender associated with the scene
  124559. */
  124560. disableGeometryBufferRenderer(): void;
  124561. }
  124562. /**
  124563. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  124564. * in several rendering techniques.
  124565. */
  124566. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  124567. /**
  124568. * The component name helpful to identify the component in the list of scene components.
  124569. */
  124570. readonly name: string;
  124571. /**
  124572. * The scene the component belongs to.
  124573. */
  124574. scene: Scene;
  124575. /**
  124576. * Creates a new instance of the component for the given scene
  124577. * @param scene Defines the scene to register the component in
  124578. */
  124579. constructor(scene: Scene);
  124580. /**
  124581. * Registers the component in a given scene
  124582. */
  124583. register(): void;
  124584. /**
  124585. * Rebuilds the elements related to this component in case of
  124586. * context lost for instance.
  124587. */
  124588. rebuild(): void;
  124589. /**
  124590. * Disposes the component and the associated ressources
  124591. */
  124592. dispose(): void;
  124593. private _gatherRenderTargets;
  124594. }
  124595. }
  124596. declare module BABYLON {
  124597. /** @hidden */
  124598. export var motionBlurPixelShader: {
  124599. name: string;
  124600. shader: string;
  124601. };
  124602. }
  124603. declare module BABYLON {
  124604. /**
  124605. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  124606. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  124607. * As an example, all you have to do is to create the post-process:
  124608. * var mb = new BABYLON.MotionBlurPostProcess(
  124609. * 'mb', // The name of the effect.
  124610. * scene, // The scene containing the objects to blur according to their velocity.
  124611. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  124612. * camera // The camera to apply the render pass to.
  124613. * );
  124614. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  124615. */
  124616. export class MotionBlurPostProcess extends PostProcess {
  124617. /**
  124618. * Defines how much the image is blurred by the movement. Default value is equal to 1
  124619. */
  124620. motionStrength: number;
  124621. /**
  124622. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  124623. */
  124624. /**
  124625. * Sets the number of iterations to be used for motion blur quality
  124626. */
  124627. motionBlurSamples: number;
  124628. private _motionBlurSamples;
  124629. private _geometryBufferRenderer;
  124630. /**
  124631. * Creates a new instance MotionBlurPostProcess
  124632. * @param name The name of the effect.
  124633. * @param scene The scene containing the objects to blur according to their velocity.
  124634. * @param options The required width/height ratio to downsize to before computing the render pass.
  124635. * @param camera The camera to apply the render pass to.
  124636. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124637. * @param engine The engine which the post process will be applied. (default: current engine)
  124638. * @param reusable If the post process can be reused on the same frame. (default: false)
  124639. * @param textureType Type of textures used when performing the post process. (default: 0)
  124640. * @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)
  124641. */
  124642. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124643. /**
  124644. * Excludes the given skinned mesh from computing bones velocities.
  124645. * 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.
  124646. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  124647. */
  124648. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  124649. /**
  124650. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  124651. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  124652. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  124653. */
  124654. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  124655. /**
  124656. * Disposes the post process.
  124657. * @param camera The camera to dispose the post process on.
  124658. */
  124659. dispose(camera?: Camera): void;
  124660. }
  124661. }
  124662. declare module BABYLON {
  124663. /** @hidden */
  124664. export var refractionPixelShader: {
  124665. name: string;
  124666. shader: string;
  124667. };
  124668. }
  124669. declare module BABYLON {
  124670. /**
  124671. * Post process which applies a refractin texture
  124672. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  124673. */
  124674. export class RefractionPostProcess extends PostProcess {
  124675. /** the base color of the refraction (used to taint the rendering) */
  124676. color: Color3;
  124677. /** simulated refraction depth */
  124678. depth: number;
  124679. /** the coefficient of the base color (0 to remove base color tainting) */
  124680. colorLevel: number;
  124681. private _refTexture;
  124682. private _ownRefractionTexture;
  124683. /**
  124684. * Gets or sets the refraction texture
  124685. * Please note that you are responsible for disposing the texture if you set it manually
  124686. */
  124687. refractionTexture: Texture;
  124688. /**
  124689. * Initializes the RefractionPostProcess
  124690. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  124691. * @param name The name of the effect.
  124692. * @param refractionTextureUrl Url of the refraction texture to use
  124693. * @param color the base color of the refraction (used to taint the rendering)
  124694. * @param depth simulated refraction depth
  124695. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  124696. * @param camera The camera to apply the render pass to.
  124697. * @param options The required width/height ratio to downsize to before computing the render pass.
  124698. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124699. * @param engine The engine which the post process will be applied. (default: current engine)
  124700. * @param reusable If the post process can be reused on the same frame. (default: false)
  124701. */
  124702. constructor(name: string, refractionTextureUrl: string,
  124703. /** the base color of the refraction (used to taint the rendering) */
  124704. color: Color3,
  124705. /** simulated refraction depth */
  124706. depth: number,
  124707. /** the coefficient of the base color (0 to remove base color tainting) */
  124708. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  124709. /**
  124710. * Disposes of the post process
  124711. * @param camera Camera to dispose post process on
  124712. */
  124713. dispose(camera: Camera): void;
  124714. }
  124715. }
  124716. declare module BABYLON {
  124717. /** @hidden */
  124718. export var sharpenPixelShader: {
  124719. name: string;
  124720. shader: string;
  124721. };
  124722. }
  124723. declare module BABYLON {
  124724. /**
  124725. * The SharpenPostProcess applies a sharpen kernel to every pixel
  124726. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  124727. */
  124728. export class SharpenPostProcess extends PostProcess {
  124729. /**
  124730. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  124731. */
  124732. colorAmount: number;
  124733. /**
  124734. * How much sharpness should be applied (default: 0.3)
  124735. */
  124736. edgeAmount: number;
  124737. /**
  124738. * Creates a new instance ConvolutionPostProcess
  124739. * @param name The name of the effect.
  124740. * @param options The required width/height ratio to downsize to before computing the render pass.
  124741. * @param camera The camera to apply the render pass to.
  124742. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124743. * @param engine The engine which the post process will be applied. (default: current engine)
  124744. * @param reusable If the post process can be reused on the same frame. (default: false)
  124745. * @param textureType Type of textures used when performing the post process. (default: 0)
  124746. * @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)
  124747. */
  124748. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124749. }
  124750. }
  124751. declare module BABYLON {
  124752. /**
  124753. * PostProcessRenderPipeline
  124754. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124755. */
  124756. export class PostProcessRenderPipeline {
  124757. private engine;
  124758. private _renderEffects;
  124759. private _renderEffectsForIsolatedPass;
  124760. /**
  124761. * List of inspectable custom properties (used by the Inspector)
  124762. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  124763. */
  124764. inspectableCustomProperties: IInspectable[];
  124765. /**
  124766. * @hidden
  124767. */
  124768. protected _cameras: Camera[];
  124769. /** @hidden */
  124770. _name: string;
  124771. /**
  124772. * Gets pipeline name
  124773. */
  124774. readonly name: string;
  124775. /**
  124776. * Initializes a PostProcessRenderPipeline
  124777. * @param engine engine to add the pipeline to
  124778. * @param name name of the pipeline
  124779. */
  124780. constructor(engine: Engine, name: string);
  124781. /**
  124782. * Gets the class name
  124783. * @returns "PostProcessRenderPipeline"
  124784. */
  124785. getClassName(): string;
  124786. /**
  124787. * If all the render effects in the pipeline are supported
  124788. */
  124789. readonly isSupported: boolean;
  124790. /**
  124791. * Adds an effect to the pipeline
  124792. * @param renderEffect the effect to add
  124793. */
  124794. addEffect(renderEffect: PostProcessRenderEffect): void;
  124795. /** @hidden */
  124796. _rebuild(): void;
  124797. /** @hidden */
  124798. _enableEffect(renderEffectName: string, cameras: Camera): void;
  124799. /** @hidden */
  124800. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  124801. /** @hidden */
  124802. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  124803. /** @hidden */
  124804. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  124805. /** @hidden */
  124806. _attachCameras(cameras: Camera, unique: boolean): void;
  124807. /** @hidden */
  124808. _attachCameras(cameras: Camera[], unique: boolean): void;
  124809. /** @hidden */
  124810. _detachCameras(cameras: Camera): void;
  124811. /** @hidden */
  124812. _detachCameras(cameras: Nullable<Camera[]>): void;
  124813. /** @hidden */
  124814. _update(): void;
  124815. /** @hidden */
  124816. _reset(): void;
  124817. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  124818. /**
  124819. * Disposes of the pipeline
  124820. */
  124821. dispose(): void;
  124822. }
  124823. }
  124824. declare module BABYLON {
  124825. /**
  124826. * PostProcessRenderPipelineManager class
  124827. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124828. */
  124829. export class PostProcessRenderPipelineManager {
  124830. private _renderPipelines;
  124831. /**
  124832. * Initializes a PostProcessRenderPipelineManager
  124833. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124834. */
  124835. constructor();
  124836. /**
  124837. * Gets the list of supported render pipelines
  124838. */
  124839. readonly supportedPipelines: PostProcessRenderPipeline[];
  124840. /**
  124841. * Adds a pipeline to the manager
  124842. * @param renderPipeline The pipeline to add
  124843. */
  124844. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  124845. /**
  124846. * Attaches a camera to the pipeline
  124847. * @param renderPipelineName The name of the pipeline to attach to
  124848. * @param cameras the camera to attach
  124849. * @param unique if the camera can be attached multiple times to the pipeline
  124850. */
  124851. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  124852. /**
  124853. * Detaches a camera from the pipeline
  124854. * @param renderPipelineName The name of the pipeline to detach from
  124855. * @param cameras the camera to detach
  124856. */
  124857. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  124858. /**
  124859. * Enables an effect by name on a pipeline
  124860. * @param renderPipelineName the name of the pipeline to enable the effect in
  124861. * @param renderEffectName the name of the effect to enable
  124862. * @param cameras the cameras that the effect should be enabled on
  124863. */
  124864. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  124865. /**
  124866. * Disables an effect by name on a pipeline
  124867. * @param renderPipelineName the name of the pipeline to disable the effect in
  124868. * @param renderEffectName the name of the effect to disable
  124869. * @param cameras the cameras that the effect should be disabled on
  124870. */
  124871. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  124872. /**
  124873. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  124874. */
  124875. update(): void;
  124876. /** @hidden */
  124877. _rebuild(): void;
  124878. /**
  124879. * Disposes of the manager and pipelines
  124880. */
  124881. dispose(): void;
  124882. }
  124883. }
  124884. declare module BABYLON {
  124885. interface Scene {
  124886. /** @hidden (Backing field) */
  124887. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  124888. /**
  124889. * Gets the postprocess render pipeline manager
  124890. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124891. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  124892. */
  124893. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  124894. }
  124895. /**
  124896. * Defines the Render Pipeline scene component responsible to rendering pipelines
  124897. */
  124898. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  124899. /**
  124900. * The component name helpfull to identify the component in the list of scene components.
  124901. */
  124902. readonly name: string;
  124903. /**
  124904. * The scene the component belongs to.
  124905. */
  124906. scene: Scene;
  124907. /**
  124908. * Creates a new instance of the component for the given scene
  124909. * @param scene Defines the scene to register the component in
  124910. */
  124911. constructor(scene: Scene);
  124912. /**
  124913. * Registers the component in a given scene
  124914. */
  124915. register(): void;
  124916. /**
  124917. * Rebuilds the elements related to this component in case of
  124918. * context lost for instance.
  124919. */
  124920. rebuild(): void;
  124921. /**
  124922. * Disposes the component and the associated ressources
  124923. */
  124924. dispose(): void;
  124925. private _gatherRenderTargets;
  124926. }
  124927. }
  124928. declare module BABYLON {
  124929. /**
  124930. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  124931. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  124932. */
  124933. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  124934. private _scene;
  124935. private _camerasToBeAttached;
  124936. /**
  124937. * ID of the sharpen post process,
  124938. */
  124939. private readonly SharpenPostProcessId;
  124940. /**
  124941. * @ignore
  124942. * ID of the image processing post process;
  124943. */
  124944. readonly ImageProcessingPostProcessId: string;
  124945. /**
  124946. * @ignore
  124947. * ID of the Fast Approximate Anti-Aliasing post process;
  124948. */
  124949. readonly FxaaPostProcessId: string;
  124950. /**
  124951. * ID of the chromatic aberration post process,
  124952. */
  124953. private readonly ChromaticAberrationPostProcessId;
  124954. /**
  124955. * ID of the grain post process
  124956. */
  124957. private readonly GrainPostProcessId;
  124958. /**
  124959. * Sharpen post process which will apply a sharpen convolution to enhance edges
  124960. */
  124961. sharpen: SharpenPostProcess;
  124962. private _sharpenEffect;
  124963. private bloom;
  124964. /**
  124965. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  124966. */
  124967. depthOfField: DepthOfFieldEffect;
  124968. /**
  124969. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  124970. */
  124971. fxaa: FxaaPostProcess;
  124972. /**
  124973. * Image post processing pass used to perform operations such as tone mapping or color grading.
  124974. */
  124975. imageProcessing: ImageProcessingPostProcess;
  124976. /**
  124977. * Chromatic aberration post process which will shift rgb colors in the image
  124978. */
  124979. chromaticAberration: ChromaticAberrationPostProcess;
  124980. private _chromaticAberrationEffect;
  124981. /**
  124982. * Grain post process which add noise to the image
  124983. */
  124984. grain: GrainPostProcess;
  124985. private _grainEffect;
  124986. /**
  124987. * Glow post process which adds a glow to emissive areas of the image
  124988. */
  124989. private _glowLayer;
  124990. /**
  124991. * Animations which can be used to tweak settings over a period of time
  124992. */
  124993. animations: Animation[];
  124994. private _imageProcessingConfigurationObserver;
  124995. private _sharpenEnabled;
  124996. private _bloomEnabled;
  124997. private _depthOfFieldEnabled;
  124998. private _depthOfFieldBlurLevel;
  124999. private _fxaaEnabled;
  125000. private _imageProcessingEnabled;
  125001. private _defaultPipelineTextureType;
  125002. private _bloomScale;
  125003. private _chromaticAberrationEnabled;
  125004. private _grainEnabled;
  125005. private _buildAllowed;
  125006. /**
  125007. * Gets active scene
  125008. */
  125009. readonly scene: Scene;
  125010. /**
  125011. * Enable or disable the sharpen process from the pipeline
  125012. */
  125013. sharpenEnabled: boolean;
  125014. private _resizeObserver;
  125015. private _hardwareScaleLevel;
  125016. private _bloomKernel;
  125017. /**
  125018. * Specifies the size of the bloom blur kernel, relative to the final output size
  125019. */
  125020. bloomKernel: number;
  125021. /**
  125022. * Specifies the weight of the bloom in the final rendering
  125023. */
  125024. private _bloomWeight;
  125025. /**
  125026. * Specifies the luma threshold for the area that will be blurred by the bloom
  125027. */
  125028. private _bloomThreshold;
  125029. private _hdr;
  125030. /**
  125031. * The strength of the bloom.
  125032. */
  125033. bloomWeight: number;
  125034. /**
  125035. * The strength of the bloom.
  125036. */
  125037. bloomThreshold: number;
  125038. /**
  125039. * The scale of the bloom, lower value will provide better performance.
  125040. */
  125041. bloomScale: number;
  125042. /**
  125043. * Enable or disable the bloom from the pipeline
  125044. */
  125045. bloomEnabled: boolean;
  125046. private _rebuildBloom;
  125047. /**
  125048. * If the depth of field is enabled.
  125049. */
  125050. depthOfFieldEnabled: boolean;
  125051. /**
  125052. * Blur level of the depth of field effect. (Higher blur will effect performance)
  125053. */
  125054. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  125055. /**
  125056. * If the anti aliasing is enabled.
  125057. */
  125058. fxaaEnabled: boolean;
  125059. private _samples;
  125060. /**
  125061. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  125062. */
  125063. samples: number;
  125064. /**
  125065. * If image processing is enabled.
  125066. */
  125067. imageProcessingEnabled: boolean;
  125068. /**
  125069. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  125070. */
  125071. glowLayerEnabled: boolean;
  125072. /**
  125073. * Gets the glow layer (or null if not defined)
  125074. */
  125075. readonly glowLayer: Nullable<GlowLayer>;
  125076. /**
  125077. * Enable or disable the chromaticAberration process from the pipeline
  125078. */
  125079. chromaticAberrationEnabled: boolean;
  125080. /**
  125081. * Enable or disable the grain process from the pipeline
  125082. */
  125083. grainEnabled: boolean;
  125084. /**
  125085. * @constructor
  125086. * @param name - The rendering pipeline name (default: "")
  125087. * @param hdr - If high dynamic range textures should be used (default: true)
  125088. * @param scene - The scene linked to this pipeline (default: the last created scene)
  125089. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  125090. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  125091. */
  125092. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  125093. /**
  125094. * Get the class name
  125095. * @returns "DefaultRenderingPipeline"
  125096. */
  125097. getClassName(): string;
  125098. /**
  125099. * Force the compilation of the entire pipeline.
  125100. */
  125101. prepare(): void;
  125102. private _hasCleared;
  125103. private _prevPostProcess;
  125104. private _prevPrevPostProcess;
  125105. private _setAutoClearAndTextureSharing;
  125106. private _depthOfFieldSceneObserver;
  125107. private _buildPipeline;
  125108. private _disposePostProcesses;
  125109. /**
  125110. * Adds a camera to the pipeline
  125111. * @param camera the camera to be added
  125112. */
  125113. addCamera(camera: Camera): void;
  125114. /**
  125115. * Removes a camera from the pipeline
  125116. * @param camera the camera to remove
  125117. */
  125118. removeCamera(camera: Camera): void;
  125119. /**
  125120. * Dispose of the pipeline and stop all post processes
  125121. */
  125122. dispose(): void;
  125123. /**
  125124. * Serialize the rendering pipeline (Used when exporting)
  125125. * @returns the serialized object
  125126. */
  125127. serialize(): any;
  125128. /**
  125129. * Parse the serialized pipeline
  125130. * @param source Source pipeline.
  125131. * @param scene The scene to load the pipeline to.
  125132. * @param rootUrl The URL of the serialized pipeline.
  125133. * @returns An instantiated pipeline from the serialized object.
  125134. */
  125135. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  125136. }
  125137. }
  125138. declare module BABYLON {
  125139. /** @hidden */
  125140. export var lensHighlightsPixelShader: {
  125141. name: string;
  125142. shader: string;
  125143. };
  125144. }
  125145. declare module BABYLON {
  125146. /** @hidden */
  125147. export var depthOfFieldPixelShader: {
  125148. name: string;
  125149. shader: string;
  125150. };
  125151. }
  125152. declare module BABYLON {
  125153. /**
  125154. * BABYLON.JS Chromatic Aberration GLSL Shader
  125155. * Author: Olivier Guyot
  125156. * Separates very slightly R, G and B colors on the edges of the screen
  125157. * Inspired by Francois Tarlier & Martins Upitis
  125158. */
  125159. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  125160. /**
  125161. * @ignore
  125162. * The chromatic aberration PostProcess id in the pipeline
  125163. */
  125164. LensChromaticAberrationEffect: string;
  125165. /**
  125166. * @ignore
  125167. * The highlights enhancing PostProcess id in the pipeline
  125168. */
  125169. HighlightsEnhancingEffect: string;
  125170. /**
  125171. * @ignore
  125172. * The depth-of-field PostProcess id in the pipeline
  125173. */
  125174. LensDepthOfFieldEffect: string;
  125175. private _scene;
  125176. private _depthTexture;
  125177. private _grainTexture;
  125178. private _chromaticAberrationPostProcess;
  125179. private _highlightsPostProcess;
  125180. private _depthOfFieldPostProcess;
  125181. private _edgeBlur;
  125182. private _grainAmount;
  125183. private _chromaticAberration;
  125184. private _distortion;
  125185. private _highlightsGain;
  125186. private _highlightsThreshold;
  125187. private _dofDistance;
  125188. private _dofAperture;
  125189. private _dofDarken;
  125190. private _dofPentagon;
  125191. private _blurNoise;
  125192. /**
  125193. * @constructor
  125194. *
  125195. * Effect parameters are as follow:
  125196. * {
  125197. * chromatic_aberration: number; // from 0 to x (1 for realism)
  125198. * edge_blur: number; // from 0 to x (1 for realism)
  125199. * distortion: number; // from 0 to x (1 for realism)
  125200. * grain_amount: number; // from 0 to 1
  125201. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  125202. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  125203. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  125204. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  125205. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  125206. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  125207. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  125208. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  125209. * }
  125210. * Note: if an effect parameter is unset, effect is disabled
  125211. *
  125212. * @param name The rendering pipeline name
  125213. * @param parameters - An object containing all parameters (see above)
  125214. * @param scene The scene linked to this pipeline
  125215. * @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)
  125216. * @param cameras The array of cameras that the rendering pipeline will be attached to
  125217. */
  125218. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  125219. /**
  125220. * Get the class name
  125221. * @returns "LensRenderingPipeline"
  125222. */
  125223. getClassName(): string;
  125224. /**
  125225. * Gets associated scene
  125226. */
  125227. readonly scene: Scene;
  125228. /**
  125229. * Gets or sets the edge blur
  125230. */
  125231. edgeBlur: number;
  125232. /**
  125233. * Gets or sets the grain amount
  125234. */
  125235. grainAmount: number;
  125236. /**
  125237. * Gets or sets the chromatic aberration amount
  125238. */
  125239. chromaticAberration: number;
  125240. /**
  125241. * Gets or sets the depth of field aperture
  125242. */
  125243. dofAperture: number;
  125244. /**
  125245. * Gets or sets the edge distortion
  125246. */
  125247. edgeDistortion: number;
  125248. /**
  125249. * Gets or sets the depth of field distortion
  125250. */
  125251. dofDistortion: number;
  125252. /**
  125253. * Gets or sets the darken out of focus amount
  125254. */
  125255. darkenOutOfFocus: number;
  125256. /**
  125257. * Gets or sets a boolean indicating if blur noise is enabled
  125258. */
  125259. blurNoise: boolean;
  125260. /**
  125261. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  125262. */
  125263. pentagonBokeh: boolean;
  125264. /**
  125265. * Gets or sets the highlight grain amount
  125266. */
  125267. highlightsGain: number;
  125268. /**
  125269. * Gets or sets the highlight threshold
  125270. */
  125271. highlightsThreshold: number;
  125272. /**
  125273. * Sets the amount of blur at the edges
  125274. * @param amount blur amount
  125275. */
  125276. setEdgeBlur(amount: number): void;
  125277. /**
  125278. * Sets edge blur to 0
  125279. */
  125280. disableEdgeBlur(): void;
  125281. /**
  125282. * Sets the amout of grain
  125283. * @param amount Amount of grain
  125284. */
  125285. setGrainAmount(amount: number): void;
  125286. /**
  125287. * Set grain amount to 0
  125288. */
  125289. disableGrain(): void;
  125290. /**
  125291. * Sets the chromatic aberration amount
  125292. * @param amount amount of chromatic aberration
  125293. */
  125294. setChromaticAberration(amount: number): void;
  125295. /**
  125296. * Sets chromatic aberration amount to 0
  125297. */
  125298. disableChromaticAberration(): void;
  125299. /**
  125300. * Sets the EdgeDistortion amount
  125301. * @param amount amount of EdgeDistortion
  125302. */
  125303. setEdgeDistortion(amount: number): void;
  125304. /**
  125305. * Sets edge distortion to 0
  125306. */
  125307. disableEdgeDistortion(): void;
  125308. /**
  125309. * Sets the FocusDistance amount
  125310. * @param amount amount of FocusDistance
  125311. */
  125312. setFocusDistance(amount: number): void;
  125313. /**
  125314. * Disables depth of field
  125315. */
  125316. disableDepthOfField(): void;
  125317. /**
  125318. * Sets the Aperture amount
  125319. * @param amount amount of Aperture
  125320. */
  125321. setAperture(amount: number): void;
  125322. /**
  125323. * Sets the DarkenOutOfFocus amount
  125324. * @param amount amount of DarkenOutOfFocus
  125325. */
  125326. setDarkenOutOfFocus(amount: number): void;
  125327. private _pentagonBokehIsEnabled;
  125328. /**
  125329. * Creates a pentagon bokeh effect
  125330. */
  125331. enablePentagonBokeh(): void;
  125332. /**
  125333. * Disables the pentagon bokeh effect
  125334. */
  125335. disablePentagonBokeh(): void;
  125336. /**
  125337. * Enables noise blur
  125338. */
  125339. enableNoiseBlur(): void;
  125340. /**
  125341. * Disables noise blur
  125342. */
  125343. disableNoiseBlur(): void;
  125344. /**
  125345. * Sets the HighlightsGain amount
  125346. * @param amount amount of HighlightsGain
  125347. */
  125348. setHighlightsGain(amount: number): void;
  125349. /**
  125350. * Sets the HighlightsThreshold amount
  125351. * @param amount amount of HighlightsThreshold
  125352. */
  125353. setHighlightsThreshold(amount: number): void;
  125354. /**
  125355. * Disables highlights
  125356. */
  125357. disableHighlights(): void;
  125358. /**
  125359. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  125360. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  125361. */
  125362. dispose(disableDepthRender?: boolean): void;
  125363. private _createChromaticAberrationPostProcess;
  125364. private _createHighlightsPostProcess;
  125365. private _createDepthOfFieldPostProcess;
  125366. private _createGrainTexture;
  125367. }
  125368. }
  125369. declare module BABYLON {
  125370. /** @hidden */
  125371. export var ssao2PixelShader: {
  125372. name: string;
  125373. shader: string;
  125374. };
  125375. }
  125376. declare module BABYLON {
  125377. /** @hidden */
  125378. export var ssaoCombinePixelShader: {
  125379. name: string;
  125380. shader: string;
  125381. };
  125382. }
  125383. declare module BABYLON {
  125384. /**
  125385. * Render pipeline to produce ssao effect
  125386. */
  125387. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  125388. /**
  125389. * @ignore
  125390. * The PassPostProcess id in the pipeline that contains the original scene color
  125391. */
  125392. SSAOOriginalSceneColorEffect: string;
  125393. /**
  125394. * @ignore
  125395. * The SSAO PostProcess id in the pipeline
  125396. */
  125397. SSAORenderEffect: string;
  125398. /**
  125399. * @ignore
  125400. * The horizontal blur PostProcess id in the pipeline
  125401. */
  125402. SSAOBlurHRenderEffect: string;
  125403. /**
  125404. * @ignore
  125405. * The vertical blur PostProcess id in the pipeline
  125406. */
  125407. SSAOBlurVRenderEffect: string;
  125408. /**
  125409. * @ignore
  125410. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  125411. */
  125412. SSAOCombineRenderEffect: string;
  125413. /**
  125414. * The output strength of the SSAO post-process. Default value is 1.0.
  125415. */
  125416. totalStrength: number;
  125417. /**
  125418. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  125419. */
  125420. maxZ: number;
  125421. /**
  125422. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  125423. */
  125424. minZAspect: number;
  125425. private _samples;
  125426. /**
  125427. * Number of samples used for the SSAO calculations. Default value is 8
  125428. */
  125429. samples: number;
  125430. private _textureSamples;
  125431. /**
  125432. * Number of samples to use for antialiasing
  125433. */
  125434. textureSamples: number;
  125435. /**
  125436. * Ratio object used for SSAO ratio and blur ratio
  125437. */
  125438. private _ratio;
  125439. /**
  125440. * Dynamically generated sphere sampler.
  125441. */
  125442. private _sampleSphere;
  125443. /**
  125444. * Blur filter offsets
  125445. */
  125446. private _samplerOffsets;
  125447. private _expensiveBlur;
  125448. /**
  125449. * If bilateral blur should be used
  125450. */
  125451. expensiveBlur: boolean;
  125452. /**
  125453. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  125454. */
  125455. radius: number;
  125456. /**
  125457. * The base color of the SSAO post-process
  125458. * The final result is "base + ssao" between [0, 1]
  125459. */
  125460. base: number;
  125461. /**
  125462. * Support test.
  125463. */
  125464. static readonly IsSupported: boolean;
  125465. private _scene;
  125466. private _depthTexture;
  125467. private _normalTexture;
  125468. private _randomTexture;
  125469. private _originalColorPostProcess;
  125470. private _ssaoPostProcess;
  125471. private _blurHPostProcess;
  125472. private _blurVPostProcess;
  125473. private _ssaoCombinePostProcess;
  125474. private _firstUpdate;
  125475. /**
  125476. * Gets active scene
  125477. */
  125478. readonly scene: Scene;
  125479. /**
  125480. * @constructor
  125481. * @param name The rendering pipeline name
  125482. * @param scene The scene linked to this pipeline
  125483. * @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 }
  125484. * @param cameras The array of cameras that the rendering pipeline will be attached to
  125485. */
  125486. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  125487. /**
  125488. * Get the class name
  125489. * @returns "SSAO2RenderingPipeline"
  125490. */
  125491. getClassName(): string;
  125492. /**
  125493. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  125494. */
  125495. dispose(disableGeometryBufferRenderer?: boolean): void;
  125496. private _createBlurPostProcess;
  125497. /** @hidden */
  125498. _rebuild(): void;
  125499. private _bits;
  125500. private _radicalInverse_VdC;
  125501. private _hammersley;
  125502. private _hemisphereSample_uniform;
  125503. private _generateHemisphere;
  125504. private _createSSAOPostProcess;
  125505. private _createSSAOCombinePostProcess;
  125506. private _createRandomTexture;
  125507. /**
  125508. * Serialize the rendering pipeline (Used when exporting)
  125509. * @returns the serialized object
  125510. */
  125511. serialize(): any;
  125512. /**
  125513. * Parse the serialized pipeline
  125514. * @param source Source pipeline.
  125515. * @param scene The scene to load the pipeline to.
  125516. * @param rootUrl The URL of the serialized pipeline.
  125517. * @returns An instantiated pipeline from the serialized object.
  125518. */
  125519. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  125520. }
  125521. }
  125522. declare module BABYLON {
  125523. /** @hidden */
  125524. export var ssaoPixelShader: {
  125525. name: string;
  125526. shader: string;
  125527. };
  125528. }
  125529. declare module BABYLON {
  125530. /**
  125531. * Render pipeline to produce ssao effect
  125532. */
  125533. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  125534. /**
  125535. * @ignore
  125536. * The PassPostProcess id in the pipeline that contains the original scene color
  125537. */
  125538. SSAOOriginalSceneColorEffect: string;
  125539. /**
  125540. * @ignore
  125541. * The SSAO PostProcess id in the pipeline
  125542. */
  125543. SSAORenderEffect: string;
  125544. /**
  125545. * @ignore
  125546. * The horizontal blur PostProcess id in the pipeline
  125547. */
  125548. SSAOBlurHRenderEffect: string;
  125549. /**
  125550. * @ignore
  125551. * The vertical blur PostProcess id in the pipeline
  125552. */
  125553. SSAOBlurVRenderEffect: string;
  125554. /**
  125555. * @ignore
  125556. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  125557. */
  125558. SSAOCombineRenderEffect: string;
  125559. /**
  125560. * The output strength of the SSAO post-process. Default value is 1.0.
  125561. */
  125562. totalStrength: number;
  125563. /**
  125564. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  125565. */
  125566. radius: number;
  125567. /**
  125568. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  125569. * Must not be equal to fallOff and superior to fallOff.
  125570. * Default value is 0.0075
  125571. */
  125572. area: number;
  125573. /**
  125574. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  125575. * Must not be equal to area and inferior to area.
  125576. * Default value is 0.000001
  125577. */
  125578. fallOff: number;
  125579. /**
  125580. * The base color of the SSAO post-process
  125581. * The final result is "base + ssao" between [0, 1]
  125582. */
  125583. base: number;
  125584. private _scene;
  125585. private _depthTexture;
  125586. private _randomTexture;
  125587. private _originalColorPostProcess;
  125588. private _ssaoPostProcess;
  125589. private _blurHPostProcess;
  125590. private _blurVPostProcess;
  125591. private _ssaoCombinePostProcess;
  125592. private _firstUpdate;
  125593. /**
  125594. * Gets active scene
  125595. */
  125596. readonly scene: Scene;
  125597. /**
  125598. * @constructor
  125599. * @param name - The rendering pipeline name
  125600. * @param scene - The scene linked to this pipeline
  125601. * @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 }
  125602. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  125603. */
  125604. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  125605. /**
  125606. * Get the class name
  125607. * @returns "SSAORenderingPipeline"
  125608. */
  125609. getClassName(): string;
  125610. /**
  125611. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  125612. */
  125613. dispose(disableDepthRender?: boolean): void;
  125614. private _createBlurPostProcess;
  125615. /** @hidden */
  125616. _rebuild(): void;
  125617. private _createSSAOPostProcess;
  125618. private _createSSAOCombinePostProcess;
  125619. private _createRandomTexture;
  125620. }
  125621. }
  125622. declare module BABYLON {
  125623. /** @hidden */
  125624. export var standardPixelShader: {
  125625. name: string;
  125626. shader: string;
  125627. };
  125628. }
  125629. declare module BABYLON {
  125630. /**
  125631. * Standard rendering pipeline
  125632. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  125633. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  125634. */
  125635. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  125636. /**
  125637. * Public members
  125638. */
  125639. /**
  125640. * Post-process which contains the original scene color before the pipeline applies all the effects
  125641. */
  125642. originalPostProcess: Nullable<PostProcess>;
  125643. /**
  125644. * Post-process used to down scale an image x4
  125645. */
  125646. downSampleX4PostProcess: Nullable<PostProcess>;
  125647. /**
  125648. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  125649. */
  125650. brightPassPostProcess: Nullable<PostProcess>;
  125651. /**
  125652. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  125653. */
  125654. blurHPostProcesses: PostProcess[];
  125655. /**
  125656. * Post-process array storing all the vertical blur post-processes used by the pipeline
  125657. */
  125658. blurVPostProcesses: PostProcess[];
  125659. /**
  125660. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  125661. */
  125662. textureAdderPostProcess: Nullable<PostProcess>;
  125663. /**
  125664. * Post-process used to create volumetric lighting effect
  125665. */
  125666. volumetricLightPostProcess: Nullable<PostProcess>;
  125667. /**
  125668. * Post-process used to smooth the previous volumetric light post-process on the X axis
  125669. */
  125670. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  125671. /**
  125672. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  125673. */
  125674. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  125675. /**
  125676. * Post-process used to merge the volumetric light effect and the real scene color
  125677. */
  125678. volumetricLightMergePostProces: Nullable<PostProcess>;
  125679. /**
  125680. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  125681. */
  125682. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  125683. /**
  125684. * Base post-process used to calculate the average luminance of the final image for HDR
  125685. */
  125686. luminancePostProcess: Nullable<PostProcess>;
  125687. /**
  125688. * Post-processes used to create down sample post-processes in order to get
  125689. * the average luminance of the final image for HDR
  125690. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  125691. */
  125692. luminanceDownSamplePostProcesses: PostProcess[];
  125693. /**
  125694. * Post-process used to create a HDR effect (light adaptation)
  125695. */
  125696. hdrPostProcess: Nullable<PostProcess>;
  125697. /**
  125698. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  125699. */
  125700. textureAdderFinalPostProcess: Nullable<PostProcess>;
  125701. /**
  125702. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  125703. */
  125704. lensFlareFinalPostProcess: Nullable<PostProcess>;
  125705. /**
  125706. * Post-process used to merge the final HDR post-process and the real scene color
  125707. */
  125708. hdrFinalPostProcess: Nullable<PostProcess>;
  125709. /**
  125710. * Post-process used to create a lens flare effect
  125711. */
  125712. lensFlarePostProcess: Nullable<PostProcess>;
  125713. /**
  125714. * Post-process that merges the result of the lens flare post-process and the real scene color
  125715. */
  125716. lensFlareComposePostProcess: Nullable<PostProcess>;
  125717. /**
  125718. * Post-process used to create a motion blur effect
  125719. */
  125720. motionBlurPostProcess: Nullable<PostProcess>;
  125721. /**
  125722. * Post-process used to create a depth of field effect
  125723. */
  125724. depthOfFieldPostProcess: Nullable<PostProcess>;
  125725. /**
  125726. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  125727. */
  125728. fxaaPostProcess: Nullable<FxaaPostProcess>;
  125729. /**
  125730. * Represents the brightness threshold in order to configure the illuminated surfaces
  125731. */
  125732. brightThreshold: number;
  125733. /**
  125734. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  125735. */
  125736. blurWidth: number;
  125737. /**
  125738. * Sets if the blur for highlighted surfaces must be only horizontal
  125739. */
  125740. horizontalBlur: boolean;
  125741. /**
  125742. * Gets the overall exposure used by the pipeline
  125743. */
  125744. /**
  125745. * Sets the overall exposure used by the pipeline
  125746. */
  125747. exposure: number;
  125748. /**
  125749. * Texture used typically to simulate "dirty" on camera lens
  125750. */
  125751. lensTexture: Nullable<Texture>;
  125752. /**
  125753. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  125754. */
  125755. volumetricLightCoefficient: number;
  125756. /**
  125757. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  125758. */
  125759. volumetricLightPower: number;
  125760. /**
  125761. * Used the set the blur intensity to smooth the volumetric lights
  125762. */
  125763. volumetricLightBlurScale: number;
  125764. /**
  125765. * Light (spot or directional) used to generate the volumetric lights rays
  125766. * The source light must have a shadow generate so the pipeline can get its
  125767. * depth map
  125768. */
  125769. sourceLight: Nullable<SpotLight | DirectionalLight>;
  125770. /**
  125771. * For eye adaptation, represents the minimum luminance the eye can see
  125772. */
  125773. hdrMinimumLuminance: number;
  125774. /**
  125775. * For eye adaptation, represents the decrease luminance speed
  125776. */
  125777. hdrDecreaseRate: number;
  125778. /**
  125779. * For eye adaptation, represents the increase luminance speed
  125780. */
  125781. hdrIncreaseRate: number;
  125782. /**
  125783. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  125784. */
  125785. /**
  125786. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  125787. */
  125788. hdrAutoExposure: boolean;
  125789. /**
  125790. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  125791. */
  125792. lensColorTexture: Nullable<Texture>;
  125793. /**
  125794. * The overall strengh for the lens flare effect
  125795. */
  125796. lensFlareStrength: number;
  125797. /**
  125798. * Dispersion coefficient for lens flare ghosts
  125799. */
  125800. lensFlareGhostDispersal: number;
  125801. /**
  125802. * Main lens flare halo width
  125803. */
  125804. lensFlareHaloWidth: number;
  125805. /**
  125806. * Based on the lens distortion effect, defines how much the lens flare result
  125807. * is distorted
  125808. */
  125809. lensFlareDistortionStrength: number;
  125810. /**
  125811. * Configures the blur intensity used for for lens flare (halo)
  125812. */
  125813. lensFlareBlurWidth: number;
  125814. /**
  125815. * Lens star texture must be used to simulate rays on the flares and is available
  125816. * in the documentation
  125817. */
  125818. lensStarTexture: Nullable<Texture>;
  125819. /**
  125820. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  125821. * flare effect by taking account of the dirt texture
  125822. */
  125823. lensFlareDirtTexture: Nullable<Texture>;
  125824. /**
  125825. * Represents the focal length for the depth of field effect
  125826. */
  125827. depthOfFieldDistance: number;
  125828. /**
  125829. * Represents the blur intensity for the blurred part of the depth of field effect
  125830. */
  125831. depthOfFieldBlurWidth: number;
  125832. /**
  125833. * Gets how much the image is blurred by the movement while using the motion blur post-process
  125834. */
  125835. /**
  125836. * Sets how much the image is blurred by the movement while using the motion blur post-process
  125837. */
  125838. motionStrength: number;
  125839. /**
  125840. * Gets wether or not the motion blur post-process is object based or screen based.
  125841. */
  125842. /**
  125843. * Sets wether or not the motion blur post-process should be object based or screen based
  125844. */
  125845. objectBasedMotionBlur: boolean;
  125846. /**
  125847. * List of animations for the pipeline (IAnimatable implementation)
  125848. */
  125849. animations: Animation[];
  125850. /**
  125851. * Private members
  125852. */
  125853. private _scene;
  125854. private _currentDepthOfFieldSource;
  125855. private _basePostProcess;
  125856. private _fixedExposure;
  125857. private _currentExposure;
  125858. private _hdrAutoExposure;
  125859. private _hdrCurrentLuminance;
  125860. private _motionStrength;
  125861. private _isObjectBasedMotionBlur;
  125862. private _floatTextureType;
  125863. private _camerasToBeAttached;
  125864. private _ratio;
  125865. private _bloomEnabled;
  125866. private _depthOfFieldEnabled;
  125867. private _vlsEnabled;
  125868. private _lensFlareEnabled;
  125869. private _hdrEnabled;
  125870. private _motionBlurEnabled;
  125871. private _fxaaEnabled;
  125872. private _motionBlurSamples;
  125873. private _volumetricLightStepsCount;
  125874. private _samples;
  125875. /**
  125876. * @ignore
  125877. * Specifies if the bloom pipeline is enabled
  125878. */
  125879. BloomEnabled: boolean;
  125880. /**
  125881. * @ignore
  125882. * Specifies if the depth of field pipeline is enabed
  125883. */
  125884. DepthOfFieldEnabled: boolean;
  125885. /**
  125886. * @ignore
  125887. * Specifies if the lens flare pipeline is enabed
  125888. */
  125889. LensFlareEnabled: boolean;
  125890. /**
  125891. * @ignore
  125892. * Specifies if the HDR pipeline is enabled
  125893. */
  125894. HDREnabled: boolean;
  125895. /**
  125896. * @ignore
  125897. * Specifies if the volumetric lights scattering effect is enabled
  125898. */
  125899. VLSEnabled: boolean;
  125900. /**
  125901. * @ignore
  125902. * Specifies if the motion blur effect is enabled
  125903. */
  125904. MotionBlurEnabled: boolean;
  125905. /**
  125906. * Specifies if anti-aliasing is enabled
  125907. */
  125908. fxaaEnabled: boolean;
  125909. /**
  125910. * Specifies the number of steps used to calculate the volumetric lights
  125911. * Typically in interval [50, 200]
  125912. */
  125913. volumetricLightStepsCount: number;
  125914. /**
  125915. * Specifies the number of samples used for the motion blur effect
  125916. * Typically in interval [16, 64]
  125917. */
  125918. motionBlurSamples: number;
  125919. /**
  125920. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  125921. */
  125922. samples: number;
  125923. /**
  125924. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  125925. * @constructor
  125926. * @param name The rendering pipeline name
  125927. * @param scene The scene linked to this pipeline
  125928. * @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)
  125929. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  125930. * @param cameras The array of cameras that the rendering pipeline will be attached to
  125931. */
  125932. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  125933. private _buildPipeline;
  125934. private _createDownSampleX4PostProcess;
  125935. private _createBrightPassPostProcess;
  125936. private _createBlurPostProcesses;
  125937. private _createTextureAdderPostProcess;
  125938. private _createVolumetricLightPostProcess;
  125939. private _createLuminancePostProcesses;
  125940. private _createHdrPostProcess;
  125941. private _createLensFlarePostProcess;
  125942. private _createDepthOfFieldPostProcess;
  125943. private _createMotionBlurPostProcess;
  125944. private _getDepthTexture;
  125945. private _disposePostProcesses;
  125946. /**
  125947. * Dispose of the pipeline and stop all post processes
  125948. */
  125949. dispose(): void;
  125950. /**
  125951. * Serialize the rendering pipeline (Used when exporting)
  125952. * @returns the serialized object
  125953. */
  125954. serialize(): any;
  125955. /**
  125956. * Parse the serialized pipeline
  125957. * @param source Source pipeline.
  125958. * @param scene The scene to load the pipeline to.
  125959. * @param rootUrl The URL of the serialized pipeline.
  125960. * @returns An instantiated pipeline from the serialized object.
  125961. */
  125962. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  125963. /**
  125964. * Luminance steps
  125965. */
  125966. static LuminanceSteps: number;
  125967. }
  125968. }
  125969. declare module BABYLON {
  125970. /** @hidden */
  125971. export var tonemapPixelShader: {
  125972. name: string;
  125973. shader: string;
  125974. };
  125975. }
  125976. declare module BABYLON {
  125977. /** Defines operator used for tonemapping */
  125978. export enum TonemappingOperator {
  125979. /** Hable */
  125980. Hable = 0,
  125981. /** Reinhard */
  125982. Reinhard = 1,
  125983. /** HejiDawson */
  125984. HejiDawson = 2,
  125985. /** Photographic */
  125986. Photographic = 3
  125987. }
  125988. /**
  125989. * Defines a post process to apply tone mapping
  125990. */
  125991. export class TonemapPostProcess extends PostProcess {
  125992. private _operator;
  125993. /** Defines the required exposure adjustement */
  125994. exposureAdjustment: number;
  125995. /**
  125996. * Creates a new TonemapPostProcess
  125997. * @param name defines the name of the postprocess
  125998. * @param _operator defines the operator to use
  125999. * @param exposureAdjustment defines the required exposure adjustement
  126000. * @param camera defines the camera to use (can be null)
  126001. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  126002. * @param engine defines the hosting engine (can be ignore if camera is set)
  126003. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  126004. */
  126005. constructor(name: string, _operator: TonemappingOperator,
  126006. /** Defines the required exposure adjustement */
  126007. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  126008. }
  126009. }
  126010. declare module BABYLON {
  126011. /** @hidden */
  126012. export var depthVertexShader: {
  126013. name: string;
  126014. shader: string;
  126015. };
  126016. }
  126017. declare module BABYLON {
  126018. /** @hidden */
  126019. export var volumetricLightScatteringPixelShader: {
  126020. name: string;
  126021. shader: string;
  126022. };
  126023. }
  126024. declare module BABYLON {
  126025. /** @hidden */
  126026. export var volumetricLightScatteringPassVertexShader: {
  126027. name: string;
  126028. shader: string;
  126029. };
  126030. }
  126031. declare module BABYLON {
  126032. /** @hidden */
  126033. export var volumetricLightScatteringPassPixelShader: {
  126034. name: string;
  126035. shader: string;
  126036. };
  126037. }
  126038. declare module BABYLON {
  126039. /**
  126040. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  126041. */
  126042. export class VolumetricLightScatteringPostProcess extends PostProcess {
  126043. private _volumetricLightScatteringPass;
  126044. private _volumetricLightScatteringRTT;
  126045. private _viewPort;
  126046. private _screenCoordinates;
  126047. private _cachedDefines;
  126048. /**
  126049. * If not undefined, the mesh position is computed from the attached node position
  126050. */
  126051. attachedNode: {
  126052. position: Vector3;
  126053. };
  126054. /**
  126055. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  126056. */
  126057. customMeshPosition: Vector3;
  126058. /**
  126059. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  126060. */
  126061. useCustomMeshPosition: boolean;
  126062. /**
  126063. * If the post-process should inverse the light scattering direction
  126064. */
  126065. invert: boolean;
  126066. /**
  126067. * The internal mesh used by the post-process
  126068. */
  126069. mesh: Mesh;
  126070. /**
  126071. * @hidden
  126072. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  126073. */
  126074. useDiffuseColor: boolean;
  126075. /**
  126076. * Array containing the excluded meshes not rendered in the internal pass
  126077. */
  126078. excludedMeshes: AbstractMesh[];
  126079. /**
  126080. * Controls the overall intensity of the post-process
  126081. */
  126082. exposure: number;
  126083. /**
  126084. * Dissipates each sample's contribution in range [0, 1]
  126085. */
  126086. decay: number;
  126087. /**
  126088. * Controls the overall intensity of each sample
  126089. */
  126090. weight: number;
  126091. /**
  126092. * Controls the density of each sample
  126093. */
  126094. density: number;
  126095. /**
  126096. * @constructor
  126097. * @param name The post-process name
  126098. * @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)
  126099. * @param camera The camera that the post-process will be attached to
  126100. * @param mesh The mesh used to create the light scattering
  126101. * @param samples The post-process quality, default 100
  126102. * @param samplingModeThe post-process filtering mode
  126103. * @param engine The babylon engine
  126104. * @param reusable If the post-process is reusable
  126105. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  126106. */
  126107. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  126108. /**
  126109. * Returns the string "VolumetricLightScatteringPostProcess"
  126110. * @returns "VolumetricLightScatteringPostProcess"
  126111. */
  126112. getClassName(): string;
  126113. private _isReady;
  126114. /**
  126115. * Sets the new light position for light scattering effect
  126116. * @param position The new custom light position
  126117. */
  126118. setCustomMeshPosition(position: Vector3): void;
  126119. /**
  126120. * Returns the light position for light scattering effect
  126121. * @return Vector3 The custom light position
  126122. */
  126123. getCustomMeshPosition(): Vector3;
  126124. /**
  126125. * Disposes the internal assets and detaches the post-process from the camera
  126126. */
  126127. dispose(camera: Camera): void;
  126128. /**
  126129. * Returns the render target texture used by the post-process
  126130. * @return the render target texture used by the post-process
  126131. */
  126132. getPass(): RenderTargetTexture;
  126133. private _meshExcluded;
  126134. private _createPass;
  126135. private _updateMeshScreenCoordinates;
  126136. /**
  126137. * Creates a default mesh for the Volumeric Light Scattering post-process
  126138. * @param name The mesh name
  126139. * @param scene The scene where to create the mesh
  126140. * @return the default mesh
  126141. */
  126142. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  126143. }
  126144. }
  126145. declare module BABYLON {
  126146. interface Scene {
  126147. /** @hidden (Backing field) */
  126148. _boundingBoxRenderer: BoundingBoxRenderer;
  126149. /** @hidden (Backing field) */
  126150. _forceShowBoundingBoxes: boolean;
  126151. /**
  126152. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  126153. */
  126154. forceShowBoundingBoxes: boolean;
  126155. /**
  126156. * Gets the bounding box renderer associated with the scene
  126157. * @returns a BoundingBoxRenderer
  126158. */
  126159. getBoundingBoxRenderer(): BoundingBoxRenderer;
  126160. }
  126161. interface AbstractMesh {
  126162. /** @hidden (Backing field) */
  126163. _showBoundingBox: boolean;
  126164. /**
  126165. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  126166. */
  126167. showBoundingBox: boolean;
  126168. }
  126169. /**
  126170. * Component responsible of rendering the bounding box of the meshes in a scene.
  126171. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  126172. */
  126173. export class BoundingBoxRenderer implements ISceneComponent {
  126174. /**
  126175. * The component name helpfull to identify the component in the list of scene components.
  126176. */
  126177. readonly name: string;
  126178. /**
  126179. * The scene the component belongs to.
  126180. */
  126181. scene: Scene;
  126182. /**
  126183. * Color of the bounding box lines placed in front of an object
  126184. */
  126185. frontColor: Color3;
  126186. /**
  126187. * Color of the bounding box lines placed behind an object
  126188. */
  126189. backColor: Color3;
  126190. /**
  126191. * Defines if the renderer should show the back lines or not
  126192. */
  126193. showBackLines: boolean;
  126194. /**
  126195. * @hidden
  126196. */
  126197. renderList: SmartArray<BoundingBox>;
  126198. private _colorShader;
  126199. private _vertexBuffers;
  126200. private _indexBuffer;
  126201. private _fillIndexBuffer;
  126202. private _fillIndexData;
  126203. /**
  126204. * Instantiates a new bounding box renderer in a scene.
  126205. * @param scene the scene the renderer renders in
  126206. */
  126207. constructor(scene: Scene);
  126208. /**
  126209. * Registers the component in a given scene
  126210. */
  126211. register(): void;
  126212. private _evaluateSubMesh;
  126213. private _activeMesh;
  126214. private _prepareRessources;
  126215. private _createIndexBuffer;
  126216. /**
  126217. * Rebuilds the elements related to this component in case of
  126218. * context lost for instance.
  126219. */
  126220. rebuild(): void;
  126221. /**
  126222. * @hidden
  126223. */
  126224. reset(): void;
  126225. /**
  126226. * Render the bounding boxes of a specific rendering group
  126227. * @param renderingGroupId defines the rendering group to render
  126228. */
  126229. render(renderingGroupId: number): void;
  126230. /**
  126231. * In case of occlusion queries, we can render the occlusion bounding box through this method
  126232. * @param mesh Define the mesh to render the occlusion bounding box for
  126233. */
  126234. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  126235. /**
  126236. * Dispose and release the resources attached to this renderer.
  126237. */
  126238. dispose(): void;
  126239. }
  126240. }
  126241. declare module BABYLON {
  126242. /** @hidden */
  126243. export var depthPixelShader: {
  126244. name: string;
  126245. shader: string;
  126246. };
  126247. }
  126248. declare module BABYLON {
  126249. /**
  126250. * This represents a depth renderer in Babylon.
  126251. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  126252. */
  126253. export class DepthRenderer {
  126254. private _scene;
  126255. private _depthMap;
  126256. private _effect;
  126257. private readonly _storeNonLinearDepth;
  126258. private readonly _clearColor;
  126259. /** Get if the depth renderer is using packed depth or not */
  126260. readonly isPacked: boolean;
  126261. private _cachedDefines;
  126262. private _camera;
  126263. /**
  126264. * Specifiess that the depth renderer will only be used within
  126265. * the camera it is created for.
  126266. * This can help forcing its rendering during the camera processing.
  126267. */
  126268. useOnlyInActiveCamera: boolean;
  126269. /** @hidden */
  126270. static _SceneComponentInitialization: (scene: Scene) => void;
  126271. /**
  126272. * Instantiates a depth renderer
  126273. * @param scene The scene the renderer belongs to
  126274. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  126275. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  126276. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  126277. */
  126278. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  126279. /**
  126280. * Creates the depth rendering effect and checks if the effect is ready.
  126281. * @param subMesh The submesh to be used to render the depth map of
  126282. * @param useInstances If multiple world instances should be used
  126283. * @returns if the depth renderer is ready to render the depth map
  126284. */
  126285. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126286. /**
  126287. * Gets the texture which the depth map will be written to.
  126288. * @returns The depth map texture
  126289. */
  126290. getDepthMap(): RenderTargetTexture;
  126291. /**
  126292. * Disposes of the depth renderer.
  126293. */
  126294. dispose(): void;
  126295. }
  126296. }
  126297. declare module BABYLON {
  126298. interface Scene {
  126299. /** @hidden (Backing field) */
  126300. _depthRenderer: {
  126301. [id: string]: DepthRenderer;
  126302. };
  126303. /**
  126304. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  126305. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  126306. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  126307. * @returns the created depth renderer
  126308. */
  126309. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  126310. /**
  126311. * Disables a depth renderer for a given camera
  126312. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  126313. */
  126314. disableDepthRenderer(camera?: Nullable<Camera>): void;
  126315. }
  126316. /**
  126317. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  126318. * in several rendering techniques.
  126319. */
  126320. export class DepthRendererSceneComponent implements ISceneComponent {
  126321. /**
  126322. * The component name helpfull to identify the component in the list of scene components.
  126323. */
  126324. readonly name: string;
  126325. /**
  126326. * The scene the component belongs to.
  126327. */
  126328. scene: Scene;
  126329. /**
  126330. * Creates a new instance of the component for the given scene
  126331. * @param scene Defines the scene to register the component in
  126332. */
  126333. constructor(scene: Scene);
  126334. /**
  126335. * Registers the component in a given scene
  126336. */
  126337. register(): void;
  126338. /**
  126339. * Rebuilds the elements related to this component in case of
  126340. * context lost for instance.
  126341. */
  126342. rebuild(): void;
  126343. /**
  126344. * Disposes the component and the associated ressources
  126345. */
  126346. dispose(): void;
  126347. private _gatherRenderTargets;
  126348. private _gatherActiveCameraRenderTargets;
  126349. }
  126350. }
  126351. declare module BABYLON {
  126352. /** @hidden */
  126353. export var outlinePixelShader: {
  126354. name: string;
  126355. shader: string;
  126356. };
  126357. }
  126358. declare module BABYLON {
  126359. /** @hidden */
  126360. export var outlineVertexShader: {
  126361. name: string;
  126362. shader: string;
  126363. };
  126364. }
  126365. declare module BABYLON {
  126366. interface Scene {
  126367. /** @hidden */
  126368. _outlineRenderer: OutlineRenderer;
  126369. /**
  126370. * Gets the outline renderer associated with the scene
  126371. * @returns a OutlineRenderer
  126372. */
  126373. getOutlineRenderer(): OutlineRenderer;
  126374. }
  126375. interface AbstractMesh {
  126376. /** @hidden (Backing field) */
  126377. _renderOutline: boolean;
  126378. /**
  126379. * Gets or sets a boolean indicating if the outline must be rendered as well
  126380. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  126381. */
  126382. renderOutline: boolean;
  126383. /** @hidden (Backing field) */
  126384. _renderOverlay: boolean;
  126385. /**
  126386. * Gets or sets a boolean indicating if the overlay must be rendered as well
  126387. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  126388. */
  126389. renderOverlay: boolean;
  126390. }
  126391. /**
  126392. * This class is responsible to draw bothe outline/overlay of meshes.
  126393. * It should not be used directly but through the available method on mesh.
  126394. */
  126395. export class OutlineRenderer implements ISceneComponent {
  126396. /**
  126397. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  126398. */
  126399. private static _StencilReference;
  126400. /**
  126401. * The name of the component. Each component must have a unique name.
  126402. */
  126403. name: string;
  126404. /**
  126405. * The scene the component belongs to.
  126406. */
  126407. scene: Scene;
  126408. /**
  126409. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  126410. */
  126411. zOffset: number;
  126412. private _engine;
  126413. private _effect;
  126414. private _cachedDefines;
  126415. private _savedDepthWrite;
  126416. /**
  126417. * Instantiates a new outline renderer. (There could be only one per scene).
  126418. * @param scene Defines the scene it belongs to
  126419. */
  126420. constructor(scene: Scene);
  126421. /**
  126422. * Register the component to one instance of a 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. * Renders the outline in the canvas.
  126436. * @param subMesh Defines the sumesh to render
  126437. * @param batch Defines the batch of meshes in case of instances
  126438. * @param useOverlay Defines if the rendering is for the overlay or the outline
  126439. */
  126440. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  126441. /**
  126442. * Returns whether or not the outline renderer is ready for a given submesh.
  126443. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  126444. * @param subMesh Defines the submesh to check readyness for
  126445. * @param useInstances Defines wheter wee are trying to render instances or not
  126446. * @returns true if ready otherwise false
  126447. */
  126448. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126449. private _beforeRenderingMesh;
  126450. private _afterRenderingMesh;
  126451. }
  126452. }
  126453. declare module BABYLON {
  126454. /**
  126455. * Class used to manage multiple sprites of different sizes on the same spritesheet
  126456. * @see http://doc.babylonjs.com/babylon101/sprites
  126457. */
  126458. export class SpritePackedManager extends SpriteManager {
  126459. /** defines the packed manager's name */
  126460. name: string;
  126461. /**
  126462. * Creates a new sprite manager from a packed sprite sheet
  126463. * @param name defines the manager's name
  126464. * @param imgUrl defines the sprite sheet url
  126465. * @param capacity defines the maximum allowed number of sprites
  126466. * @param scene defines the hosting scene
  126467. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  126468. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  126469. * @param samplingMode defines the smapling mode to use with spritesheet
  126470. * @param fromPacked set to true; do not alter
  126471. */
  126472. constructor(
  126473. /** defines the packed manager's name */
  126474. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  126475. }
  126476. }
  126477. declare module BABYLON {
  126478. /**
  126479. * Defines the list of states available for a task inside a AssetsManager
  126480. */
  126481. export enum AssetTaskState {
  126482. /**
  126483. * Initialization
  126484. */
  126485. INIT = 0,
  126486. /**
  126487. * Running
  126488. */
  126489. RUNNING = 1,
  126490. /**
  126491. * Done
  126492. */
  126493. DONE = 2,
  126494. /**
  126495. * Error
  126496. */
  126497. ERROR = 3
  126498. }
  126499. /**
  126500. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  126501. */
  126502. export abstract class AbstractAssetTask {
  126503. /**
  126504. * Task name
  126505. */ name: string;
  126506. /**
  126507. * Callback called when the task is successful
  126508. */
  126509. onSuccess: (task: any) => void;
  126510. /**
  126511. * Callback called when the task is not successful
  126512. */
  126513. onError: (task: any, message?: string, exception?: any) => void;
  126514. /**
  126515. * Creates a new AssetsManager
  126516. * @param name defines the name of the task
  126517. */
  126518. constructor(
  126519. /**
  126520. * Task name
  126521. */ name: string);
  126522. private _isCompleted;
  126523. private _taskState;
  126524. private _errorObject;
  126525. /**
  126526. * Get if the task is completed
  126527. */
  126528. readonly isCompleted: boolean;
  126529. /**
  126530. * Gets the current state of the task
  126531. */
  126532. readonly taskState: AssetTaskState;
  126533. /**
  126534. * Gets the current error object (if task is in error)
  126535. */
  126536. readonly errorObject: {
  126537. message?: string;
  126538. exception?: any;
  126539. };
  126540. /**
  126541. * Internal only
  126542. * @hidden
  126543. */
  126544. _setErrorObject(message?: string, exception?: any): void;
  126545. /**
  126546. * Execute the current task
  126547. * @param scene defines the scene where you want your assets to be loaded
  126548. * @param onSuccess is a callback called when the task is successfully executed
  126549. * @param onError is a callback called if an error occurs
  126550. */
  126551. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126552. /**
  126553. * Execute the current task
  126554. * @param scene defines the scene where you want your assets to be loaded
  126555. * @param onSuccess is a callback called when the task is successfully executed
  126556. * @param onError is a callback called if an error occurs
  126557. */
  126558. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126559. /**
  126560. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  126561. * This can be used with failed tasks that have the reason for failure fixed.
  126562. */
  126563. reset(): void;
  126564. private onErrorCallback;
  126565. private onDoneCallback;
  126566. }
  126567. /**
  126568. * Define the interface used by progress events raised during assets loading
  126569. */
  126570. export interface IAssetsProgressEvent {
  126571. /**
  126572. * Defines the number of remaining tasks to process
  126573. */
  126574. remainingCount: number;
  126575. /**
  126576. * Defines the total number of tasks
  126577. */
  126578. totalCount: number;
  126579. /**
  126580. * Defines the task that was just processed
  126581. */
  126582. task: AbstractAssetTask;
  126583. }
  126584. /**
  126585. * Class used to share progress information about assets loading
  126586. */
  126587. export class AssetsProgressEvent implements IAssetsProgressEvent {
  126588. /**
  126589. * Defines the number of remaining tasks to process
  126590. */
  126591. remainingCount: number;
  126592. /**
  126593. * Defines the total number of tasks
  126594. */
  126595. totalCount: number;
  126596. /**
  126597. * Defines the task that was just processed
  126598. */
  126599. task: AbstractAssetTask;
  126600. /**
  126601. * Creates a AssetsProgressEvent
  126602. * @param remainingCount defines the number of remaining tasks to process
  126603. * @param totalCount defines the total number of tasks
  126604. * @param task defines the task that was just processed
  126605. */
  126606. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  126607. }
  126608. /**
  126609. * Define a task used by AssetsManager to load meshes
  126610. */
  126611. export class MeshAssetTask extends AbstractAssetTask {
  126612. /**
  126613. * Defines the name of the task
  126614. */
  126615. name: string;
  126616. /**
  126617. * Defines the list of mesh's names you want to load
  126618. */
  126619. meshesNames: any;
  126620. /**
  126621. * Defines the root url to use as a base to load your meshes and associated resources
  126622. */
  126623. rootUrl: string;
  126624. /**
  126625. * Defines the filename of the scene to load from
  126626. */
  126627. sceneFilename: string;
  126628. /**
  126629. * Gets the list of loaded meshes
  126630. */
  126631. loadedMeshes: Array<AbstractMesh>;
  126632. /**
  126633. * Gets the list of loaded particle systems
  126634. */
  126635. loadedParticleSystems: Array<IParticleSystem>;
  126636. /**
  126637. * Gets the list of loaded skeletons
  126638. */
  126639. loadedSkeletons: Array<Skeleton>;
  126640. /**
  126641. * Gets the list of loaded animation groups
  126642. */
  126643. loadedAnimationGroups: Array<AnimationGroup>;
  126644. /**
  126645. * Callback called when the task is successful
  126646. */
  126647. onSuccess: (task: MeshAssetTask) => void;
  126648. /**
  126649. * Callback called when the task is successful
  126650. */
  126651. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  126652. /**
  126653. * Creates a new MeshAssetTask
  126654. * @param name defines the name of the task
  126655. * @param meshesNames defines the list of mesh's names you want to load
  126656. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  126657. * @param sceneFilename defines the filename of the scene to load from
  126658. */
  126659. constructor(
  126660. /**
  126661. * Defines the name of the task
  126662. */
  126663. name: string,
  126664. /**
  126665. * Defines the list of mesh's names you want to load
  126666. */
  126667. meshesNames: any,
  126668. /**
  126669. * Defines the root url to use as a base to load your meshes and associated resources
  126670. */
  126671. rootUrl: string,
  126672. /**
  126673. * Defines the filename of the scene to load from
  126674. */
  126675. sceneFilename: string);
  126676. /**
  126677. * Execute the current task
  126678. * @param scene defines the scene where you want your assets to be loaded
  126679. * @param onSuccess is a callback called when the task is successfully executed
  126680. * @param onError is a callback called if an error occurs
  126681. */
  126682. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126683. }
  126684. /**
  126685. * Define a task used by AssetsManager to load text content
  126686. */
  126687. export class TextFileAssetTask extends AbstractAssetTask {
  126688. /**
  126689. * Defines the name of the task
  126690. */
  126691. name: string;
  126692. /**
  126693. * Defines the location of the file to load
  126694. */
  126695. url: string;
  126696. /**
  126697. * Gets the loaded text string
  126698. */
  126699. text: string;
  126700. /**
  126701. * Callback called when the task is successful
  126702. */
  126703. onSuccess: (task: TextFileAssetTask) => void;
  126704. /**
  126705. * Callback called when the task is successful
  126706. */
  126707. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  126708. /**
  126709. * Creates a new TextFileAssetTask object
  126710. * @param name defines the name of the task
  126711. * @param url defines the location of the file to load
  126712. */
  126713. constructor(
  126714. /**
  126715. * Defines the name of the task
  126716. */
  126717. name: string,
  126718. /**
  126719. * Defines the location of the file to load
  126720. */
  126721. url: string);
  126722. /**
  126723. * Execute the current task
  126724. * @param scene defines the scene where you want your assets to be loaded
  126725. * @param onSuccess is a callback called when the task is successfully executed
  126726. * @param onError is a callback called if an error occurs
  126727. */
  126728. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126729. }
  126730. /**
  126731. * Define a task used by AssetsManager to load binary data
  126732. */
  126733. export class BinaryFileAssetTask extends AbstractAssetTask {
  126734. /**
  126735. * Defines the name of the task
  126736. */
  126737. name: string;
  126738. /**
  126739. * Defines the location of the file to load
  126740. */
  126741. url: string;
  126742. /**
  126743. * Gets the lodaded data (as an array buffer)
  126744. */
  126745. data: ArrayBuffer;
  126746. /**
  126747. * Callback called when the task is successful
  126748. */
  126749. onSuccess: (task: BinaryFileAssetTask) => void;
  126750. /**
  126751. * Callback called when the task is successful
  126752. */
  126753. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  126754. /**
  126755. * Creates a new BinaryFileAssetTask object
  126756. * @param name defines the name of the new task
  126757. * @param url defines the location of the file to load
  126758. */
  126759. constructor(
  126760. /**
  126761. * Defines the name of the task
  126762. */
  126763. name: string,
  126764. /**
  126765. * Defines the location of the file to load
  126766. */
  126767. url: string);
  126768. /**
  126769. * Execute the current task
  126770. * @param scene defines the scene where you want your assets to be loaded
  126771. * @param onSuccess is a callback called when the task is successfully executed
  126772. * @param onError is a callback called if an error occurs
  126773. */
  126774. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126775. }
  126776. /**
  126777. * Define a task used by AssetsManager to load images
  126778. */
  126779. export class ImageAssetTask extends AbstractAssetTask {
  126780. /**
  126781. * Defines the name of the task
  126782. */
  126783. name: string;
  126784. /**
  126785. * Defines the location of the image to load
  126786. */
  126787. url: string;
  126788. /**
  126789. * Gets the loaded images
  126790. */
  126791. image: HTMLImageElement;
  126792. /**
  126793. * Callback called when the task is successful
  126794. */
  126795. onSuccess: (task: ImageAssetTask) => void;
  126796. /**
  126797. * Callback called when the task is successful
  126798. */
  126799. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  126800. /**
  126801. * Creates a new ImageAssetTask
  126802. * @param name defines the name of the task
  126803. * @param url defines the location of the image to load
  126804. */
  126805. constructor(
  126806. /**
  126807. * Defines the name of the task
  126808. */
  126809. name: string,
  126810. /**
  126811. * Defines the location of the image to load
  126812. */
  126813. url: string);
  126814. /**
  126815. * Execute the current task
  126816. * @param scene defines the scene where you want your assets to be loaded
  126817. * @param onSuccess is a callback called when the task is successfully executed
  126818. * @param onError is a callback called if an error occurs
  126819. */
  126820. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126821. }
  126822. /**
  126823. * Defines the interface used by texture loading tasks
  126824. */
  126825. export interface ITextureAssetTask<TEX extends BaseTexture> {
  126826. /**
  126827. * Gets the loaded texture
  126828. */
  126829. texture: TEX;
  126830. }
  126831. /**
  126832. * Define a task used by AssetsManager to load 2D textures
  126833. */
  126834. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  126835. /**
  126836. * Defines the name of the task
  126837. */
  126838. name: string;
  126839. /**
  126840. * Defines the location of the file to load
  126841. */
  126842. url: string;
  126843. /**
  126844. * Defines if mipmap should not be generated (default is false)
  126845. */
  126846. noMipmap?: boolean | undefined;
  126847. /**
  126848. * Defines if texture must be inverted on Y axis (default is false)
  126849. */
  126850. invertY?: boolean | undefined;
  126851. /**
  126852. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  126853. */
  126854. samplingMode: number;
  126855. /**
  126856. * Gets the loaded texture
  126857. */
  126858. texture: Texture;
  126859. /**
  126860. * Callback called when the task is successful
  126861. */
  126862. onSuccess: (task: TextureAssetTask) => void;
  126863. /**
  126864. * Callback called when the task is successful
  126865. */
  126866. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  126867. /**
  126868. * Creates a new TextureAssetTask object
  126869. * @param name defines the name of the task
  126870. * @param url defines the location of the file to load
  126871. * @param noMipmap defines if mipmap should not be generated (default is false)
  126872. * @param invertY defines if texture must be inverted on Y axis (default is false)
  126873. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  126874. */
  126875. constructor(
  126876. /**
  126877. * Defines the name of the task
  126878. */
  126879. name: string,
  126880. /**
  126881. * Defines the location of the file to load
  126882. */
  126883. url: string,
  126884. /**
  126885. * Defines if mipmap should not be generated (default is false)
  126886. */
  126887. noMipmap?: boolean | undefined,
  126888. /**
  126889. * Defines if texture must be inverted on Y axis (default is false)
  126890. */
  126891. invertY?: boolean | undefined,
  126892. /**
  126893. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  126894. */
  126895. samplingMode?: number);
  126896. /**
  126897. * Execute the current task
  126898. * @param scene defines the scene where you want your assets to be loaded
  126899. * @param onSuccess is a callback called when the task is successfully executed
  126900. * @param onError is a callback called if an error occurs
  126901. */
  126902. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126903. }
  126904. /**
  126905. * Define a task used by AssetsManager to load cube textures
  126906. */
  126907. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  126908. /**
  126909. * Defines the name of the task
  126910. */
  126911. name: string;
  126912. /**
  126913. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  126914. */
  126915. url: string;
  126916. /**
  126917. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  126918. */
  126919. extensions?: string[] | undefined;
  126920. /**
  126921. * Defines if mipmaps should not be generated (default is false)
  126922. */
  126923. noMipmap?: boolean | undefined;
  126924. /**
  126925. * Defines the explicit list of files (undefined by default)
  126926. */
  126927. files?: string[] | undefined;
  126928. /**
  126929. * Gets the loaded texture
  126930. */
  126931. texture: CubeTexture;
  126932. /**
  126933. * Callback called when the task is successful
  126934. */
  126935. onSuccess: (task: CubeTextureAssetTask) => void;
  126936. /**
  126937. * Callback called when the task is successful
  126938. */
  126939. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  126940. /**
  126941. * Creates a new CubeTextureAssetTask
  126942. * @param name defines the name of the task
  126943. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  126944. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  126945. * @param noMipmap defines if mipmaps should not be generated (default is false)
  126946. * @param files defines the explicit list of files (undefined by default)
  126947. */
  126948. constructor(
  126949. /**
  126950. * Defines the name of the task
  126951. */
  126952. name: string,
  126953. /**
  126954. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  126955. */
  126956. url: string,
  126957. /**
  126958. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  126959. */
  126960. extensions?: string[] | undefined,
  126961. /**
  126962. * Defines if mipmaps should not be generated (default is false)
  126963. */
  126964. noMipmap?: boolean | undefined,
  126965. /**
  126966. * Defines the explicit list of files (undefined by default)
  126967. */
  126968. files?: string[] | undefined);
  126969. /**
  126970. * Execute the current task
  126971. * @param scene defines the scene where you want your assets to be loaded
  126972. * @param onSuccess is a callback called when the task is successfully executed
  126973. * @param onError is a callback called if an error occurs
  126974. */
  126975. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126976. }
  126977. /**
  126978. * Define a task used by AssetsManager to load HDR cube textures
  126979. */
  126980. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  126981. /**
  126982. * Defines the name of the task
  126983. */
  126984. name: string;
  126985. /**
  126986. * Defines the location of the file to load
  126987. */
  126988. url: string;
  126989. /**
  126990. * Defines the desired size (the more it increases the longer the generation will be)
  126991. */
  126992. size: number;
  126993. /**
  126994. * Defines if mipmaps should not be generated (default is false)
  126995. */
  126996. noMipmap: boolean;
  126997. /**
  126998. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  126999. */
  127000. generateHarmonics: boolean;
  127001. /**
  127002. * 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)
  127003. */
  127004. gammaSpace: boolean;
  127005. /**
  127006. * Internal Use Only
  127007. */
  127008. reserved: boolean;
  127009. /**
  127010. * Gets the loaded texture
  127011. */
  127012. texture: HDRCubeTexture;
  127013. /**
  127014. * Callback called when the task is successful
  127015. */
  127016. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  127017. /**
  127018. * Callback called when the task is successful
  127019. */
  127020. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  127021. /**
  127022. * Creates a new HDRCubeTextureAssetTask object
  127023. * @param name defines the name of the task
  127024. * @param url defines the location of the file to load
  127025. * @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.
  127026. * @param noMipmap defines if mipmaps should not be generated (default is false)
  127027. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  127028. * @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)
  127029. * @param reserved Internal use only
  127030. */
  127031. constructor(
  127032. /**
  127033. * Defines the name of the task
  127034. */
  127035. name: string,
  127036. /**
  127037. * Defines the location of the file to load
  127038. */
  127039. url: string,
  127040. /**
  127041. * Defines the desired size (the more it increases the longer the generation will be)
  127042. */
  127043. size: number,
  127044. /**
  127045. * Defines if mipmaps should not be generated (default is false)
  127046. */
  127047. noMipmap?: boolean,
  127048. /**
  127049. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  127050. */
  127051. generateHarmonics?: boolean,
  127052. /**
  127053. * 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)
  127054. */
  127055. gammaSpace?: boolean,
  127056. /**
  127057. * Internal Use Only
  127058. */
  127059. reserved?: boolean);
  127060. /**
  127061. * Execute the current task
  127062. * @param scene defines the scene where you want your assets to be loaded
  127063. * @param onSuccess is a callback called when the task is successfully executed
  127064. * @param onError is a callback called if an error occurs
  127065. */
  127066. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  127067. }
  127068. /**
  127069. * Define a task used by AssetsManager to load Equirectangular cube textures
  127070. */
  127071. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  127072. /**
  127073. * Defines the name of the task
  127074. */
  127075. name: string;
  127076. /**
  127077. * Defines the location of the file to load
  127078. */
  127079. url: string;
  127080. /**
  127081. * Defines the desired size (the more it increases the longer the generation will be)
  127082. */
  127083. size: number;
  127084. /**
  127085. * Defines if mipmaps should not be generated (default is false)
  127086. */
  127087. noMipmap: boolean;
  127088. /**
  127089. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  127090. * but the standard material would require them in Gamma space) (default is true)
  127091. */
  127092. gammaSpace: boolean;
  127093. /**
  127094. * Gets the loaded texture
  127095. */
  127096. texture: EquiRectangularCubeTexture;
  127097. /**
  127098. * Callback called when the task is successful
  127099. */
  127100. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  127101. /**
  127102. * Callback called when the task is successful
  127103. */
  127104. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  127105. /**
  127106. * Creates a new EquiRectangularCubeTextureAssetTask object
  127107. * @param name defines the name of the task
  127108. * @param url defines the location of the file to load
  127109. * @param size defines the desired size (the more it increases the longer the generation will be)
  127110. * If the size is omitted this implies you are using a preprocessed cubemap.
  127111. * @param noMipmap defines if mipmaps should not be generated (default is false)
  127112. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  127113. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  127114. * (default is true)
  127115. */
  127116. constructor(
  127117. /**
  127118. * Defines the name of the task
  127119. */
  127120. name: string,
  127121. /**
  127122. * Defines the location of the file to load
  127123. */
  127124. url: string,
  127125. /**
  127126. * Defines the desired size (the more it increases the longer the generation will be)
  127127. */
  127128. size: number,
  127129. /**
  127130. * Defines if mipmaps should not be generated (default is false)
  127131. */
  127132. noMipmap?: boolean,
  127133. /**
  127134. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  127135. * but the standard material would require them in Gamma space) (default is true)
  127136. */
  127137. gammaSpace?: boolean);
  127138. /**
  127139. * Execute the current task
  127140. * @param scene defines the scene where you want your assets to be loaded
  127141. * @param onSuccess is a callback called when the task is successfully executed
  127142. * @param onError is a callback called if an error occurs
  127143. */
  127144. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  127145. }
  127146. /**
  127147. * This class can be used to easily import assets into a scene
  127148. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  127149. */
  127150. export class AssetsManager {
  127151. private _scene;
  127152. private _isLoading;
  127153. protected _tasks: AbstractAssetTask[];
  127154. protected _waitingTasksCount: number;
  127155. protected _totalTasksCount: number;
  127156. /**
  127157. * Callback called when all tasks are processed
  127158. */
  127159. onFinish: (tasks: AbstractAssetTask[]) => void;
  127160. /**
  127161. * Callback called when a task is successful
  127162. */
  127163. onTaskSuccess: (task: AbstractAssetTask) => void;
  127164. /**
  127165. * Callback called when a task had an error
  127166. */
  127167. onTaskError: (task: AbstractAssetTask) => void;
  127168. /**
  127169. * Callback called when a task is done (whatever the result is)
  127170. */
  127171. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  127172. /**
  127173. * Observable called when all tasks are processed
  127174. */
  127175. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  127176. /**
  127177. * Observable called when a task had an error
  127178. */
  127179. onTaskErrorObservable: Observable<AbstractAssetTask>;
  127180. /**
  127181. * Observable called when all tasks were executed
  127182. */
  127183. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  127184. /**
  127185. * Observable called when a task is done (whatever the result is)
  127186. */
  127187. onProgressObservable: Observable<IAssetsProgressEvent>;
  127188. /**
  127189. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  127190. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  127191. */
  127192. useDefaultLoadingScreen: boolean;
  127193. /**
  127194. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  127195. * when all assets have been downloaded.
  127196. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  127197. */
  127198. autoHideLoadingUI: boolean;
  127199. /**
  127200. * Creates a new AssetsManager
  127201. * @param scene defines the scene to work on
  127202. */
  127203. constructor(scene: Scene);
  127204. /**
  127205. * Add a MeshAssetTask to the list of active tasks
  127206. * @param taskName defines the name of the new task
  127207. * @param meshesNames defines the name of meshes to load
  127208. * @param rootUrl defines the root url to use to locate files
  127209. * @param sceneFilename defines the filename of the scene file
  127210. * @returns a new MeshAssetTask object
  127211. */
  127212. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  127213. /**
  127214. * Add a TextFileAssetTask to the list of active tasks
  127215. * @param taskName defines the name of the new task
  127216. * @param url defines the url of the file to load
  127217. * @returns a new TextFileAssetTask object
  127218. */
  127219. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  127220. /**
  127221. * Add a BinaryFileAssetTask to the list of active tasks
  127222. * @param taskName defines the name of the new task
  127223. * @param url defines the url of the file to load
  127224. * @returns a new BinaryFileAssetTask object
  127225. */
  127226. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  127227. /**
  127228. * Add a ImageAssetTask to the list of active tasks
  127229. * @param taskName defines the name of the new task
  127230. * @param url defines the url of the file to load
  127231. * @returns a new ImageAssetTask object
  127232. */
  127233. addImageTask(taskName: string, url: string): ImageAssetTask;
  127234. /**
  127235. * Add a TextureAssetTask to the list of active tasks
  127236. * @param taskName defines the name of the new task
  127237. * @param url defines the url of the file to load
  127238. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  127239. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  127240. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  127241. * @returns a new TextureAssetTask object
  127242. */
  127243. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  127244. /**
  127245. * Add a CubeTextureAssetTask to the list of active tasks
  127246. * @param taskName defines the name of the new task
  127247. * @param url defines the url of the file to load
  127248. * @param extensions defines the extension to use to load the cube map (can be null)
  127249. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  127250. * @param files defines the list of files to load (can be null)
  127251. * @returns a new CubeTextureAssetTask object
  127252. */
  127253. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  127254. /**
  127255. *
  127256. * Add a HDRCubeTextureAssetTask to the list of active tasks
  127257. * @param taskName defines the name of the new task
  127258. * @param url defines the url of the file to load
  127259. * @param size defines the size you want for the cubemap (can be null)
  127260. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  127261. * @param generateHarmonics defines if you want to automatically generate (true by default)
  127262. * @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)
  127263. * @param reserved Internal use only
  127264. * @returns a new HDRCubeTextureAssetTask object
  127265. */
  127266. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  127267. /**
  127268. *
  127269. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  127270. * @param taskName defines the name of the new task
  127271. * @param url defines the url of the file to load
  127272. * @param size defines the size you want for the cubemap (can be null)
  127273. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  127274. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  127275. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  127276. * @returns a new EquiRectangularCubeTextureAssetTask object
  127277. */
  127278. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  127279. /**
  127280. * Remove a task from the assets manager.
  127281. * @param task the task to remove
  127282. */
  127283. removeTask(task: AbstractAssetTask): void;
  127284. private _decreaseWaitingTasksCount;
  127285. private _runTask;
  127286. /**
  127287. * Reset the AssetsManager and remove all tasks
  127288. * @return the current instance of the AssetsManager
  127289. */
  127290. reset(): AssetsManager;
  127291. /**
  127292. * Start the loading process
  127293. * @return the current instance of the AssetsManager
  127294. */
  127295. load(): AssetsManager;
  127296. /**
  127297. * Start the loading process as an async operation
  127298. * @return a promise returning the list of failed tasks
  127299. */
  127300. loadAsync(): Promise<void>;
  127301. }
  127302. }
  127303. declare module BABYLON {
  127304. /**
  127305. * Wrapper class for promise with external resolve and reject.
  127306. */
  127307. export class Deferred<T> {
  127308. /**
  127309. * The promise associated with this deferred object.
  127310. */
  127311. readonly promise: Promise<T>;
  127312. private _resolve;
  127313. private _reject;
  127314. /**
  127315. * The resolve method of the promise associated with this deferred object.
  127316. */
  127317. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  127318. /**
  127319. * The reject method of the promise associated with this deferred object.
  127320. */
  127321. readonly reject: (reason?: any) => void;
  127322. /**
  127323. * Constructor for this deferred object.
  127324. */
  127325. constructor();
  127326. }
  127327. }
  127328. declare module BABYLON {
  127329. /**
  127330. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  127331. */
  127332. export class MeshExploder {
  127333. private _centerMesh;
  127334. private _meshes;
  127335. private _meshesOrigins;
  127336. private _toCenterVectors;
  127337. private _scaledDirection;
  127338. private _newPosition;
  127339. private _centerPosition;
  127340. /**
  127341. * Explodes meshes from a center mesh.
  127342. * @param meshes The meshes to explode.
  127343. * @param centerMesh The mesh to be center of explosion.
  127344. */
  127345. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  127346. private _setCenterMesh;
  127347. /**
  127348. * Get class name
  127349. * @returns "MeshExploder"
  127350. */
  127351. getClassName(): string;
  127352. /**
  127353. * "Exploded meshes"
  127354. * @returns Array of meshes with the centerMesh at index 0.
  127355. */
  127356. getMeshes(): Array<Mesh>;
  127357. /**
  127358. * Explodes meshes giving a specific direction
  127359. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  127360. */
  127361. explode(direction?: number): void;
  127362. }
  127363. }
  127364. declare module BABYLON {
  127365. /**
  127366. * Class used to help managing file picking and drag'n'drop
  127367. */
  127368. export class FilesInput {
  127369. /**
  127370. * List of files ready to be loaded
  127371. */
  127372. static readonly FilesToLoad: {
  127373. [key: string]: File;
  127374. };
  127375. /**
  127376. * Callback called when a file is processed
  127377. */
  127378. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  127379. private _engine;
  127380. private _currentScene;
  127381. private _sceneLoadedCallback;
  127382. private _progressCallback;
  127383. private _additionalRenderLoopLogicCallback;
  127384. private _textureLoadingCallback;
  127385. private _startingProcessingFilesCallback;
  127386. private _onReloadCallback;
  127387. private _errorCallback;
  127388. private _elementToMonitor;
  127389. private _sceneFileToLoad;
  127390. private _filesToLoad;
  127391. /**
  127392. * Creates a new FilesInput
  127393. * @param engine defines the rendering engine
  127394. * @param scene defines the hosting scene
  127395. * @param sceneLoadedCallback callback called when scene is loaded
  127396. * @param progressCallback callback called to track progress
  127397. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  127398. * @param textureLoadingCallback callback called when a texture is loading
  127399. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  127400. * @param onReloadCallback callback called when a reload is requested
  127401. * @param errorCallback callback call if an error occurs
  127402. */
  127403. 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);
  127404. private _dragEnterHandler;
  127405. private _dragOverHandler;
  127406. private _dropHandler;
  127407. /**
  127408. * Calls this function to listen to drag'n'drop events on a specific DOM element
  127409. * @param elementToMonitor defines the DOM element to track
  127410. */
  127411. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  127412. /**
  127413. * Release all associated resources
  127414. */
  127415. dispose(): void;
  127416. private renderFunction;
  127417. private drag;
  127418. private drop;
  127419. private _traverseFolder;
  127420. private _processFiles;
  127421. /**
  127422. * Load files from a drop event
  127423. * @param event defines the drop event to use as source
  127424. */
  127425. loadFiles(event: any): void;
  127426. private _processReload;
  127427. /**
  127428. * Reload the current scene from the loaded files
  127429. */
  127430. reload(): void;
  127431. }
  127432. }
  127433. declare module BABYLON {
  127434. /**
  127435. * Defines the root class used to create scene optimization to use with SceneOptimizer
  127436. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127437. */
  127438. export class SceneOptimization {
  127439. /**
  127440. * Defines the priority of this optimization (0 by default which means first in the list)
  127441. */
  127442. priority: number;
  127443. /**
  127444. * Gets a string describing the action executed by the current optimization
  127445. * @returns description string
  127446. */
  127447. getDescription(): string;
  127448. /**
  127449. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127450. * @param scene defines the current scene where to apply this optimization
  127451. * @param optimizer defines the current optimizer
  127452. * @returns true if everything that can be done was applied
  127453. */
  127454. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127455. /**
  127456. * Creates the SceneOptimization object
  127457. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  127458. * @param desc defines the description associated with the optimization
  127459. */
  127460. constructor(
  127461. /**
  127462. * Defines the priority of this optimization (0 by default which means first in the list)
  127463. */
  127464. priority?: number);
  127465. }
  127466. /**
  127467. * Defines an optimization used to reduce the size of render target textures
  127468. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127469. */
  127470. export class TextureOptimization extends SceneOptimization {
  127471. /**
  127472. * Defines the priority of this optimization (0 by default which means first in the list)
  127473. */
  127474. priority: number;
  127475. /**
  127476. * 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
  127477. */
  127478. maximumSize: number;
  127479. /**
  127480. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  127481. */
  127482. step: number;
  127483. /**
  127484. * Gets a string describing the action executed by the current optimization
  127485. * @returns description string
  127486. */
  127487. getDescription(): string;
  127488. /**
  127489. * Creates the TextureOptimization object
  127490. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  127491. * @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
  127492. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  127493. */
  127494. constructor(
  127495. /**
  127496. * Defines the priority of this optimization (0 by default which means first in the list)
  127497. */
  127498. priority?: number,
  127499. /**
  127500. * 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
  127501. */
  127502. maximumSize?: number,
  127503. /**
  127504. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  127505. */
  127506. step?: number);
  127507. /**
  127508. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127509. * @param scene defines the current scene where to apply this optimization
  127510. * @param optimizer defines the current optimizer
  127511. * @returns true if everything that can be done was applied
  127512. */
  127513. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127514. }
  127515. /**
  127516. * Defines an optimization used to increase or decrease the rendering resolution
  127517. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127518. */
  127519. export class HardwareScalingOptimization extends SceneOptimization {
  127520. /**
  127521. * Defines the priority of this optimization (0 by default which means first in the list)
  127522. */
  127523. priority: number;
  127524. /**
  127525. * Defines the maximum scale to use (2 by default)
  127526. */
  127527. maximumScale: number;
  127528. /**
  127529. * Defines the step to use between two passes (0.5 by default)
  127530. */
  127531. step: number;
  127532. private _currentScale;
  127533. private _directionOffset;
  127534. /**
  127535. * Gets a string describing the action executed by the current optimization
  127536. * @return description string
  127537. */
  127538. getDescription(): string;
  127539. /**
  127540. * Creates the HardwareScalingOptimization object
  127541. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  127542. * @param maximumScale defines the maximum scale to use (2 by default)
  127543. * @param step defines the step to use between two passes (0.5 by default)
  127544. */
  127545. constructor(
  127546. /**
  127547. * Defines the priority of this optimization (0 by default which means first in the list)
  127548. */
  127549. priority?: number,
  127550. /**
  127551. * Defines the maximum scale to use (2 by default)
  127552. */
  127553. maximumScale?: number,
  127554. /**
  127555. * Defines the step to use between two passes (0.5 by default)
  127556. */
  127557. step?: number);
  127558. /**
  127559. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127560. * @param scene defines the current scene where to apply this optimization
  127561. * @param optimizer defines the current optimizer
  127562. * @returns true if everything that can be done was applied
  127563. */
  127564. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127565. }
  127566. /**
  127567. * Defines an optimization used to remove shadows
  127568. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127569. */
  127570. export class ShadowsOptimization extends SceneOptimization {
  127571. /**
  127572. * Gets a string describing the action executed by the current optimization
  127573. * @return description string
  127574. */
  127575. getDescription(): string;
  127576. /**
  127577. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127578. * @param scene defines the current scene where to apply this optimization
  127579. * @param optimizer defines the current optimizer
  127580. * @returns true if everything that can be done was applied
  127581. */
  127582. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127583. }
  127584. /**
  127585. * Defines an optimization used to turn post-processes off
  127586. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127587. */
  127588. export class PostProcessesOptimization extends SceneOptimization {
  127589. /**
  127590. * Gets a string describing the action executed by the current optimization
  127591. * @return description string
  127592. */
  127593. getDescription(): string;
  127594. /**
  127595. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127596. * @param scene defines the current scene where to apply this optimization
  127597. * @param optimizer defines the current optimizer
  127598. * @returns true if everything that can be done was applied
  127599. */
  127600. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127601. }
  127602. /**
  127603. * Defines an optimization used to turn lens flares off
  127604. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127605. */
  127606. export class LensFlaresOptimization extends SceneOptimization {
  127607. /**
  127608. * Gets a string describing the action executed by the current optimization
  127609. * @return description string
  127610. */
  127611. getDescription(): string;
  127612. /**
  127613. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127614. * @param scene defines the current scene where to apply this optimization
  127615. * @param optimizer defines the current optimizer
  127616. * @returns true if everything that can be done was applied
  127617. */
  127618. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127619. }
  127620. /**
  127621. * Defines an optimization based on user defined callback.
  127622. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127623. */
  127624. export class CustomOptimization extends SceneOptimization {
  127625. /**
  127626. * Callback called to apply the custom optimization.
  127627. */
  127628. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  127629. /**
  127630. * Callback called to get custom description
  127631. */
  127632. onGetDescription: () => string;
  127633. /**
  127634. * Gets a string describing the action executed by the current optimization
  127635. * @returns description string
  127636. */
  127637. getDescription(): string;
  127638. /**
  127639. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127640. * @param scene defines the current scene where to apply this optimization
  127641. * @param optimizer defines the current optimizer
  127642. * @returns true if everything that can be done was applied
  127643. */
  127644. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127645. }
  127646. /**
  127647. * Defines an optimization used to turn particles off
  127648. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127649. */
  127650. export class ParticlesOptimization extends SceneOptimization {
  127651. /**
  127652. * Gets a string describing the action executed by the current optimization
  127653. * @return description string
  127654. */
  127655. getDescription(): string;
  127656. /**
  127657. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127658. * @param scene defines the current scene where to apply this optimization
  127659. * @param optimizer defines the current optimizer
  127660. * @returns true if everything that can be done was applied
  127661. */
  127662. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127663. }
  127664. /**
  127665. * Defines an optimization used to turn render targets off
  127666. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127667. */
  127668. export class RenderTargetsOptimization extends SceneOptimization {
  127669. /**
  127670. * Gets a string describing the action executed by the current optimization
  127671. * @return description string
  127672. */
  127673. getDescription(): string;
  127674. /**
  127675. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127676. * @param scene defines the current scene where to apply this optimization
  127677. * @param optimizer defines the current optimizer
  127678. * @returns true if everything that can be done was applied
  127679. */
  127680. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127681. }
  127682. /**
  127683. * Defines an optimization used to merge meshes with compatible materials
  127684. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127685. */
  127686. export class MergeMeshesOptimization extends SceneOptimization {
  127687. private static _UpdateSelectionTree;
  127688. /**
  127689. * Gets or sets a boolean which defines if optimization octree has to be updated
  127690. */
  127691. /**
  127692. * Gets or sets a boolean which defines if optimization octree has to be updated
  127693. */
  127694. static UpdateSelectionTree: boolean;
  127695. /**
  127696. * Gets a string describing the action executed by the current optimization
  127697. * @return description string
  127698. */
  127699. getDescription(): string;
  127700. private _canBeMerged;
  127701. /**
  127702. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127703. * @param scene defines the current scene where to apply this optimization
  127704. * @param optimizer defines the current optimizer
  127705. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  127706. * @returns true if everything that can be done was applied
  127707. */
  127708. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  127709. }
  127710. /**
  127711. * Defines a list of options used by SceneOptimizer
  127712. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127713. */
  127714. export class SceneOptimizerOptions {
  127715. /**
  127716. * Defines the target frame rate to reach (60 by default)
  127717. */
  127718. targetFrameRate: number;
  127719. /**
  127720. * Defines the interval between two checkes (2000ms by default)
  127721. */
  127722. trackerDuration: number;
  127723. /**
  127724. * Gets the list of optimizations to apply
  127725. */
  127726. optimizations: SceneOptimization[];
  127727. /**
  127728. * Creates a new list of options used by SceneOptimizer
  127729. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  127730. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  127731. */
  127732. constructor(
  127733. /**
  127734. * Defines the target frame rate to reach (60 by default)
  127735. */
  127736. targetFrameRate?: number,
  127737. /**
  127738. * Defines the interval between two checkes (2000ms by default)
  127739. */
  127740. trackerDuration?: number);
  127741. /**
  127742. * Add a new optimization
  127743. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  127744. * @returns the current SceneOptimizerOptions
  127745. */
  127746. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  127747. /**
  127748. * Add a new custom optimization
  127749. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  127750. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  127751. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  127752. * @returns the current SceneOptimizerOptions
  127753. */
  127754. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  127755. /**
  127756. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  127757. * @param targetFrameRate defines the target frame rate (60 by default)
  127758. * @returns a SceneOptimizerOptions object
  127759. */
  127760. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  127761. /**
  127762. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  127763. * @param targetFrameRate defines the target frame rate (60 by default)
  127764. * @returns a SceneOptimizerOptions object
  127765. */
  127766. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  127767. /**
  127768. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  127769. * @param targetFrameRate defines the target frame rate (60 by default)
  127770. * @returns a SceneOptimizerOptions object
  127771. */
  127772. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  127773. }
  127774. /**
  127775. * Class used to run optimizations in order to reach a target frame rate
  127776. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127777. */
  127778. export class SceneOptimizer implements IDisposable {
  127779. private _isRunning;
  127780. private _options;
  127781. private _scene;
  127782. private _currentPriorityLevel;
  127783. private _targetFrameRate;
  127784. private _trackerDuration;
  127785. private _currentFrameRate;
  127786. private _sceneDisposeObserver;
  127787. private _improvementMode;
  127788. /**
  127789. * Defines an observable called when the optimizer reaches the target frame rate
  127790. */
  127791. onSuccessObservable: Observable<SceneOptimizer>;
  127792. /**
  127793. * Defines an observable called when the optimizer enables an optimization
  127794. */
  127795. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  127796. /**
  127797. * Defines an observable called when the optimizer is not able to reach the target frame rate
  127798. */
  127799. onFailureObservable: Observable<SceneOptimizer>;
  127800. /**
  127801. * Gets a boolean indicating if the optimizer is in improvement mode
  127802. */
  127803. readonly isInImprovementMode: boolean;
  127804. /**
  127805. * Gets the current priority level (0 at start)
  127806. */
  127807. readonly currentPriorityLevel: number;
  127808. /**
  127809. * Gets the current frame rate checked by the SceneOptimizer
  127810. */
  127811. readonly currentFrameRate: number;
  127812. /**
  127813. * Gets or sets the current target frame rate (60 by default)
  127814. */
  127815. /**
  127816. * Gets or sets the current target frame rate (60 by default)
  127817. */
  127818. targetFrameRate: number;
  127819. /**
  127820. * Gets or sets the current interval between two checks (every 2000ms by default)
  127821. */
  127822. /**
  127823. * Gets or sets the current interval between two checks (every 2000ms by default)
  127824. */
  127825. trackerDuration: number;
  127826. /**
  127827. * Gets the list of active optimizations
  127828. */
  127829. readonly optimizations: SceneOptimization[];
  127830. /**
  127831. * Creates a new SceneOptimizer
  127832. * @param scene defines the scene to work on
  127833. * @param options defines the options to use with the SceneOptimizer
  127834. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  127835. * @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)
  127836. */
  127837. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  127838. /**
  127839. * Stops the current optimizer
  127840. */
  127841. stop(): void;
  127842. /**
  127843. * Reset the optimizer to initial step (current priority level = 0)
  127844. */
  127845. reset(): void;
  127846. /**
  127847. * Start the optimizer. By default it will try to reach a specific framerate
  127848. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  127849. */
  127850. start(): void;
  127851. private _checkCurrentState;
  127852. /**
  127853. * Release all resources
  127854. */
  127855. dispose(): void;
  127856. /**
  127857. * Helper function to create a SceneOptimizer with one single line of code
  127858. * @param scene defines the scene to work on
  127859. * @param options defines the options to use with the SceneOptimizer
  127860. * @param onSuccess defines a callback to call on success
  127861. * @param onFailure defines a callback to call on failure
  127862. * @returns the new SceneOptimizer object
  127863. */
  127864. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  127865. }
  127866. }
  127867. declare module BABYLON {
  127868. /**
  127869. * Class used to serialize a scene into a string
  127870. */
  127871. export class SceneSerializer {
  127872. /**
  127873. * Clear cache used by a previous serialization
  127874. */
  127875. static ClearCache(): void;
  127876. /**
  127877. * Serialize a scene into a JSON compatible object
  127878. * @param scene defines the scene to serialize
  127879. * @returns a JSON compatible object
  127880. */
  127881. static Serialize(scene: Scene): any;
  127882. /**
  127883. * Serialize a mesh into a JSON compatible object
  127884. * @param toSerialize defines the mesh to serialize
  127885. * @param withParents defines if parents must be serialized as well
  127886. * @param withChildren defines if children must be serialized as well
  127887. * @returns a JSON compatible object
  127888. */
  127889. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  127890. }
  127891. }
  127892. declare module BABYLON {
  127893. /**
  127894. * Class used to host texture specific utilities
  127895. */
  127896. export class TextureTools {
  127897. /**
  127898. * Uses the GPU to create a copy texture rescaled at a given size
  127899. * @param texture Texture to copy from
  127900. * @param width defines the desired width
  127901. * @param height defines the desired height
  127902. * @param useBilinearMode defines if bilinear mode has to be used
  127903. * @return the generated texture
  127904. */
  127905. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  127906. }
  127907. }
  127908. declare module BABYLON {
  127909. /**
  127910. * This represents the different options available for the video capture.
  127911. */
  127912. export interface VideoRecorderOptions {
  127913. /** Defines the mime type of the video. */
  127914. mimeType: string;
  127915. /** Defines the FPS the video should be recorded at. */
  127916. fps: number;
  127917. /** Defines the chunk size for the recording data. */
  127918. recordChunckSize: number;
  127919. /** The audio tracks to attach to the recording. */
  127920. audioTracks?: MediaStreamTrack[];
  127921. }
  127922. /**
  127923. * This can help with recording videos from BabylonJS.
  127924. * This is based on the available WebRTC functionalities of the browser.
  127925. *
  127926. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  127927. */
  127928. export class VideoRecorder {
  127929. private static readonly _defaultOptions;
  127930. /**
  127931. * Returns whether or not the VideoRecorder is available in your browser.
  127932. * @param engine Defines the Babylon Engine.
  127933. * @returns true if supported otherwise false.
  127934. */
  127935. static IsSupported(engine: Engine): boolean;
  127936. private readonly _options;
  127937. private _canvas;
  127938. private _mediaRecorder;
  127939. private _recordedChunks;
  127940. private _fileName;
  127941. private _resolve;
  127942. private _reject;
  127943. /**
  127944. * True when a recording is already in progress.
  127945. */
  127946. readonly isRecording: boolean;
  127947. /**
  127948. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  127949. * @param engine Defines the BabylonJS Engine you wish to record.
  127950. * @param options Defines options that can be used to customize the capture.
  127951. */
  127952. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  127953. /**
  127954. * Stops the current recording before the default capture timeout passed in the startRecording function.
  127955. */
  127956. stopRecording(): void;
  127957. /**
  127958. * Starts recording the canvas for a max duration specified in parameters.
  127959. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  127960. * If null no automatic download will start and you can rely on the promise to get the data back.
  127961. * @param maxDuration Defines the maximum recording time in seconds.
  127962. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  127963. * @return A promise callback at the end of the recording with the video data in Blob.
  127964. */
  127965. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  127966. /**
  127967. * Releases internal resources used during the recording.
  127968. */
  127969. dispose(): void;
  127970. private _handleDataAvailable;
  127971. private _handleError;
  127972. private _handleStop;
  127973. }
  127974. }
  127975. declare module BABYLON {
  127976. /**
  127977. * Class containing a set of static utilities functions for screenshots
  127978. */
  127979. export class ScreenshotTools {
  127980. /**
  127981. * Captures a screenshot of the current rendering
  127982. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  127983. * @param engine defines the rendering engine
  127984. * @param camera defines the source camera
  127985. * @param size This parameter can be set to a single number or to an object with the
  127986. * following (optional) properties: precision, width, height. If a single number is passed,
  127987. * it will be used for both width and height. If an object is passed, the screenshot size
  127988. * will be derived from the parameters. The precision property is a multiplier allowing
  127989. * rendering at a higher or lower resolution
  127990. * @param successCallback defines the callback receives a single parameter which contains the
  127991. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  127992. * src parameter of an <img> to display it
  127993. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  127994. * Check your browser for supported MIME types
  127995. */
  127996. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  127997. /**
  127998. * Captures a screenshot of the current rendering
  127999. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  128000. * @param engine defines the rendering engine
  128001. * @param camera defines the source camera
  128002. * @param size This parameter can be set to a single number or to an object with the
  128003. * following (optional) properties: precision, width, height. If a single number is passed,
  128004. * it will be used for both width and height. If an object is passed, the screenshot size
  128005. * will be derived from the parameters. The precision property is a multiplier allowing
  128006. * rendering at a higher or lower resolution
  128007. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  128008. * Check your browser for supported MIME types
  128009. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  128010. * to the src parameter of an <img> to display it
  128011. */
  128012. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  128013. /**
  128014. * Generates an image screenshot from the specified camera.
  128015. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  128016. * @param engine The engine to use for rendering
  128017. * @param camera The camera to use for rendering
  128018. * @param size This parameter can be set to a single number or to an object with the
  128019. * following (optional) properties: precision, width, height. If a single number is passed,
  128020. * it will be used for both width and height. If an object is passed, the screenshot size
  128021. * will be derived from the parameters. The precision property is a multiplier allowing
  128022. * rendering at a higher or lower resolution
  128023. * @param successCallback The callback receives a single parameter which contains the
  128024. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  128025. * src parameter of an <img> to display it
  128026. * @param mimeType The MIME type of the screenshot image (default: image/png).
  128027. * Check your browser for supported MIME types
  128028. * @param samples Texture samples (default: 1)
  128029. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  128030. * @param fileName A name for for the downloaded file.
  128031. */
  128032. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  128033. /**
  128034. * Generates an image screenshot from the specified camera.
  128035. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  128036. * @param engine The engine to use for rendering
  128037. * @param camera The camera to use for rendering
  128038. * @param size This parameter can be set to a single number or to an object with the
  128039. * following (optional) properties: precision, width, height. If a single number is passed,
  128040. * it will be used for both width and height. If an object is passed, the screenshot size
  128041. * will be derived from the parameters. The precision property is a multiplier allowing
  128042. * rendering at a higher or lower resolution
  128043. * @param mimeType The MIME type of the screenshot image (default: image/png).
  128044. * Check your browser for supported MIME types
  128045. * @param samples Texture samples (default: 1)
  128046. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  128047. * @param fileName A name for for the downloaded file.
  128048. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  128049. * to the src parameter of an <img> to display it
  128050. */
  128051. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  128052. /**
  128053. * Gets height and width for screenshot size
  128054. * @private
  128055. */
  128056. private static _getScreenshotSize;
  128057. }
  128058. }
  128059. declare module BABYLON {
  128060. /**
  128061. * A cursor which tracks a point on a path
  128062. */
  128063. export class PathCursor {
  128064. private path;
  128065. /**
  128066. * Stores path cursor callbacks for when an onchange event is triggered
  128067. */
  128068. private _onchange;
  128069. /**
  128070. * The value of the path cursor
  128071. */
  128072. value: number;
  128073. /**
  128074. * The animation array of the path cursor
  128075. */
  128076. animations: Animation[];
  128077. /**
  128078. * Initializes the path cursor
  128079. * @param path The path to track
  128080. */
  128081. constructor(path: Path2);
  128082. /**
  128083. * Gets the cursor point on the path
  128084. * @returns A point on the path cursor at the cursor location
  128085. */
  128086. getPoint(): Vector3;
  128087. /**
  128088. * Moves the cursor ahead by the step amount
  128089. * @param step The amount to move the cursor forward
  128090. * @returns This path cursor
  128091. */
  128092. moveAhead(step?: number): PathCursor;
  128093. /**
  128094. * Moves the cursor behind by the step amount
  128095. * @param step The amount to move the cursor back
  128096. * @returns This path cursor
  128097. */
  128098. moveBack(step?: number): PathCursor;
  128099. /**
  128100. * Moves the cursor by the step amount
  128101. * If the step amount is greater than one, an exception is thrown
  128102. * @param step The amount to move the cursor
  128103. * @returns This path cursor
  128104. */
  128105. move(step: number): PathCursor;
  128106. /**
  128107. * Ensures that the value is limited between zero and one
  128108. * @returns This path cursor
  128109. */
  128110. private ensureLimits;
  128111. /**
  128112. * Runs onchange callbacks on change (used by the animation engine)
  128113. * @returns This path cursor
  128114. */
  128115. private raiseOnChange;
  128116. /**
  128117. * Executes a function on change
  128118. * @param f A path cursor onchange callback
  128119. * @returns This path cursor
  128120. */
  128121. onchange(f: (cursor: PathCursor) => void): PathCursor;
  128122. }
  128123. }
  128124. declare module BABYLON {
  128125. /** @hidden */
  128126. export var blurPixelShader: {
  128127. name: string;
  128128. shader: string;
  128129. };
  128130. }
  128131. declare module BABYLON {
  128132. /** @hidden */
  128133. export var pointCloudVertexDeclaration: {
  128134. name: string;
  128135. shader: string;
  128136. };
  128137. }
  128138. // Mixins
  128139. interface Window {
  128140. mozIndexedDB: IDBFactory;
  128141. webkitIndexedDB: IDBFactory;
  128142. msIndexedDB: IDBFactory;
  128143. webkitURL: typeof URL;
  128144. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  128145. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  128146. WebGLRenderingContext: WebGLRenderingContext;
  128147. MSGesture: MSGesture;
  128148. CANNON: any;
  128149. AudioContext: AudioContext;
  128150. webkitAudioContext: AudioContext;
  128151. PointerEvent: any;
  128152. Math: Math;
  128153. Uint8Array: Uint8ArrayConstructor;
  128154. Float32Array: Float32ArrayConstructor;
  128155. mozURL: typeof URL;
  128156. msURL: typeof URL;
  128157. VRFrameData: any; // WebVR, from specs 1.1
  128158. DracoDecoderModule: any;
  128159. setImmediate(handler: (...args: any[]) => void): number;
  128160. }
  128161. interface HTMLCanvasElement {
  128162. requestPointerLock(): void;
  128163. msRequestPointerLock?(): void;
  128164. mozRequestPointerLock?(): void;
  128165. webkitRequestPointerLock?(): void;
  128166. /** Track wether a record is in progress */
  128167. isRecording: boolean;
  128168. /** Capture Stream method defined by some browsers */
  128169. captureStream(fps?: number): MediaStream;
  128170. }
  128171. interface CanvasRenderingContext2D {
  128172. msImageSmoothingEnabled: boolean;
  128173. }
  128174. interface MouseEvent {
  128175. mozMovementX: number;
  128176. mozMovementY: number;
  128177. webkitMovementX: number;
  128178. webkitMovementY: number;
  128179. msMovementX: number;
  128180. msMovementY: number;
  128181. }
  128182. interface Navigator {
  128183. mozGetVRDevices: (any: any) => any;
  128184. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  128185. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  128186. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  128187. webkitGetGamepads(): Gamepad[];
  128188. msGetGamepads(): Gamepad[];
  128189. webkitGamepads(): Gamepad[];
  128190. }
  128191. interface HTMLVideoElement {
  128192. mozSrcObject: any;
  128193. }
  128194. interface Math {
  128195. fround(x: number): number;
  128196. imul(a: number, b: number): number;
  128197. }
  128198. interface WebGLRenderingContext {
  128199. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  128200. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  128201. vertexAttribDivisor(index: number, divisor: number): void;
  128202. createVertexArray(): any;
  128203. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  128204. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  128205. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  128206. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  128207. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  128208. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  128209. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  128210. // Queries
  128211. createQuery(): WebGLQuery;
  128212. deleteQuery(query: WebGLQuery): void;
  128213. beginQuery(target: number, query: WebGLQuery): void;
  128214. endQuery(target: number): void;
  128215. getQueryParameter(query: WebGLQuery, pname: number): any;
  128216. getQuery(target: number, pname: number): any;
  128217. MAX_SAMPLES: number;
  128218. RGBA8: number;
  128219. READ_FRAMEBUFFER: number;
  128220. DRAW_FRAMEBUFFER: number;
  128221. UNIFORM_BUFFER: number;
  128222. HALF_FLOAT_OES: number;
  128223. RGBA16F: number;
  128224. RGBA32F: number;
  128225. R32F: number;
  128226. RG32F: number;
  128227. RGB32F: number;
  128228. R16F: number;
  128229. RG16F: number;
  128230. RGB16F: number;
  128231. RED: number;
  128232. RG: number;
  128233. R8: number;
  128234. RG8: number;
  128235. UNSIGNED_INT_24_8: number;
  128236. DEPTH24_STENCIL8: number;
  128237. /* Multiple Render Targets */
  128238. drawBuffers(buffers: number[]): void;
  128239. readBuffer(src: number): void;
  128240. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  128241. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  128242. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  128243. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  128244. // Occlusion Query
  128245. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  128246. ANY_SAMPLES_PASSED: number;
  128247. QUERY_RESULT_AVAILABLE: number;
  128248. QUERY_RESULT: number;
  128249. }
  128250. interface WebGLProgram {
  128251. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  128252. }
  128253. interface EXT_disjoint_timer_query {
  128254. QUERY_COUNTER_BITS_EXT: number;
  128255. TIME_ELAPSED_EXT: number;
  128256. TIMESTAMP_EXT: number;
  128257. GPU_DISJOINT_EXT: number;
  128258. QUERY_RESULT_EXT: number;
  128259. QUERY_RESULT_AVAILABLE_EXT: number;
  128260. queryCounterEXT(query: WebGLQuery, target: number): void;
  128261. createQueryEXT(): WebGLQuery;
  128262. beginQueryEXT(target: number, query: WebGLQuery): void;
  128263. endQueryEXT(target: number): void;
  128264. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  128265. deleteQueryEXT(query: WebGLQuery): void;
  128266. }
  128267. interface WebGLUniformLocation {
  128268. _currentState: any;
  128269. }
  128270. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  128271. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  128272. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  128273. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  128274. interface WebGLRenderingContext {
  128275. readonly RASTERIZER_DISCARD: number;
  128276. readonly DEPTH_COMPONENT24: number;
  128277. readonly TEXTURE_3D: number;
  128278. readonly TEXTURE_2D_ARRAY: number;
  128279. readonly TEXTURE_COMPARE_FUNC: number;
  128280. readonly TEXTURE_COMPARE_MODE: number;
  128281. readonly COMPARE_REF_TO_TEXTURE: number;
  128282. readonly TEXTURE_WRAP_R: number;
  128283. readonly HALF_FLOAT: number;
  128284. readonly RGB8: number;
  128285. readonly RED_INTEGER: number;
  128286. readonly RG_INTEGER: number;
  128287. readonly RGB_INTEGER: number;
  128288. readonly RGBA_INTEGER: number;
  128289. readonly R8_SNORM: number;
  128290. readonly RG8_SNORM: number;
  128291. readonly RGB8_SNORM: number;
  128292. readonly RGBA8_SNORM: number;
  128293. readonly R8I: number;
  128294. readonly RG8I: number;
  128295. readonly RGB8I: number;
  128296. readonly RGBA8I: number;
  128297. readonly R8UI: number;
  128298. readonly RG8UI: number;
  128299. readonly RGB8UI: number;
  128300. readonly RGBA8UI: number;
  128301. readonly R16I: number;
  128302. readonly RG16I: number;
  128303. readonly RGB16I: number;
  128304. readonly RGBA16I: number;
  128305. readonly R16UI: number;
  128306. readonly RG16UI: number;
  128307. readonly RGB16UI: number;
  128308. readonly RGBA16UI: number;
  128309. readonly R32I: number;
  128310. readonly RG32I: number;
  128311. readonly RGB32I: number;
  128312. readonly RGBA32I: number;
  128313. readonly R32UI: number;
  128314. readonly RG32UI: number;
  128315. readonly RGB32UI: number;
  128316. readonly RGBA32UI: number;
  128317. readonly RGB10_A2UI: number;
  128318. readonly R11F_G11F_B10F: number;
  128319. readonly RGB9_E5: number;
  128320. readonly RGB10_A2: number;
  128321. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  128322. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  128323. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  128324. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  128325. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  128326. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  128327. 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;
  128328. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  128329. readonly TRANSFORM_FEEDBACK: number;
  128330. readonly INTERLEAVED_ATTRIBS: number;
  128331. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  128332. createTransformFeedback(): WebGLTransformFeedback;
  128333. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  128334. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  128335. beginTransformFeedback(primitiveMode: number): void;
  128336. endTransformFeedback(): void;
  128337. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  128338. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  128339. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  128340. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  128341. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  128342. }
  128343. interface ImageBitmap {
  128344. readonly width: number;
  128345. readonly height: number;
  128346. close(): void;
  128347. }
  128348. interface WebGLQuery extends WebGLObject {
  128349. }
  128350. declare var WebGLQuery: {
  128351. prototype: WebGLQuery;
  128352. new(): WebGLQuery;
  128353. };
  128354. interface WebGLSampler extends WebGLObject {
  128355. }
  128356. declare var WebGLSampler: {
  128357. prototype: WebGLSampler;
  128358. new(): WebGLSampler;
  128359. };
  128360. interface WebGLSync extends WebGLObject {
  128361. }
  128362. declare var WebGLSync: {
  128363. prototype: WebGLSync;
  128364. new(): WebGLSync;
  128365. };
  128366. interface WebGLTransformFeedback extends WebGLObject {
  128367. }
  128368. declare var WebGLTransformFeedback: {
  128369. prototype: WebGLTransformFeedback;
  128370. new(): WebGLTransformFeedback;
  128371. };
  128372. interface WebGLVertexArrayObject extends WebGLObject {
  128373. }
  128374. declare var WebGLVertexArrayObject: {
  128375. prototype: WebGLVertexArrayObject;
  128376. new(): WebGLVertexArrayObject;
  128377. };
  128378. // Type definitions for WebVR API
  128379. // Project: https://w3c.github.io/webvr/
  128380. // Definitions by: six a <https://github.com/lostfictions>
  128381. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  128382. interface VRDisplay extends EventTarget {
  128383. /**
  128384. * Dictionary of capabilities describing the VRDisplay.
  128385. */
  128386. readonly capabilities: VRDisplayCapabilities;
  128387. /**
  128388. * z-depth defining the far plane of the eye view frustum
  128389. * enables mapping of values in the render target depth
  128390. * attachment to scene coordinates. Initially set to 10000.0.
  128391. */
  128392. depthFar: number;
  128393. /**
  128394. * z-depth defining the near plane of the eye view frustum
  128395. * enables mapping of values in the render target depth
  128396. * attachment to scene coordinates. Initially set to 0.01.
  128397. */
  128398. depthNear: number;
  128399. /**
  128400. * An identifier for this distinct VRDisplay. Used as an
  128401. * association point in the Gamepad API.
  128402. */
  128403. readonly displayId: number;
  128404. /**
  128405. * A display name, a user-readable name identifying it.
  128406. */
  128407. readonly displayName: string;
  128408. readonly isConnected: boolean;
  128409. readonly isPresenting: boolean;
  128410. /**
  128411. * If this VRDisplay supports room-scale experiences, the optional
  128412. * stage attribute contains details on the room-scale parameters.
  128413. */
  128414. readonly stageParameters: VRStageParameters | null;
  128415. /**
  128416. * Passing the value returned by `requestAnimationFrame` to
  128417. * `cancelAnimationFrame` will unregister the callback.
  128418. * @param handle Define the hanle of the request to cancel
  128419. */
  128420. cancelAnimationFrame(handle: number): void;
  128421. /**
  128422. * Stops presenting to the VRDisplay.
  128423. * @returns a promise to know when it stopped
  128424. */
  128425. exitPresent(): Promise<void>;
  128426. /**
  128427. * Return the current VREyeParameters for the given eye.
  128428. * @param whichEye Define the eye we want the parameter for
  128429. * @returns the eye parameters
  128430. */
  128431. getEyeParameters(whichEye: string): VREyeParameters;
  128432. /**
  128433. * Populates the passed VRFrameData with the information required to render
  128434. * the current frame.
  128435. * @param frameData Define the data structure to populate
  128436. * @returns true if ok otherwise false
  128437. */
  128438. getFrameData(frameData: VRFrameData): boolean;
  128439. /**
  128440. * Get the layers currently being presented.
  128441. * @returns the list of VR layers
  128442. */
  128443. getLayers(): VRLayer[];
  128444. /**
  128445. * Return a VRPose containing the future predicted pose of the VRDisplay
  128446. * when the current frame will be presented. The value returned will not
  128447. * change until JavaScript has returned control to the browser.
  128448. *
  128449. * The VRPose will contain the position, orientation, velocity,
  128450. * and acceleration of each of these properties.
  128451. * @returns the pose object
  128452. */
  128453. getPose(): VRPose;
  128454. /**
  128455. * Return the current instantaneous pose of the VRDisplay, with no
  128456. * prediction applied.
  128457. * @returns the current instantaneous pose
  128458. */
  128459. getImmediatePose(): VRPose;
  128460. /**
  128461. * The callback passed to `requestAnimationFrame` will be called
  128462. * any time a new frame should be rendered. When the VRDisplay is
  128463. * presenting the callback will be called at the native refresh
  128464. * rate of the HMD. When not presenting this function acts
  128465. * identically to how window.requestAnimationFrame acts. Content should
  128466. * make no assumptions of frame rate or vsync behavior as the HMD runs
  128467. * asynchronously from other displays and at differing refresh rates.
  128468. * @param callback Define the eaction to run next frame
  128469. * @returns the request handle it
  128470. */
  128471. requestAnimationFrame(callback: FrameRequestCallback): number;
  128472. /**
  128473. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  128474. * Repeat calls while already presenting will update the VRLayers being displayed.
  128475. * @param layers Define the list of layer to present
  128476. * @returns a promise to know when the request has been fulfilled
  128477. */
  128478. requestPresent(layers: VRLayer[]): Promise<void>;
  128479. /**
  128480. * Reset the pose for this display, treating its current position and
  128481. * orientation as the "origin/zero" values. VRPose.position,
  128482. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  128483. * updated when calling resetPose(). This should be called in only
  128484. * sitting-space experiences.
  128485. */
  128486. resetPose(): void;
  128487. /**
  128488. * The VRLayer provided to the VRDisplay will be captured and presented
  128489. * in the HMD. Calling this function has the same effect on the source
  128490. * canvas as any other operation that uses its source image, and canvases
  128491. * created without preserveDrawingBuffer set to true will be cleared.
  128492. * @param pose Define the pose to submit
  128493. */
  128494. submitFrame(pose?: VRPose): void;
  128495. }
  128496. declare var VRDisplay: {
  128497. prototype: VRDisplay;
  128498. new(): VRDisplay;
  128499. };
  128500. interface VRLayer {
  128501. leftBounds?: number[] | Float32Array | null;
  128502. rightBounds?: number[] | Float32Array | null;
  128503. source?: HTMLCanvasElement | null;
  128504. }
  128505. interface VRDisplayCapabilities {
  128506. readonly canPresent: boolean;
  128507. readonly hasExternalDisplay: boolean;
  128508. readonly hasOrientation: boolean;
  128509. readonly hasPosition: boolean;
  128510. readonly maxLayers: number;
  128511. }
  128512. interface VREyeParameters {
  128513. /** @deprecated */
  128514. readonly fieldOfView: VRFieldOfView;
  128515. readonly offset: Float32Array;
  128516. readonly renderHeight: number;
  128517. readonly renderWidth: number;
  128518. }
  128519. interface VRFieldOfView {
  128520. readonly downDegrees: number;
  128521. readonly leftDegrees: number;
  128522. readonly rightDegrees: number;
  128523. readonly upDegrees: number;
  128524. }
  128525. interface VRFrameData {
  128526. readonly leftProjectionMatrix: Float32Array;
  128527. readonly leftViewMatrix: Float32Array;
  128528. readonly pose: VRPose;
  128529. readonly rightProjectionMatrix: Float32Array;
  128530. readonly rightViewMatrix: Float32Array;
  128531. readonly timestamp: number;
  128532. }
  128533. interface VRPose {
  128534. readonly angularAcceleration: Float32Array | null;
  128535. readonly angularVelocity: Float32Array | null;
  128536. readonly linearAcceleration: Float32Array | null;
  128537. readonly linearVelocity: Float32Array | null;
  128538. readonly orientation: Float32Array | null;
  128539. readonly position: Float32Array | null;
  128540. readonly timestamp: number;
  128541. }
  128542. interface VRStageParameters {
  128543. sittingToStandingTransform?: Float32Array;
  128544. sizeX?: number;
  128545. sizeY?: number;
  128546. }
  128547. interface Navigator {
  128548. getVRDisplays(): Promise<VRDisplay[]>;
  128549. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  128550. }
  128551. interface Window {
  128552. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  128553. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  128554. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  128555. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  128556. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  128557. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  128558. }
  128559. interface Gamepad {
  128560. readonly displayId: number;
  128561. }
  128562. type XRSessionMode =
  128563. | "inline"
  128564. | "immersive-vr"
  128565. | "immersive-ar";
  128566. type XRReferenceSpaceType =
  128567. | "viewer"
  128568. | "local"
  128569. | "local-floor"
  128570. | "bounded-floor"
  128571. | "unbounded";
  128572. type XREnvironmentBlendMode =
  128573. | "opaque"
  128574. | "additive"
  128575. | "alpha-blend";
  128576. type XRVisibilityState =
  128577. | "visible"
  128578. | "visible-blurred"
  128579. | "hidden";
  128580. type XRHandedness =
  128581. | "none"
  128582. | "left"
  128583. | "right";
  128584. type XRTargetRayMode =
  128585. | "gaze"
  128586. | "tracked-pointer"
  128587. | "screen";
  128588. type XREye =
  128589. | "none"
  128590. | "left"
  128591. | "right";
  128592. interface XRSpace extends EventTarget {
  128593. }
  128594. interface XRRenderState {
  128595. depthNear?: number;
  128596. depthFar?: number;
  128597. inlineVerticalFieldOfView?: number;
  128598. baseLayer?: XRWebGLLayer;
  128599. }
  128600. interface XRInputSource {
  128601. handedness: XRHandedness;
  128602. targetRayMode: XRTargetRayMode;
  128603. targetRaySpace: XRSpace;
  128604. gripSpace: XRSpace | undefined;
  128605. gamepad: Gamepad | undefined;
  128606. profiles: Array<string>;
  128607. }
  128608. interface XRSession {
  128609. addEventListener: Function;
  128610. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  128611. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  128612. requestAnimationFrame: Function;
  128613. end(): Promise<void>;
  128614. renderState: XRRenderState;
  128615. inputSources: Array<XRInputSource>;
  128616. }
  128617. interface XRReferenceSpace extends XRSpace {
  128618. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  128619. onreset: any;
  128620. }
  128621. interface XRFrame {
  128622. session: XRSession;
  128623. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  128624. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  128625. }
  128626. interface XRViewerPose extends XRPose {
  128627. views: Array<XRView>;
  128628. }
  128629. interface XRPose {
  128630. transform: XRRigidTransform;
  128631. emulatedPosition: boolean;
  128632. }
  128633. declare var XRWebGLLayer: {
  128634. prototype: XRWebGLLayer;
  128635. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  128636. };
  128637. interface XRWebGLLayer {
  128638. framebuffer: WebGLFramebuffer;
  128639. framebufferWidth: number;
  128640. framebufferHeight: number;
  128641. getViewport: Function;
  128642. }
  128643. interface XRRigidTransform {
  128644. position: DOMPointReadOnly;
  128645. orientation: DOMPointReadOnly;
  128646. matrix: Float32Array;
  128647. inverse: XRRigidTransform;
  128648. }
  128649. interface XRView {
  128650. eye: XREye;
  128651. projectionMatrix: Float32Array;
  128652. transform: XRRigidTransform;
  128653. }
  128654. interface XRInputSourceChangeEvent {
  128655. session: XRSession;
  128656. removed: Array<XRInputSource>;
  128657. added: Array<XRInputSource>;
  128658. }